Socket
Socket
Sign inDemoInstall

@splitsoftware/browser-rum-agent

Package Overview
Dependencies
Maintainers
8
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@splitsoftware/browser-rum-agent - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1-rc.0

cjs/metrics/openTelemetry.js

3

CHANGES.txt

@@ -0,1 +1,4 @@

0.6.0 (XXX XX, 2024)
- Added a new event collector named `openTelemetryCollector`. This collector integrates with the OpenTelemetry SDK and Splunk RUM for Web to automatically capture OpenTelemetry spans and forward them to Split as events. Read more in our docs.
0.5.0 (March 4, 2024)

@@ -2,0 +5,0 @@ - Added a default prefix for events to simplify compatibility with Split's out-of-the-box metrics feature. This value can be changed or overridden with an empty string via the `prefix` config option.

8

cjs/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.webVitals = exports.routeChanges = exports.tti = exports.SplitRumAgent = void 0;
exports.webVitals = exports.tti = exports.routeChanges = exports.openTelemetryIntegration = exports.SplitRumAgent = void 0;
// Create SplitRumAgent namespace and export it for ESM/CJS imports

@@ -9,7 +9,9 @@ // Must use a named import to create the SplitRumAgent namespace (side effects)

// Pluggable event collectors
var openTelemetry_1 = require("./metrics/openTelemetry");
Object.defineProperty(exports, "openTelemetryIntegration", { enumerable: true, get: function () { return openTelemetry_1.openTelemetryIntegration; } });
var routeChanges_1 = require("./metrics/routeChanges");
Object.defineProperty(exports, "routeChanges", { enumerable: true, get: function () { return routeChanges_1.routeChanges; } });
var tti_1 = require("./metrics/tti");
Object.defineProperty(exports, "tti", { enumerable: true, get: function () { return tti_1.tti; } });
var routeChanges_1 = require("./metrics/routeChanges");
Object.defineProperty(exports, "routeChanges", { enumerable: true, get: function () { return routeChanges_1.routeChanges; } });
var webVitals_1 = require("./metrics/webVitals");
Object.defineProperty(exports, "webVitals", { enumerable: true, get: function () { return webVitals_1.webVitals; } });

@@ -38,2 +38,2 @@ "use strict";

exports.userAgent = getUserAgent();
exports.languageVersion = 'jsrum-' + '0.5.0';
exports.languageVersion = 'jsrum-' + '0.5.1-rc.0';

@@ -55,4 +55,4 @@ "use strict";

}
// @ts-expect-error adding timestamp to event
eventData.timestamp = Date.now(); // <-- This is not the most accurate but it shouldn't really matter much. The error margin should be small. We can actually calculate the timestamp later.
if (!eventData.timestamp)
eventData.timestamp = Date.now(); // <-- This is not the most accurate but it shouldn't really matter much. The error margin should be small. We can actually calculate the timestamp later.
if (conf.prefix)

@@ -59,0 +59,0 @@ eventData.eventTypeId = conf.prefix + "." + eventData.eventTypeId;

@@ -5,4 +5,5 @@ // Create SplitRumAgent namespace and export it for ESM/CJS imports

// Pluggable event collectors
export { openTelemetryIntegration } from './metrics/openTelemetry';
export { routeChanges } from './metrics/routeChanges';
export { tti } from './metrics/tti';
export { routeChanges } from './metrics/routeChanges';
export { webVitals } from './metrics/webVitals';

@@ -31,2 +31,2 @@ /* eslint-disable compat/compat */

export var userAgent = getUserAgent();
export var languageVersion = 'jsrum-' + '0.5.0';
export var languageVersion = 'jsrum-' + '0.5.1-rc.0';

@@ -50,4 +50,4 @@ import { getConnectionType, getUrl, userAgent } from './context';

}
// @ts-expect-error adding timestamp to event
eventData.timestamp = Date.now(); // <-- This is not the most accurate but it shouldn't really matter much. The error margin should be small. We can actually calculate the timestamp later.
if (!eventData.timestamp)
eventData.timestamp = Date.now(); // <-- This is not the most accurate but it shouldn't really matter much. The error margin should be small. We can actually calculate the timestamp later.
if (conf.prefix)

@@ -54,0 +54,0 @@ eventData.eventTypeId = conf.prefix + "." + eventData.eventTypeId;

{
"name": "@splitsoftware/browser-rum-agent",
"version": "0.5.0",
"version": "0.5.1-rc.0",
"description": "Split Software RUM Agent for Browsers.",

@@ -41,2 +41,3 @@ "main": "cjs/index.js",

"dependencies": {
"@opentelemetry/sdk-trace-base": "^1.22.0",
"web-vitals": "^3.5.0"

@@ -43,0 +44,0 @@ },

/* eslint-disable no-use-before-define */
import type { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';
import { Attributes } from '@opentelemetry/api';
import type { ReportOpts } from 'web-vitals';
// Interface from `@splunk/otel-web` package
export interface SplunkOtelWebExporterOptions {
/**
* Allows remapping Span's attributes right before they're serialized.
* One potential use case of this method is to remove PII from the attributes.
*/
onAttributesSerializing?: (attributes: Attributes, span: ReadableSpan) => Attributes;
}
/**

@@ -19,2 +30,3 @@ * Type of a property value.

properties?: Properties,
timestamp?: number,
};

@@ -377,1 +389,60 @@

export declare function webVitals(options?: IWebVitalsOptions): EventCollector;
export interface IOpenTelemetryIntegrationOptions {
/**
* A function to be called before tracking an event.
* It receives the event object and should return the event object to be tracked, or `undefined` to prevent the event from being tracked.
* Useful to modify the event before it is tracked, or to prevent it from being tracked.
*
* @param event - The Split event to be tracked.
* @param span - The OpenTelemetry span object that originated the event.
* @returns The event object to be tracked, or `undefined` to prevent the event from being tracked.
*/
beforeTrack?: (event: EventData, span: ReadableSpan) => EventData | undefined
}
/**
* Collects spans from the OpenTelemetry SDK for Web or the Splunk RUM for Web, by creating an Span exporter ({@link https://opentelemetry.io/docs/languages/js/exporters/}),
* and converting them to Split events.
*
* Setup example with OpenTelemetry SDK for Web:
* ```
* import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
* import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
* import { SplitRumAgent, openTelemetryIntegration } from '@splitsoftware/browser-rum-agent';
*
* const integration = openTelemetryIntegration();
*
* const provider = new WebTracerProvider();
* provider.addSpanProcessor(new BatchSpanProcessor(integration.spanExporter));
* SplitRumAgent.register(integration.eventCollector);
* ```
*
* Setup example with Splunk RUM for Web {@link https://docs.splunk.com/observability/en/gdi/get-data-in/rum/browser/configure-rum-browser-instrumentation.html#exporter-settings}:
* ```
* import SplunkRum from '@splunk/otel-web';
* import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
* import { SplitRumAgent, openTelemetryIntegration } from '@splitsoftware/browser-rum-agent';
*
* const integration = openTelemetryIntegration();
*
* SplunkRum.init(...);
* SplunkRum.provider.addSpanProcessor(new BatchSpanProcessor(integration.spanExporter));
* SplitRumAgent.register(integration.eventCollector);
* ```
*
* or with Splunk exporter option:
* ```
* SplunkRum.init({
* exporter: integration.splunkExporter,
* ...
* });
* ```
*
* @param options - Collector options.
*/
export declare function openTelemetryIntegration(options?: IOpenTelemetryIntegrationOptions): {
spanExporter: SpanExporter,
splunkExporter: SplunkOtelWebExporterOptions,
eventCollector: EventCollector
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc