Options
All
  • Public
  • Public/Protected
  • All
Menu

@uclatall/engauge

enGauge

Simple package for tracking (gauging) engagement on webpages. Used to track user activity on pages in CourseKata textbooks.

Installation

Currently, this package is only available via our private GitHub repository. If you have access, follow these steps to configure npm to use the GitHub registry in addition to the standard NPM registry:

  1. Authenticate to GitHub Packages. For more information, see Authenticating to GitHub Packages.

  2. In the same directory as your package.json file, create or edit an .npmrc file to include a line associating this package's organization scope with the GitHub registry.

@uclatall:registry=https://npm.pkg.github.com
  1. Install the full-scoped package as a dependency:
npm install @uclatall/engauge

Usage

Connecting

To start monitoring,

  1. initialize the app,
  2. connect to the report signal,
  3. start monitoring.

Here is a simple example using console.log() to print the reports:

import {Engauge} from '@uclatall/engauge';

const report_handler = payload => console.log(payload);
const engauge = new Engauge();
engauge.connect(report_handler);
document.addEventListener('DOMContentLoaded', () => engauge.monitor());

Stopping and Disconnecting

To disconnect from the report cycle, pass the same handler that was initially connected:

...

engauge.disconnect(report_handler);
// handler will not be called after this point

Disconnecting does not stop monitoring. To stop monitoring you can use the unmonitor() method and new states will no longer be tracked:

engauge.unmonitor();

See the full documentation for more information on configuration and the report payload.

Generated using TypeDoc