Skip to main content
@heretic-hq/collector opens an edge session, runs browser measurements, and posts the payload. It returns a request ID for a later server-side read.

Install

The package supports named and default imports:
It also exports resolveEndpoint(config?), PROBE_VERSION, SURFACE_VERSION, and RENDER_VERSION. There is no public Collector class, createCollector, collect method, or heretic.explain method.

Run one collection

The return type is:
The function converts collection failures into { ok: false, reason }. It starts one run per page. Later calls reuse the first run and do not apply a new configuration. requestId is a join key, not a verdict. Ordinary success is { ok: true, requestId: "<32 lowercase hex>" }. The edge returns it only after the tenant projection is committed. ZDR success is exactly { ok: true } and has no request ID.

Public site key

siteKey accepts a public key in this form:
The key attributes a settled projection to a site. It is safe in browser code. It does not sign collection and cannot authorize verdict reads. The type makes siteKey optional, but a missing, unknown, or revoked value does not produce a tenant-readable attribution. Use an hrtc_sk_... secret only on the server.

Configuration

The DoH object has this shape:

Endpoint resolution

resolveEndpoint(config?) checks candidates in this order:
  1. config.endpoint
  2. An HTTPS endpoint in globalThis.__hereticEdge
  3. A non-expired endpoint in sessionStorage
  4. DoH discovery when doh is set
  5. Control-plane discovery when controlPlane is set
  6. The first configured fallback, or https://tcp.waw.probe.heretic.quest
The built-in fallback contains Warsaw. You can pin a deployed edge when needed: The browser must connect directly to the selected measurement edge. A proxy in front of that endpoint changes the connection being measured.

Request sequence

A normal run makes these requests:
With zdr: true, the final request is:
The first health response teaches a fresh QUIC origin its Alt-Svc route. The second health request carries the nonce over HTTP/3 when the browser supports it. The TCP origin does not advertise HTTP/3.

Script tag

The browser build defines a global heretic function:
You can serve dist/heretic.js from your origin. An edge-hosted bundle self-targets the edge that served it. Call the global with a public key for tenant attribution:

Collection controls

surface

surface: false removes the declared-surface section. Current rules read fields from that section, so disabling it can reduce coverage or remove findings. The payload records the configured omission.

render

render: false omits fixed canvas and WebGL raster collection. It does not disable identity. The base measured payload can still supply canvas or audio anchors, and the machine ID uses cores, display, and timezone.

rawSurface

rawSurface: false keeps the surface section but coarsens or omits exact forms of:
  • WebRTC host candidate addresses
  • battery level and finite charge or discharge times
  • storage quota and usage
The payload can still contain address counts and families, a coarse battery level, and storage buckets.

budgetMs

The collector checks budgetMs between sections in the core measured phase. A section already running may finish after the budget. Skipped sections record skipped: 'budget-cut' and appear in budget.cut. Fixed rendering and declared-surface collection run afterward, outside budgetMs. Declared-surface sections have their own deadlines. budgetMs is not a whole-run deadline.

zdr

zdr: true posts to /z. Parsed claims stay request-local. A valid request creates no assessment, identity, projection, NDJSON record, request ID, or retrievable session. It removes the owned per-nonce session and linked state, then returns { ok: true }. Malformed or incomplete ZDR submissions retain only a hidden, nonpersistable baseline marker. They retain none of the submitted request data.

Worker CSP

The parallel probe uses blob: workers. If the page’s CSP blocks them, the payload records:
Other collection continues. Allow the worker with:

Payload versions

Continue on the server

Pass the returned request ID unchanged to your server. See Tenant verdict endpoint.