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

@evrdk/traceway

v1.2.4

Published

Traceway browser error reporting, distributed tracing and session replay.

Readme

@evrdk/traceway

A framework-independent browser SDK for Traceway. It captures exceptions, messages, console and action breadcrumbs, and optional DOM replay, and sends them directly to a Traceway project.

bun add @evrdk/traceway
import { init, recordAction, captureExceptionWithAttributes } from "@evrdk/traceway";

init("PROJECT_TOKEN@https://traceway.example.com/api/report", {
  version: "1.4.0",
  attributes: { environment: "production" }
});

recordAction("checkout", "submit", { items: 2 });
try {
  await submitOrder();
} catch (error) {
  if (error instanceof Error) captureExceptionWithAttributes(error, { operation: "submitOrder" });
  throw error;
}

Use the project's browser ingest token and complete report URL. The package supplies an ESM entry with TypeScript declarations for modern import consumers. Bundle it with your browser application; runtime dependencies remain external in the package output. The build targets the widely available browser baseline (Chrome/Edge 111, Firefox 114, Safari/iOS 16.4).

API

| Export | Behavior | | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | init(connectionString, options?) | Creates the singleton, starts enabled capture, and chains the page's existing error and rejection handlers. | | captureException(error, options?), captureExceptionWithAttributes(error, attributes?, options?) | Normalize the stack and report the error. An explicit options.distributedTraceId overrides the active request ID. | | captureMessage(message) | Report a message with isMessage: true. | | recordAction(category, name, data?) | Add a custom timestamped breadcrumb. | | setAttribute(key, value), setAttributes(attributes), removeAttribute(key), clearAttributes() | Change attributes on subsequent reports and refresh the open session. Browser defaults are overridden by global attributes, then by per-exception attributes. | | flush(timeoutMs?) | Drain pending recording/uploads while preserving the live session and recorder. The wait defaults to 15 seconds; detached work retains its attempt deadline. | | stop() | End the singleton, release instrumentation/replay and discard unsent work and callbacks. init() also returns an owner-safe disposer. | | getActiveDistributedTraceId(), DISTRIBUTED_TRACE_HEADER | Read the page's current request ID (or null) and the header name traceway-trace-id. Same-origin fetch and XHR requests receive the header. Concurrent requests share one active slot. | | createAxiosInterceptor() | Use with axios.interceptors.request.use(...) to set a fresh trace header on the request config. | | formatBrowserStackTrace(error) | Normalize browser frames, including eval locations, for Traceway source-map lookup. | | TracewayFrontendClient | Construct an independent client with the same connection string and options. Supports explicit event recording, attribute updates, session inspection, addException, and flush. | | installGlobalHandlers(client), installConsoleInstrumentation(client), installNavigationInstrumentation(client) | Install these hooks for an explicitly constructed client. Its stop() method releases them. Singleton initialization installs the enabled hooks. |

The root exports TracewayFrontendOptions, ExceptionStackTrace, CollectionFrame, ReportRequest, SessionRecordingPayload, TracewayEvent, LogEvent, NetworkEvent, NavigationEvent, and CustomEvent as TypeScript types. Singleton capture and attribute calls before initialization are no-ops.

Configuration

| Option | Default | Purpose | | ---------------------------------------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | debug | false | Log filtering decisions and policy-hook failures to the console. | | version | "" | Sent as the report's appVersion. | | attributes | Empty | Initial string attributes for sessions and exceptions. | | ignoreErrors | DEFAULT_IGNORE_PATTERNS | Substrings or regexes tested against the normalized stack/message. Replaces the default network, timeout, abort and common 4xx patterns; use [] to disable them. | | beforeCapture | Unset | Receives the exception after ignore filtering and before enrichment. Returning false drops it; a thrown callback does not drop it. | | captureLogs, captureNetwork, captureNavigation | true each | Enable console logs, fetch/XHR breadcrumbs, and History API/popstate/hashchange breadcrumbs respectively. Disabling network breadcrumbs leaves trace headers active. | | captureHttpServerErrors | false | Promote fetch and XHR responses with status ≥500 to an issue. | | eventsWindowMs, eventsMaxCount | 10,000 ms / 200, or 30,000 ms / 600 with always-on sessions | Age and count limits, applied separately to logs and actions. | | sessionRecording | true | Record rrweb events. Disable to keep only logs/actions on exception clips. | | sessionRecordingSegmentDuration | 30,000 ms | Rotate on rrweb event timestamps and start each segment with a fresh snapshot. | | recordAllSessions | false | Upload each completed segment and maintain a parent session, even if no exception occurs. |

Recording and transport

In default mode an exception's sessionRecordingId matches its clip's exceptionId. The clip includes one snapshot-based segment and available breadcrumbs. rrweb captures ordinary inputs and DOM text; password values are masked both in snapshots and input events. Console arguments, URLs, custom action data and other ordinary text are not automatically redacted.

Always-on mode also links exceptions and indexed replay segments to a session UUID. Replay resumes from a fresh snapshot after the page becomes visible. Standalone connection strings maintain the tab's session in token-scoped sessionStorage; provider connections use the explicit non-secret scope described below. A same-tab navigation or back/forward cache restore can continue a recently closed session, preserving the original entry URL, path, referrer and next segment index. A duplicated live tab starts a separate session. Inactivity ends a session at its last activity after 15 minutes; the maximum duration is 60 minutes. Activity can open a new session. Disabling DOM recording does not disable always-on session rows.

Normal uploads POST gzip JSON (collectionFrames, appVersion, serverName) with bearer authentication. Each occurrence has a diagnostic UUID reportId; it is not an idempotency key. The sender batches for a fixed 1,500 ms from the first pending item and detaches before attempting. One regular request runs at a time, with a 15-second total deadline covering compression, current credential resolution and fetch. Every outcome discards the detached batch: missing credentials, cancellation, timeout, network error and every HTTP status. There is no retry, backoff, acknowledgement parsing or upload persistence. Standalone connections accept any 2xx; Browser provider connections require 204. Consumer 401/403 invokes the credential's disabling callback; 5xx does not. Fresh events may still be collected.

Pending content is bounded to 100 occurrences, 200 upload items and 5 MiB - 4 KiB serialized bytes, with five-minute expiry. Serialized envelopes are capped at 5 MiB and compressed uploads at 6 MiB. An exception and optional clip are one item; oversized clips are omitted before dropping fitting exceptions. Auxiliary sessions/recordings use the same one-attempt policy. flush waits for existing work and at most one fresh attempt within its caller deadline. A caller timeout does not requeue detached work.

Every active client prepares session/replay metadata synchronously on hidden/pagehide and detaches only unsent items for one best-effort gzip keepalive request alongside a regular request. Keepalive bodies share a 64 KiB outstanding budget across SDK owners. If the complete batch exceeds the remaining budget, exit delivery omits replay and clears its occurrence links, then selects fitting error/session metadata using conservative compressed singleton budgets. Omitted items are diagnosed and discarded. Batches that cannot acquire the keepalive slot are dropped, including when credentials are missing. Consecutive lifecycle events cannot resend detached items. Hiding is not disposal: fresh events can use normal delivery. Disposal aborts requests and clears timers and pending content. Abrupt termination and oversized exit batches can lose reports. Debug IDs from Traceway or Sentry bundler registries remain matched to exception stack filenames.

Active replay retains at most 4.5 MiB of rrweb events across its current/previous segments. Logs and actions each retain at most 256 KiB, 64 KiB per event and 1,000 entries, keeping active replay plus breadcrumbs within 5 MiB. Incomplete oversized segments are omitted until a fresh snapshot; no truncated segment is uploaded. Breadcrumb input is isolated from later caller mutation. Disposal clears active recording and queued payloads.

Gateway integrations can pass { endpoint, credential, sessionScope? } instead of a connection string. The TransportCredential contract supplies currentToken(), forbidden() and an optional local-only failed(status, outcome?) diagnostic; Browser implements it with a fixed privately held credential and explicit expiry. The SDK stores no second token. A supplied stable, non-secret sessionScope selects one traceway:session:provider: storage entry across eligible navigation. Without a scope, provider sessions stay page-local and create no storage entry. Blocked storage also falls back to page-local recording. No migration is attempted for old random provider keys. Browser derives its versioned scope internally from canonical endpoint and verified application/deployment/environment/user identity; page URLs, display names and credentials are excluded. Same-owner token replacement preserves the scope and recorder/session. Continuation records retain session timing, entry metadata and segment index, plus a per-page ownership nonce so stale disposal cannot delete a replacement continuing the same UUID. Explicit stop/disposal clears the owned continuation even after hidden or pagehide; navigation and bfcache restoration preserve eligible continuation. Every send checks currentToken(), including after asynchronous compression. There is no renewal or automatic 401 retry. Standalone connection strings remain supported.

captureExceptionWithContext(error, attributes, context) is the integration intake for an already captured occurrence. Its context requires the original millisecond timestamp, report ID, nullable distributed trace ID and attachment ("immediate" or "retained"). Explicit null never selects an ambient request. Retained intake omits current browser metadata and replay/session association; unavailable historical context is not invented. Immediate intake snapshots current metadata and attachments. Both paths retain their original report and clip across retries. Ordinary standalone capture keeps its capture-time ambient defaults. The wire schema is unchanged.

Optional captureHttpServerErrors uses each fetch/XHR completion's request-owned trace ID (or null), after transport cleanup. Concurrent requests and completion order do not affect these synthetic reports. Arbitrary application errors still use page-global ambient correlation unless explicitly attributed. Standalone and Browser network projection use the same request-start timestamp, rounded duration, status, available byte counts and sanitized error/abort/timeout outcome. The native event does not wait for supplementary response-body parsing.

An HTTP 2xx response clears the sent batch from the queue. The SDK ignores the response body. captureExceptionWithAttributes accepts a reportId so gateway integrations can preserve occurrence identity. See the gateway wire contract.

Using @evrdk/browser

Applications using @evrdk/browser only install that package. Its SDK import is deferred until validated configuration enables telemetry. Let the adapter initialize Traceway: it sets application, environment, user and feature-flag attributes and applies expected-error and HTTP payload policies. It disables automatic global instrumentation while enabling native network recording through createNetworkRequestObserver(request). The returned observer binds the current client at request start and shares the standalone projection; stopping or replacing that client cannot send a late completion into its successor. Browser supplies destination/body policy and supplementary body actions. Preserve dynamic imports and code splitting when bundling the application.

Compatibility and verification

The upstream deviation log records the original library baseline and intentional local changes. Update it whenever package behavior, APIs, dependencies, or distribution diverge from upstream.

The implementation is maintained here, based on Traceway browser and shared core v1.2.1. It includes PR #4: the browser uses only the recorder entry point, with event types from @rrweb/types. Core pins both to 2.2.0. Neither upstream Traceway SDK is a dependency. The replay player is not bundled.

Repeated singleton initialization replaces the previous client's hooks and discards its unsent recording. A corrupt persisted session starts a new one.

From Core, run:

bun run --cwd packages/traceway test
bun run --cwd packages/traceway check-types
bun run --cwd packages/traceway build
bun run --cwd packages/traceway validate

Bundle size

Full public ESM entries bundled as standalone scripts, with the same esbuild 0.27.7 settings (--bundle --minify --platform=browser --format=iife --global-name=Traceway --target=es2020). Raw and gzip sizes exclude source maps; gzip uses level 9.

| Entry | Raw bytes | Gzip bytes | | ------------------------------------- | --------: | ---------: | | Published upstream v1.2.1, full rrweb | 215,390 | 68,883 | | PR #4, recorder-only | 110,101 | 34,536 | | @evrdk/traceway | 111,413 | 35,428 |

The first-party package is 48.3% smaller than upstream before compression and 48.6% smaller after gzip.

Shared observation

@evrdk/traceway/observation is a lightweight entry with no recorder or transport imports. subscribeObservation() shares one fetch/XHR wrapper and global error listener set in the realm. Request start, completion and optional body projections use one request ID; trace IDs remain separate. Native results, throws, body streams, events and existing global handlers are preserved. Subscriber failures are isolated. Unsubscribing the last owner restores only still-owned methods; detached wrappers become inert.

While observation is active, same-origin HTTP(S) fetch/XHR requests carry x-request-id, using the same ID as local diagnostics and HTTP payload actions. Caller-supplied IDs are preserved and used by observation; otherwise a fresh UUID is generated per request. Header attachment does not depend on trace propagation, body capture or observation capacity. Cross-origin application requests receive no generated header, and fetch requests with mode: "no-cors" skip attachment because that mode restricts custom headers. Wrappers cover only their own window’s fetch/XHR calls. traceway-trace-id remains separate.

Subscribers select permitted destinations before requesting body capture. Structured JSON/XML reads are shared, capped at 16 KiB, four concurrent readers and two seconds; SSE/NDJSON, binary and opaque Request streams are skipped. XHR payload capture reads text responses only. Document request bodies pass bounded node/text checks before XML serialization; overlong request metadata is skipped. Pending request observation is limited to 100 records and 60 seconds. observationStats() exposes counts and a saturating drop counter, without payloads.

internalFetch() executes SDK/integration requests once through the current host fetch while bypassing observation and trace propagation. It preserves a caller-supplied x-request-id or generates one, including for cross-origin service endpoints and before observation starts. Those endpoints must allow x-request-id through CORS. Exact configured endpoint paths are also excluded defensively. SDK uploads use this path. automaticInstrumentation: false lets an integration own observation and classification while retaining SDK transport/replay. Standalone initialization retains its default consumer. init() returns an owner-safe disposer; stop() ends the current client, releases instrumentation/replay and cancels/discards unsent uploads. Late failures cannot schedule retries after stop. Already dispatched uploads cannot be recalled.