@compilorama/staly
v0.4.1
Published
Privacy-first analytics
Downloads
30
Readme
Staly
Privacy-first analytics.
Installation
npm install @compilorama/staly --save
Usage
Staly is based on Plausible by default, but you can optionally use another service. See Adapters section below to learn more.
import Staly from '@compilorama/staly';
const staly = new Staly();
staly.init('glorious.codes');
staly.trackPageview();
To avoid being tracked by any site using Staly, set analytics
search param as disabled
. Your preference will be set in a cookie and the following visits won't be tracked even without declaring the analytics search param on url.
https://glorious.codes?analytics=disabled
API
init
/*
** @token: String [required]
** @options: Object [optional]
*/
// Domain registered on Plausible
const token = 'compilorama.com';
// Local development is not tracked by default, but you can make it work by
// setting trackLocalhost option as true on initializaton.
const options = { trackLocalhost: true };
const staly = new Staly();
staly.init(token, options);
trackPageview
staly.trackPageview();
Adapters
You can optionally use Staly with the following adapters. Click over one of them to get specific instructions:
Contributing
Install Node. Download the "Recommend for Most Users" version.
Clone the repo:
git clone [email protected]:compilorama/staly.git
- Go to the project directory:
cd staly
- Install the project dependencies:
npm install
- Build the project:
npm run build
Tests
Ensure that all code that you have added is covered with unit tests:
npm run test -- --coverage