A web app's worst failures happen where your server cannot see them: a hydration error, a rejected promise in a click handler, a fetch that never reached you because the user's network dropped. The browser SDK catches those and puts them on the same timeline as the server work they caused. A few things it does are worth explaining, because they are the opposite of what a quick integration would do.
No API key in the page
Everything in a JavaScript bundle is public. An ingest key shipped to the client is a key any visitor can read out of the page source and use to write into your account. So the page does not talk to Sentrinel at all. It posts to an endpoint on your own server, which forwards with the key:
// the page โ before hydration
import { initSentrinelBrowser } from "@sentrinel/plugin/browser";
const sentrinel = initSentrinelBrowser({ release: "2026.9.2" });
// app/api/sentrinel/route.ts โ the path the page posts to by default
import { createSentrinelTunnel } from "@sentrinel/plugin/tunnel";
export const POST = createSentrinelTunnel({
serverUrl: "https://api.sentrinel.dev",
appName: "storefront",
env: "prod",
apiKey: process.env.SENTRINEL_API_KEY!, // never reaches the client
});
The tunnel also pins the app and environment on the server, ignoring whatever a batch claims, so finding the endpoint does not let anyone write into a different app of yours. It is plain Request/Response: Next route handlers, Bun, Elysia, Hono, Remix, Workers. Django and FastAPI have their own.
The default path is /api/sentrinel. It used to be /api/_sentrinel โ which Next's App Router cannot serve at all, because a folder that starts with an underscore is private. Pages built against the old default are still out there, so a server that routes by path can answer both with isSentrinelTunnelPath().
Initialise before hydration
An error thrown while hydrating is one of the most common real failures on a server-rendered site, and a handler installed after hydration misses it. The SDK is safe to import from code that also runs on the server (no window, no-op handle) and safe to initialise twice (the second call returns the first handle) โ which matters, because StrictMode and hot reload both re-run module init.
One trace from the click to the query
Same-origin requests get a traceparent header, and the backend plugin continues that trace instead of starting its own: the click, the request and the handler land on one waterfall. Third-party URLs get nothing by default โ sending trace ids to a vendor leaks them, and a custom header turns a simple request into one that needs a CORS preflight. Widen it with tracePropagationTargets when you own both ends.
Browser timings are client data and are kept apart from the backend's. A fetch timed in the page includes the network and the browser's queueing; the server's number for the same call does not. They used to be rolled into the same endpoint metrics, doubling every count and blending two unrelated latencies into one p95. Now browser requests are their own rows, in the web part of the app, and client spans on the trace.
The page's URL is where the secrets are
Password-reset links, magic links, OAuth code, ?api_key=, pre-signed storage signatures โ the page URL is exactly where they turn up. Every URL the SDK sends has those values replaced with ***: request query strings, the page URL on every record, error source URLs, referrers, and the session-replay URL. The fragment is included, because OAuth's implicit flow returns #access_token=โฆ. beforeSend runs before anything is put on the wire, for whatever else should never leave the device.
Nothing is dropped because the network blinked
A batch stays queued until the tunnel answers with a success, and failures are retried with backoff โ bounded, so a long outage cannot grow the page's memory. A session whose batch failed is resent with its current state, so a crash that happened after the failure is not overwritten by an older snapshot. When the page is hidden or closed, what is still waiting goes by sendBeacon or a keepalive request โ the only transports a browser guarantees to finish once the page is going away.
Every visitor is someone
Each browser has a persisted id. Until you say who the user is, everything is filed under guest:<device id> โ a visitor who hit an error before signing up is one consumer you can follow across visits โ and sentrinel.identify(user.id) links that history to the person. Same-origin requests carry the identity to your backend, so server-side errors are filed under the same person. See Every install is someone.
And the rest
Sessions per page load feed the same Release health page as mobile; web vitals (LCP, CLS, INP) are attached to the session; session replay records the moments before an error, masked by default. Browser noise nobody can act on โ Script error., the benign ResizeObserver loop warning, anything from an extension โ is dropped before it counts.
The web reference has every option.