@splunk/otel-web-session-recorder
🚀 Installation & Setup
•
⚙️ Configuration
•
🛠️ Troubleshooting
•
📚 API Reference
For complete instructions for how to get started with the Splunk distribution of OpenTelemetry JavaScript for Web, see Install the Browser RUM agent for Splunk RUM, Instrument browser-based web applications for Splunk RUM and Record browser sessions.
Privacy-aware visual session replay for web applications. The Splunk Session Recorder extends @splunk/otel-web with comprehensive session recording capabilities, correlating visual user interactions with OpenTelemetry telemetry for enhanced debugging and user experience analysis.
🚀 Installation & Setup
Package Manager Installation
1. Install the Packages
npm install @splunk/otel-web @splunk/otel-web-session-recorder
pnpm add @splunk/otel-web @splunk/otel-web-session-recorder
yarn add @splunk/otel-web @splunk/otel-web-session-recorder
2. Initialize RUM and Session Recorder
import { SplunkRum } from '@splunk/otel-web'
import SplunkSessionRecorder from '@splunk/otel-web-session-recorder'
SplunkRum.init({
realm: 'us1',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
applicationName: 'my-web-app',
deploymentEnvironment: 'production',
})
SplunkSessionRecorder.init({
realm: 'us1',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
})
CDN Installation
1. Load the Scripts
<script
src="https://cdn.signalfx.com/o11y-gdi-rum/<version>/splunk-otel-web.js"
crossorigin="anonymous"
integrity="sha384-<integrity>"
></script>
<script
src="https://cdn.signalfx.com/o11y-gdi-rum/<version>/splunk-session-recorder.js"
crossorigin="anonymous"
integrity="sha384-<integrity>"
></script>
Replace <version> and <integrity> with the values from GitHub Releases.
2. Initialize RUM and Session Recorder
<script>
SplunkRum.init({
realm: 'us1',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
applicationName: 'my-web-app',
deploymentEnvironment: 'production',
})
SplunkSessionRecorder.init({
realm: 'us1',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
})
</script>
Complete CDN Example
<!DOCTYPE html>
<html>
<head>
<title>My Web App with Session Recording</title>
<script
src="https://cdn.signalfx.com/o11y-gdi-rum/<version>/splunk-otel-web.js"
crossorigin="anonymous"
integrity="sha384-<integrity>"
></script>
<script
src="https://cdn.signalfx.com/o11y-gdi-rum/<version>/splunk-session-recorder.js"
crossorigin="anonymous"
integrity="sha384-<integrity>"
></script>
<script>
SplunkRum.init({
realm: 'us1',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
applicationName: 'my-web-app',
deploymentEnvironment: 'production',
})
SplunkSessionRecorder.init({
realm: 'us1',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
debug: false,
})
</script>
</head>
<body>
</body>
</html>
⚠️ Important: Always call SplunkRum.init() before SplunkSessionRecorder.init().
⚙️ Configuration Options
realm | string | ✅ | - | Splunk realm (us0, us1, eu0, etc.) |
rumAccessToken | string | ✅ | - | RUM access token for authentication |
beaconEndpoint | string | ❌ | - | Custom destination URL for captured data (overrides realm) |
debug | boolean | ❌ | false | Enable debug logging |
persistFailedReplayData | boolean | ❌ | true | Store failed uploads in localStorage for retry |
maskAllInputs | boolean | ❌ | true | Mask all form input values |
maskAllText | boolean | ❌ | false | Mask all text content |
sensitivityRules | SensitivityRule[] | ❌ | [] | Custom rules for masking, unmasking, or excluding elements |
features.canvas | boolean | ❌ | false | Record canvas elements |
features.iframes | boolean | ❌ | false | Record iframe content |
features.video | boolean | ❌ | false | Record video elements |
features.cacheAssets | boolean | ❌ | true | Cache assets for replay |
features.packAssets | boolean | PackAssetsConfig | ❌ | true | Pack assets to reduce payload size |
maxExportIntervalMs | number | ❌ | 5000 | Maximum interval between data exports (milliseconds) |
logLevel | 'debug' | 'info' | 'warn' | 'error' | ❌ | 'warn' | Logging level for session recorder |
Sensitivity Rules Configuration
interface SensitivityRule {
rule: 'mask' | 'unmask' | 'exclude'
selector: string
}
SplunkSessionRecorder.init({
realm: 'us1',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
sensitivityRules: [
{ rule: 'mask', selector: '.sensitive-data' },
{ rule: 'exclude', selector: '.payment-form' },
{ rule: 'unmask', selector: '.public-content' },
],
})
Asset Packing Configuration
interface PackAssetsConfig {
fonts?: boolean
styles?: boolean
images?:
| boolean
| {
onlyViewportImages?: boolean
pack?: boolean
quality?: number
}
}
SplunkSessionRecorder.init({
realm: 'us1',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
features: {
packAssets: {
fonts: true,
styles: true,
images: {
onlyViewportImages: true,
pack: true,
quality: 0.8,
},
},
},
})
Complete Configuration Example
import SplunkSessionRecorder from '@splunk/otel-web-session-recorder'
SplunkSessionRecorder.init({
realm: 'us1',
rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
beaconEndpoint: 'https://custom-endpoint.com/v1/rumreplay',
maskAllInputs: true,
maskAllText: false,
sensitivityRules: [
{ rule: 'exclude', selector: '.payment-form' },
{ rule: 'mask', selector: '.sensitive-data' },
{ rule: 'unmask', selector: '.public-info' },
],
features: {
canvas: false,
iframes: false,
video: false,
cacheAssets: true,
packAssets: {
fonts: true,
styles: true,
images: {
onlyViewportImages: true,
pack: true,
quality: 0.7,
},
},
},
maxExportIntervalMs: 5000,
logLevel: 'warn',
debug: false,
persistFailedReplayData: true,
})
🛠️ Troubleshooting
For troubleshooting issues with the Splunk Session Recorder, see Troubleshoot browser instrumentation for Splunk Observability Cloud in the official documentation.
📚 API Reference
SplunkSessionRecorder Class
Static Methods
init(config) | SessionRecorderConfig | void | Initialize session recorder |
start() | - | void | Start recording current session |
stop() | - | void | Stop recording current session |
interface SessionRecorderConfig {
realm: string
rumAccessToken: string
maskAllInputs?: boolean
maskAllText?: boolean
sensitivityRules?: SensitivityRule[]
features?: {
canvas?: boolean
iframes?: boolean
video?: boolean
cacheAssets?: boolean
packAssets?: boolean | PackAssetsConfig
}
maxExportIntervalMs?: number
logLevel?: 'debug' | 'info' | 'warn' | 'error'
debug?: boolean
beaconEndpoint?: string
persistFailedReplayData?: boolean
}
interface SensitivityRule {
rule: 'mask' | 'unmask' | 'exclude'
selector: string
}
interface UserInfo {
id?: string
email?: string
attributes?: Record<string, string>
}
License
Licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
ℹ️ SignalFx was acquired by Splunk in October 2019. See Splunk SignalFx for more information.