@splitsoftware/browser-rum-agent
Advanced tools
Comparing version 0.5.0 to 0.5.1-rc.0
@@ -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. |
"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 | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137187
73
2908
2
+ Added@opentelemetry/api@1.9.0(transitive)
+ Added@opentelemetry/core@1.26.0(transitive)
+ Added@opentelemetry/resources@1.26.0(transitive)
+ Added@opentelemetry/sdk-trace-base@1.26.0(transitive)
+ Added@opentelemetry/semantic-conventions@1.27.0(transitive)