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

@echomirror/analytics

v0.1.0

Published

Privacy-safe emotional UX analytics for EchoMirror applications

Readme

@echomirror/analytics

Privacy-safe emotional UX event tracking, persistent batching, identity stitching, and local mood rollups.

Installation

npm install @echomirror/analytics

Track events

import { AnalyticsClient, createWebhookTransport } from '@echomirror/analytics'

const analytics = new AnalyticsClient({
  transport: createWebhookTransport({ url: '/api/analytics' }),
  batchSize: 20,
  flushIntervalMs: 10_000,
})

analytics.track('mood_logged', {
  score: 8,
  note: 'A private journal entry',
  tags: ['work', 'grateful'],
  source: 'manual',
})
analytics.trackGiftSent({ amount: 5, asset: 'ECHO', recipientType: 'friend' })

Built-in event names and properties are typed. Custom names also work through track(name, properties).

By default, the mood event above only queues score, moodCategory, hasNote, tagCount, and source. Note and tag text are removed before the event is persisted, not just before it is sent. Common PII/content property names are also recursively removed from custom events.

Sensitive-property opt-in

const analytics = new AnalyticsClient({
  transport,
  privacy: { allowSensitiveProperties: true },
})

This setting sends raw notes, tags, and other sensitive fields. Enable it only after obtaining appropriate consent and reviewing the destination's retention and access controls.

Offline queue and identity stitching

The browser build uses localStorage; non-browser and mobile integrations can provide any synchronous localStorage-compatible storage. Events have stable IDs across retries so the destination can deduplicate them.

analytics.trackMoodLogged({ score: 6 })

// After sign-in, queued events receive this user ID. An identity_stitched event
// also aliases this account to anonymous events that were already delivered.
analytics.identify('account-123')

await analytics.flush()
analytics.stop()

The transport must reject on delivery failure. The batch then remains persisted and is retried on the next timed or manual flush.

Local dashboard aggregation and Differential Privacy

Raw tags and mood metrics can be aggregated locally without entering the outbound event queue. Output aggregates use Differential Privacy (DP) noise injection and small-cohort suppression to prevent statistical re-identification:

import { aggregateMood, aggregateMoodThisWeek } from '@echomirror/analytics'

// Aggregation with default privacy protection (epsilon = 1.0, minCohortSize = 5)
const rollup = aggregateMoodThisWeek(moodEntries)
// { averageScore, entryCount, mostCommonTags, from, to }

// Customizing privacy budget and cohort threshold
const customRollup = aggregateMood(moodEntries, {
  from: '2026-07-20T00:00:00Z',
  to: '2026-07-26T23:59:59Z',
  privacy: {
    epsilon: 1.0,        // Privacy budget (default: 1.0)
    minCohortSize: 5,    // Suppression threshold (default: 5)
  },
})

// Opt-out for internal raw diagnostics:
const rawRollup = aggregateMood(moodEntries, {
  from: '2026-07-20T00:00:00Z',
  to: '2026-07-26T23:59:59Z',
  raw: true,
})

Understanding Epsilon ($\varepsilon$) and Privacy Budget

Differential privacy injects mathematically calibrated zero-mean Laplace noise into aggregate counts and average mood scores. The privacy budget parameter epsilon ($\varepsilon$) controls the privacy-vs-utility tradeoff:

  • Lower $\varepsilon$ (e.g. 0.1 – 0.5): Stronger privacy guarantee. More random noise is injected into the output. Best for public reporting or small cohorts.
  • $\varepsilon = 1.0$ (Default): Balanced privacy and utility. Standard conservative default suitable for user-facing dashboards and aggregated team metrics.
  • Higher $\varepsilon$ (e.g. 2.0 – 5.0): Weaker privacy guarantee, higher precision. Lower noise added to results. Suitable only for high-volume internal operational statistics.

Small Cohort Suppression

Noise injection alone cannot reliably prevent membership inference on tiny cohorts (e.g. groups of 1–3 users). To eliminate this risk, aggregateMood enforces a minimum cohort size (minCohortSize, default: 5).

If the number of matching records in the requested time window is less than minCohortSize, the aggregate output is suppressed:

  • averageScore: null
  • entryCount: null
  • mostCommonTags: []
  • suppressed: true

Privacy Model Guarantees and Limits

  • What this protects: Guarantees that an observer analyzing the aggregate outputs (averageScore, entryCount, tag frequencies) cannot determine with high statistical confidence whether any single user's data was included or excluded in the aggregation, protecting against linkage and differencing attacks.
  • What this does NOT protect: Differential privacy applies strictly to the output of aggregateMood / aggregateMoodThisWeek. It provides no protection for upstream data storage, raw logs, or backend data pipelines that ingest and retain individual events prior to aggregation.

Export shape

Every transport receives vendor-neutral JSON:

interface AnalyticsBatch {
  schemaVersion: 1
  batchId: string
  sentAt: string
  events: Array<{
    id: string
    name: string
    timestamp: string
    anonymousId: string
    sessionId: string
    userId?: string
    properties: Record<string, JsonValue>
  }>
}

Use createWebhookTransport() for a plain endpoint, or implement AnalyticsTransport to map this shape to PostHog, Mixpanel, or another destination. Deduplicate on each event's stable id.