Socket
Socket
Sign inDemoInstall

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-rum-core - npm Package Compare versions

Comparing version 5.7.0 to 5.8.0

17

cjs/boot/rumPublicApi.d.ts

@@ -17,3 +17,3 @@ import type { Context, InitConfiguration, User, DeflateWorker, DeflateEncoderStreamId, DeflateEncoder } from '@datadog/browser-core';

getReplayStats: (viewId: string) => ReplayStats | undefined;
getSessionReplayLink: (configuration: RumConfiguration, sessionManager: RumSessionManager, viewContexts: ViewContexts) => string | undefined;
getSessionReplayLink: () => string | undefined;
}

@@ -36,2 +36,13 @@ interface RumPublicApiOptions {

addError: (error: unknown, context?: object) => void;
/**
* Add a custom timing relative to the start of the current view,
* stored in @view.custom_timings.<timing_name>
*
* @param name name of the custom timing
* @param [time] epoch timestamp of the custom timing (if not set, will use current time)
*
* Note: passing a relative time is discouraged since it is actually used as-is but displayed relative to the view start.
* We currently don't provide a way to retrieve the view start time, so it can be challenging to provide a timing relative to the view start.
* see https://github.com/DataDog/browser-sdk/issues/2552
*/
addTiming: (name: string, time?: number) => void;

@@ -48,4 +59,2 @@ setUser: (newUser: User) => void;

stopSession: () => void;
startSessionReplayRecording: () => void;
stopSessionReplayRecording: () => void;
/**

@@ -56,2 +65,4 @@ * This feature is currently in beta. For more information see the full [feature flag tracking guide](https://docs.datadoghq.com/real_user_monitoring/feature_flag_tracking/).

getSessionReplayLink: () => string | undefined;
startSessionReplayRecording: () => void;
stopSessionReplayRecording: () => void;
} & {

@@ -58,0 +69,0 @@ onReady(callback: () => void): void;

47

cjs/boot/rumPublicApi.js

@@ -14,6 +14,8 @@ "use strict";

var userContextManager = (0, browser_core_1.createContextManager)(customerDataTrackerManager.getOrCreateTracker(1 /* CustomerDataType.User */));
function getCommonContext() {
return (0, commonContext_1.buildCommonContext)(globalContextManager, userContextManager, recorderApi);
}
var getInternalContextStrategy = function () { return undefined; };
var getInitConfigurationStrategy = function () { return undefined; };
var stopSessionStrategy = browser_core_1.noop;
var getSessionReplayLinkStrategy = function () { return undefined; };
var bufferApiCalls = new browser_core_1.BoundedBuffer();

