File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff 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' )
9295sse .onopen = function () { console .log (' [sse] open' ) }
9396sse .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
You can’t perform that action at this time.
0 commit comments