https://github.com/oscarotero/analogger
Deno library to consume access logs files and generate reports
https://github.com/oscarotero/analogger
analytics deno logs
Last synced: 2 months ago
JSON representation
Deno library to consume access logs files and generate reports
- Host: GitHub
- URL: https://github.com/oscarotero/analogger
- Owner: oscarotero
- License: mit
- Created: 2021-11-07T18:53:50.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-11-23T19:42:15.000Z (over 2 years ago)
- Last Synced: 2025-10-03T23:52:23.074Z (9 months ago)
- Topics: analytics, deno, logs
- Language: TypeScript
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Analogger
This is a simple [Deno](https://deno.land/) library to consume access logs
generated by nginx/apache and generate reports about visits, sessions, etc.
It's divided in two scopes:
- **Transformers:** to parse, transform and enrich the data from log files.
- **Reporters:** to generate reports of this data.
## Example
```ts
import {
read,
show,
reports,
transform,
transformers as t
} from "https://deno.land/x/analogger/mod.ts";
// Step 1: Read the log file.
const logs = read("./access.log");
// Step 2: Parse and transform the logs:
const result = await transform(
logs,
t.parse(), // Parse the data.
t.filterByExtensions([".html", ""]), // Filter by .html extensions or not extension at all.
t.filter((log) => log.status === 200), // Get only requests generating a 200 status code response.
t.isBot(), // Add the `isBot` property indicating if the request is from a bot (ex: Google).
t.filter((log) => !log.isBot), // Discard request from bots
t.parseUserAgent(), // Parse the user-agent info
t.sessionId(), // Add the `sessionId` property with an autogenerated session id
t.searchEngine(), // Add the `searchEngine` property (google, bing, yahoo...)
t.socialNetwork(), // Add the `socialNetwork` property (facebook, twitter, instagram...)
);
// Step 3: Generate reports with this data.
// For example, the number of sessions by month:
const report = reports.sessions(result, "monthly");
// Step 3: See the report in your browser
await show(report);
```