JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 55
  • Score
    100M100P100Q7505F
  • License MIT

Privacy-first analytics

Package Exports

  • @glorious/analytics

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@glorious/analytics) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Glorious Analytics

Privacy-first analytics.

CircleCI Coverage Status

Installation

npm install @glorious/analytics --save

Usage

Glorious Analytics is based on Plausible, a simple and privacy-friendly alternative to Google Analytics.

import GAnalytics from '@glorious/analytics';

const analytics = new GAnalytics();
analytics.init('glorious.codes');
analytics.trackPageview();

To avoid been tracked by any site using Glorious Analytics, 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 = 'glorious.codes';
// 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 analytics = new GAnalytics();

analytics.init(token, options);

trackPageview

analytics.trackPageview();

Contributing

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

  2. Clone the repo:

git clone git@github.com:glorious-codes/glorious-analytics.git
  1. Go to the project directory:
cd glorious-analytics
  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