Tracking events server side with JavaScript #1833
khromov
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
👋 Wanted to share this JS/TS module I wrote for tracking events on the server side.
It was a little fiddly to get working, as I noticed that tracking requests to Umami requires a "non-bot" user-agent (as defined by the
isbot
npm package).The limitations of the module is kind of what you expect - it does not support a concept of "session" (ie.
x-umami-cache
) so each request will generate a new session. I think this could perhaps be improved (one session for the whole server to not have to generate new sessions all the time?) The big point of sending events server side for me was to not track individual users and instead only aggregate usage numbers.I welcome suggestions and improvements!
Usage
Pageview:
Event:
(
userAgent
is optional, you can send it if you have access to it in your environment, otherwise a standard user agent will be used for all requests)The module:
Beta Was this translation helpful? Give feedback.
All reactions