@@ -29,15 +31,9 @@ var addTimingStrategy = function (name, time) {

var addActionStrategy = function (action, commonContext) {
if (commonContext === void 0) { commonContext = (0, commonContext_1.buildCommonContext)(globalContextManager, userContextManager, recorderApi); }
if (commonContext === void 0) { commonContext = getCommonContext(); }
bufferApiCalls.add(function () { return addActionStrategy(action, commonContext); });
};
var addErrorStrategy = function (providedError, commonContext) {
if (commonContext === void 0) { commonContext = (0, commonContext_1.buildCommonContext)(globalContextManager, userContextManager, recorderApi); }
if (commonContext === void 0) { commonContext = getCommonContext(); }
bufferApiCalls.add(function () { return addErrorStrategy(providedError, commonContext); });
};
var recorderStartStrategy = function () {
bufferApiCalls.add(function () { return recorderStartStrategy(); });
};
var recorderStopStrategy = function () {
bufferApiCalls.add(function () { return recorderStopStrategy(); });
};
var addFeatureFlagEvaluationStrategy = function (key, value) {

@@ -105,18 +101,9 @@ bufferApiCalls.add(function () { return addFeatureFlagEvaluationStrategy(key, value); });

if (initConfiguration.storeContextsAcrossPages) {
var beforeInitGlobalContext = globalContextManager.getContext();
globalContextManager = (0, browser_core_1.createStoredContextManager)(configuration, RUM_STORAGE_KEY, 2 /* CustomerDataType.GlobalContext */, customerDataTrackerManager.getOrCreateTracker(2 /* CustomerDataType.GlobalContext */));
globalContextManager.setContext((0, browser_core_1.combine)(globalContextManager.getContext(), beforeInitGlobalContext));
var beforeInitUserContext = userContextManager.getContext();
userContextManager = (0, browser_core_1.createStoredContextManager)(configuration, RUM_STORAGE_KEY, 1 /* CustomerDataType.User */, customerDataTrackerManager.getOrCreateTracker(1 /* CustomerDataType.User */));
userContextManager.setContext((0, browser_core_1.combine)(userContextManager.getContext(), beforeInitUserContext));
(0, browser_core_1.storeContextManager)(configuration, globalContextManager, RUM_STORAGE_KEY, 2 /* CustomerDataType.GlobalContext */);
(0, browser_core_1.storeContextManager)(configuration, userContextManager, RUM_STORAGE_KEY, 1 /* CustomerDataType.User */);
}
customerDataTrackerManager.setCompressionStatus(deflateWorker ? 1 /* CustomerDataCompressionStatus.Enabled */ : 2 /* CustomerDataCompressionStatus.Disabled */);
var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, globalContextManager, userContextManager, initialViewOptions, deflateWorker && createDeflateEncoder
var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && createDeflateEncoder
? function (streamId) { return createDeflateEncoder(configuration, deflateWorker, streamId); }
: browser_core_1.createIdentityEncoder);
getSessionReplayLinkStrategy = function () {
return recorderApi.getSessionReplayLink(configuration, startRumResults.session, startRumResults.viewContexts);
};
recorderStartStrategy = recorderApi.start;
recorderStopStrategy = recorderApi.stop;
(startViewStrategy = startRumResults.startView, addActionStrategy = startRumResults.addAction, addErrorStrategy = startRumResults.addError, addTimingStrategy = startRumResults.addTiming, addFeatureFlagEvaluationStrategy = startRumResults.addFeatureFlagEvaluation, getInternalContextStrategy = startRumResults.getInternalContext, stopSessionStrategy = startRumResults.stopSession);

@@ -158,3 +145,15 @@ recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts, deflateWorker);

},
/**
* Add a custom timing relative to the start of the current view,
* stored in @view.custom_timings.<timing_name>
*
* @param name name of the custom timing
* @param [time] epoch timestamp of the custom timing (if not set, will use current time)
*
* Note: passing a relative time is discouraged since it is actually used as-is but displayed relative to the view start.
* We currently don't provide a way to retrieve the view start time, so it can be challenging to provide a timing relative to the view start.
* see https://github.com/DataDog/browser-sdk/issues/2552
*/
addTiming: (0, browser_core_1.monitor)(function (name, time) {
// TODO: next major decide to drop relative time support or update its behaviour
addTimingStrategy((0, browser_core_1.sanitize)(name), time);

@@ -179,4 +178,2 @@ }),

}),
startSessionReplayRecording: (0, browser_core_1.monitor)(function () { return recorderStartStrategy(); }),
stopSessionReplayRecording: (0, browser_core_1.monitor)(function () { return recorderStopStrategy(); }),
/**

@@ -188,3 +185,5 @@ * This feature is currently in beta. For more information see the full [feature flag tracking guide](https://docs.datadoghq.com/real_user_monitoring/feature_flag_tracking/).

}),
getSessionReplayLink: (0, browser_core_1.monitor)(function () { return getSessionReplayLinkStrategy(); }),
getSessionReplayLink: (0, browser_core_1.monitor)(function () { return recorderApi.getSessionReplayLink(); }),
startSessionReplayRecording: (0, browser_core_1.monitor)(function () { return recorderApi.start(); }),
stopSessionReplayRecording: (0, browser_core_1.monitor)(function () { return recorderApi.stop(); }),
});

@@ -191,0 +190,0 @@ return rumPublicApi;

@@ -1,2 +0,2 @@

import type { Observable, RawError, ContextManager, DeflateEncoderStreamId, Encoder, CustomerDataTrackerManager } from '@datadog/browser-core';
import type { Observable, RawError, DeflateEncoderStreamId, Encoder, CustomerDataTrackerManager } from '@datadog/browser-core';
import { LifeCycle } from '../domain/lifeCycle';

@@ -9,3 +9,3 @@ import type { RumSessionManager } from '../domain/rumSessionManager';

import type { RecorderApi } from './rumPublicApi';
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, globalContextManager: ContextManager, userContextManager: ContextManager, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder): {
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, getCommonContext: () => CommonContext, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder): {
addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;

@@ -23,3 +23,3 @@ addError: ({ error, handlingStack, startClocks, context: customerContext }: import("../domain/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void;

};
export declare function startRumEventCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, location: Location, sessionManager: RumSessionManager, locationChangeObservable: Observable<LocationChange>, domMutationObservable: Observable<void>, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): {
export declare function startRumEventCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, location: Location, sessionManager: RumSessionManager, locationChangeObservable: Observable<LocationChange>, domMutationObservable: Observable<void>, getCommonContext: () => CommonContext, reportError: (error: RawError) => void): {
viewContexts: import("../domain/contexts/viewContexts").ViewContexts;

@@ -26,0 +26,0 @@ pageStateHistory: import("../domain/contexts/pageStateHistory").PageStateHistory;

@@ -26,5 +26,4 @@ "use strict";

var pageStateHistory_1 = require("../domain/contexts/pageStateHistory");
var commonContext_1 = require("../domain/contexts/commonContext");
var displayContext_1 = require("../domain/contexts/displayContext");
function startRum(initConfiguration, configuration, recorderApi, customerDataTrackerManager, globalContextManager, userContextManager, initialViewOptions, createEncoder) {
function startRum(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, createEncoder) {
var cleanupTasks = [];

@@ -72,3 +71,3 @@ var lifeCycle = new lifeCycle_1.LifeCycle();

var locationChangeObservable = (0, locationChangeObservable_1.createLocationChangeObservable)(configuration, location);
var _a = startRumEventCollection(lifeCycle, configuration, location, session, locationChangeObservable, domMutationObservable, function () { return (0, commonContext_1.buildCommonContext)(globalContextManager, userContextManager, recorderApi); }, reportError), viewContexts = _a.viewContexts, pageStateHistory = _a.pageStateHistory, urlContexts = _a.urlContexts, actionContexts = _a.actionContexts, addAction = _a.addAction, stopRumEventCollection = _a.stop;
var _a = startRumEventCollection(lifeCycle, configuration, location, session, locationChangeObservable, domMutationObservable, getCommonContext, reportError), viewContexts = _a.viewContexts, pageStateHistory = _a.pageStateHistory, urlContexts = _a.urlContexts, actionContexts = _a.actionContexts, addAction = _a.addAction, stopRumEventCollection = _a.stop;
cleanupTasks.push(stopRumEventCollection);

@@ -109,3 +108,3 @@ (0, browser_core_1.addTelemetryConfiguration)((0, configuration_1.serializeRumConfiguration)(initConfiguration));

}
function startRumEventCollection(lifeCycle, configuration, location, sessionManager, locationChangeObservable, domMutationObservable, buildCommonContext, reportError) {
function startRumEventCollection(lifeCycle, configuration, location, sessionManager, locationChangeObservable, domMutationObservable, getCommonContext, reportError) {
var viewContexts = (0, viewContexts_1.startViewContexts)(lifeCycle);

@@ -116,3 +115,3 @@ var urlContexts = (0, urlContexts_1.startUrlContexts)(lifeCycle, locationChangeObservable, location);

var displayContext = (0, displayContext_1.startDisplayContext)(configuration);
(0, assembly_1.startRumAssembly)(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, buildCommonContext, reportError);
(0, assembly_1.startRumAssembly)(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, getCommonContext, reportError);
return {

@@ -119,0 +118,0 @@ viewContexts: viewContexts,

@@ -10,2 +10,2 @@ import type { RawError } from '@datadog/browser-core';

import type { CommonContext } from './contexts/commonContext';
export declare function startRumAssembly(configuration: RumConfiguration, lifeCycle: LifeCycle, sessionManager: RumSessionManager, viewContexts: ViewContexts, urlContexts: UrlContexts, actionContexts: ActionContexts, displayContext: DisplayContext, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): void;
export declare function startRumAssembly(configuration: RumConfiguration, lifeCycle: LifeCycle, sessionManager: RumSessionManager, viewContexts: ViewContexts, urlContexts: UrlContexts, actionContexts: ActionContexts, displayContext: DisplayContext, getCommonContext: () => CommonContext, reportError: (error: RawError) => void): void;

@@ -17,3 +17,3 @@ "use strict";

var modifiableFieldPathsByEvent;
function startRumAssembly(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, buildCommonContext, reportError) {
function startRumAssembly(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, getCommonContext, reportError) {
var _a, _b;

@@ -50,3 +50,3 @@ modifiableFieldPathsByEvent = (_a = {},

if (session && viewContext && urlContext) {
var commonContext = savedCommonContext || buildCommonContext();
var commonContext = savedCommonContext || getCommonContext();
var actionId = actionContexts.findActionId(startTime);

@@ -61,3 +61,3 @@ var rumContext = {

},
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "5.7.0" : undefined,
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "5.8.0" : undefined,
},

@@ -85,2 +85,3 @@ application: {

display: displayContext.get(),
connectivity: (0, browser_core_1.getConnectivity)(),
};

@@ -87,0 +88,0 @@ var serverRumEvent = (0, browser_core_1.combine)(rumContext, rawRumEvent);

@@ -1,2 +0,2 @@

import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel } from '@datadog/browser-core';
import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel, Connectivity } from '@datadog/browser-core';
import type { PageState } from './domain/contexts/pageStateHistory';

@@ -219,2 +219,3 @@ export declare const enum RumEventType {

};
connectivity: Connectivity;
action?: {

@@ -221,0 +222,0 @@ id: string | string[];

@@ -895,3 +895,3 @@ /**

*/
readonly source?: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku';
readonly source?: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku' | 'unity';
/**

@@ -948,4 +948,8 @@ * View properties

*/
readonly interfaces: ('bluetooth' | 'cellular' | 'ethernet' | 'wifi' | 'wimax' | 'mixed' | 'other' | 'unknown' | 'none')[];
readonly interfaces?: ('bluetooth' | 'cellular' | 'ethernet' | 'wifi' | 'wimax' | 'mixed' | 'other' | 'unknown' | 'none')[];
/**
* Cellular connection type reflecting the measured network performance
*/
readonly effective_type?: 'slow_2g' | '2g' | '3g' | '4g';
/**
* Cellular connectivity properties

@@ -1133,3 +1137,3 @@ */

