BuildImplementation guide5 min read

Browser RUM Implementation Guide

By Nicolas Narbais

Use Grafana Faro to capture browser errors, views, Web Vitals, and selected frontend journeys without collecting customer data by accident.

Last updated on

Capture real user browser experience (views, Web Vitals, JavaScript errors, and owned API calls) with the Grafana Faro Web SDK across four levels. Enable browser tracing only when you need to follow an action into an API that already emits backend traces.

LevelGoalWhat it proves
1Collect browser baselineViews, sessions, Web Vitals, uncaught errors
2Normalize journeys and eventsRoute templates, release identity, zero PII
3Connect owned APIs to backend tracestraceparent on allowlisted API origins only
4Make browser health operationalDashboards + sustained-impact alerts
flowchart LR B["Browser + Grafana Faro SDK"] -->|"Views, errors, Web Vitals"| FC["Faro collector"] B -.->|"traceparent (allowlisted origins only)"| API["Owned backend API"] API --> BT["Backend traces"]

Split ownership cleanly upfront: the application team owns the SDK, release identity, and data policy; platform/security owns the public token, origin allowlist, and CORS policy.

Before starting

  • Start with one app: agree on public origins, environments, owners, and one customer journey.
  • Protect keys: create a browser-scoped public key with strict origin restrictions and a rotation owner. Never ship a server-side ingestion key to the browser.
  • Lock identity: standardize app.name, immutable build SHA in app.version, and app.environment (matching service.name if tracing is enabled).
  • Define privacy boundaries: strip or normalize URL parameters, fragments, error messages, console output, and event fields containing customer data; require consent before persistent IDs or session replay.
  • List allowlists and exclusions: name third-party URLs to ignore (ignoreUrls) and exact API origins allowed to receive traceparent/tracestate.

Level 1 - Collect the browser baseline

Initialize Faro once in the browser entry point before mounting the app (browser-only for SSR apps), reading collector URL and public key from build-time environment variables:

import { getWebInstrumentations, initializeFaro } from '@grafana/faro-web-sdk';

initializeFaro({
  url: import.meta.env.VITE_FARO_URL,
  apiKey: import.meta.env.VITE_FARO_PUBLIC_KEY,
  app: {
    name: 'customer-portal',
    version: import.meta.env.VITE_RELEASE_SHA,
    environment: import.meta.env.VITE_DEPLOYMENT_ENVIRONMENT,
  },
  instrumentations: [...getWebInstrumentations()],
  ignoreUrls: [
    /^https:\/\/faro-collector\.example\.com\//,
    /^https:\/\/analytics\.example\.com\//,
  ],
});

Always spread getWebInstrumentations() when adding custom instrumentations, because replacing it silently drops default Web Vitals and uncaught error capture.

Deploy to staging, load a known route, verify a 2xx collector call in the browser Network panel, and trigger one controlled error to verify stack trace and page context.

Exit criteria: A known navigation records a view, session, app identity, release SHA, and supported Web Vitals; a test error arrives once with usable stack and page context.

Level 2 - Normalize views and journey events

For single-page apps, add your framework’s router instrumentation so client-side route transitions record properly (document-load alone misses SPA navigation).

  • Use route templates: name views /checkout or /orders/:orderId, never raw URLs carrying customer IDs, emails, search queries, tokens, or fragments.
  • Emit bounded journey events only:
faro.api.pushEvent('checkout_submitted', {
  flow: 'standard',
  payment_method: 'card',
});
Warning

Prohibited RUM data: Never send form inputs, support messages, payment data, credentials, headers, response bodies, full URLs, user/session/cart/order IDs, unapproved console logs, or unconsented session replay.

Run both a successful and failed journey plus a deliberately sensitive test fixture, confirming the benign events differentiate outcomes while the sensitive value never arrives.

Exit criteria: The first journey has normalized views, bounded events, release-over-release comparison, and a passing negative PII test.

Level 3 - Connect an owned API to backend traces

Enable @grafana/faro-web-tracing only when the target API already emits server traces. Same-origin requests receive trace headers automatically; restrict cross-origin propagation with an explicit propagateTraceHeaderCorsUrls allowlist:

import { getWebInstrumentations, initializeFaro } from '@grafana/faro-web-sdk';
import { TracingInstrumentation } from '@grafana/faro-web-tracing';

initializeFaro({
  url: import.meta.env.VITE_FARO_URL,
  apiKey: import.meta.env.VITE_FARO_PUBLIC_KEY,
  app: { name: 'customer-portal', version: import.meta.env.VITE_RELEASE_SHA },
  instrumentations: [
    ...getWebInstrumentations(),
    new TracingInstrumentation({
      instrumentationOptions: {
        propagateTraceHeaderCorsUrls: [/^https:\/\/api\.example\.com\//],
      },
    }),
  ],
  ignoreUrls: [/^https:\/\/faro-collector\.example\.com\//],
});

On the API side, allow traceparent and tracestate in CORS for the frontend origin and continue the inbound trace context in the server SDK. Keep frontend and backend service names distinct, and never trust browser-supplied headers for auth, tenant, or role decisions.

Verify two calls: an allowlisted API call shares one trace ID from browser to backend, and a non-allowlisted cross-origin call receives no trace header.

Exit criteria: One browser action traces end to end into the owned API without widening cross-origin header propagation.

Level 4 - Make browser experience operational

Build one team-owned dashboard from proven RUM signals:

  • Traffic and releases: views split by release SHA and environment.
  • Errors: browser error rate and grouped top errors.
  • User speed: Web Vital distributions and poor-experience rates.
  • API health: owned API error rate and latency (with trace pivot when Level 3 is on).
  • Journey outcomes: primary funnel event and success/failure ratio.

Alert only on sustained customer impact with a named owner and traffic/sampling floor: a release-specific error spike, a Web Vital regression on a key route (like /checkout), or sustained owned-API failures. Test the notification route.

Exit criteria: On-call can attribute a regression to a release or route and immediately tell browser bugs, UX regressions, and owned-API failures apart.

Troubleshooting path

Start from one known page load in DevTools:

SymptomCheck firstFix
No data reaches collectorBrowser Network tab for collector requestFix collector URL, public key, origin allowlist, CSP, CORS, or ad-blocker
Duplicate views or eventsEntry-point initializationEnsure initializeFaro runs once on client mount only
Views arrive without Web Vitals/errorsinstrumentations array & browser supportKeep ...getWebInstrumentations() intact
Custom event missingConsent gate, event name, source filterTrigger the exact journey and inspect blocked/filtered branches
Browser and API traces do not jointraceparent header, CORS preflight, server SDKAllow traceparent/tracestate on the API origin only; verify server propagation

Completion criterion

A production-equivalent journey records normalized views, release identity, Web Vitals, and safe error tracking; the team can separate browser regressions from owned-API failures (and pivot into backend traces if Level 3 is enabled); and zero prohibited customer data appears in RUM attributes.

References

Written by

Nicolas Narbais

Nicolas Narbais builds, breaks, debugs, and scales observability systems using OpenTelemetry and modern telemetry pipelines. He shares practical, opinionated lessons to help engineers get better signal with less noise.

Olatuak Editorial Philosophy

Better signal, not more telemetry.

Olatuak helps platform engineers, SREs, and observability teams turn noisy telemetry into clear operational decisions without blindly collecting more data.

Scroll to zoom · Drag to pan · Double-click to reset