You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53-1Lines changed: 53 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,18 +50,70 @@ If you just want to get the views for an id and don't want to increment the view
50
50
51
51
If you want to get all views for all ids, set the `all` query parameter to `true` on a root request. (i.e. `/?all=true`) If you pass the `all` parameter to an id, all ids starting with that pathname will be included. E.g. `/x?all=true` will match views for `/x`, `/xyz` but not `/y`.
52
52
53
+
### Options
54
+
55
+
```
56
+
$ micro-analytics --help
57
+
Usage: micro-analytics [options] [command]
58
+
59
+
Commands:
60
+
61
+
help Display help
62
+
63
+
Options:
64
+
65
+
-a, --adapter [value] Database adapter used (defaults to "flat-file-db")
66
+
-h, --help Output usage information
67
+
-H, --host [value] Host to listen on (defaults to "0.0.0.0")
68
+
-p, --port <n> Port to listen on (defaults to 3000)
69
+
-v, --version Output the version number
70
+
```
71
+
53
72
### Database adapters
54
73
55
74
By default, `micro-analytics` uses `flat-file-db`, a fast in-process flat file database, which makes for easy setup and backups.
56
75
57
-
This works fine for side-project usage, but for a production application with bajillions of visitors you might want to use a real database with a _database adapter_. Install the necessary npm package (e.g. `micro-analytics-adapter-xyz`) and then specify the `DB_ADAPTER` environment variable: `$ DB_ADAPTER=xyz micro-analytics`
76
+
This works fine for side-project usage, but for a production application with bajillions of visitors you might want to use a real database with a _database adapter_. Install the necessary npm package (e.g. `micro-analytics-adapter-xyz`) and then specify the `DB_ADAPTER` environment variable: `$ DB_ADAPTER=xyz micro-analytics` or use the `--adapter` cli option.
58
77
59
78
These are the available database adapters, made by the community:
Don't see your favorite database here? Writing your own adapter is super easy! See [`writing-adapters.md`](writing-adapters.md) for a simple step-by-step guide.
64
83
84
+
### Live updates
85
+
86
+
micro-analytics also let's you listen into updates live with [server-sent events][].
87
+
That means you can e.g. build a realtime dashboard for your analytics!
88
+
89
+
Note: Make sure your database adapter supports this feature. If not, bug them to implement it!
90
+
micro-analytics will tell you when it starts up if it is supported, so the easiest way to find
91
+
out is just to start it up.
92
+
93
+
The example below shows how you can listen for events in the browser, just swap
94
+
micro-analytics.now.sh with your own domain and give it a try.
// Console.error a warning message, but normally exit the process to avoid printing ugly npm ERR lines and stack trace.
13
-
console.error(`\n${repeatCharacter(' ',22)}⚠️ ERROR ⚠️\n${repeatCharacter('-',55)}\nYou specified "${process.env.DB_ADAPTER}" as the DB_ADAPTER, but no package\ncalled "${adapterName}" was found.\n\nPlease make sure you spelled the name correctly and\nhave "npm install"ed the necessary adapter package!\n${repeatCharacter('-',55)}\n`)
// Console.error a warning message, but normally exit the process to avoid printing ugly npm ERR lines and stack trace.
12
+
console.error(`\n${repeatCharacter(' ',22)}⚠️ ERROR ⚠️\n${repeatCharacter('-',55)}\nYou specified "${adapterName}" as the DB_ADAPTER, but no package\ncalled "micro-analytics-adapter-${adapterName}" was found.\n\nPlease make sure you spelled the name correctly and\nhave "npm install"ed the necessary adapter package!\n${repeatCharacter('-',55)}\n`)
0 commit comments