*/
readonly source: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku';
readonly source: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku' | 'unity';
[k: string]: unknown;

@@ -1136,0 +1140,0 @@ };

@@ -17,3 +17,3 @@ import type { Context, InitConfiguration, User, DeflateWorker, DeflateEncoderStreamId, DeflateEncoder } from '@datadog/browser-core';

getReplayStats: (viewId: string) => ReplayStats | undefined;
getSessionReplayLink: (configuration: RumConfiguration, sessionManager: RumSessionManager, viewContexts: ViewContexts) => string | undefined;
getSessionReplayLink: () => string | undefined;
}

@@ -36,2 +36,13 @@ interface RumPublicApiOptions {

addError: (error: unknown, context?: object) => void;
/**
* Add a custom timing relative to the start of the current view,
* stored in @view.custom_timings.<timing_name>
*
* @param name name of the custom timing
* @param [time] epoch timestamp of the custom timing (if not set, will use current time)
*
* Note: passing a relative time is discouraged since it is actually used as-is but displayed relative to the view start.
* We currently don't provide a way to retrieve the view start time, so it can be challenging to provide a timing relative to the view start.
* see https://github.com/DataDog/browser-sdk/issues/2552
*/
addTiming: (name: string, time?: number) => void;

@@ -48,4 +59,2 @@ setUser: (newUser: User) => void;

stopSession: () => void;
startSessionReplayRecording: () => void;
stopSessionReplayRecording: () => void;
/**

@@ -56,2 +65,4 @@ * This feature is currently in beta. For more information see the full [feature flag tracking guide](https://docs.datadoghq.com/real_user_monitoring/feature_flag_tracking/).

getSessionReplayLink: () => string | undefined;
startSessionReplayRecording: () => void;
stopSessionReplayRecording: () => void;
} & {

@@ -58,0 +69,0 @@ onReady(callback: () => void): void;

@@ -1,2 +0,2 @@

import { noop, willSyntheticsInjectRum, assign, BoundedBuffer, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, checkUser, sanitizeUser, sanitize, createStoredContextManager, combine, createIdentityEncoder, createCustomerDataTrackerManager, } from '@datadog/browser-core';
import { noop, willSyntheticsInjectRum, assign, BoundedBuffer, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, checkUser, sanitizeUser, sanitize, createIdentityEncoder, createCustomerDataTrackerManager, storeContextManager, } from '@datadog/browser-core';
import { validateAndBuildRumConfiguration } from '../domain/configuration';

@@ -11,6 +11,8 @@ import { buildCommonContext } from '../domain/contexts/commonContext';

var userContextManager = createContextManager(customerDataTrackerManager.getOrCreateTracker(1 /* CustomerDataType.User */));
function getCommonContext() {
return buildCommonContext(globalContextManager, userContextManager, recorderApi);
}
var getInternalContextStrategy = function () { return undefined; };
var getInitConfigurationStrategy = function () { return undefined; };
var stopSessionStrategy = noop;
var getSessionReplayLinkStrategy = function () { return undefined; };
var bufferApiCalls = new BoundedBuffer();

