Socket
Book a DemoInstallSign in
Socket

@atxmtx/metrics

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atxmtx/metrics

Google Analytics event tracking for Atom packages

Source
npmnpm
Version
0.5.0
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

@atxmtx/metrics

npm npm CircleCI David

Google Analytics event tracking for Atom packages

Installation

npm install @atxmtx/metrics -S

Usage

Basic Examples

Once the Metrics class has been instantiated, events can be fired from anywhere in your package.

// JavaScript
import Metrics from '@atxmtx/metrics';

export async function activate() {
    const ga = new Metrics('UA-XXXX-Y');

    ga.event({
      category: 'Demo',
      action: 'Package activated!'
    });
};
# CoffeeScript
const Metrics = require "@atxmtx/metrics"

module.exports =
  activate: () ->
    ga = new Metrics("UA-XXXX-Y");

    ga.event {
      category: "Demo"
      action: "Package activated!"
    }

Command Metrics Example

Command metrics allow simple tracking of invoked package commands. In the following example, all commands provided by the settings-view package will be tracked by Google Analytics.

// JavaScript
import Metrics from '@atxmtx/metrics';

export async function activate() {
    new Metrics('UA-XXXX-Y', {
      commandCategory: 'Settings View Commands',
      commandAction: [
        'settings-view:*'
      ]
    });
};
# CoffeeScript
const Metrics = require "@atxmtx/metrics"

module.exports =
  activate: () ->
    new Metrics('UA-XXXX-Y',
      commandCategory: 'Settings View Commands'
      commandAction: [
        'settings-view:*'
      ])

Note: Invoking commands from tool-bar packages is currently not supported!

Methods

constructor

Usage: new Metrics(trackingID: string, options: object)

Instantiates class and adds event listeners, unless option.muted is used

listen

Usage: listen()

Manuall add event listener, e.g. for when option.muted is true

mute

Usage: mute()

Removes event listener

event

Usage: event({ category: string, action: string, label?: string, value?: number})

Sends an event to Google Analystics

Options

cacheBuster

Type: boolean
Default: false

Used to send a random number in GET requests to ensure browsers and proxies don't cache hits.

commandAction

Type: string | string[]

Used to track specified package commands, supports wildcards (e.g. my-package:*).

commandCategory

Type: string
Default: Package Command

Default event category for package commands.

consentSetting

Type: string

Specifies a package setting in which the user can deny tracking, e.g. in compliance with the GDPR.

dryRun

Type: boolean
Default: false

Skips sending the actual request to Google Analytics.

muted

Type: boolean
Default: false

Skips adding event listeners when the class is instantiated.

trackDevMode

Type: boolean
Default: false

Enables tracking if the current window is in development mode.

trackSpecMode

Type: boolean
Default: false

Enables tracking if current window is running specs.

License

This work is dual-licensed under The MIT License and the GNU General Public License, version 2.0

Keywords

atom

FAQs

Package last updated on 23 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts