Contents

Browser deployment compatibility snapshots

This credential-free suite exercises production-packed posthog-js through its native snippet, regular npm, slim npm and static-loader entrypoints. Historical deployments keep published posthog-js@1.354.0 core bytes for snippet and regular npm, and posthog-js@1.407.6 for slim with AllExtensions. Both load the current checkout's CDN extensions. SDK methods and extension setup are not replaced by the harness.

Commands

Use Node 24 and the repository's pnpm version. From the repository root:

 1pnpm install --frozen-lockfile
 2pnpm --filter posthog-js exec playwright install chromium firefox webkit
 3pnpm turbo run build --filter=@posthog-tooling/sdk-mock-server
 4pnpm --filter posthog-js compatibility:self-test
 5pnpm --filter posthog-js compatibility:controls
 6pnpm --filter posthog-js compatibility:test
 7
 8# Explicitly regenerate all seven files for code review:
 9pnpm --filter posthog-js compatibility:update
10
11# A focused, read-only check (reported as partial):
12pnpm --filter posthog-js compatibility:test --engines chromium --modes npm --comparisons current --scenarios core,logs

Both test and update build this checkout using its normal production build, pack its SDK/workspace dependencies, install isolated consumers and execute at least two repeats per selected cell. Registry access is needed for preparation; browser traffic is restricted to the local fixture/backend server. Native HTTP traffic uses a deny-only proxy without loopback bypass. Chromium/Firefox traffic is not intercepted by Playwright, preserving navigation/Beacon delivery; WebKit additionally aborts HTTPS requests because its macOS HTTP proxy can be bypassed for TLS. Live controls require zero connections to other loopback HTTP/HTTPS origins. Standalone consumers use pnpm 11.7.0 with a seven-day dependency cooldown, exact current dependency overrides, local PostHog tarballs, and frozen dependency locks for both historical packages. No product credentials are required. Install browser system dependencies on Linux with Playwright's install --with-deps command or use the CI's pinned Playwright image.

Selectors are comma-separated --engines, --modes, --comparisons (current,historical) and --scenarios. --repeats may increase the repeat count, never reduce it below two. --output /path/to/new-directory selects a new evidence directory; existing directories are rejected. The default is a unique directory under the ignored repository-root test-results/compatibility/. Controls likewise accept --output.

A full run comprises 714 cells / 1,428 executions: seven supported deployments × three engines × 34 scenarios. Current cores cover snippet, regular npm, slim npm and the static loader; historical cores retain the original three entrypoints because those releases did not ship a loader. goldens/ contains exactly seven readable JSON files, each with 102 cells. Updates reject partial/incomplete coverage, functional failures, unexpected errors, changed inputs and unequal repetitions before publishing a staged complete directory. Checks never write expected files. Semantic differences in runs/report.json identify deployment, browser, scenario, JSON path and expected/actual values. Ordered callbacks and nested payload batches remain ordered.

The loader mode dynamically inserts the production-packed /static/loader.js?project_token=phc_COMPAT tag with JSON configuration and default automatic initialization. Its native SDK request is held while public calls are queued. A public queue callback observes readiness because auto-init JSON cannot carry a loaded function. Each scenario independently requires exactly one loader request and one core request from the same unversioned namespace (/static/array.js), with no forwarded query parameters. Major and exact-version namespaces are covered by the focused static-loader Playwright tests. Deferred initialization remains covered by the focused static-loader Playwright tests.

Browser engines execute in parallel against one prepared input manifest; each engine's cells and repetitions remain sequential. All engines finish and close before the combined matrix is validated.

Follow the snapshot update criteria in the browser contributor guide before regenerating expectations.

Evidence and reproducibility

Each execution records settings, raw API/UI/replay/network observations, complete HTTP wire evidence (including exact body bytes in base64), normalized observations and backend inspection. Failures retain failure.json and a best-effort screenshot. Matrix evidence records actual versions, host, browser versions, source state, tarballs, consumer locks and expected/before/after SHA-256 inventories. Uncommitted source additions, changes and deletions are fingerprinted as the working tree, not attributed to an unchanged HEAD. No staging or stashing is required.

The normalization retains null/missing/explicit undefined/error distinctions, application values, coordinates, privacy markers, identity relationships, decoded replay content and compression versions. Replay network records normalize only finite native clock fields (startTime, endTime, timeOrigin, timestamp) and known navigation/resource timing measurements; initial-navigation request/response phases allow a bounded 4 ms pre-origin offset observed in Firefox. Negative clocks outside that bound, on noninitial/resource records, or in unrelated fields remain observable. Independent assertions validate the fixture requests' ordering and clock relationship first. Request/response headers, bodies, methods, status, URLs and record order remain observable. Only recognized core/extension metadata is replaced with role tokens after asserting the actual value against its manifest. The fixture loader tag's recorded data-config JSON normalizes local fixture origins while retaining its configuration values; unrelated DOM attributes remain untouched. Raw evidence retains actual versions. Independent HTTP deliveries may reorder; arrays inside delivered batches and callbacks do not. Pending-barrier samples and known CPU/encoded-size diagnostics are preserved raw, with bounded normalization used for comparison. Web Vitals compares delivery and metric structure, not exact FCP values or ratings: finite nonnegative measurements, recognized ratings and SDK metric IDs normalize only inside $web_vitals events; raw measurements remain in the evidence.

The execution profile fixes viewport (1024×768), locale, UTC timezone, light color scheme, reduced motion, blocked service workers and the pinned Playwright 1.52 Desktop Chrome/Firefox/Safari user agents. Chrome/Firefox report the profile's Windows desktop OS; Safari reports macOS. OS/device attributes remain observable, including in logs. This profile emulates those desktop user agents; it does not change the host OS or claim complete device emulation. Host-dependent rendering and browser implementation differences must still pass the same snapshots on each supported host. Browser binaries, Playwright code and the native bundler are fingerprinted. Firefox's installation-local .parentlock runtime file is excluded from the tooling inventory. Browser/tooling upgrades require reviewed snapshot changes. Interaction and replay-lifecycle scenarios use a paused Playwright clock and synchronize native browser/config execution before advancing timers. The replay network scenario freezes only Date, preserving native performance.now(), resource timings and timer scheduling; other scenarios use Playwright's fixed-time clock. Replay lifecycle clock advances wait for native gzip's Response.blob() and Blob.arrayBuffer() reads to settle, including their promise continuations, so flush timers see the captured activity. Large replay idle intervals advance in bounded steps, draining native HTTP between steps so simulated time cannot race real responses. Only navigation-ending unload and replay-bounce enable request batching; the HTTPS egress guard remains active.

Independent behavior gates and controls

Scenarios cover core lifecycle, identity/reset/consent/flags, autocapture, surveys, logs, replay, exception autocapture, toolbar loading, conversations, disabled products, extension failure, delayed loading, unload, version fallback, listener cleanup, forms, links, rage/dead clicks, scrolling and heatmaps. Functional, privacy, exact-once delivery and native-loader/UI assertions run in both check and update mode.

The xhr scenario forces native XHR for the core lifecycle, including successful flags, identity/reset, consent and event delivery. The timeout scenarios first load a cached flag, then hold real HTTP responses until the browser's XHR timeout fires. They check automatic retry/recovery, exhausted retries, cached values, error classification and one callback per logical reload. Browser request resource types independently prove that flags and capture use XHR. The pinned historical cores predate automatic flag retries, so their recovery case also verifies an explicit public reload after the failed attempt.

Additional product and replay cases cover:

  • Automatic survey appearance, textarea input and submission through the rendered UI, alongside the existing manual-display case.
  • Real browser FCP collection and backend $web_vitals delivery with valid metric fields and matching session/window/URL metadata.
  • Replay network request/response headers and bodies: harmless JSON remains complete, sensitive headers and password bodies are redacted, and native requests/responses retain their original content. This scenario uses the existing _forceAllowLocalhostNetworkCapture test override in the loaded callback to enable the recorder on the loopback fixture; fetch and masking implementations are not replaced.
  • Replay CSS variables with shorthand/longhand declarations and pre-snapshot insertRule(), checked against both original and reconstructed computed styles.
  • Cold start with legacy persisted recording config lacking cache_timestamp, held live config, a capture while waiting, preservation of the saved config and recording after release. Startup before live config is observed rather than forced: current cores wait for fresh config, while historical cores use their own policy.
  • Recording idle/wake, analytics-session rotation, passive real-navigation unload and minimum-duration gating, with full snapshots, privacy checks and reconstruction of the changed DOM.
  • Recording start conditions evaluated by the lazy recorder from the core's persisted remote config: an event trigger overriding a zero sample rate, a URL trigger followed by a URL blocklist pause and resume on a URL matching neither pattern, and a variant linked flag that first loads a nonmatching variant and then switches to the linked one. Each records the recorder status and requires no upload before its condition matches. The blocklist case also rejects blocked-page content anywhere in the final replay.
  • Uncaught errors, unhandled rejections, console.error and manual captureException() delivered as $exception events. Native clicks on fixture buttons start each failure so stack frames reference only the fixture script. The fixture's own page errors and rejections must each occur exactly once (the SDK's onunhandledrejection handler returns false and cancels the event, so Chromium and WebKit don't report the rejection as a page error while Playwright's Firefox still does; a change to this list may indicate an SDK change); they are retained in raw evidence and excluded from snapshots, and any other runtime error still fails the cell.
  • Toolbar authorization from a #__posthog URL state: the consumed hash, stored parameters, one script request and the parameters and SDK instance passed to ph_load_toolbar. A stub stands in for the PostHog app's toolbar.js.
  • The conversations widget opening, sending a first message, polling for and rendering a reply, and marking it read on the paused clock, against fixed widget API responses. Like the API, the fixture rejects widget requests without the configured widget token or the anonymous visitor's widget_session_id, rejects a message without its distinct_id, and serves the ticket only to the visitor who started it.

Self-tests protect small semantic API/payload changes, nested batch/callback order, exact coverage, repeat equality, historical source attribution and update publication/rollback faults. Browser controls hold real gzip output for a minimum-duration replay mutation and require identical snapshots after release, with current and historical cores in all three engines. Live controls also alter an artifact without repinning and require rejection before browser execution. They then pin a throwing survey CDN script and require failures through both current and historical native loaders. A separate control removes captureLog from the prepared current consumer and requires log scenarios to fail instead of publishing new expectations. An empty Web Vitals CDN extension must also fail both current and historical delivery scenarios. Disabling Replay header/body capture must fail both core families even when the application requests succeed, preventing an update from accepting missing network records. A throwing static-loader bootstrap must also fail its deployment scenarios. Expected snapshots remain unchanged in all controls.

Historical coverage and limits

The historical pins are independently verified against their published SHA-512 package integrities and frozen consumer locks. Slim uses 1.407.6, which preserves private names across its core and extension bundles. All 714 cells must reach full functional readiness and pass the independent behavior gates.

Historical logs API coverage is unavailable. Historical version-fallback cases use strict_script_versioning: false and prove only the legacy loader path; current cases use 'fallback' and require a versioned 404 followed by legacy success and rendered survey UI. Disabled products retain enabled flags. Survey coverage is one open-text popover. Scrolling uses explicit public pageview/pageleave captures around native wheel input, not automatic navigation pageleave. This is not exhaustive SDK, historical-version, quota/retry, survey-type, CJS, touch or production-ingestion coverage. Shared mock routes are synthetic backend responses, not ingestion-service conformance.

The CI job is read-only and credential-free and retains diagnostic artifacts on failure. Run the same full check on Linux before claiming host portability; a passing run on one host alone does not establish that gate.