Socket
Socket
Sign inDemoInstall

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
177
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 4.48.2 to 4.49.0

cjs/domain/action/actionCollection.d.ts

16

cjs/boot/rumPublicApi.d.ts

@@ -7,3 +7,3 @@ import type { Context, InitConfiguration, RelativeTime, User, Observable } from '@datadog/browser-core';

import type { RumConfiguration, RumInitConfiguration } from '../domain/configuration';
import type { ViewOptions } from '../domain/rumEventsCollection/view/trackViews';
import type { ViewOptions } from '../domain/view/trackViews';
import type { startRum } from './startRum';

@@ -28,7 +28,7 @@ export type RumPublicApi = ReturnType<typeof makeRumPublicApi>;

/** @deprecated: use setGlobalContextProperty instead */
addRumGlobalContext: (key: string, value: any) => void;
setGlobalContextProperty: (key: string, property: any) => void;
addRumGlobalContext: (key: any, value: any) => void;
setGlobalContextProperty: (key: any, value: any) => void;
/** @deprecated: use removeGlobalContextProperty instead */
removeRumGlobalContext: (key: string) => void;
removeGlobalContextProperty: (key: string) => void;
removeRumGlobalContext: (key: any) => void;
removeGlobalContextProperty: (key: any) => void;
/** @deprecated: use getGlobalContext instead */

@@ -38,4 +38,4 @@ getRumGlobalContext: () => Context;

/** @deprecated: use setGlobalContext instead */
setRumGlobalContext: (newContext: object) => void;
setGlobalContext: (newContext: Context) => void;
setRumGlobalContext: (context: any) => void;
setGlobalContext: (context: any) => void;
clearGlobalContext: () => void;

@@ -50,3 +50,3 @@ getInternalContext: (startTime?: number) => import("../domain/contexts/internalContext").InternalContext | undefined;

setUserProperty: (key: any, property: any) => void;
removeUserProperty: (key: string) => void;
removeUserProperty: (key: any) => void;
/** @deprecated: renamed to clearUser */

@@ -53,0 +53,0 @@ removeUser: () => void;

@@ -7,7 +7,8 @@ "use strict";

