npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@atxm/metrics

v0.14.0

Published

Event tracking for your Atom packages made easy

Downloads

40

Readme

@atxm/metrics

npm npm CircleCI David

Event tracking for your Atom packages made easy. Supports Google Analytics and Matomo.

Installation

npm install @atxm/metrics -S

Usage

Tracking of commands provided by your package and configuration changes is enabled by default. Additionally, custom events can be fired from anywhere in your package.

Keep in mind that you need to initialize the metrics provider after adding your Atom commands!

Examples:

import { Analytics as Metrics } from '@atxm/metrics';

export async function activate() {
  // Initialize metrics provider
  await Metrics.init('UA-XXXXXX-Y');

  // Dispatch custom event
  Metrics.emit({
    category: 'Demo',
    action: 'Package activated!'
  });
};
import { Matomo as Metrics } from '@atxm/metrics';

export async function activate() {
  // Initialize metrics provider
  const trackingUrl = 'https://url.to/matomo.php';
  const siteId = '123';
  await Metrics.init(trackingUrl, siteId)

  // Dispatch custom event
  Metrics.emit({
    category: 'Demo',
    action: 'Package activated!'
  });
}

Note: In order to make your Atom package compliant with the GDPR or the CCPA, you need to provide a privacy policy and a consent setting!

Providers

This modules currently exposes two providers: Google Analytics and Matomo. Both share the same methods but differ in their initialization.

Methods

init

Google Analytics: init(trackingID: string, options: object)
Matomo: init(trackingURL: string, siteID: string | number = 1, options: object)

Initializes module, unless option.muted is used

listen

Usage: listen()

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

mute

Usage: mute()

Removes event listener

emit

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

Dispatches 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.

categories

Type: object

categories.commands

Type: string
Default: Package Commands

Specifies event category name for package commands

categories.configuration

Type: string
Default: Package Configuration

Specifies event category name for package configuration

consentSetting

Type: string

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

dryRun

Type: boolean
Default: false

Skips sending the actual data request.

ipOverride

Type: boolean | string
Default: false

Allows overriding the user IP address. Uses 127.0.0.1 when true.

Note: This option only works with Google Analytics

muted

Type: boolean
Default: false

Skips adding event listeners when the module is initialized.

randomClientID

Type: boolean
Default: false

Uses a random UUID as client ID for each tracking event.

tracking

Type: object

Enables/disables automatic tracking

tracking.commands

Type: boolean
Default: true

Dispatches an event whenever a command provided by your package is invoked. Requires the metrics provider to initialize after your commands were added!

import { Analytics as Metrics } from '@atxm/metrics';

export async function activate() {
  // First, register commands
  subscriptions.add(
    atom.commands.add('atom-workspace', {
      'demo:log-to-console': () => {
        console.log('Demo time');
      }
    })
  );

  // Next, initialize metrics provider
  await Metrics.init('UA-XXXXXX-Y');
};

tracking.configuration

Type: boolean
Default: true

Dispatches an event whenever the configuration for a package has been changed.

Note: The configuration types string and array will be ignored for privacy reasons!

trackInDevMode

Type: boolean
Default: false

Enables tracking if the current window is in development mode.

trackInSpecMode

Type: boolean
Default: false

Enables tracking if current window is running specs.

Debugging

Running Atom in developer mode will log useful message to the console.

License

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