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

@doist/interaction-trace

v1.1.0

Published

A performance monitoring library for tracking the time from user interactions to next paint (INP) and last long-animation frame (LoAF), with declarative trace signing and third-party reporting.

Readme

@doist/interaction-trace

npm version License: MIT Node.js

A performance monitoring library for tracking user interactions using Interaction to Next Paint (INP) and Long Animation Frames (LoAF). Features declarative trace signing and pluggable reporting.

Installation

npm install @doist/interaction-trace

Usage

Initialize the Monitor

import { initInteractionTraceMonitor } from '@doist/interaction-trace'

const cleanup = initInteractionTraceMonitor({
    reporter: (report) => {
        // Send to your analytics service
        console.log('Trace report:', report)
    },
    enrollment: {
        sampleRate: 10, // 10% of sessions
        isEnabled: () => {
            if (user.isInternal) return true    // force enable for internal users
            return undefined                     // everyone else: use sampleRate
        },
    },
    abortSignal: controller.signal, // Optional: auto-cleanup when aborted
})

// Or call cleanup() manually when done

Sign Traces

A trace measures the time from a user click to the browser completing all visual updates. Traces are created automatically on pointerup events—use signInteractionTrace() to name and provide details for the pending trace.

import { signInteractionTrace } from '@doist/interaction-trace'

button.addEventListener('click', () => {
    signInteractionTrace('open modal', { modalId: 'settings' })
    openModal()
})

TypeScript

Create a pre-typed function for compile-time validation of trace names and details:

import { signInteractionTrace } from '@doist/interaction-trace'

type MyTraces = {
    'open modal': { modalId: string }
    'submit form': { formId: string }
}

const signAppTrace = signInteractionTrace.withTypes<MyTraces>()

signAppTrace('open modal', { modalId: 'settings' })   // ✅ Works
signAppTrace('opne modal', { modalId: 'settings' })   // ❌ Error: typo caught
signAppTrace('open modal', { formId: 'x' })           // ❌ Error: wrong details

React Integration

import { useInteractionTrace } from '@doist/interaction-trace/react'

function SettingsModal() {
    useInteractionTrace('open modal', { modalId: 'settings' })
    return <div>...</div>
}

TypeScript

import { useInteractionTrace } from '@doist/interaction-trace/react'

type MyTraces = {
    'open modal': { modalId: string }
    'submit form': { formId: string }
}

const useAppTrace = useInteractionTrace.withTypes<MyTraces>()

function SettingsModal() {
    useAppTrace('open modal', { modalId: 'settings' })
    return <div>...</div>
}

Configuration

Enrollment Options

| Option | Type | Description | |--------|------|-------------| | sampleRate | number | Percentage of sessions to enroll (0-100) | | persistKey | string | sessionStorage key for enrollment state. Default: 'interaction-trace-enrolled' | | isEnabled | () => boolean \| undefined | Override function. true/false override sampling, undefined defers to sampleRate |

Reporter Interface

The reporter receives a TraceReport object:

type TraceReport = {
    id: string                        // Unique trace ID (crypto.randomUUID())
    duration: number                  // Total LoAF duration (ms)
    inp: number | undefined           // INP value if captured (ms)
    details: {
        name: string                  // Trace name from signInteractionTrace()
        [key: string]: unknown        // Additional details
    }
    device: {
        memoryGB: string              // Bucketed: "0.25-2", "3-7", "8-plus", or "unknown"
        cpuCores: string              // Bucketed: "1-8", "9-16", "17-plus"
    }
}

Browser Support

Requires Chrome 123+ for Long Animation Frames and Event Timing APIs. In unsupported browsers, the monitor silently no-ops—your app continues to work normally, just without trace collection.

Known Limitations

Keyboard Interactions

This library only tracks pointer-based interactions (pointerup events). Keyboard-initiated interactions (e.g., pressing Enter to submit a form, Space to toggle a checkbox) are not captured. INP metrics will only reflect mouse/touch interactions.

If your application has significant keyboard usage, consider this when interpreting the collected metrics.

Development

Development requires Node.js >= 22.18.0 (see .node-version).

npm install
npm run build
npm test

Releasing

This project uses release-please to automate releases. Commits merged to main with fix: trigger patch releases, feat: triggers minor releases, and feat!: or fix!: triggers major releases.

When commits land on main, release-please creates a release PR. Merging it publishes to npm and GitHub Packages.

License

Released under the MIT License.