0.4.1 • Published 2 years ago
@compilorama/staly v0.4.1
Staly
Privacy-first analytics.
Installation
npm install @compilorama/staly --saveUsage
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=disabledAPI
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 git@github.com:compilorama/staly.git- Go to the project directory:
cd staly- Install the project dependencies:
npm install- Build the project:
npm run buildTests
Ensure that all code that you have added is covered with unit tests:
npm run test -- --coverage0.4.1
2 years ago