var commonContext_1 = require("../domain/contexts/commonContext");
var RUM_STORAGE_KEY = 'rum';
function makeRumPublicApi(startRumImpl, recorderApi, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.ignoreInitIfSyntheticsWillInjectRum, ignoreInitIfSyntheticsWillInjectRum = _c === void 0 ? true : _c;
var isAlreadyInitialized = false;
var globalContextManager = (0, browser_core_1.createContextManager)("global context" /* CustomerDataType.GlobalContext */);
var userContextManager = (0, browser_core_1.createContextManager)("user" /* CustomerDataType.User */);
var globalContextManager = (0, browser_core_1.createContextManager)(2 /* CustomerDataType.GlobalContext */);
var userContextManager = (0, browser_core_1.createContextManager)(1 /* CustomerDataType.User */);
var getInternalContextStrategy = function () { return undefined; };

@@ -38,2 +39,6 @@ var getInitConfigurationStrategy = function () { return undefined; };

function initRum(initConfiguration) {
if (!initConfiguration) {
browser_core_1.display.error('Missing configuration');
return;
}
// This function should be available, regardless of initialization success.

@@ -80,2 +85,10 @@ getInitConfigurationStrategy = function () { return (0, browser_core_1.deepClone)(initConfiguration); };

function doStartRum(initConfiguration, configuration, initialViewOptions) {
if (initConfiguration.storeContextsAcrossPages) {
var beforeInitGlobalContext = globalContextManager.getContext();
globalContextManager = (0, browser_core_1.createStoredContextManager)(configuration, RUM_STORAGE_KEY, 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 */);
userContextManager.setContext((0, browser_core_1.combine)(userContextManager.getContext(), beforeInitUserContext));
}
var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, globalContextManager, userContextManager, initialViewOptions);

@@ -96,14 +109,14 @@ getSessionReplayLinkStrategy = function () {

/** @deprecated: use setGlobalContextProperty instead */
addRumGlobalContext: (0, browser_core_1.monitor)(globalContextManager.add),
setGlobalContextProperty: (0, browser_core_1.monitor)(globalContextManager.setContextProperty),
addRumGlobalContext: (0, browser_core_1.monitor)(function (key, value) { return globalContextManager.add(key, value); }),
setGlobalContextProperty: (0, browser_core_1.monitor)(function (key, value) { return globalContextManager.setContextProperty(key, value); }),
/** @deprecated: use removeGlobalContextProperty instead */
removeRumGlobalContext: (0, browser_core_1.monitor)(globalContextManager.remove),
removeGlobalContextProperty: (0, browser_core_1.monitor)(globalContextManager.removeContextProperty),
removeRumGlobalContext: (0, browser_core_1.monitor)(function (key) { return globalContextManager.remove(key); }),
removeGlobalContextProperty: (0, browser_core_1.monitor)(function (key) { return globalContextManager.removeContextProperty(key); }),
/** @deprecated: use getGlobalContext instead */
getRumGlobalContext: (0, browser_core_1.monitor)(globalContextManager.get),
getGlobalContext: (0, browser_core_1.monitor)(globalContextManager.getContext),
getRumGlobalContext: (0, browser_core_1.monitor)(function () { return globalContextManager.get(); }),
getGlobalContext: (0, browser_core_1.monitor)(function () { return globalContextManager.getContext(); }),
/** @deprecated: use setGlobalContext instead */
setRumGlobalContext: (0, browser_core_1.monitor)(globalContextManager.set),
setGlobalContext: (0, browser_core_1.monitor)(globalContextManager.setContext),
clearGlobalContext: (0, browser_core_1.monitor)(globalContextManager.clearContext),
setRumGlobalContext: (0, browser_core_1.monitor)(function (context) { return globalContextManager.set(context); }),
setGlobalContext: (0, browser_core_1.monitor)(function (context) { return globalContextManager.setContext(context); }),
clearGlobalContext: (0, browser_core_1.monitor)(function () { return globalContextManager.clearContext(); }),
getInternalContext: (0, browser_core_1.monitor)(function (startTime) { return getInternalContextStrategy(startTime); }),

@@ -138,3 +151,3 @@ getInitConfiguration: (0, browser_core_1.monitor)(function () { return getInitConfigurationStrategy(); }),

}),
getUser: (0, browser_core_1.monitor)(userContextManager.getContext),
getUser: (0, browser_core_1.monitor)(function () { return userContextManager.getContext(); }),
setUserProperty: (0, browser_core_1.monitor)(function (key, property) {

@@ -145,6 +158,6 @@ var _a;

}),
removeUserProperty: (0, browser_core_1.monitor)(userContextManager.removeContextProperty),
removeUserProperty: (0, browser_core_1.monitor)(function (key) { return userContextManager.removeContextProperty(key); }),
/** @deprecated: renamed to clearUser */
removeUser: (0, browser_core_1.monitor)(userContextManager.clearContext),
clearUser: (0, browser_core_1.monitor)(userContextManager.clearContext),
removeUser: (0, browser_core_1.monitor)(function () { return userContextManager.clearContext(); }),
clearUser: (0, browser_core_1.monitor)(function () { return userContextManager.clearContext(); }),
startView: startView,

@@ -151,0 +164,0 @@ stopSession: (0, browser_core_1.monitor)(function () {

@@ -6,8 +6,8 @@ import type { Observable, RawError, ContextManager } from '@datadog/browser-core';

import type { RumConfiguration, RumInitConfiguration } from '../domain/configuration';
import type { ViewOptions } from '../domain/rumEventsCollection/view/trackViews';
import type { ViewOptions } from '../domain/view/trackViews';
import type { CommonContext } from '../domain/contexts/commonContext';
import type { RecorderApi } from './rumPublicApi';
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, globalContextManager: ContextManager, userContextManager: ContextManager, initialViewOptions?: ViewOptions): {
addAction: (action: import("../domain/rumEventsCollection/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;
addError: ({ error, handlingStack, startClocks, context: customerContext }: import("../domain/rumEventsCollection/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;
addError: ({ error, handlingStack, startClocks, context: customerContext }: import("../domain/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
addTiming: (name: string, time?: import("@datadog/browser-core").TimeStamp | import("@datadog/browser-core").RelativeTime) => void;

@@ -21,2 +21,3 @@ addFeatureFlagEvaluation: (key: string, value: import("@datadog/browser-core").ContextValue) => void;

getInternalContext: (startTime?: number | undefined) => import("../domain/contexts/internalContext").InternalContext | undefined;
stop: () => void;
};

@@ -30,5 +31,5 @@ export declare function startRumEventCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, location: Location, sessionManager: RumSessionManager, locationChangeObservable: Observable<LocationChange>, domMutationObservable: Observable<void>, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): {

};
addAction: (action: import("../domain/rumEventsCollection/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;
actionContexts: import("../domain/rumEventsCollection/action/trackClickActions").ActionContexts;
addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;
actionContexts: import("../domain/action/trackClickActions").ActionContexts;
stop: () => void;
};

@@ -12,7 +12,7 @@ "use strict";

var requestCollection_1 = require("../domain/requestCollection");
var actionCollection_1 = require("../domain/rumEventsCollection/action/actionCollection");
var errorCollection_1 = require("../domain/rumEventsCollection/error/errorCollection");
var longTaskCollection_1 = require("../domain/rumEventsCollection/longTask/longTaskCollection");
var resourceCollection_1 = require("../domain/rumEventsCollection/resource/resourceCollection");
var viewCollection_1 = require("../domain/rumEventsCollection/view/viewCollection");
var actionCollection_1 = require("../domain/action/actionCollection");
var errorCollection_1 = require("../domain/error/errorCollection");
var longTaskCollection_1 = require("../domain/longTask/longTaskCollection");
var resourceCollection_1 = require("../domain/resource/resourceCollection");
var viewCollection_1 = require("../domain/view/viewCollection");
var rumSessionManager_1 = require("../domain/rumSessionManager");

@@ -28,4 +28,6 @@ var startRumBatch_1 = require("../transport/startRumBatch");

var commonContext_1 = require("../domain/contexts/commonContext");
var startWebVitalTelemetryDebug_1 = require("../domain/rumEventsCollection/view/startWebVitalTelemetryDebug");
var startWebVitalTelemetryDebug_1 = require("../domain/view/startWebVitalTelemetryDebug");
var displayContext_1 = require("../domain/contexts/displayContext");
function startRum(initConfiguration, configuration, recorderApi, globalContextManager, userContextManager, initialViewOptions) {
var cleanupTasks = [];
var lifeCycle = new lifeCycle_1.LifeCycle();

@@ -57,9 +59,11 @@ lifeCycle.subscribe(11 /* LifeCycleEventType.RUM_EVENT_COLLECTED */, function (event) { return (0, browser_core_1.sendToExtension)('rum', event); });

var pageExitObservable = (0, browser_core_1.createPageExitObservable)(configuration);
pageExitObservable.subscribe(function (event) {
var pageExitSubscription = pageExitObservable.subscribe(function (event) {
lifeCycle.notify(9 /* LifeCycleEventType.PAGE_EXITED */, event);
});
cleanupTasks.push(function () { return pageExitSubscription.unsubscribe(); });
var session = !(0, browser_core_1.canUseEventBridge)() ? (0, rumSessionManager_1.startRumSessionManager)(configuration, lifeCycle) : (0, rumSessionManager_1.startRumSessionManagerStub)();
if (!(0, browser_core_1.canUseEventBridge)()) {
var batch = (0, startRumBatch_1.startRumBatch)(configuration, lifeCycle, telemetry.observable, reportError, pageExitObservable, session.expireObservable);
(0, startCustomerDataTelemetry_1.startCustomerDataTelemetry)(configuration, telemetry, lifeCycle, globalContextManager, userContextManager, featureFlagContexts, batch.flushObservable);
var batch_1 = (0, startRumBatch_1.startRumBatch)(configuration, lifeCycle, telemetry.observable, reportError, pageExitObservable, session.expireObservable);
cleanupTasks.push(function () { return batch_1.stop(); });
(0, startCustomerDataTelemetry_1.startCustomerDataTelemetry)(configuration, telemetry, lifeCycle, globalContextManager, userContextManager, featureFlagContexts, batch_1.flushObservable);
}

@@ -71,3 +75,4 @@ else {

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;
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;
cleanupTasks.push(stopRumEventCollection);
(0, browser_core_1.addTelemetryConfiguration)((0, configuration_1.serializeRumConfiguration)(initConfiguration));

@@ -77,3 +82,4 @@ (0, longTaskCollection_1.startLongTaskCollection)(lifeCycle, session);

var webVitalTelemetryDebug = (0, startWebVitalTelemetryDebug_1.startWebVitalTelemetryDebug)(configuration, telemetry, recorderApi, session);
var _b = (0, viewCollection_1.startViewCollection)(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, webVitalTelemetryDebug, initialViewOptions), addTiming = _b.addTiming, startView = _b.startView;
var _b = (0, viewCollection_1.startViewCollection)(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, webVitalTelemetryDebug, initialViewOptions), addTiming = _b.addTiming, startView = _b.startView, stopViewCollection = _b.stop;
cleanupTasks.push(stopViewCollection);
var addError = (0, errorCollection_1.startErrorCollection)(lifeCycle, configuration, pageStateHistory, featureFlagContexts).addError;

@@ -94,2 +100,5 @@ (0, requestCollection_1.startRequestCollection)(lifeCycle, configuration, session);

getInternalContext: internalContext.get,
stop: function () {
cleanupTasks.forEach(function (task) { return task(); });
},
};

@@ -111,3 +120,4 @@ }

var _a = (0, actionCollection_1.startActionCollection)(lifeCycle, domMutationObservable, configuration, pageStateHistory), addAction = _a.addAction, actionContexts = _a.actionContexts;
(0, assembly_1.startRumAssembly)(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, buildCommonContext, reportError);
var displayContext = (0, displayContext_1.startDisplayContext)(configuration);
(0, assembly_1.startRumAssembly)(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, buildCommonContext, reportError);
return {

@@ -120,2 +130,5 @@ viewContexts: viewContexts,

stop: function () {
displayContext.stop();
pageStateHistory.stop();
urlContexts.stop();
viewContexts.stop();

@@ -122,0 +135,0 @@ pageStateHistory.stop();

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

var browser_core_1 = require("@datadog/browser-core");
var resourceUtils_1 = require("../domain/rumEventsCollection/resource/resourceUtils");
var resourceUtils_1 = require("../domain/resource/resourceUtils");
var getDocumentTraceId_1 = require("../domain/tracing/getDocumentTraceId");

@@ -8,0 +8,0 @@ function supportPerformanceObject() {

@@ -7,4 +7,5 @@ import type { RawError } from '@datadog/browser-core';

import type { RumConfiguration } from './configuration';
import type { ActionContexts } from './rumEventsCollection/action/actionCollection';
import type { ActionContexts } from './action/actionCollection';
import type { DisplayContext } from './contexts/displayContext';
import type { CommonContext } from './contexts/commonContext';
export declare function startRumAssembly(configuration: RumConfiguration, lifeCycle: LifeCycle, sessionManager: RumSessionManager, viewContexts: ViewContexts, urlContexts: UrlContexts, actionContexts: ActionContexts, 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, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): void;

@@ -7,5 +7,5 @@ "use strict";

var ciTestContext_1 = require("./contexts/ciTestContext");
var displayContext_1 = require("./contexts/displayContext");
var limitModification_1 = require("./limitModification");
var VIEW_MODIFIABLE_FIELD_PATHS = {
'view.name': 'string',
'view.url': 'string',

@@ -18,3 +18,3 @@ 'view.referrer': 'string',

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

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

},
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.48.2" : undefined,
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.49.0" : undefined,
},

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

ci_test: ciTestContext,
display: (0, displayContext_1.getDisplayContext)(configuration),
display: displayContext.get(),
};

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

import type { RumConfiguration } from '../configuration';
export declare function getDisplayContext(configuration: RumConfiguration): {
viewport: {
width: number;
height: number;
export type DisplayContext = ReturnType<typeof startDisplayContext>;
export declare function startDisplayContext(configuration: RumConfiguration): {
get: () => {
viewport: import("../../browser/viewportObservable").ViewportDimension;
};
stop: () => void;
};
export declare function resetDisplayContext(): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resetDisplayContext = exports.getDisplayContext = void 0;
exports.startDisplayContext = void 0;
var viewportObservable_1 = require("../../browser/viewportObservable");
var viewport;
var stopListeners;
function getDisplayContext(configuration) {
if (!viewport) {
viewport = (0, viewportObservable_1.getViewportDimension)();
stopListeners = (0, viewportObservable_1.initViewportObservable)(configuration).subscribe(function (viewportDimension) {
viewport = viewportDimension;
}).unsubscribe;
}
function startDisplayContext(configuration) {
var viewport = (0, viewportObservable_1.getViewportDimension)();
var unsubscribeViewport = (0, viewportObservable_1.initViewportObservable)(configuration).subscribe(function (viewportDimension) {
viewport = viewportDimension;
}).unsubscribe;
return {
viewport: viewport,
get: function () { return ({ viewport: viewport }); },
stop: unsubscribeViewport,
};
}
exports.getDisplayContext = getDisplayContext;
function resetDisplayContext() {
if (stopListeners) {
stopListeners();
}
viewport = undefined;
}
exports.resetDisplayContext = resetDisplayContext;
exports.startDisplayContext = startDisplayContext;
//# sourceMappingURL=displayContext.js.map

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

if (!alreadyWarned) {
alreadyWarned = (0, browser_core_1.warnIfCustomerDataLimitReached)(bytesCountCache, "feature flag evaluation" /* CustomerDataType.FeatureFlag */);
alreadyWarned = (0, browser_core_1.warnIfCustomerDataLimitReached)(bytesCountCache, 0 /* CustomerDataType.FeatureFlag */);
}

@@ -45,0 +45,0 @@ }, exports.BYTES_COMPUTATION_THROTTLING_DELAY), computeBytesCountThrottled = _a.throttled, cancelPendingComputation = _a.cancel;

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

import type { ActionContexts } from '../rumEventsCollection/action/actionCollection';
import type { ActionContexts } from '../action/actionCollection';
import type { RumSessionManager } from '../rumSessionManager';

@@ -3,0 +3,0 @@ import type { ViewContexts } from './viewContexts';

@@ -9,4 +9,4 @@ import type { Context, PageExitEvent, RawError, RelativeTime } from '@datadog/browser-core';

import type { RequestCompleteEvent, RequestStartEvent } from './requestCollection';
import type { AutoAction } from './rumEventsCollection/action/actionCollection';
import type { ViewEvent, ViewCreatedEvent, ViewEndedEvent } from './rumEventsCollection/view/trackViews';
import type { AutoAction } from './action/actionCollection';
import type { ViewEvent, ViewCreatedEvent, ViewEndedEvent } from './view/trackViews';
export declare const enum LifeCycleEventType {

@@ -13,0 +13,0 @@ PERFORMANCE_ENTRIES_COLLECTED = 0,

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

var browser_core_1 = require("@datadog/browser-core");
var resourceUtils_1 = require("./rumEventsCollection/resource/resourceUtils");
var resourceUtils_1 = require("./resource/resourceUtils");
var tracer_1 = require("./tracing/tracer");

@@ -8,0 +8,0 @@ var nextRequestIndex = 1;

@@ -15,2 +15,3 @@ "use strict";

var subscription = lifeCycle.subscribe(11 /* LifeCycleEventType.RUM_EVENT_COLLECTED */, function (event) {
var _a;
if (event.type === 'view' || !isChildEvent(event)) {

@@ -36,4 +37,6 @@ return;

case "resource" /* RumEventType.RESOURCE */:
eventCounts.resourceCount += 1;
callback();
if (!((_a = event._dd) === null || _a === void 0 ? void 0 : _a.discarded)) {
eventCounts.resourceCount += 1;
callback();
}
break;

@@ -40,0 +43,0 @@ }

@@ -7,3 +7,3 @@ export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi';

export { LifeCycle, LifeCycleEventType } from './domain/lifeCycle';
export { ViewCreatedEvent } from './domain/rumEventsCollection/view/trackViews';
export { ViewCreatedEvent } from './domain/view/trackViews';
export { ViewContexts, ViewContext } from './domain/contexts/viewContexts';

@@ -15,5 +15,5 @@ export { RumSessionManager, RumSessionPlan, RumSession } from './domain/rumSessionManager';

export { RumInitConfiguration, RumConfiguration } from './domain/configuration';
export { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './domain/rumEventsCollection/action/getActionNameFromElement';
export { STABLE_ATTRIBUTES } from './domain/rumEventsCollection/action/getSelectorFromElement';
export { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './domain/action/getActionNameFromElement';
export { STABLE_ATTRIBUTES } from './domain/action/getSelectorFromElement';
export * from './browser/htmlDomUtils';
export { getSessionReplayUrl } from './domain/getSessionReplayUrl';

@@ -32,5 +32,5 @@ "use strict";

Object.defineProperty(exports, "getScrollY", { enumerable: true, get: function () { return scroll_1.getScrollY; } });
var getActionNameFromElement_1 = require("./domain/rumEventsCollection/action/getActionNameFromElement");
var getActionNameFromElement_1 = require("./domain/action/getActionNameFromElement");
Object.defineProperty(exports, "DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE", { enumerable: true, get: function () { return getActionNameFromElement_1.DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE; } });
var getSelectorFromElement_1 = require("./domain/rumEventsCollection/action/getSelectorFromElement");
var getSelectorFromElement_1 = require("./domain/action/getSelectorFromElement");
Object.defineProperty(exports, "STABLE_ATTRIBUTES", { enumerable: true, get: function () { return getSelectorFromElement_1.STABLE_ATTRIBUTES; } });

@@ -37,0 +37,0 @@ __exportStar(require("./browser/htmlDomUtils"), exports);

@@ -1037,3 +1037,3 @@ /**

*/
readonly session_replay_sample_rate: number;
readonly session_replay_sample_rate?: number;
[k: string]: unknown;

@@ -1040,0 +1040,0 @@ };

@@ -8,2 +8,3 @@ import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent } from '@datadog/browser-core';

upsert: (message: Context, key: string) => void;
stop: () => void;
};

@@ -7,3 +7,3 @@ import type { Context, InitConfiguration, RelativeTime, User, Observable } from '@datadog/browser-core';

import type { RumConfiguration, RumInitConfiguration } from '../domain/configuration';
import type { ViewOptions } from '../domain/rumEventsCollection/view/trackViews';
import type { ViewOptions } from '../domain/view/trackViews';
import type { startRum } from './startRum';

@@ -28,7 +28,7 @@ export type RumPublicApi = ReturnType<typeof makeRumPublicApi>;

/** @deprecated: use setGlobalContextProperty instead */
addRumGlobalContext: (key: string, value: any) => void;
setGlobalContextProperty: (key: string, property: any) => void;
addRumGlobalContext: (key: any, value: any) => void;
setGlobalContextProperty: (key: any, value: any) => void;
/** @deprecated: use removeGlobalContextProperty instead */
removeRumGlobalContext: (key: string) => void;
removeGlobalContextProperty: (key: string) => void;
removeRumGlobalContext: (key: any) => void;
removeGlobalContextProperty: (key: any) => void;
/** @deprecated: use getGlobalContext instead */

@@ -38,4 +38,4 @@ getRumGlobalContext: () => Context;

/** @deprecated: use setGlobalContext instead */
setRumGlobalContext: (newContext: object) => void;
setGlobalContext: (newContext: Context) => void;
setRumGlobalContext: (context: any) => void;
setGlobalContext: (context: any) => void;
clearGlobalContext: () => void;

@@ -50,3 +50,3 @@ getInternalContext: (startTime?: number) => import("../domain/contexts/internalContext").InternalContext | undefined;

setUserProperty: (key: any, property: any) => void;
removeUserProperty: (key: string) => void;
removeUserProperty: (key: any) => void;
/** @deprecated: renamed to clearUser */

@@ -53,0 +53,0 @@ removeUser: () => void;

@@ -1,9 +0,10 @@

import { noop, willSyntheticsInjectRum, assign, BoundedBuffer, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, checkUser, sanitizeUser, sanitize, } from '@datadog/browser-core';
import { noop, willSyntheticsInjectRum, assign, BoundedBuffer, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, checkUser, sanitizeUser, sanitize, createStoredContextManager, combine, } from '@datadog/browser-core';
import { validateAndBuildRumConfiguration } from '../domain/configuration';
import { buildCommonContext } from '../domain/contexts/commonContext';
var RUM_STORAGE_KEY = 'rum';
export function makeRumPublicApi(startRumImpl, recorderApi, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.ignoreInitIfSyntheticsWillInjectRum, ignoreInitIfSyntheticsWillInjectRum = _c === void 0 ? true : _c;
var isAlreadyInitialized = false;
var globalContextManager = createContextManager("global context" /* CustomerDataType.GlobalContext */);
var userContextManager = createContextManager("user" /* CustomerDataType.User */);
var globalContextManager = createContextManager(2 /* CustomerDataType.GlobalContext */);
var userContextManager = createContextManager(1 /* CustomerDataType.User */);
var getInternalContextStrategy = function () { return undefined; };

@@ -34,2 +35,6 @@ var getInitConfigurationStrategy = function () { return undefined; };

function initRum(initConfiguration) {
if (!initConfiguration) {
display.error('Missing configuration');
return;
}
// This function should be available, regardless of initialization success.

@@ -76,2 +81,10 @@ getInitConfigurationStrategy = function () { return deepClone(initConfiguration); };

function doStartRum(initConfiguration, configuration, initialViewOptions) {
if (initConfiguration.storeContextsAcrossPages) {
var beforeInitGlobalContext = globalContextManager.getContext();
globalContextManager = createStoredContextManager(configuration, RUM_STORAGE_KEY, 2 /* CustomerDataType.GlobalContext */);
globalContextManager.setContext(combine(globalContextManager.getContext(), beforeInitGlobalContext));
var beforeInitUserContext = userContextManager.getContext();
userContextManager = createStoredContextManager(configuration, RUM_STORAGE_KEY, 1 /* CustomerDataType.User */);
userContextManager.setContext(combine(userContextManager.getContext(), beforeInitUserContext));
}
var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, globalContextManager, userContextManager, initialViewOptions);

@@ -92,14 +105,14 @@ getSessionReplayLinkStrategy = function () {

/** @deprecated: use setGlobalContextProperty instead */
addRumGlobalContext: monitor(globalContextManager.add),
setGlobalContextProperty: monitor(globalContextManager.setContextProperty),
addRumGlobalContext: monitor(function (key, value) { return globalContextManager.add(key, value); }),
setGlobalContextProperty: monitor(function (key, value) { return globalContextManager.setContextProperty(key, value); }),
/** @deprecated: use removeGlobalContextProperty instead */
removeRumGlobalContext: monitor(globalContextManager.remove),
removeGlobalContextProperty: monitor(globalContextManager.removeContextProperty),
removeRumGlobalContext: monitor(function (key) { return globalContextManager.remove(key); }),
removeGlobalContextProperty: monitor(function (key) { return globalContextManager.removeContextProperty(key); }),
/** @deprecated: use getGlobalContext instead */
getRumGlobalContext: monitor(globalContextManager.get),
getGlobalContext: monitor(globalContextManager.getContext),
getRumGlobalContext: monitor(function () { return globalContextManager.get(); }),
getGlobalContext: monitor(function () { return globalContextManager.getContext(); }),
/** @deprecated: use setGlobalContext instead */
setRumGlobalContext: monitor(globalContextManager.set),
setGlobalContext: monitor(globalContextManager.setContext),
clearGlobalContext: monitor(globalContextManager.clearContext),
setRumGlobalContext: monitor(function (context) { return globalContextManager.set(context); }),
setGlobalContext: monitor(function (context) { return globalContextManager.setContext(context); }),
clearGlobalContext: monitor(function () { return globalContextManager.clearContext(); }),
getInternalContext: monitor(function (startTime) { return getInternalContextStrategy(startTime); }),

@@ -134,3 +147,3 @@ getInitConfiguration: monitor(function () { return getInitConfigurationStrategy(); }),

}),
getUser: monitor(userContextManager.getContext),
getUser: monitor(function () { return userContextManager.getContext(); }),
setUserProperty: monitor(function (key, property) {

@@ -141,6 +154,6 @@ var _a;

}),
removeUserProperty: monitor(userContextManager.removeContextProperty),
removeUserProperty: monitor(function (key) { return userContextManager.removeContextProperty(key); }),
/** @deprecated: renamed to clearUser */
removeUser: monitor(userContextManager.clearContext),
clearUser: monitor(userContextManager.clearContext),
removeUser: monitor(function () { return userContextManager.clearContext(); }),
clearUser: monitor(function () { return userContextManager.clearContext(); }),
startView: startView,

@@ -147,0 +160,0 @@ stopSession: monitor(function () {

@@ -6,8 +6,8 @@ import type { Observable, RawError, ContextManager } from '@datadog/browser-core';

import type { RumConfiguration, RumInitConfiguration } from '../domain/configuration';
import type { ViewOptions } from '../domain/rumEventsCollection/view/trackViews';
import type { ViewOptions } from '../domain/view/trackViews';
import type { CommonContext } from '../domain/contexts/commonContext';
import type { RecorderApi } from './rumPublicApi';
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, globalContextManager: ContextManager, userContextManager: ContextManager, initialViewOptions?: ViewOptions): {
addAction: (action: import("../domain/rumEventsCollection/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;
addError: ({ error, handlingStack, startClocks, context: customerContext }: import("../domain/rumEventsCollection/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;
addError: ({ error, handlingStack, startClocks, context: customerContext }: import("../domain/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
addTiming: (name: string, time?: import("@datadog/browser-core").TimeStamp | import("@datadog/browser-core").RelativeTime) => void;

@@ -21,2 +21,3 @@ addFeatureFlagEvaluation: (key: string, value: import("@datadog/browser-core").ContextValue) => void;

getInternalContext: (startTime?: number | undefined) => import("../domain/contexts/internalContext").InternalContext | undefined;
stop: () => void;
};

@@ -30,5 +31,5 @@ export declare function startRumEventCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, location: Location, sessionManager: RumSessionManager, locationChangeObservable: Observable<LocationChange>, domMutationObservable: Observable<void>, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): {

};
addAction: (action: import("../domain/rumEventsCollection/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;
actionContexts: import("../domain/rumEventsCollection/action/trackClickActions").ActionContexts;
addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;
actionContexts: import("../domain/action/trackClickActions").ActionContexts;
stop: () => void;
};

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

import { startRequestCollection } from '../domain/requestCollection';
import { startActionCollection } from '../domain/rumEventsCollection/action/actionCollection';
import { startErrorCollection } from '../domain/rumEventsCollection/error/errorCollection';
import { startLongTaskCollection } from '../domain/rumEventsCollection/longTask/longTaskCollection';
import { startResourceCollection } from '../domain/rumEventsCollection/resource/resourceCollection';
import { startViewCollection } from '../domain/rumEventsCollection/view/viewCollection';
import { startActionCollection } from '../domain/action/actionCollection';
import { startErrorCollection } from '../domain/error/errorCollection';
import { startLongTaskCollection } from '../domain/longTask/longTaskCollection';
import { startResourceCollection } from '../domain/resource/resourceCollection';
import { startViewCollection } from '../domain/view/viewCollection';
import { startRumSessionManager, startRumSessionManagerStub } from '../domain/rumSessionManager';

@@ -25,4 +25,6 @@ import { startRumBatch } from '../transport/startRumBatch';

import { buildCommonContext } from '../domain/contexts/commonContext';
import { startWebVitalTelemetryDebug } from '../domain/rumEventsCollection/view/startWebVitalTelemetryDebug';
import { startWebVitalTelemetryDebug } from '../domain/view/startWebVitalTelemetryDebug';
import { startDisplayContext } from '../domain/contexts/displayContext';
export function startRum(initConfiguration, configuration, recorderApi, globalContextManager, userContextManager, initialViewOptions) {
var cleanupTasks = [];
var lifeCycle = new LifeCycle();

@@ -54,9 +56,11 @@ lifeCycle.subscribe(11 /* LifeCycleEventType.RUM_EVENT_COLLECTED */, function (event) { return sendToExtension('rum', event); });

var pageExitObservable = createPageExitObservable(configuration);
pageExitObservable.subscribe(function (event) {
var pageExitSubscription = pageExitObservable.subscribe(function (event) {
lifeCycle.notify(9 /* LifeCycleEventType.PAGE_EXITED */, event);
});
cleanupTasks.push(function () { return pageExitSubscription.unsubscribe(); });
var session = !canUseEventBridge() ? startRumSessionManager(configuration, lifeCycle) : startRumSessionManagerStub();
if (!canUseEventBridge()) {
var batch = startRumBatch(configuration, lifeCycle, telemetry.observable, reportError, pageExitObservable, session.expireObservable);
startCustomerDataTelemetry(configuration, telemetry, lifeCycle, globalContextManager, userContextManager, featureFlagContexts, batch.flushObservable);
var batch_1 = startRumBatch(configuration, lifeCycle, telemetry.observable, reportError, pageExitObservable, session.expireObservable);
cleanupTasks.push(function () { return batch_1.stop(); });
startCustomerDataTelemetry(configuration, telemetry, lifeCycle, globalContextManager, userContextManager, featureFlagContexts, batch_1.flushObservable);
}

@@ -68,3 +72,4 @@ else {

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;
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;
cleanupTasks.push(stopRumEventCollection);
addTelemetryConfiguration(serializeRumConfiguration(initConfiguration));

@@ -74,3 +79,4 @@ startLongTaskCollection(lifeCycle, session);

var webVitalTelemetryDebug = startWebVitalTelemetryDebug(configuration, telemetry, recorderApi, session);
var _b = startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, webVitalTelemetryDebug, initialViewOptions), addTiming = _b.addTiming, startView = _b.startView;
var _b = startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, webVitalTelemetryDebug, initialViewOptions), addTiming = _b.addTiming, startView = _b.startView, stopViewCollection = _b.stop;
cleanupTasks.push(stopViewCollection);
var addError = startErrorCollection(lifeCycle, configuration, pageStateHistory, featureFlagContexts).addError;

@@ -91,2 +97,5 @@ startRequestCollection(lifeCycle, configuration, session);

getInternalContext: internalContext.get,
stop: function () {
cleanupTasks.forEach(function (task) { return task(); });
},
};

@@ -107,3 +116,4 @@ }

var _a = startActionCollection(lifeCycle, domMutationObservable, configuration, pageStateHistory), addAction = _a.addAction, actionContexts = _a.actionContexts;
startRumAssembly(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, buildCommonContext, reportError);
var displayContext = startDisplayContext(configuration);
startRumAssembly(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, displayContext, buildCommonContext, reportError);
return {

@@ -116,2 +126,5 @@ viewContexts: viewContexts,

stop: function () {
displayContext.stop();
pageStateHistory.stop();
urlContexts.stop();
viewContexts.stop();

@@ -118,0 +131,0 @@ pageStateHistory.stop();

import { dateNow, assign, addEventListeners, getRelativeTime, isNumber, monitor, setTimeout, relativeNow, runOnReadyState, addEventListener, } from '@datadog/browser-core';
import { FAKE_INITIAL_DOCUMENT, isAllowedRequestUrl } from '../domain/rumEventsCollection/resource/resourceUtils';
import { FAKE_INITIAL_DOCUMENT, isAllowedRequestUrl } from '../domain/resource/resourceUtils';
import { getDocumentTraceId } from '../domain/tracing/getDocumentTraceId';

@@ -4,0 +4,0 @@ function supportPerformanceObject() {

@@ -7,4 +7,5 @@ import type { RawError } from '@datadog/browser-core';

import type { RumConfiguration } from './configuration';
import type { ActionContexts } from './rumEventsCollection/action/actionCollection';
import type { ActionContexts } from './action/actionCollection';
import type { DisplayContext } from './contexts/displayContext';
import type { CommonContext } from './contexts/commonContext';
export declare function startRumAssembly(configuration: RumConfiguration, lifeCycle: LifeCycle, sessionManager: RumSessionManager, viewContexts: ViewContexts, urlContexts: UrlContexts, actionContexts: ActionContexts, 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, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): void;
import { combine, isEmptyObject, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, assign, round, } from '@datadog/browser-core';
import { getSyntheticsContext } from './contexts/syntheticsContext';
import { getCiTestContext } from './contexts/ciTestContext';
import { getDisplayContext } from './contexts/displayContext';
import { limitModification } from './limitModification';
var VIEW_MODIFIABLE_FIELD_PATHS = {
'view.name': 'string',
'view.url': 'string',

@@ -14,3 +14,3 @@ 'view.referrer': 'string',

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

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

},
browser_sdk_version: canUseEventBridge() ? "4.48.2" : undefined,
browser_sdk_version: canUseEventBridge() ? "4.49.0" : undefined,
},

@@ -81,3 +81,3 @@ application: {

ci_test: ciTestContext,
display: getDisplayContext(configuration),
display: displayContext.get(),
};

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

import type { RumConfiguration } from '../configuration';
export declare function getDisplayContext(configuration: RumConfiguration): {
viewport: {
width: number;
height: number;
export type DisplayContext = ReturnType<typeof startDisplayContext>;
export declare function startDisplayContext(configuration: RumConfiguration): {
get: () => {
viewport: import("../../browser/viewportObservable").ViewportDimension;
};
stop: () => void;
};
export declare function resetDisplayContext(): void;
import { getViewportDimension, initViewportObservable } from '../../browser/viewportObservable';
var viewport;
var stopListeners;
export function getDisplayContext(configuration) {
if (!viewport) {
viewport = getViewportDimension();
stopListeners = initViewportObservable(configuration).subscribe(function (viewportDimension) {
viewport = viewportDimension;
}).unsubscribe;
}
export function startDisplayContext(configuration) {
var viewport = getViewportDimension();
var unsubscribeViewport = initViewportObservable(configuration).subscribe(function (viewportDimension) {
viewport = viewportDimension;
}).unsubscribe;
return {
viewport: viewport,
get: function () { return ({ viewport: viewport }); },
stop: unsubscribeViewport,
};
}
export function resetDisplayContext() {
if (stopListeners) {
stopListeners();
}
viewport = undefined;
}
//# sourceMappingURL=displayContext.js.map

@@ -39,3 +39,3 @@ import { warnIfCustomerDataLimitReached, throttle, jsonStringify, computeBytesCount, noop, isExperimentalFeatureEnabled, SESSION_TIME_OUT_DELAY, ValueHistory, ExperimentalFeature, } from '@datadog/browser-core';

if (!alreadyWarned) {
alreadyWarned = warnIfCustomerDataLimitReached(bytesCountCache, "feature flag evaluation" /* CustomerDataType.FeatureFlag */);
alreadyWarned = warnIfCustomerDataLimitReached(bytesCountCache, 0 /* CustomerDataType.FeatureFlag */);
}

@@ -42,0 +42,0 @@ }, BYTES_COMPUTATION_THROTTLING_DELAY), computeBytesCountThrottled = _a.throttled, cancelPendingComputation = _a.cancel;

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

import type { ActionContexts } from '../rumEventsCollection/action/actionCollection';
import type { ActionContexts } from '../action/actionCollection';
import type { RumSessionManager } from '../rumSessionManager';

@@ -3,0 +3,0 @@ import type { ViewContexts } from './viewContexts';

@@ -9,4 +9,4 @@ import type { Context, PageExitEvent, RawError, RelativeTime } from '@datadog/browser-core';

import type { RequestCompleteEvent, RequestStartEvent } from './requestCollection';
import type { AutoAction } from './rumEventsCollection/action/actionCollection';
import type { ViewEvent, ViewCreatedEvent, ViewEndedEvent } from './rumEventsCollection/view/trackViews';
import type { AutoAction } from './action/actionCollection';
import type { ViewEvent, ViewCreatedEvent, ViewEndedEvent } from './view/trackViews';
export declare const enum LifeCycleEventType {

@@ -13,0 +13,0 @@ PERFORMANCE_ENTRIES_COLLECTED = 0,

import { initFetchObservable, initXhrObservable, readBytesFromStream, elapsed, timeStampNow, tryToClone, } from '@datadog/browser-core';
import { isAllowedRequestUrl } from './rumEventsCollection/resource/resourceUtils';
import { isAllowedRequestUrl } from './resource/resourceUtils';
import { startTracer } from './tracing/tracer';

@@ -4,0 +4,0 @@ var nextRequestIndex = 1;

@@ -12,2 +12,3 @@ import { noop } from '@datadog/browser-core';

var subscription = lifeCycle.subscribe(11 /* LifeCycleEventType.RUM_EVENT_COLLECTED */, function (event) {
var _a;
if (event.type === 'view' || !isChildEvent(event)) {

@@ -33,4 +34,6 @@ return;

case "resource" /* RumEventType.RESOURCE */:
eventCounts.resourceCount += 1;
callback();
if (!((_a = event._dd) === null || _a === void 0 ? void 0 : _a.discarded)) {
eventCounts.resourceCount += 1;
callback();
}
break;

@@ -37,0 +40,0 @@ }

@@ -7,3 +7,3 @@ export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi';

export { LifeCycle, LifeCycleEventType } from './domain/lifeCycle';
export { ViewCreatedEvent } from './domain/rumEventsCollection/view/trackViews';
export { ViewCreatedEvent } from './domain/view/trackViews';
export { ViewContexts, ViewContext } from './domain/contexts/viewContexts';

@@ -15,5 +15,5 @@ export { RumSessionManager, RumSessionPlan, RumSession } from './domain/rumSessionManager';

export { RumInitConfiguration, RumConfiguration } from './domain/configuration';
export { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './domain/rumEventsCollection/action/getActionNameFromElement';
export { STABLE_ATTRIBUTES } from './domain/rumEventsCollection/action/getSelectorFromElement';
export { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './domain/action/getActionNameFromElement';
export { STABLE_ATTRIBUTES } from './domain/action/getSelectorFromElement';
export * from './browser/htmlDomUtils';
export { getSessionReplayUrl } from './domain/getSessionReplayUrl';

@@ -7,6 +7,6 @@ export { makeRumPublicApi } from './boot/rumPublicApi';

export { getScrollX, getScrollY } from './browser/scroll';
export { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './domain/rumEventsCollection/action/getActionNameFromElement';
export { STABLE_ATTRIBUTES } from './domain/rumEventsCollection/action/getSelectorFromElement';
export { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './domain/action/getActionNameFromElement';
export { STABLE_ATTRIBUTES } from './domain/action/getSelectorFromElement';
export * from './browser/htmlDomUtils';
export { getSessionReplayUrl } from './domain/getSessionReplayUrl';
//# sourceMappingURL=index.js.map

@@ -1037,3 +1037,3 @@ /**

*/
readonly session_replay_sample_rate: number;
readonly session_replay_sample_rate?: number;
[k: string]: unknown;

@@ -1040,0 +1040,0 @@ };

@@ -8,2 +8,3 @@ import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent } from '@datadog/browser-core';

upsert: (message: Context, key: string) => void;
stop: () => void;
};
{
"name": "@datadog/browser-rum-core",
"version": "4.48.2",
"version": "4.49.0",
"license": "Apache-2.0",

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

"dependencies": {
"@datadog/browser-core": "4.48.2"
"@datadog/browser-core": "4.49.0"
},

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

},
"gitHead": "da0c864639fd36358540f38342787b9967638ed4"
"gitHead": "4aa09a00c7457f4d4f302b15bc1c1bb645072016"
}

@@ -21,2 +21,4 @@ import type { Context, InitConfiguration, TimeStamp, RelativeTime, User, Observable } from '@datadog/browser-core'

sanitize,
createStoredContextManager,
combine,
} from '@datadog/browser-core'

@@ -30,3 +32,3 @@ import type { LifeCycle } from '../domain/lifeCycle'

import { validateAndBuildRumConfiguration } from '../domain/configuration'
import type { ViewOptions } from '../domain/rumEventsCollection/view/trackViews'
import type { ViewOptions } from '../domain/view/trackViews'
import { buildCommonContext } from '../domain/contexts/commonContext'

@@ -64,2 +66,4 @@ import type { startRum } from './startRum'

const RUM_STORAGE_KEY = 'rum'
export function makeRumPublicApi(

@@ -72,4 +76,4 @@ startRumImpl: StartRum,

const globalContextManager = createContextManager(CustomerDataType.GlobalContext)
const userContextManager = createContextManager(CustomerDataType.User)
let globalContextManager = createContextManager(CustomerDataType.GlobalContext)
let userContextManager = createContextManager(CustomerDataType.User)

@@ -106,2 +110,6 @@ let getInternalContextStrategy: StartRumResult['getInternalContext'] = () => undefined

function initRum(initConfiguration: RumInitConfiguration) {
if (!initConfiguration) {
display.error('Missing configuration')
return
}
// This function should be available, regardless of initialization success.

@@ -160,2 +168,12 @@ getInitConfigurationStrategy = () => deepClone<InitConfiguration>(initConfiguration)

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

@@ -202,18 +220,18 @@ initConfiguration,

/** @deprecated: use setGlobalContextProperty instead */
addRumGlobalContext: monitor(globalContextManager.add),
setGlobalContextProperty: monitor(globalContextManager.setContextProperty),
addRumGlobalContext: monitor((key, value) => globalContextManager.add(key, value)),
setGlobalContextProperty: monitor((key, value) => globalContextManager.setContextProperty(key, value)),
/** @deprecated: use removeGlobalContextProperty instead */
removeRumGlobalContext: monitor(globalContextManager.remove),
removeGlobalContextProperty: monitor(globalContextManager.removeContextProperty),
removeRumGlobalContext: monitor((key) => globalContextManager.remove(key)),
removeGlobalContextProperty: monitor((key) => globalContextManager.removeContextProperty(key)),
/** @deprecated: use getGlobalContext instead */
getRumGlobalContext: monitor(globalContextManager.get),
getGlobalContext: monitor(globalContextManager.getContext),
getRumGlobalContext: monitor(() => globalContextManager.get()),
getGlobalContext: monitor(() => globalContextManager.getContext()),
/** @deprecated: use setGlobalContext instead */
setRumGlobalContext: monitor(globalContextManager.set),
setGlobalContext: monitor(globalContextManager.setContext),
setRumGlobalContext: monitor((context) => globalContextManager.set(context)),
setGlobalContext: monitor((context) => globalContextManager.setContext(context)),
clearGlobalContext: monitor(globalContextManager.clearContext),
clearGlobalContext: monitor(() => globalContextManager.clearContext()),

@@ -254,3 +272,3 @@ getInternalContext: monitor((startTime?: number) => getInternalContextStrategy(startTime)),

getUser: monitor(userContextManager.getContext),
getUser: monitor(() => userContextManager.getContext()),

@@ -262,7 +280,7 @@ setUserProperty: monitor((key, property) => {

removeUserProperty: monitor(userContextManager.removeContextProperty),
removeUserProperty: monitor((key) => userContextManager.removeContextProperty(key)),
/** @deprecated: renamed to clearUser */
removeUser: monitor(userContextManager.clearContext),
clearUser: monitor(userContextManager.clearContext),
removeUser: monitor(() => userContextManager.clearContext()),
clearUser: monitor(() => userContextManager.clearContext()),

@@ -269,0 +287,0 @@ startView,

@@ -19,7 +19,7 @@ import type { Observable, TelemetryEvent, RawError, ContextManager } from '@datadog/browser-core'

import { startRequestCollection } from '../domain/requestCollection'
import { startActionCollection } from '../domain/rumEventsCollection/action/actionCollection'
import { startErrorCollection } from '../domain/rumEventsCollection/error/errorCollection'
import { startLongTaskCollection } from '../domain/rumEventsCollection/longTask/longTaskCollection'
import { startResourceCollection } from '../domain/rumEventsCollection/resource/resourceCollection'
import { startViewCollection } from '../domain/rumEventsCollection/view/viewCollection'
import { startActionCollection } from '../domain/action/actionCollection'
import { startErrorCollection } from '../domain/error/errorCollection'
import { startLongTaskCollection } from '../domain/longTask/longTaskCollection'
import { startResourceCollection } from '../domain/resource/resourceCollection'
import { startViewCollection } from '../domain/view/viewCollection'
import type { RumSessionManager } from '../domain/rumSessionManager'

@@ -34,3 +34,3 @@ import { startRumSessionManager, startRumSessionManagerStub } from '../domain/rumSessionManager'

import { serializeRumConfiguration } from '../domain/configuration'
import type { ViewOptions } from '../domain/rumEventsCollection/view/trackViews'
import type { ViewOptions } from '../domain/view/trackViews'
import { startFeatureFlagContexts } from '../domain/contexts/featureFlagContext'

@@ -41,3 +41,4 @@ import { startCustomerDataTelemetry } from '../domain/startCustomerDataTelemetry'

import { buildCommonContext } from '../domain/contexts/commonContext'
import { startWebVitalTelemetryDebug } from '../domain/rumEventsCollection/view/startWebVitalTelemetryDebug'
import { startWebVitalTelemetryDebug } from '../domain/view/startWebVitalTelemetryDebug'
import { startDisplayContext } from '../domain/contexts/displayContext'
import type { RecorderApi } from './rumPublicApi'

@@ -53,2 +54,3 @@

) {
const cleanupTasks: Array<() => void> = []
const lifeCycle = new LifeCycle()

@@ -81,5 +83,6 @@

const pageExitObservable = createPageExitObservable(configuration)
pageExitObservable.subscribe((event) => {
const pageExitSubscription = pageExitObservable.subscribe((event) => {
lifeCycle.notify(LifeCycleEventType.PAGE_EXITED, event)
})
cleanupTasks.push(() => pageExitSubscription.unsubscribe())

@@ -96,2 +99,3 @@ const session = !canUseEventBridge() ? startRumSessionManager(configuration, lifeCycle) : startRumSessionManagerStub()

)
cleanupTasks.push(() => batch.stop())
startCustomerDataTelemetry(

@@ -113,3 +117,10 @@ configuration,

const { viewContexts, pageStateHistory, urlContexts, actionContexts, addAction } = startRumEventCollection(
const {
viewContexts,
pageStateHistory,
urlContexts,
actionContexts,
addAction,
stop: stopRumEventCollection,
} = startRumEventCollection(
lifeCycle,

@@ -124,2 +135,3 @@ configuration,

)
cleanupTasks.push(stopRumEventCollection)

@@ -132,3 +144,7 @@ addTelemetryConfiguration(serializeRumConfiguration(initConfiguration))

const webVitalTelemetryDebug = startWebVitalTelemetryDebug(configuration, telemetry, recorderApi, session)
const { addTiming, startView } = startViewCollection(
const {
addTiming,
startView,
stop: stopViewCollection,
} = startViewCollection(
lifeCycle,

@@ -145,2 +161,4 @@ configuration,

)
cleanupTasks.push(stopViewCollection)
const { addError } = startErrorCollection(lifeCycle, configuration, pageStateHistory, featureFlagContexts)

@@ -170,2 +188,5 @@

getInternalContext: internalContext.get,
stop: () => {
cleanupTasks.forEach((task) => task())
},
}

@@ -205,2 +226,4 @@ }

const displayContext = startDisplayContext(configuration)
startRumAssembly(

@@ -213,2 +236,3 @@ configuration,

actionContexts,
displayContext,
buildCommonContext,

@@ -225,2 +249,5 @@ reportError

stop: () => {
displayContext.stop()
pageStateHistory.stop()
urlContexts.stop()
viewContexts.stop()

@@ -227,0 +254,0 @@ pageStateHistory.stop()

@@ -19,3 +19,3 @@ import type { Duration, RelativeTime, TimeStamp } from '@datadog/browser-core'

import { LifeCycleEventType } from '../domain/lifeCycle'
import { FAKE_INITIAL_DOCUMENT, isAllowedRequestUrl } from '../domain/rumEventsCollection/resource/resourceUtils'
import { FAKE_INITIAL_DOCUMENT, isAllowedRequestUrl } from '../domain/resource/resourceUtils'

@@ -22,0 +22,0 @@ import { getDocumentTraceId } from '../domain/tracing/getDocumentTraceId'

@@ -31,4 +31,4 @@ import type { Context, RawError, EventRateLimiter, User } from '@datadog/browser-core'

import type { RumConfiguration } from './configuration'
import type { ActionContexts } from './rumEventsCollection/action/actionCollection'
import { getDisplayContext } from './contexts/displayContext'
import type { ActionContexts } from './action/actionCollection'
import type { DisplayContext } from './contexts/displayContext'
import type { CommonContext } from './contexts/commonContext'

@@ -48,2 +48,3 @@ import type { ModifiableFieldPaths } from './limitModification'

const VIEW_MODIFIABLE_FIELD_PATHS: ModifiableFieldPaths = {
'view.name': 'string',
'view.url': 'string',

@@ -68,2 +69,3 @@ 'view.referrer': 'string',

actionContexts: ActionContexts,
displayContext: DisplayContext,
buildCommonContext: () => CommonContext,

@@ -159,3 +161,3 @@ reportError: (error: RawError) => void

ci_test: ciTestContext,
display: getDisplayContext(configuration),
display: displayContext.get(),
}

@@ -162,0 +164,0 @@

import type { RumConfiguration } from '../configuration'
import { getViewportDimension, initViewportObservable } from '../../browser/viewportObservable'
let viewport: { width: number; height: number } | undefined
let stopListeners: (() => void) | undefined
export type DisplayContext = ReturnType<typeof startDisplayContext>
export function getDisplayContext(configuration: RumConfiguration) {
if (!viewport) {
viewport = getViewportDimension()
stopListeners = initViewportObservable(configuration).subscribe((viewportDimension) => {
viewport = viewportDimension
}).unsubscribe
}
export function startDisplayContext(configuration: RumConfiguration) {
let viewport = getViewportDimension()
const unsubscribeViewport = initViewportObservable(configuration).subscribe((viewportDimension) => {
viewport = viewportDimension
}).unsubscribe
return {
viewport,
get: () => ({ viewport }),
stop: unsubscribeViewport,
}
}
export function resetDisplayContext() {
if (stopListeners) {
stopListeners()
}
viewport = undefined
}
import type { RelativeTime } from '@datadog/browser-core'
import type { ActionContexts } from '../rumEventsCollection/action/actionCollection'
import type { ActionContexts } from '../action/actionCollection'
import type { RumSessionManager } from '../rumSessionManager'

@@ -4,0 +4,0 @@ import type { ViewContexts } from './viewContexts'

@@ -117,3 +117,3 @@ import type { Duration, RelativeTime } from '@datadog/browser-core'

function computePageState(event: Event) {
function computePageState(event: Event & { type: DOM_EVENT }) {
if (event.type === DOM_EVENT.FREEZE) {

@@ -120,0 +120,0 @@ return PageState.FROZEN

@@ -5,3 +5,3 @@ import type { RelativeTime, ClocksState } from '@datadog/browser-core'

import { LifeCycleEventType } from '../lifeCycle'
import type { ViewCreatedEvent } from '../rumEventsCollection/view/trackViews'
import type { ViewCreatedEvent } from '../view/trackViews'

@@ -8,0 +8,0 @@ export const VIEW_CONTEXT_TIME_OUT_DELAY = SESSION_TIME_OUT_DELAY

@@ -9,4 +9,4 @@ import type { Context, PageExitEvent, RawError, RelativeTime } from '@datadog/browser-core'

import type { RequestCompleteEvent, RequestStartEvent } from './requestCollection'
import type { AutoAction } from './rumEventsCollection/action/actionCollection'
import type { ViewEvent, ViewCreatedEvent, ViewEndedEvent } from './rumEventsCollection/view/trackViews'
import type { AutoAction } from './action/actionCollection'
import type { ViewEvent, ViewCreatedEvent, ViewEndedEvent } from './view/trackViews'

@@ -13,0 +13,0 @@ export const enum LifeCycleEventType {

@@ -22,3 +22,3 @@ import type {

import { LifeCycleEventType } from './lifeCycle'
import { isAllowedRequestUrl } from './rumEventsCollection/resource/resourceUtils'
import { isAllowedRequestUrl } from './resource/resourceUtils'
import type { TraceIdentifier, Tracer } from './tracing/tracer'

@@ -25,0 +25,0 @@ import { startTracer } from './tracing/tracer'

@@ -53,4 +53,6 @@ import { noop } from '@datadog/browser-core'

case RumEventType.RESOURCE:
eventCounts.resourceCount += 1
callback()
if (!event._dd?.discarded) {
eventCounts.resourceCount += 1
callback()
}
break

@@ -57,0 +59,0 @@ }

@@ -24,3 +24,3 @@ export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi'

export { LifeCycle, LifeCycleEventType } from './domain/lifeCycle'
export { ViewCreatedEvent } from './domain/rumEventsCollection/view/trackViews'
export { ViewCreatedEvent } from './domain/view/trackViews'
export { ViewContexts, ViewContext } from './domain/contexts/viewContexts'

@@ -32,5 +32,5 @@ export { RumSessionManager, RumSessionPlan, RumSession } from './domain/rumSessionManager'

export { RumInitConfiguration, RumConfiguration } from './domain/configuration'
export { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './domain/rumEventsCollection/action/getActionNameFromElement'
export { STABLE_ATTRIBUTES } from './domain/rumEventsCollection/action/getSelectorFromElement'
export { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './domain/action/getActionNameFromElement'
export { STABLE_ATTRIBUTES } from './domain/action/getSelectorFromElement'
export * from './browser/htmlDomUtils'
export { getSessionReplayUrl } from './domain/getSessionReplayUrl'

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

*/
readonly session_replay_sample_rate: number
readonly session_replay_sample_rate?: number
[k: string]: unknown

@@ -1108,0 +1108,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

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

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

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