@@ -26,15 +28,9 @@ var addTimingStrategy = function (name, time) {

var addActionStrategy = function (action, commonContext) {
if (commonContext === void 0) { commonContext = buildCommonContext(globalContextManager, userContextManager, recorderApi); }
if (commonContext === void 0) { commonContext = getCommonContext(); }
bufferApiCalls.add(function () { return addActionStrategy(action, commonContext); });
};
var addErrorStrategy = function (providedError, commonContext) {
if (commonContext === void 0) { commonContext = buildCommonContext(globalContextManager, userContextManager, recorderApi); }
if (commonContext === void 0) { commonContext = getCommonContext(); }
bufferApiCalls.add(function () { return addErrorStrategy(providedError, commonContext); });
};
var recorderStartStrategy = function () {
bufferApiCalls.add(function () { return recorderStartStrategy(); });
};
var recorderStopStrategy = function () {
bufferApiCalls.add(function () { return recorderStopStrategy(); });
};
var addFeatureFlagEvaluationStrategy = function (key, value) {

@@ -102,18 +98,9 @@ bufferApiCalls.add(function () { return addFeatureFlagEvaluationStrategy(key, value); });

if (initConfiguration.storeContextsAcrossPages) {
var beforeInitGlobalContext = globalContextManager.getContext();
globalContextManager = createStoredContextManager(configuration, RUM_STORAGE_KEY, 2 /* CustomerDataType.GlobalContext */, customerDataTrackerManager.getOrCreateTracker(2 /* CustomerDataType.GlobalContext */));
globalContextManager.setContext(combine(globalContextManager.getContext(), beforeInitGlobalContext));
var beforeInitUserContext = userContextManager.getContext();
userContextManager = createStoredContextManager(configuration, RUM_STORAGE_KEY, 1 /* CustomerDataType.User */, customerDataTrackerManager.getOrCreateTracker(1 /* CustomerDataType.User */));
userContextManager.setContext(combine(userContextManager.getContext(), beforeInitUserContext));
storeContextManager(configuration, globalContextManager, RUM_STORAGE_KEY, 2 /* CustomerDataType.GlobalContext */);
storeContextManager(configuration, userContextManager, RUM_STORAGE_KEY, 1 /* CustomerDataType.User */);
}
customerDataTrackerManager.setCompressionStatus(deflateWorker ? 1 /* CustomerDataCompressionStatus.Enabled */ : 2 /* CustomerDataCompressionStatus.Disabled */);
var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, globalContextManager, userContextManager, initialViewOptions, deflateWorker && createDeflateEncoder
var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && createDeflateEncoder
? function (streamId) { return createDeflateEncoder(configuration, deflateWorker, streamId); }
: createIdentityEncoder);
getSessionReplayLinkStrategy = function () {
return recorderApi.getSessionReplayLink(configuration, startRumResults.session, startRumResults.viewContexts);
};
recorderStartStrategy = recorderApi.start;
recorderStopStrategy = recorderApi.stop;
(startViewStrategy = startRumResults.startView, addActionStrategy = startRumResults.addAction, addErrorStrategy = startRumResults.addError, addTimingStrategy = startRumResults.addTiming, addFeatureFlagEvaluationStrategy = startRumResults.addFeatureFlagEvaluation, getInternalContextStrategy = startRumResults.getInternalContext, stopSessionStrategy = startRumResults.stopSession);

@@ -155,3 +142,15 @@ recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts, deflateWorker);

},
/**
* Add a custom timing relative to the start of the current view,
* stored in @view.custom_timings.<timing_name>
*
* @param name name of the custom timing
* @param [time] epoch timestamp of the custom timing (if not set, will use current time)
*
* Note: passing a relative time is discouraged since it is actually used as-is but displayed relative to the view start.
* We currently don't provide a way to retrieve the view start time, so it can be challenging to provide a timing relative to the view start.
* see https://github.com/DataDog/browser-sdk/issues/2552
*/
addTiming: monitor(function (name, time) {
// TODO: next major decide to drop relative time support or update its behaviour
addTimingStrategy(sanitize(name), time);

@@ -176,4 +175,2 @@ }),

}),
startSessionReplayRecording: monitor(function () { return recorderStartStrategy(); }),
stopSessionReplayRecording: monitor(function () { return recorderStopStrategy(); }),
/**

@@ -185,3 +182,5 @@ * This feature is currently in beta. For more information see the full [feature flag tracking guide](https://docs.datadoghq.com/real_user_monitoring/feature_flag_tracking/).

}),
getSessionReplayLink: monitor(function () { return getSessionReplayLinkStrategy(); }),
getSessionReplayLink: monitor(function () { return recorderApi.getSessionReplayLink(); }),
startSessionReplayRecording: monitor(function () { return recorderApi.start(); }),
stopSessionReplayRecording: monitor(function () { return recorderApi.stop(); }),
});

@@ -188,0 +187,0 @@ return rumPublicApi;

@@ -1,2 +0,2 @@

import type { Observable, RawError, ContextManager, DeflateEncoderStreamId, Encoder, CustomerDataTrackerManager } from '@datadog/browser-core';
import type { Observable, RawError, DeflateEncoderStreamId, Encoder, CustomerDataTrackerManager } from '@datadog/browser-core';
import { LifeCycle } from '../domain/lifeCycle';

@@ -9,3 +9,3 @@ import type { RumSessionManager } from '../domain/rumSessionManager';

import type { RecorderApi } from './rumPublicApi';
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, globalContextManager: ContextManager, userContextManager: ContextManager, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder): {
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, getCommonContext: () => CommonContext, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder): {
addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;

@@ -23,3 +23,3 @@ addError: ({ error, handlingStack, startClocks, context: customerContext }: import("../domain/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void;

};
export declare function startRumEventCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, location: Location, sessionManager: RumSessionManager, locationChangeObservable: Observable<LocationChange>, domMutationObservable: Observable<void>, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): {
export declare function startRumEventCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, location: Location, sessionManager: RumSessionManager, locationChangeObservable: Observable<LocationChange>, domMutationObservable: Observable<void>, getCommonContext: () => CommonContext, reportError: (error: RawError) => void): {
viewContexts: import("../domain/contexts/viewContexts").ViewContexts;

@@ -26,0 +26,0 @@ pageStateHistory: import("../domain/contexts/pageStateHistory").PageStateHistory;

@@ -23,5 +23,4 @@ import { sendToExtension, createPageExitObservable, addTelemetryConfiguration, startTelemetry, canUseEventBridge, getEventBridge, addTelemetryDebug, } from '@datadog/browser-core';

import { startPageStateHistory } from '../domain/contexts/pageStateHistory';
import { buildCommonContext } from '../domain/contexts/commonContext';
import { startDisplayContext } from '../domain/contexts/displayContext';
export function startRum(initConfiguration, configuration, recorderApi, customerDataTrackerManager, globalContextManager, userContextManager, initialViewOptions, createEncoder) {
export function startRum(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, createEncoder) {
var cleanupTasks = [];

@@ -69,3 +68,3 @@ var lifeCycle = new LifeCycle();

var locationChangeObservable = createLocationChangeObservable(configuration, location);
var _a = startRumEventCollection(lifeCycle, configuration, location, session, locationChangeObservable, domMutationObservable, function () { return buildCommonContext(globalContextManager, userContextManager, recorderApi); }, reportError), viewContexts = _a.viewContexts, pageStateHistory = _a.pageStateHistory, urlContexts = _a.urlContexts, actionContexts = _a.actionContexts, addAction = _a.addAction, stopRumEventCollection = _a.stop;
var _a = startRumEventCollection(lifeCycle, configuration, location, session, locationChangeObservable, domMutationObservable, getCommonContext, reportError), viewContexts = _a.viewContexts, pageStateHistory = _a.pageStateHistory, urlContexts = _a.urlContexts, actionContexts = _a.actionContexts, addAction = _a.addAction, stopRumEventCollection = _a.stop;
cleanupTasks.push(stopRumEventCollection);

@@ -105,3 +104,3 @@ addTelemetryConfiguration(serializeRumConfiguration(initConfiguration));

}
export function startRumEventCollection(lifeCycle, configuration, location, sessionManager, locationChangeObservable, domMutationObservable, buildCommonContext, reportError) {
export function startRumEventCollection(lifeCycle, configuration, location, sessionManager, locationChangeObservable, domMutationObservable, getCommonContext, reportError) {
var viewContexts = startViewContexts(lifeCycle);

@@ -112,3 +111,3 @@ var urlContexts = startUrlContexts(lifeCycle, locationChangeObservable, location);

var displayContext = startDisplayContext(configuration);
startRumAssembly(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, buildCommonContext, reportError);
startRumAssembly(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, getCommonContext, reportError);
return {

@@ -115,0 +114,0 @@ viewContexts: viewContexts,

@@ -10,2 +10,2 @@ import type { RawError } from '@datadog/browser-core';

import type { CommonContext } from './contexts/commonContext';
export declare function startRumAssembly(configuration: RumConfiguration, lifeCycle: LifeCycle, sessionManager: RumSessionManager, viewContexts: ViewContexts, urlContexts: UrlContexts, actionContexts: ActionContexts, displayContext: DisplayContext, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): void;
export declare function startRumAssembly(configuration: RumConfiguration, lifeCycle: LifeCycle, sessionManager: RumSessionManager, viewContexts: ViewContexts, urlContexts: UrlContexts, actionContexts: ActionContexts, displayContext: DisplayContext, getCommonContext: () => CommonContext, reportError: (error: RawError) => void): void;

@@ -1,2 +0,2 @@

import { combine, isEmptyObject, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, assign, round, isExperimentalFeatureEnabled, ExperimentalFeature, } from '@datadog/browser-core';
import { combine, isEmptyObject, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, assign, round, isExperimentalFeatureEnabled, ExperimentalFeature, getConnectivity, } from '@datadog/browser-core';
import { getSyntheticsContext } from './contexts/syntheticsContext';

@@ -14,3 +14,3 @@ import { getCiTestContext } from './contexts/ciTestContext';

var modifiableFieldPathsByEvent;
export function startRumAssembly(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, buildCommonContext, reportError) {
export function startRumAssembly(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, getCommonContext, reportError) {
var _a, _b;

@@ -47,3 +47,3 @@ modifiableFieldPathsByEvent = (_a = {},

if (session && viewContext && urlContext) {
var commonContext = savedCommonContext || buildCommonContext();
var commonContext = savedCommonContext || getCommonContext();
var actionId = actionContexts.findActionId(startTime);

@@ -58,3 +58,3 @@ var rumContext = {

},
browser_sdk_version: canUseEventBridge() ? "5.7.0" : undefined,
browser_sdk_version: canUseEventBridge() ? "5.8.0" : undefined,
},

@@ -82,2 +82,3 @@ application: {

display: displayContext.get(),
connectivity: getConnectivity(),
};

@@ -84,0 +85,0 @@ var serverRumEvent = combine(rumContext, rawRumEvent);

@@ -1,2 +0,2 @@

import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel } from '@datadog/browser-core';
import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel, Connectivity } from '@datadog/browser-core';
import type { PageState } from './domain/contexts/pageStateHistory';

@@ -219,2 +219,3 @@ export declare const enum RumEventType {

};
connectivity: Connectivity;
action?: {

@@ -221,0 +222,0 @@ id: string | string[];

@@ -895,3 +895,3 @@ /**

*/
readonly source?: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku';
readonly source?: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku' | 'unity';
/**

@@ -948,4 +948,8 @@ * View properties

*/
readonly interfaces: ('bluetooth' | 'cellular' | 'ethernet' | 'wifi' | 'wimax' | 'mixed' | 'other' | 'unknown' | 'none')[];
readonly interfaces?: ('bluetooth' | 'cellular' | 'ethernet' | 'wifi' | 'wimax' | 'mixed' | 'other' | 'unknown' | 'none')[];
/**
* Cellular connection type reflecting the measured network performance
*/
readonly effective_type?: 'slow_2g' | '2g' | '3g' | '4g';
/**
* Cellular connectivity properties

@@ -1133,3 +1137,3 @@ */

