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

@hint/utils-telemetry

v1.0.8

Published

hint tools

Downloads

41

Readme

Utils telemetry (@hint/utils-telemetry)

A collection of utilities to help consistently gather telemetry across webhint clients.

API

determineHintStatus

Extract pass/fail/fixing/fixed status for each hint from scan results. A hint is considered 'fixed' when passing after failing the previous scan. The 'fixing' status is when the number of failures decreases between scans.

To avoid false-positives for the 'fixing' and 'fixed' statuses, callers should ensure the previous scan occurs on the same URL with the same configuration.

import { determineHintStatus } from '@hint/utils-telemetry';

/*
 * status['hint-compat-api/css'] === 'passed'
 * status['hint-compat-api/html'] === 'failed'
 */
const prev = {};
const next = { 'compat-api/css': 0, 'compat-api/html': 1 };
const status = determineHintStatus(prev, next);

/*
 * status['hint-compat-api/css'] === 'passed'
 * status['hint-compat-api/html'] === 'fixing'
 */
const prev = { 'compat-api/css': 0, 'compat-api/html': 2 };
const next = { 'compat-api/css': 0, 'compat-api/html': 1 };
const status = determineHintStatus(prev, next);

/*
 * status['hint-compat-api/css'] === 'passed'
 * status['hint-compat-api/html'] === 'fixed'
 */
const prev = { 'compat-api/css': 0, 'compat-api/html': 1 };
const next = { 'compat-api/css': 0, 'compat-api/html': 0 };
const status = determineHintStatus(prev, next);

getUpdatedActivity

Retrieve an updated activity log if and only if it has not already been updated in the current UTC day.

import { getUpdatedActivity } from '@hint/utils-telemetry';

/*
 * Omitting previous activity returns a fresh entry for today:
 * {
 *   last28Days: '1000000000000000000000000000',
 *   lastUpdated: '2019-11-08T00:00:00.000Z'
 * }
 */
console.log(getUpdatedActivity());

// Calling on the same day as previous activity returns `null`.
getUpdatedActivity({
    last28Days: '1000000000000000000000000000',
    lastUpdated: '2019-11-08T00:00:00.000Z'
});

/*
 * Calling on a different day than previous activity fills in the gaps:
 * {
 *   last28Days: '1010000000000000000000000000',
 *   lastUpdated: '2019-11-08T00:00:00.000Z'
 * }
 */
getUpdatedActivity({
    last28Days: '1000000000000000000000000000',
    lastUpdated: '2019-11-06T00:00:00.000Z'
});

enabled

Check if telemetry is currently enabled.

enabled(); // true / false

initTelemetry

Initialize telemetry with the provided options

initTelemetry({

    // How long to gather events before submitting.
    batchDelay: 15000,

    // Any default properties to include with every event (e.g. 'extension-version').
    defaultProperties: {} as Properties,

    // Whether telemetry is initially enabled.
    enabled: false,

    // The instrumentation key to use with Application Insights.
    instrumentationKey: '',

    // The method to use to post telemetry to Application Insights (must be overridden).
    post: (url: string, data: string) => {
        return Promise.resolve(200);
    }

});

trackEvent

Log a named custom event to Application Insights (if telemetry is enabled).

trackEvent('vscode-save', determineHintStatus(prevResults, results));

updateTelemetry

Enable or disable telemetry.

updateTelemetry(true); // Enabled
updateTelemetry(false); // Disabled