Skip to content

SDK Reference

The SiteQwality client SDK is a single browser-side package: @siteqwality/rum. It collects Real User Monitoring data and (when activated) session replay segments.

It is not a back-end ingestion library — for back-end metrics/logs/traces, ship via the OTel SDK or direct HTTP to the ingestion endpoints. See Observability.

CaptureAlways-onActivated by filter
Web Vitals (LCP, FCP, CLS, INP, TTFB)yes
View counts, page loadsyes
Aggregate error countyes
Aggregate action countyes
Individual error stacksyes
Click / keypress targetsyes
Resource timings (fetch/XHR)yes
Long tasks (>50ms)yes
Distributed-trace IDs (traceparent injection)yes
DOM snapshots + mutations (rrweb)yes (capture_replay: true)
Terminal window
npm install @siteqwality/rum
<script type="module" src="https://cdn.siteqwality.com/rum/v1/sdk.min.js"></script>
import { SiteQwalityRUM } from '@siteqwality/rum';
await SiteQwalityRUM.init({
applicationId: 'abc123', // from RUM application
clientToken: 'pub_def456', // from RUM application (public token)
service: 'web', // logical service name
version: '1.4.2', // app version (used for source-map matching)
env: 'prod', // 'prod' | 'staging' | 'dev'
// Optional overrides — for self-hosted SiteQwality
apiBase: 'https://api.siteqwality.com',
ingestBase: 'https://rum.siteqwality.com',
replayBase: 'https://replay.siteqwality.com',
});

init is idempotent — calling it twice is a no-op.

Identify the user. Call after login, or as soon as you know who’s there.

SiteQwalityRUM.setUser({
id: 'usr_abc123',
email: 'alice@example.com',
name: 'Alice',
});
FieldRequiredDescription
idoptionalYour internal user ID. Indexed for filtering.
emailoptionalUser’s email.
nameoptionalDisplay name.

User context attaches to all subsequent events and replay segments.

Track a custom error in addition to auto-captured errors.

try {
await chargeCard();
} catch (err) {
SiteQwalityRUM.addError(err, { feature: 'checkout', step: '3' });
throw err;
}
ParamTypeDescription
errorErrorAny JS Error.
contextRecord<string, string>Optional free-form context.

Track a custom action (click-equivalent business event).

SiteQwalityRUM.addAction('checkout_completed', { variant: 'A' });
ParamTypeDescription
namestringAction label.
contextRecord<string, string>Optional metadata.

The SDK ships with TypeScript types:

import type { RumConfig, UserContext } from '@siteqwality/rum';

Notable types:

  • RumConfiginit argument shape.
  • UserContextsetUser argument shape.
  • RumMeasureEvent, RumDetailEvent, RumErrorEvent — internal payload shapes (rarely needed).
  • SessionFilterRule, SdkConfig — server-fetched config shape.

The SDK is free; what costs is the data it sends. See RUM pricing and Replay pricing.

  • Modern browsers — Chrome, Firefox, Safari, Edge (last 2 versions).
  • ES2020+ output. The CDN bundle is an ES module (<script type="module">).
  • For older browsers, transpile via your bundler. The npm bundle is published as both ESM and CJS.