plausible / plausible-tracker

Frontend library to interact with Plausible Analytics

Home Page:https://github.com/plausible/plausible-tracker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add ability to customize localhost url

madebyfabian opened this issue · comments

I am running localhost from a custom host (https://myapp.local).
The way the localhost detection is currently implemented, the tracker does not recognize if I am on localhost or not, and therefore sends the request.

const isLocalhost =
/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*:)*?:?0*1$/.test(
location.hostname
) || location.protocol === 'file:';

Possible Implementation

I would suggest to add an option where a user can change their localhost url and therefore making isLocalhost true. Happy to add a PR if you agree.