Skip to content

Configuration

Everything the SDK can be told, and what it does when you tell it nothing.

import { init } from '@ritim/browser-sdk';
init({
projectKey: 'P-ABC123',
release: 'a1b2c3d',
sampleRate: 0.25,
trackSoftNavigations: true,
captureInteractionText: false,
debug: false,
});
Option Type Default Meaning
projectKey string required Public project key, P-XXXXXX.
release string inferred Release identifier. See Releases.
endpoint string build-time Override the compiled-in collector.
sampleRate number 0.25 Client-side rate, 0–1. Clamped to that range.
trackSoftNavigations boolean true false measures only the initial document load.
captureInteractionText boolean false Include element text in interaction targets. See below.
debug boolean false Log every payload to the console. Never enable in production.

The type is exported, so you can build the object elsewhere and keep it checked:

import { init, type RumInitOptions } from '@ritim/browser-sdk';
const options: RumInitOptions = { projectKey: 'P-ABC123' };
init(options);

sampleRate is a client-side rate: the SDK decides per page view whether to measure at all, so an unsampled view costs nothing beyond the bundle.

The default of 0.25 matches the default a new project gets in the dashboard. Three page views in four deliberately do nothing — correct for production, and the single most common reason a new install looks broken. Set it to 1 while verifying and put it back afterwards.

Values outside 0–1 are clamped rather than rejected.

Off by default. When on, an interaction on an element with no id reports a short text excerpt alongside the tag name:

captureInteractionText: false → button
captureInteractionText: true → button "Add to cart"

An id always wins — an element with one reports #add-to-cart either way, and the text is never read. The excerpt is whitespace-collapsed and truncated to fit a short field.

init({ projectKey: 'P-ABC123', trackSoftNavigations: false });

This measures the initial document load and nothing after it. Reach for it when your app rewrites the URL for something that is not a view change — a filter panel that pushes state on every keystroke will otherwise produce a measurement per keystroke, and burn your event allowance doing it.

Where two sources say the same thing, the more specific wins:

  1. init({ … })
  2. <meta name="rum-release"> — release only
  3. data-* on the script tag
  4. what the SDK can infer from the page — release only, see Releases

Logs every payload to the console before it is sent. It is a development aid and nothing more: it does not change what is collected or where it goes, and leaving it on in production just puts your measurements in your visitors’ consoles.

init({ projectKey: 'P-ABC123', debug: true });