JSPM

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

Understand how your tool is being used by anonymously reporting usage metrics to Google Analytics

Package Exports

  • insight

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 (insight) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Insight Build Status

Understand how your tool is being used by anonymously reporting usage metrics to Google Analytics

This module uses the newly released Universal Analytics API from Google Analytics

Analytics dashboard example

Displaying metrics from Yeoman which makes use of Insight.

analytics screenshot

Example usage

var Insight = require('insight');

var insight = new Insight({
    // Google Analytics tracking code
    trackingCode: 'UA-XXXXXXXX-X'
});

// ask for permission the first time
if (insight.optOut === undefined) {
    return insight.askPermission();
}

insight.track('foo', 'bar');
// recorded in Analytics as `/foo/bar`

or a live example

Documentation

Insight(settings)

trackingCode

Type: string
Required

Your Google Analytics trackingCode

packagePath

Type: string
Default: 'package.json'

Relative path to your module package.json

packageName

Type: string
Default: Inferred from packageFile

Used instead of inferring it from packageFile
Requires you to also specify packageVersion

packageVersion

Type: string
Default: Inferred from packageFile

Used instead of inferring it from packageFile
Requires you to also specify packageName

Instance methods

.track(keyword, [keyword, ...])

Accepts keywords which ends up as a path in Analytics.

.track('init', 'backbone') becomes /init/backbone

.askPermission([message, callback])

Asks the user for permission to track and sets the optOut property. You can also choose to set this manually.

askPermission screenshot

Optionally supply your own message and callback. The callback will be called with the arguments error and optOut when the prompt is done, and is useful for when you want to continue the execution while the prompt is running.

.optOut

Returns a boolean whether the user has opted out of tracking. Should preferably only be set by a user action, eg. a prompt.

License

BSD license and copyright Google