*/
readonly source: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku';
readonly source: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku' | 'unity';
[k: string]: unknown;

@@ -1136,0 +1140,0 @@ };

{
"name": "@datadog/browser-rum-core",
"version": "5.7.0",
"version": "5.8.0",
"license": "Apache-2.0",

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

"dependencies": {
"@datadog/browser-core": "5.7.0"
"@datadog/browser-core": "5.8.0"
},

@@ -32,3 +32,3 @@ "devDependencies": {

},
"gitHead": "c631b23ad26be38c64db98c134cb3c57fa5cf7f7"
"gitHead": "450e621c48d00e8f50c97d6cc12c4ae7a7989daf"
}

@@ -30,7 +30,6 @@ import type {

sanitize,
createStoredContextManager,
combine,
createIdentityEncoder,
CustomerDataCompressionStatus,
createCustomerDataTrackerManager,
storeContextManager,
} from '@datadog/browser-core'

@@ -66,7 +65,3 @@ import type { LifeCycle } from '../domain/lifeCycle'

getReplayStats: (viewId: string) => ReplayStats | undefined
getSessionReplayLink: (
configuration: RumConfiguration,
sessionManager: RumSessionManager,
viewContexts: ViewContexts
) => string | undefined
getSessionReplayLink: () => string | undefined
}

