plausible / plausible-tracker

Frontend library to interact with Plausible Analytics
https://github.com/plausible/plausible-tracker
MIT License
214 stars 46 forks source link

location is not defined #56

Open pixelpaulaus opened 11 months ago

pixelpaulaus commented 11 months ago

Versions

0.3.8

Describe the bug

"location is not defined" errir given when trying to do server side tracking, as the location object is not there in nodejs, but the module expects it.

Expected behavior

don't make location object a requirement in the environment. I have tried passing my own URL and DOMAIN, but it still calls for the getConfig() function which expects the location.href and location.hostname

Steps to reproduce

so any server side tracking in nodeJS

Daniel15 commented 11 months ago

I don't think this module would work at all in Node.js... It uses a lot of browser APIs, and sends data using XMLHttpRequest which doesn't work in Node either.

For server-side logging, you can instead hit the events API directly: https://plausible.io/docs/events-api