0.4.1 • Published 7 months ago

@compilorama/staly v0.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Staly

Privacy-first analytics.

CircleCI Coverage Status

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

  1. Install Node. Download the "Recommend for Most Users" version.

  2. Clone the repo:

git clone git@github.com:compilorama/staly.git
  1. Go to the project directory:
cd staly
  1. Install the project dependencies:
npm install
  1. Build the project:
npm run build

Tests

Ensure that all code that you have added is covered with unit tests:

npm run test -- --coverage