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

@askdepth/contracts

v0.2.0

Published

Wire contracts for the Askdepth RUM SDK — base events, anomaly payloads, W3C Trace Context.

Downloads

697

Readme

@askdepth/contracts

Wire contracts, Zod schemas, and TypeScript definitions for the Askdepth telemetry protocol.

This package defines the single source of truth for:

  • RUM telemetry events (Rage Clicks, Dead Clicks, Error Clicks, Track, Identify).
  • Wire Telemetry Envelope (TelemetryEnvelope) and Protocol Versioning.
  • W3C Trace Context propagation (traceparent header validation and parsing).
  • Session Replay slice manifests, chunk payloads, and rrweb event definitions.

Installation

# pnpm
pnpm add @askdepth/contracts

# npm
npm install @askdepth/contracts

# yarn
yarn add @askdepth/contracts

Key Exports & Usage

1. Wire Telemetry Envelope

Validate or construct telemetry batches transmitted to the Askdepth ingest server:

import {
  createTelemetryEnvelope,
  parseTelemetryEnvelope,
  type TelemetryEnvelope,
} from '@askdepth/contracts';

// Creating an envelope
const envelope = createTelemetryEnvelope({
  projectId: '550e8400-e29b-41d4-a716-446655440000',
  sessionId: 'c8f7d6a5-b4c3-4d2e-8f1a-0b9c8d7e6f5a',
  environment: 'production',
  events: [
    {
      type: 'track',
      name: 'checkout_started',
      properties: { cartValue: 99.99 },
    },
  ],
});

// Parsing & validating incoming payload on server
const validated = parseTelemetryEnvelope(rawPayload);

2. W3C Distributed Tracing (traceparent)

Format and parse W3C Trace Context headers according to W3C Recommendation:

import {
  formatTraceparent,
  parseTraceparent,
  TraceparentHeaderSchema,
} from '@askdepth/contracts';

// Format: 00-{trace_id}-{parent_id}-{trace_flags}
const headerValue = formatTraceparent({
  traceId: '4bf92f3577b34da6a3ce929d0e0e4736',
  parentId: '00f067aa0ba902b7',
  sampled: true,
});

// Parse header safely
const parts = parseTraceparent(headerValue);
// parts.traceId -> '4bf92f3577b34da6a3ce929d0e0e4736'
// parts.sampled -> true

3. RUM Anomaly Events (Frustration Heuristics)

Strict Zod schemas for user frustration detection:

import {
  RageClickEventSchema,
  DeadClickEventSchema,
  ErrorClickEventSchema,
  type RageClickEvent,
} from '@askdepth/contracts';

const isRageClick = RageClickEventSchema.safeParse(event).success;

4. Session Replay Contracts (Sprint 2)

Schemas for 45-second session replay slices, compression algorithms, and chunks:

import {
  ReplaySliceManifestSchema,
  ReplayUploadPayloadSchema,
  RRWebEventSchema,
  type ReplaySliceManifest,
  type ReplayUploadPayload,
} from '@askdepth/contracts';

// Validate replay manifest
const manifest = ReplaySliceManifestSchema.parse({
  slice_id: '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
  triggering_anomaly_id: 'anom_rage_123',
  session_id: '550e8400-e29b-41d4-a716-446655440000',
  environment: 'production',
  start_timestamp: 1711500000000,
  trigger_timestamp: 1711500045000,
  duration_ms: 45000,
  has_baseline_snapshot: true,
  events_count: 142,
  uncompressed_byte_size: 154000,
  compressed_byte_size: 24500,
  compression_algorithm: 'gzip',
  sequence_number: 1,
});

Wire Protocol Versioning

This worktree exports PROTOCOL_VERSION = '0.1.0'; the package version remains 0.1.1 until Changesets generates the next package release. The already published 0.1.1 artifact is immutable and does not receive this source change. While the protocol is pre-1.0, incompatible wire changes increment its minor version; after 1.0.0, they increment the major version. Package releases and wire protocol versions remain separate version axes, as described in docs/VERSIONING_AND_LIFECYCLE.md.


License

MIT © Askdepth