@@ -97,11 +92,14 @@ interface RumPublicApiOptions {

const customerDataTrackerManager = createCustomerDataTrackerManager(CustomerDataCompressionStatus.Unknown)
let globalContextManager = createContextManager(
const globalContextManager = createContextManager(
customerDataTrackerManager.getOrCreateTracker(CustomerDataType.GlobalContext)
)
let userContextManager = createContextManager(customerDataTrackerManager.getOrCreateTracker(CustomerDataType.User))
const userContextManager = createContextManager(customerDataTrackerManager.getOrCreateTracker(CustomerDataType.User))
function getCommonContext() {
return buildCommonContext(globalContextManager, userContextManager, recorderApi)
}
let getInternalContextStrategy: StartRumResult['getInternalContext'] = () => undefined
let getInitConfigurationStrategy = (): InitConfiguration | undefined => undefined
let stopSessionStrategy: () => void = noop
let getSessionReplayLinkStrategy: () => string | undefined = () => undefined

@@ -115,23 +113,9 @@ let bufferApiCalls = new BoundedBuffer()

}
let addActionStrategy: StartRumResult['addAction'] = (
action,
commonContext = buildCommonContext(globalContextManager, userContextManager, recorderApi)
) => {
let addActionStrategy: StartRumResult['addAction'] = (action, commonContext = getCommonContext()) => {
bufferApiCalls.add(() => addActionStrategy(action, commonContext))
}
let addErrorStrategy: StartRumResult['addError'] = (
providedError,
commonContext = buildCommonContext(globalContextManager, userContextManager, recorderApi)
) => {
let addErrorStrategy: StartRumResult['addError'] = (providedError, commonContext = getCommonContext()) => {
bufferApiCalls.add(() => addErrorStrategy(providedError, commonContext))
}
let recorderStartStrategy: typeof recorderApi.start = () => {
bufferApiCalls.add(() => recorderStartStrategy())
}
let recorderStopStrategy: typeof recorderApi.stop = () => {
bufferApiCalls.add(() => recorderStopStrategy())
}
let addFeatureFlagEvaluationStrategy: StartRumResult['addFeatureFlagEvaluation'] = (key: string, value: any) => {

@@ -217,19 +201,4 @@ bufferApiCalls.add(() => addFeatureFlagEvaluationStrategy(key, value))

if (initConfiguration.storeContextsAcrossPages) {
const beforeInitGlobalContext = globalContextManager.getContext()
globalContextManager = createStoredContextManager(
configuration,
RUM_STORAGE_KEY,
CustomerDataType.GlobalContext,
customerDataTrackerManager.getOrCreateTracker(CustomerDataType.GlobalContext)
)
globalContextManager.setContext(combine(globalContextManager.getContext(), beforeInitGlobalContext))
const beforeInitUserContext = userContextManager.getContext()
userContextManager = createStoredContextManager(
configuration,
RUM_STORAGE_KEY,
CustomerDataType.User,
customerDataTrackerManager.getOrCreateTracker(CustomerDataType.User)
)
userContextManager.setContext(combine(userContextManager.getContext(), beforeInitUserContext))
storeContextManager(configuration, globalContextManager, RUM_STORAGE_KEY, CustomerDataType.GlobalContext)
storeContextManager(configuration, userContextManager, RUM_STORAGE_KEY, CustomerDataType.User)
}

@@ -246,4 +215,3 @@

customerDataTrackerManager,
globalContextManager,
userContextManager,
getCommonContext,
initialViewOptions,

@@ -254,6 +222,2 @@ deflateWorker && createDeflateEncoder

)
getSessionReplayLinkStrategy = () =>
recorderApi.getSessionReplayLink(configuration, startRumResults.session, startRumResults.viewContexts)
recorderStartStrategy = recorderApi.start
recorderStopStrategy = recorderApi.stop
;({

@@ -324,3 +288,15 @@ startView: startViewStrategy,

/**
* Add a custom timing relative to the start of the current view,
* stored in @view.custom_timings.<timing_name>
*
* @param name name of the custom timing
* @param [time] epoch timestamp of the custom timing (if not set, will use current time)
*
* Note: passing a relative time is discouraged since it is actually used as-is but displayed relative to the view start.
* We currently don't provide a way to retrieve the view start time, so it can be challenging to provide a timing relative to the view start.
* see https://github.com/DataDog/browser-sdk/issues/2552
*/
addTiming: monitor((name: string, time?: number) => {
// TODO: next major decide to drop relative time support or update its behaviour
addTimingStrategy(sanitize(name)!, time as RelativeTime | TimeStamp | undefined)

@@ -352,5 +328,2 @@ }),

startSessionReplayRecording: monitor(() => recorderStartStrategy()),
stopSessionReplayRecording: monitor(() => recorderStopStrategy()),
/**

@@ -362,3 +335,6 @@ * This feature is currently in beta. For more information see the full [feature flag tracking guide](https://docs.datadoghq.com/real_user_monitoring/feature_flag_tracking/).

}),
getSessionReplayLink: monitor(() => getSessionReplayLinkStrategy()),
getSessionReplayLink: monitor(() => recorderApi.getSessionReplayLink()),
startSessionReplayRecording: monitor(() => recorderApi.start()),
stopSessionReplayRecording: monitor(() => recorderApi.stop()),
})

@@ -365,0 +341,0 @@

@@ -5,3 +5,2 @@ import type {

RawError,
ContextManager,
DeflateEncoderStreamId,

@@ -48,3 +47,2 @@ Encoder,

import type { CommonContext } from '../domain/contexts/commonContext'
import { buildCommonContext } from '../domain/contexts/commonContext'
import { startDisplayContext } from '../domain/contexts/displayContext'

@@ -58,4 +56,3 @@ import type { RecorderApi } from './rumPublicApi'

customerDataTrackerManager: CustomerDataTrackerManager,
globalContextManager: ContextManager,
userContextManager: ContextManager,
getCommonContext: () => CommonContext,
initialViewOptions: ViewOptions | undefined,

@@ -134,3 +131,3 @@ createEncoder: (streamId: DeflateEncoderStreamId) => Encoder

domMutationObservable,
() => buildCommonContext(globalContextManager, userContextManager, recorderApi),
getCommonContext,
reportError

@@ -208,3 +205,3 @@ )

domMutationObservable: Observable<void>,
buildCommonContext: () => CommonContext,
getCommonContext: () => CommonContext,
reportError: (error: RawError) => void

@@ -234,3 +231,3 @@ ) {

displayContext,
buildCommonContext,
getCommonContext,
reportError

@@ -237,0 +234,0 @@ )

@@ -14,2 +14,3 @@ import type { Context, RawError, EventRateLimiter, User } from '@datadog/browser-core'

ExperimentalFeature,
getConnectivity,
} from '@datadog/browser-core'

@@ -71,3 +72,3 @@ import type { RumEventDomainContext } from '../domainContext.types'

displayContext: DisplayContext,
buildCommonContext: () => CommonContext,
getCommonContext: () => CommonContext,
reportError: (error: RawError) => void

@@ -129,3 +130,3 @@ ) {

if (session && viewContext && urlContext) {
const commonContext = savedCommonContext || buildCommonContext()
const commonContext = savedCommonContext || getCommonContext()
const actionId = actionContexts.findActionId(startTime)

@@ -164,2 +165,3 @@

display: displayContext.get(),
connectivity: getConnectivity(),
}

@@ -166,0 +168,0 @@

@@ -11,2 +11,3 @@ import type {

DefaultPrivacyLevel,
Connectivity,
} from '@datadog/browser-core'

@@ -250,2 +251,3 @@ import type { PageState } from './domain/contexts/pageStateHistory'

}
connectivity: Connectivity
action?: {

@@ -252,0 +254,0 @@ id: string | string[]

@@ -953,3 +953,3 @@ /* eslint-disable */

*/
readonly source?: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku'
readonly source?: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku' | 'unity'
/**

@@ -1006,3 +1006,3 @@ * View properties

*/
readonly interfaces: (
readonly interfaces?: (
| 'bluetooth'

@@ -1019,2 +1019,6 @@ | 'cellular'

/**
* Cellular connection type reflecting the measured network performance
*/
readonly effective_type?: 'slow_2g' | '2g' | '3g' | '4g'
/**
* Cellular connectivity properties

@@ -1209,3 +1213,3 @@ */

*/
readonly source: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku'
readonly source: 'android' | 'ios' | 'browser' | 'flutter' | 'react-native' | 'roku' | 'unity'
[k: string]: unknown

@@ -1212,0 +1216,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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