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.
What it does
Section titled “What it does”| Capture | Always-on | Activated by filter |
|---|---|---|
| Web Vitals (LCP, FCP, CLS, INP, TTFB) | yes | — |
| View counts, page loads | yes | — |
| Aggregate error count | yes | — |
| Aggregate action count | yes | — |
| Individual error stacks | — | yes |
| Click / keypress targets | — | yes |
| Resource timings (fetch/XHR) | — | yes |
| Long tasks (>50ms) | — | yes |
| Distributed-trace IDs (traceparent injection) | yes | — |
| DOM snapshots + mutations (rrweb) | — | yes (capture_replay: true) |
Install
Section titled “Install”npm install @siteqwality/rum<script type="module" src="https://cdn.siteqwality.com/rum/v1/sdk.min.js"></script>Initialize
Section titled “Initialize”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.
Public methods
Section titled “Public methods”setUser(user)
Section titled “setUser(user)”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',});| Field | Required | Description |
|---|---|---|
id | optional | Your internal user ID. Indexed for filtering. |
email | optional | User’s email. |
name | optional | Display name. |
User context attaches to all subsequent events and replay segments.
addError(error, context?)
Section titled “addError(error, context?)”Track a custom error in addition to auto-captured errors.
try { await chargeCard();} catch (err) { SiteQwalityRUM.addError(err, { feature: 'checkout', step: '3' }); throw err;}| Param | Type | Description |
|---|---|---|
error | Error | Any JS Error. |
context | Record<string, string> | Optional free-form context. |
addAction(name, context?)
Section titled “addAction(name, context?)”Track a custom action (click-equivalent business event).
SiteQwalityRUM.addAction('checkout_completed', { variant: 'A' });| Param | Type | Description |
|---|---|---|
name | string | Action label. |
context | Record<string, string> | Optional metadata. |
TypeScript types
Section titled “TypeScript types”The SDK ships with TypeScript types:
import type { RumConfig, UserContext } from '@siteqwality/rum';Notable types:
RumConfig—initargument shape.UserContext—setUserargument shape.RumMeasureEvent,RumDetailEvent,RumErrorEvent— internal payload shapes (rarely needed).SessionFilterRule,SdkConfig— server-fetched config shape.
Pricing
Section titled “Pricing”The SDK is free; what costs is the data it sends. See RUM pricing and Replay pricing.
Compatibility
Section titled “Compatibility”- 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.