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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@duffcloudservices/telemetry

v0.1.0

Published

Shared Azure Application Insights telemetry for DCS Vue sites — one App Insights config (with the bfcache-safe unload fix) and a useTelemetry composable.

Readme

@duffcloudservices/telemetry

Shared Azure Application Insights telemetry for DCS Vue sites. One place owns the App Insights config and the useTelemetry composable, so every DCS surface (marketing web/, generated customer sites) gets the same behavior — including the fleet-wide bfcache / Lighthouse unload fix.

Why this package exists

The App Insights JavaScript SDK, by default, registers a listener on the deprecated unload event. That:

  • makes pages ineligible for the browser back/forward cache (bfcache), and
  • trips the Lighthouse "avoid unload event listeners" best-practices audit (~19 points — enough to pin flagship sites at Best-Practices 54).

The fix is a single config field — disablePageUnloadEvents: ['unload'] — which tells the SDK to skip the unload hook while still flushing telemetry on pagehide / visibilitychange (the supported path). This package bakes that into the default config so no consumer can forget it.

Install

pnpm add @duffcloudservices/telemetry
# peers you already have on a DCS Vue site:
pnpm add @microsoft/applicationinsights-web vue

Usage — composable (SPA / eager)

The connection string, cloud role, environment and app version are supplied by the consumer (read your own import.meta.env / build defines and pass plain values in), keeping this package portable.

import { useTelemetry } from '@duffcloudservices/telemetry'

const telemetry = useTelemetry({
  connectionString: import.meta.env.VITE_APP_INSIGHTS_CONNECTION_STRING,
  instrumentationKey: import.meta.env.VITE_APP_INSIGHTS_INSTRUMENT_KEY,
  cloudRole: 'dcs-web',
  dev: import.meta.env.DEV,
  environment: import.meta.env.MODE,
  appVersion: __APP_VERSION__,
})

telemetry.initialize() // synchronous; no-op (with a loud one-shot warn) when unconfigured
telemetry.trackCtaClick('hero-cta', '/contact')

initialize() is synchronous because the SDK is statically imported.

Usage — config only (lazy / inert loaders)

Sites that lazy-load the SDK themselves (to stay inert when telemetry is unconfigured) can import just the config — no SDK is pulled in:

import { createTelemetryConfig } from '@duffcloudservices/telemetry/config'

const { ApplicationInsights } = await import('@microsoft/applicationinsights-web')
const ai = new ApplicationInsights({
  config: createTelemetryConfig({ connectionString: cs, enableAutoRouteTracking: false }),
})
ai.loadAppInsights()

API

| Export | Description | | --- | --- | | useTelemetry(options?) | Full composable: initialize, trackEvent, trackPageView, trackCtaClick, trackException, trackMetric, trackDependency, flush, startTrackPage, stopTrackPage, plus isEnabled / isInitialized / initializationError refs. | | createTelemetryConfig(options?) | Builds the App Insights config with DCS defaults + the disablePageUnloadEvents: ['unload'] fix. Pure, no SDK import. | | DEFAULT_DISABLE_PAGE_UNLOAD_EVENTS | ['unload'] — the disabled-events default. | | DEFAULT_CLOUD_ROLE | 'dcs-site'. | | types | TelemetryOptions, TelemetryConfigOptions, ApplicationInsightsConfig, TelemetryEvent, TelemetryPageView, TelemetryException, TelemetryDependency, TelemetryMetric. |

TelemetryOptions

| Option | Default | Notes | | --- | --- | --- | | connectionString / instrumentationKey | — | at least one enables telemetry | | cloudRole | 'dcs-site' | ai.cloud.role + app_name property | | appVersion | window.__APP_VERSION__ ?? 'unknown' | stamped on every event | | environment | 'unknown' | e.g. import.meta.env.MODE | | dev | false | verbose SDK logging when true | | enableAutoRouteTracking | true | SDK built-in SPA route tracking | | disablePageUnloadEvents | ['unload'] | the fix — override only if you know why | | overrides | — | deep Partial<ApplicationInsightsConfig>, applied last |

License

MIT © Duff Cloud Services