πŸš€ DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

@splunk/otel-web

Package Overview
Dependencies
Maintainers
14
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@splunk/otel-web

Splunk distribution of Open Telemetry for browser environment.

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
14K
-22.99%
Maintainers
14
Weekly downloads
Β 
Created
Source

@splunk/otel-web

πŸš€ Installation & Setup Β Β β€’Β Β  βš™οΈ Configuration Β Β β€’Β Β  πŸ› οΈ Troubleshooting Β Β β€’Β Β  πŸ“š API Reference

Latest GitHub release version npm package version Apache 2.0 License Bundle size

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 and Instrument browser-based web applications for Splunk RUM.

Splunk RUM for Browser collects performance metrics, web vitals, errors, and other forms of data for every user session to enable you to detect and troubleshoot problems in your application. For a complete view of your application from browser to back-end, integrate with Splunk APM.

πŸš€ Installation & Setup

Package Manager Installation

1. Install the Package

npm install @splunk/otel-web
# or
pnpm add @splunk/otel-web
# or
yarn add @splunk/otel-web

2. Initialize RUM

import { SplunkRum } from '@splunk/otel-web'

SplunkRum.init({
	realm: 'us1', // Your Splunk realm
	rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN', // RUM access token
	applicationName: 'my-web-app', // Application identifier
	deploymentEnvironment: 'production', // Environment (dev, staging, prod)
})

CDN Installation

1. Load the Script

Choose a versioning strategy based on your needs:

Major Version Lock (Recommended)

<!-- Locks to v1.x.x - gets latest minor and patch updates -->
<script src="https://cdn.signalfx.com/o11y-gdi-rum/v1/splunk-otel-web.js" crossorigin="anonymous"></script>

Minor Version Lock

<!-- Locks to v1.1.x - gets latest patch updates only -->
<script src="https://cdn.signalfx.com/o11y-gdi-rum/v1.1/splunk-otel-web.js" crossorigin="anonymous"></script>

Exact Version Lock

<!-- Locks to exact version v1.1.0 - no automatic updates -->
<script
	src="https://cdn.signalfx.com/o11y-gdi-rum/v1.1.0/splunk-otel-web.js"
	crossorigin="anonymous"
	integrity="sha384-<integrity>"
></script>

Latest Version (Not Recommended)

<!-- Always pulls the latest released version -->
<script src="https://cdn.signalfx.com/o11y-gdi-rum/latest/splunk-otel-web.js" crossorigin="anonymous"></script>

⚠️ Warning: Using latest automatically pulls the newest released version of the RUM agent, which may introduce breaking changes without notice. This can cause unexpected behavior in production. Use a version lock strategy instead.

πŸ“– For version numbers and integrity hashes, see GitHub Releases.

πŸ“š For detailed CDN setup instructions, see the official documentation.

2. Initialize RUM

<script>
	SplunkRum.init({
		realm: 'us1', // Your Splunk realm
		rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN', // RUM access token
		applicationName: 'my-web-app', // Application identifier
		deploymentEnvironment: 'production', // Environment (dev, staging, prod)
	})
</script>

Complete CDN Example

<!DOCTYPE html>
<html>
	<head>
		<title>My Web App</title>
		<!-- Load Splunk RUM (using major version lock) -->
		<script src="https://cdn.signalfx.com/o11y-gdi-rum/v1/splunk-otel-web.js" crossorigin="anonymous"></script>
		<script>
			SplunkRum.init({
				realm: 'us1',
				rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',
				applicationName: 'my-web-app',
				deploymentEnvironment: 'production',
				debug: false, // Set to true for development
			})
		</script>
	</head>
	<body>
		<!-- Your app content -->
	</body>
</html>

βš™οΈ Configuration Options

