SDK reference
init(options)
Section titled “init(options)”Initializes the browser RUM SDK. options accepts the following properties:
| Property | Type | Description |
|---|---|---|
applicationName | string | The application’s name. |
endpoint | string (required) | KloudMate’s collector endpoint: https://otel.kloudmate.com:4318 |
rumAccessToken | string (required) | The workspace’s Frontend ingest key. See The ingest key. |
deploymentEnvironment | string | The application’s environment, such as dev, prod, or staging. |
version | string | The application’s version, such as 0.0.1. |
globalAttributes | object | Key-value pairs added to every span. |
sampleRate | number | Share of sessions that send telemetry at all, from 0 to 1. Defaults to 1. |
sessionRecorder | object { enabled: boolean, sampleRate: number, options: RRWebRecordConfig } | Configure session recording. Set enabled to true to record. Off by default. See Record sessions for replay. |
events | object | Which automatic events to capture, including console output. See Choose what the SDK captures. |
ignoreUrls | (string | RegExp)[] | URLs to skip instrumenting entirely. No span is created and no trace header is added. |
propagateTraceHeaderCorsUrls | (string | RegExp)[] | Cross-origin URLs allowed to receive the traceparent header. See Correlate RUM traces with OpenTelemetry backends. |
excludeBots | boolean | function | Skip automated and crawler traffic so it never starts a session. Defaults to true. |
captureConsoleErrors | boolean | Report console.error(...) as a real error, not only as a console line. Defaults to true. |
Methods
Section titled “Methods”| Method | Description |
|---|---|
setUser(user) | Set the signed-in user. id and email map to the userId and userEmail attributes; any other field is added as an attribute on every span. See Identify the user. |
endSession() | End the session in every tab on sign-out, clearing everything setUser() set. |
setGlobalAttributes(attributes) | Add key-value pairs to every subsequent span. Set a key to null to remove it. |
getGlobalAttributes() | Return the current global attributes. |
getSessionId() | Return the session ID, or null between endSession() and the start of the next session. |
addEvent(name, attributes) | Record a custom event. See Send custom events. |
recordException(error, attributes) | Report a handled error that automatic capture never sees. Pass an Error to keep the stack trace, or a string. |
The mobile SDKs share one KloudMateRumConfig across Android, iOS, and React Native. TypeScript definitions for the full React Native option list ship with the package.
Data attributes
Section titled “Data attributes”The attributes you’re most likely to group or filter on:
| Attribute | Description |
|---|---|
serviceName | The RUM application name. |
rumSessionId | The RUM session’s ID. |
origin | Origin of the instrumented app, such as https://example.com. |
route | Part of the app’s URL excluding origin and search. |
search | Search params of the app’s URL. |
component | The instrumentation that produced the span. |
eventType | The type of user interaction, such as click or submit. |
userId | User’s synthetic ID. |
userEmail | User’s email. |
browser | User’s browser name. |
browserVersion | User’s browser version. |
country | User’s country. |
city | User’s city. |
os | User’s operating system. |
osVersion | User’s operating system version. |
device | User’s device. |
deviceType | User’s device type. |
screen.width | Screen width in logical pixels. Shown as Screen in session detail, and behind the Screen resolution breakdown on Overview. |
screen.height | Screen height in logical pixels. |
screen.density | Display scale factor. Shown as Screen Density when it is not 1. |