Skip to content

Commit 85d06e5

Browse files
committed
Update live updates docs
1 parent 2b3ef9d commit 85d06e5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,18 @@ Don't see your favorite database here? Writing your own adapter is super easy! S
8383

8484
### Live updates
8585

86-
micro-analytics has support for live updates with [server-sent events][]. This is an optional feature
87-
in the adapter backend so check that your chosen backend has the support for it. Below is a little
88-
example on how to listen for the events.
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.
8992

9093
```es6
91-
const sse = new EventSource('/sse')
94+
const sse = new EventSource('https://micro-analytics.now.sh/sse')
9295
sse.onopen = function () { console.log('[sse] open') }
9396
sse.onerror = function (error) { console.error('[sse error]', error) }
94-
sse.addEventListener('new-event', function (e) { console.log('[sse]', e) })
97+
sse.addEventListener('micro-analytics-ping', function (e) { console.log('[sse]', e) })
9598
```
9699

97100
[server-sent events]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

0 commit comments

Comments
 (0)