OptionTypeRequiredDefaultDescription
realmstringβœ…-Splunk realm (us0, us1, eu0, etc.)
rumAccessTokenstringβœ…-Publicly-visible RUM access token
applicationNamestring❌'unknown-browser-app'Application name identifier
deploymentEnvironmentstring❌-Sets the environment attribute
versionstring❌-Sets the app.version attribute
beaconEndpointstring❌-Custom destination URL (overrides realm)
debugboolean❌falseEnable internal debug logging
cookieDomainstring❌window.location.hostnameDomain for session cookies
ignoreUrlsArray<string|RegExp>❌[]URLs to exclude from tracing
globalAttributesAttributes❌{}Attributes added to every span
persistence'cookie'|'localStorage'❌'cookie'Where to store session data
disableAutomationFrameworksboolean❌falseBlock automation frameworks
disableBotsboolean❌falseBlock bots (Google bot, Bing bot, etc.)
user.trackingMode'noTracking'|'anonymousTracking'❌'noTracking'User tracking behavior
exporter.otlpboolean❌falseUse OTLP format instead of Zipkin
exporter.onAttributesSerializingfunction❌-Transform attributes before export
privacy.maskAllTextboolean❌trueMask all text from text nodes
privacy.sensitivityRulesArray<SensitivityRule>❌[]Rules for text sensitivity by selector
Instrumentations
instrumentations.connectivityboolean|Config❌falseNetwork connectivity monitoring
instrumentations.documentboolean|Config❌trueDocument load instrumentation
instrumentations.errorsboolean|Config❌trueError capture
instrumentations.fetchboolean|Config❌trueFetch API monitoring
instrumentations.interactionsboolean|Config❌trueUser interaction tracking
instrumentations.longtaskboolean|Config❌trueLong task detection (>50ms)
instrumentations.postloadboolean|Config❌truePost-load resource timing
instrumentations.socketioboolean|Config❌falseSocket.IO client monitoring
instrumentations.visibilityboolean|Config❌falsePage visibility changes
instrumentations.webvitalsboolean|Config❌trueWeb Vitals collection
instrumentations.websocketboolean|Config❌falseWebSocket monitoring
instrumentations.xhrboolean|Config❌trueXMLHttpRequest monitoring

Privacy Configuration

The privacy configuration allows you to control how text content is collected from user interactions:

  • maskAllText: When true (default), all text from text nodes is masked unless an unmask rule applies
  • sensitivityRules: Array of rules that determine text sensitivity based on CSS selectors. Rules are applied in order, with later rules overriding earlier ones

Rule Types:

  • mask: Mask text content in matching elements
  • unmask: Unmask text content in matching elements
  • exclude: Exclude matching elements from text collection entirely

Example:

privacy: {
  maskAllText: true,
  sensitivityRules: [
    { rule: 'unmask', selector: '.public-content' },
    { rule: 'exclude', selector: '.sensitive-data' },
    { rule: 'mask', selector: '.public-content .private-info' }
  ]
}

Complete Configuration Example

import { SplunkRum } from '@splunk/otel-web'

SplunkRum.init({
	// Required settings
	realm: 'us1',
	rumAccessToken: 'YOUR_RUM_ACCESS_TOKEN',

	// Application identification
	applicationName: 'my-web-app',
	deploymentEnvironment: 'production',
	version: '1.2.3',

	cookieDomain: window.location.hostname,
	persistence: 'cookie',
	ignoreUrls: [/\/health-check/, '/analytics/track', 'https://third-party-ads.com'],

	// Global attributes for all spans
	globalAttributes: {
		'team': 'frontend',
		'feature.flag.checkout': 'enabled',
	},

	// Bot detection
	disableAutomationFrameworks: true,
	disableBots: true,

	// User tracking
	user: {
		trackingMode: 'anonymousTracking',
	},

	// Privacy configuration
	privacy: {
		maskAllText: true, // Mask all text from text nodes by default
		sensitivityRules: [
			// Unmask text in specific elements
			{ rule: 'unmask', selector: '.public-content' },
			{ rule: 'unmask', selector: 'h1, h2, h3' },
			// Exclude sensitive elements entirely
			{ rule: 'exclude', selector: '.sensitive-data' },
			// Override previous rules for specific cases
			{ rule: 'mask', selector: '.public-content .private-info' },
		],
	},

	// Export options
	exporter: {
		otlp: true, // Use OTLP instead of Zipkin
		onAttributesSerializing: (attributes, span) => {
			// Remove or hash sensitive data
			if (attributes['http.url']) {
				attributes['http.url'] = sanitizeUrl(attributes['http.url'])
			}
			return attributes
		},
	},

	// Instrumentation control
	instrumentations: {
		// Core instrumentations (enabled by default)
		document: true,
		errors: true,
		fetch: true,
		interactions: true,
		longtask: true,
		postload: true,
		webvitals: true,
		xhr: true,

		// Optional instrumentations (disabled by default)
		connectivity: false,
		socketio: false,
		visibility: false,
		websocket: false,
	},

	// Development
	debug: process.env.NODE_ENV !== 'production',
})

πŸ“š API Reference

SplunkRum Class

Static Methods

MethodParametersReturnsDescription
init(config)SplunkRumConfigvoidInitialize the RUM SDK
setGlobalAttributes(attrs)AttributesvoidAdd global span attributes
getSessionId()-stringGet current session ID

Properties

PropertyTypeDescription
providerTracerProviderOpenTelemetry tracer provider

πŸ› οΈ Troubleshooting

For troubleshooting issues with the Splunk Distribution of OpenTelemetry JS for Web, see Troubleshoot browser instrumentation for Splunk Observability Cloud in the official documentation.

πŸ“œ 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.

Keywords

splunk

FAQs

Package last updated on 21 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts