Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
183
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.46.0 to 4.47.0

8

cjs/boot/startRum.js

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

var featureFlagContexts = (0, featureFlagContext_1.startFeatureFlagContexts)(lifeCycle);
var pageExitObservable = (0, browser_core_1.createPageExitObservable)();
var pageExitObservable = (0, browser_core_1.createPageExitObservable)(configuration);
pageExitObservable.subscribe(function (event) {

@@ -68,3 +68,3 @@ lifeCycle.notify(9 /* LifeCycleEventType.PAGE_EXITED */, event);

var domMutationObservable = (0, domMutationObservable_1.createDOMMutationObservable)();
var locationChangeObservable = (0, locationChangeObservable_1.createLocationChangeObservable)(location);
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;

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

var _b = (0, viewCollection_1.startViewCollection)(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, webVitalTelemetryDebug, initialViewOptions), addTiming = _b.addTiming, startView = _b.startView;
var addError = (0, errorCollection_1.startErrorCollection)(lifeCycle, pageStateHistory, featureFlagContexts).addError;
var addError = (0, errorCollection_1.startErrorCollection)(lifeCycle, configuration, pageStateHistory, featureFlagContexts).addError;
(0, requestCollection_1.startRequestCollection)(lifeCycle, configuration, session);

@@ -106,3 +106,3 @@ (0, performanceCollection_1.startPerformanceCollection)(lifeCycle, configuration);

var urlContexts = (0, urlContexts_1.startUrlContexts)(lifeCycle, locationChangeObservable, location);
var pageStateHistory = (0, pageStateHistory_1.startPageStateHistory)();
var pageStateHistory = (0, pageStateHistory_1.startPageStateHistory)(configuration);
var _a = (0, actionCollection_1.startActionCollection)(lifeCycle, domMutationObservable, configuration, pageStateHistory), addAction = _a.addAction, actionContexts = _a.actionContexts;

@@ -109,0 +109,0 @@ (0, assembly_1.startRumAssembly)(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, buildCommonContext, reportError);

import { Observable } from '@datadog/browser-core';
import type { RumConfiguration } from '../domain/configuration';
export interface LocationChange {

@@ -6,2 +7,2 @@ oldLocation: Readonly<Location>;

}
export declare function createLocationChangeObservable(location: Location): Observable<LocationChange>;
export declare function createLocationChangeObservable(configuration: RumConfiguration, location: Location): Observable<LocationChange>;

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

var browser_core_1 = require("@datadog/browser-core");
function createLocationChangeObservable(location) {
function createLocationChangeObservable(configuration, location) {
var currentLocation = (0, browser_core_1.shallowClone)(location);
var observable = new browser_core_1.Observable(function () {
var stopHistoryTracking = trackHistory(onLocationChange).stop;
var stopHashTracking = trackHash(onLocationChange).stop;
var stopHistoryTracking = trackHistory(configuration, onLocationChange).stop;
var stopHashTracking = trackHash(configuration, onLocationChange).stop;
return function () {

@@ -30,3 +30,3 @@ stopHistoryTracking();

exports.createLocationChangeObservable = createLocationChangeObservable;
function trackHistory(onHistoryChange) {
function trackHistory(configuration, onHistoryChange) {
var stopInstrumentingPushState = (0, browser_core_1.instrumentMethodAndCallOriginal)(history, 'pushState', {

@@ -38,3 +38,3 @@ after: onHistoryChange,

}).stop;
var removeListener = (0, browser_core_1.addEventListener)(window, "popstate" /* DOM_EVENT.POP_STATE */, onHistoryChange).stop;
var removeListener = (0, browser_core_1.addEventListener)(configuration, window, "popstate" /* DOM_EVENT.POP_STATE */, onHistoryChange).stop;
return {

@@ -48,5 +48,5 @@ stop: function () {

}
function trackHash(onHashChange) {
return (0, browser_core_1.addEventListener)(window, "hashchange" /* DOM_EVENT.HASH_CHANGE */, onHashChange);
function trackHash(configuration, onHashChange) {
return (0, browser_core_1.addEventListener)(configuration, window, "hashchange" /* DOM_EVENT.HASH_CHANGE */, onHashChange);
}
//# sourceMappingURL=locationChangeObservable.js.map

@@ -68,5 +68,5 @@ import type { Duration, RelativeTime } from '@datadog/browser-core';

export declare function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration): void;
export declare function retrieveInitialDocumentResourceTiming(callback: (timing: RumPerformanceResourceTiming) => void): void;
export declare function retrieveInitialDocumentResourceTiming(configuration: RumConfiguration, callback: (timing: RumPerformanceResourceTiming) => void): void;
export type RelativePerformanceTiming = {
-readonly [key in keyof Omit<PerformanceTiming, 'toJSON'>]: RelativeTime;
};

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

function startPerformanceCollection(lifeCycle, configuration) {
retrieveInitialDocumentResourceTiming(function (timing) {
retrieveInitialDocumentResourceTiming(configuration, function (timing) {
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);

@@ -51,3 +51,3 @@ });

// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
(0, browser_core_1.addEventListener)(performance, 'resourcetimingbufferfull', function () {
(0, browser_core_1.addEventListener)(configuration, performance, 'resourcetimingbufferfull', function () {
performance.clearResourceTimings();

@@ -58,3 +58,3 @@ });

if (!supportPerformanceTimingEvent('navigation')) {
retrieveNavigationTiming(function (timing) {
retrieveNavigationTiming(configuration, function (timing) {
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);

@@ -64,3 +64,3 @@ });

if (!supportPerformanceTimingEvent('first-input')) {
retrieveFirstInputTiming(function (timing) {
retrieveFirstInputTiming(configuration, function (timing) {
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);

@@ -71,4 +71,4 @@ });

exports.startPerformanceCollection = startPerformanceCollection;
function retrieveInitialDocumentResourceTiming(callback) {
(0, browser_core_1.runOnReadyState)('interactive', function () {
function retrieveInitialDocumentResourceTiming(configuration, callback) {
(0, browser_core_1.runOnReadyState)(configuration, 'interactive', function () {
var timing;

@@ -97,3 +97,3 @@ var forcedAttributes = {

exports.retrieveInitialDocumentResourceTiming = retrieveInitialDocumentResourceTiming;
function retrieveNavigationTiming(callback) {
function retrieveNavigationTiming(configuration, callback) {
function sendFakeTiming() {

@@ -104,3 +104,3 @@ callback((0, browser_core_1.assign)(computeRelativePerformanceTiming(), {

}
(0, browser_core_1.runOnReadyState)('complete', function () {
(0, browser_core_1.runOnReadyState)(configuration, 'complete', function () {
// Send it a bit after the actual load event, so the "loadEventEnd" timing is accurate

@@ -114,6 +114,6 @@ (0, browser_core_1.setTimeout)(sendFakeTiming);

*/
function retrieveFirstInputTiming(callback) {
function retrieveFirstInputTiming(configuration, callback) {
var startTimeStamp = (0, browser_core_1.dateNow)();
var timingSent = false;
var removeEventListeners = (0, browser_core_1.addEventListeners)(window, ["click" /* DOM_EVENT.CLICK */, "mousedown" /* DOM_EVENT.MOUSE_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */, "touchstart" /* DOM_EVENT.TOUCH_START */, "pointerdown" /* DOM_EVENT.POINTER_DOWN */], function (evt) {
var removeEventListeners = (0, browser_core_1.addEventListeners)(configuration, window, ["click" /* DOM_EVENT.CLICK */, "mousedown" /* DOM_EVENT.MOUSE_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */, "touchstart" /* DOM_EVENT.TOUCH_START */, "pointerdown" /* DOM_EVENT.POINTER_DOWN */], function (evt) {
// Only count cancelable events, which should trigger behavior important to the user.

@@ -132,3 +132,3 @@ if (!evt.cancelable) {

if (evt.type === "pointerdown" /* DOM_EVENT.POINTER_DOWN */) {
sendTimingIfPointerIsNotCancelled(timing);
sendTimingIfPointerIsNotCancelled(configuration, timing);
}

@@ -145,4 +145,4 @@ else {

*/
function sendTimingIfPointerIsNotCancelled(timing) {
(0, browser_core_1.addEventListeners)(window, ["pointerup" /* DOM_EVENT.POINTER_UP */, "pointercancel" /* DOM_EVENT.POINTER_CANCEL */], function (event) {
function sendTimingIfPointerIsNotCancelled(configuration, timing) {
(0, browser_core_1.addEventListeners)(configuration, window, ["pointerup" /* DOM_EVENT.POINTER_UP */, "pointercancel" /* DOM_EVENT.POINTER_CANCEL */], function (event) {
if (event.type === "pointerup" /* DOM_EVENT.POINTER_UP */) {

@@ -149,0 +149,0 @@ sendTiming(timing);

import { Observable } from '@datadog/browser-core';
import type { RumConfiguration } from '../domain/configuration';
export interface ViewportDimension {

@@ -6,4 +7,4 @@ height: number;

}
export declare function initViewportObservable(): Observable<ViewportDimension>;
export declare function createViewportObservable(): Observable<ViewportDimension>;
export declare function initViewportObservable(configuration: RumConfiguration): Observable<ViewportDimension>;
export declare function createViewportObservable(configuration: RumConfiguration): Observable<ViewportDimension>;
export declare function getViewportDimension(): ViewportDimension;

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

var viewportObservable;
function initViewportObservable() {
function initViewportObservable(configuration) {
if (!viewportObservable) {
viewportObservable = createViewportObservable();
viewportObservable = createViewportObservable(configuration);
}

@@ -14,3 +14,3 @@ return viewportObservable;

exports.initViewportObservable = initViewportObservable;
function createViewportObservable() {
function createViewportObservable(configuration) {
var observable = new browser_core_1.Observable(function () {

@@ -20,3 +20,4 @@ var updateDimension = (0, browser_core_1.throttle)(function () {

}, 200).throttled;
return (0, browser_core_1.addEventListener)(window, "resize" /* DOM_EVENT.RESIZE */, updateDimension, { capture: true, passive: true }).stop;
return (0, browser_core_1.addEventListener)(configuration, window, "resize" /* DOM_EVENT.RESIZE */, updateDimension, { capture: true, passive: true })
.stop;
});

@@ -23,0 +24,0 @@ return observable;

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

},
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.46.0" : undefined,
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.47.0" : undefined,
},

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

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

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

@@ -14,2 +14,3 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core';

excludedActivityUrls?: MatchOption[] | undefined;
workerUrl?: string;
/**

@@ -49,2 +50,3 @@ * @deprecated use allowedTracingUrls instead

excludedActivityUrls: MatchOption[];
workerUrl: string | undefined;
applicationId: string;

@@ -51,0 +53,0 @@ defaultPrivacyLevel: DefaultPrivacyLevel;

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

excludedActivityUrls: (_f = initConfiguration.excludedActivityUrls) !== null && _f !== void 0 ? _f : [],
workerUrl: initConfiguration.workerUrl,
trackUserInteractions: trackUserInteractions || trackFrustrations,

@@ -180,2 +181,3 @@ trackFrustrations: trackFrustrations,

use_excluded_activity_urls: Array.isArray(configuration.excludedActivityUrls) && configuration.excludedActivityUrls.length > 0,
use_worker_url: !!configuration.workerUrl,
track_frustrations: configuration.trackFrustrations,

@@ -182,0 +184,0 @@ track_views_manually: configuration.trackViewsManually,

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

export declare function getDisplayContext(): {
import type { RumConfiguration } from '../configuration';
export declare function getDisplayContext(configuration: RumConfiguration): {
viewport: {

@@ -3,0 +4,0 @@ width: number;

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

var stopListeners;
function getDisplayContext() {
function getDisplayContext(configuration) {
if (!viewport) {
viewport = (0, viewportObservable_1.getViewportDimension)();
stopListeners = (0, viewportObservable_1.initViewportObservable)().subscribe(function (viewportDimension) {
stopListeners = (0, viewportObservable_1.initViewportObservable)(configuration).subscribe(function (viewportDimension) {
viewport = viewportDimension;

@@ -13,0 +13,0 @@ }).unsubscribe;

import type { Duration, RelativeTime } from '@datadog/browser-core';
import type { RumConfiguration } from '../configuration';
import type { PageStateServerEntry } from '../../rawRumEvent.types';

@@ -23,2 +24,2 @@ export declare const MAX_PAGE_STATE_ENTRIES = 4000;

}
export declare function startPageStateHistory(maxPageStateEntriesSelectable?: number): PageStateHistory;
export declare function startPageStateHistory(configuration: RumConfiguration, maxPageStateEntriesSelectable?: number): PageStateHistory;

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

exports.PAGE_STATE_CONTEXT_TIME_OUT_DELAY = browser_core_1.SESSION_TIME_OUT_DELAY;
function startPageStateHistory(maxPageStateEntriesSelectable) {
function startPageStateHistory(configuration, maxPageStateEntriesSelectable) {
if (maxPageStateEntriesSelectable === void 0) { maxPageStateEntriesSelectable = exports.MAX_PAGE_STATE_ENTRIES_SELECTABLE; }

@@ -16,3 +16,3 @@ var pageStateHistory = new browser_core_1.ValueHistory(exports.PAGE_STATE_CONTEXT_TIME_OUT_DELAY, exports.MAX_PAGE_STATE_ENTRIES);

addPageState(getPageState(), (0, browser_core_1.relativeNow)());
var stopEventListeners = (0, browser_core_1.addEventListeners)(window, [
var stopEventListeners = (0, browser_core_1.addEventListeners)(configuration, window, [
"pageshow" /* DOM_EVENT.PAGE_SHOW */,

@@ -19,0 +19,0 @@ "focus" /* DOM_EVENT.FOCUS */,

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

function trackXhr(lifeCycle, configuration, tracer) {
var subscription = (0, browser_core_1.initXhrObservable)().subscribe(function (rawContext) {
var subscription = (0, browser_core_1.initXhrObservable)(configuration).subscribe(function (rawContext) {
var context = rawContext;

@@ -18,0 +18,0 @@ if (!(0, resourceUtils_1.isAllowedRequestUrl)(configuration, context.url)) {

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

}
return "".concat(element.tagName, ".").concat((0, browser_core_1.cssEscape)(className));
return "".concat((0, browser_core_1.cssEscape)(element.tagName), ".").concat((0, browser_core_1.cssEscape)(className));
}

@@ -86,3 +86,3 @@ }

function getTagNameSelector(element) {
return element.tagName;
return (0, browser_core_1.cssEscape)(element.tagName);
}

@@ -105,3 +105,3 @@ function getStableAttributeSelector(element, actionNameAttribute) {

if (element.hasAttribute(attributeName)) {
return "".concat(element.tagName, "[").concat(attributeName, "=\"").concat((0, browser_core_1.cssEscape)(element.getAttribute(attributeName)), "\"]");
return "".concat((0, browser_core_1.cssEscape)(element.tagName), "[").concat(attributeName, "=\"").concat((0, browser_core_1.cssEscape)(element.getAttribute(attributeName)), "\"]");
}

@@ -119,3 +119,3 @@ }

}
return "".concat(element.tagName, ":nth-of-type(").concat(elementIndex, ")");
return "".concat((0, browser_core_1.cssEscape)(element.tagName), ":nth-of-type(").concat(elementIndex, ")");
}

@@ -122,0 +122,0 @@ function findSelector(element, selectorGetters, predicate, actionNameAttribute, childSelector) {

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

import type { RumConfiguration } from '../../configuration';
export type MouseEventOnElement = PointerEvent & {

@@ -12,4 +13,4 @@ target: Element;

}
export declare function listenActionEvents<ClickContext>({ onPointerDown, onPointerUp }: ActionEventsHooks<ClickContext>): {
export declare function listenActionEvents<ClickContext>(configuration: RumConfiguration, { onPointerDown, onPointerUp }: ActionEventsHooks<ClickContext>): {
stop: () => void;
};

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

var browser_core_1 = require("@datadog/browser-core");
function listenActionEvents(_a) {
function listenActionEvents(configuration, _a) {
var onPointerDown = _a.onPointerDown, onPointerUp = _a.onPointerUp;

@@ -15,3 +15,3 @@ var selectionEmptyAtPointerDown;

var listeners = [
(0, browser_core_1.addEventListener)(window, "pointerdown" /* DOM_EVENT.POINTER_DOWN */, function (event) {
(0, browser_core_1.addEventListener)(configuration, window, "pointerdown" /* DOM_EVENT.POINTER_DOWN */, function (event) {
if (isValidPointerEvent(event)) {

@@ -26,3 +26,3 @@ selectionEmptyAtPointerDown = isSelectionEmpty();

}, { capture: true }),
(0, browser_core_1.addEventListener)(window, "selectionchange" /* DOM_EVENT.SELECTION_CHANGE */, function () {
(0, browser_core_1.addEventListener)(configuration, window, "selectionchange" /* DOM_EVENT.SELECTION_CHANGE */, function () {
if (!selectionEmptyAtPointerDown || !isSelectionEmpty()) {

@@ -32,3 +32,3 @@ userActivity.selection = true;

}, { capture: true }),
(0, browser_core_1.addEventListener)(window, "pointerup" /* DOM_EVENT.POINTER_UP */, function (event) {
(0, browser_core_1.addEventListener)(configuration, window, "pointerup" /* DOM_EVENT.POINTER_UP */, function (event) {
if (isValidPointerEvent(event) && clickContext) {

@@ -41,3 +41,3 @@ // Use a scoped variable to make sure the value is not changed by other clicks

}, { capture: true }),
(0, browser_core_1.addEventListener)(window, "input" /* DOM_EVENT.INPUT */, function () {
(0, browser_core_1.addEventListener)(configuration, window, "input" /* DOM_EVENT.INPUT */, function () {
userActivity.input = true;

@@ -44,0 +44,0 @@ }, { capture: true }),

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

lifeCycle.subscribe(4 /* LifeCycleEventType.VIEW_ENDED */, stopClickChain);
var stopActionEventsListener = (0, listenActionEvents_1.listenActionEvents)({
var stopActionEventsListener = (0, listenActionEvents_1.listenActionEvents)(configuration, {
onPointerDown: function (pointerDownEvent) {

@@ -26,0 +26,0 @@ return processPointerDown(configuration, lifeCycle, domMutationObservable, history, pointerDownEvent);

import type { Context, ClocksState } from '@datadog/browser-core';
import type { RumConfiguration } from '../../configuration';
import type { LifeCycle } from '../../lifeCycle';

@@ -12,3 +13,3 @@ import type { FeatureFlagContexts } from '../../contexts/featureFlagContext';

}
export declare function startErrorCollection(lifeCycle: LifeCycle, pageStateHistory: PageStateHistory, featureFlagContexts: FeatureFlagContexts): {
export declare function startErrorCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, pageStateHistory: PageStateHistory, featureFlagContexts: FeatureFlagContexts): {
addError: ({ error, handlingStack, startClocks, context: customerContext }: ProvidedError, savedCommonContext?: CommonContext | undefined) => void;

@@ -15,0 +16,0 @@ };

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

var trackReportError_1 = require("./trackReportError");
function startErrorCollection(lifeCycle, pageStateHistory, featureFlagContexts) {
function startErrorCollection(lifeCycle, configuration, pageStateHistory, featureFlagContexts) {
var errorObservable = new browser_core_1.Observable();
(0, trackConsoleError_1.trackConsoleError)(errorObservable);
(0, browser_core_1.trackRuntimeError)(errorObservable);
(0, trackReportError_1.trackReportError)(errorObservable);
(0, trackReportError_1.trackReportError)(configuration, errorObservable);
errorObservable.subscribe(function (error) { return lifeCycle.notify(12 /* LifeCycleEventType.RAW_ERROR_COLLECTED */, { error: error }); });

@@ -14,0 +14,0 @@ return doStartErrorCollection(lifeCycle, pageStateHistory, featureFlagContexts);

import type { Observable, RawError } from '@datadog/browser-core';
export declare function trackReportError(errorObservable: Observable<RawError>): {
import type { RumConfiguration } from '../../configuration';
export declare function trackReportError(configuration: RumConfiguration, errorObservable: Observable<RawError>): {
stop: () => void;
};

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

var browser_core_1 = require("@datadog/browser-core");
function trackReportError(errorObservable) {
var subscription = (0, browser_core_1.initReportObservable)([browser_core_1.RawReportType.cspViolation, browser_core_1.RawReportType.intervention]).subscribe(function (reportError) {
function trackReportError(configuration, errorObservable) {
var subscription = (0, browser_core_1.initReportObservable)(configuration, [
browser_core_1.RawReportType.cspViolation,
browser_core_1.RawReportType.intervention,
]).subscribe(function (reportError) {
return errorObservable.notify({

@@ -9,0 +12,0 @@ startClocks: (0, browser_core_1.clocksNow)(),

import type { RelativeTime } from '@datadog/browser-core';
export declare function trackFirstHidden(eventTarget?: Window): {
import type { RumConfiguration } from '../../configuration';
export declare function trackFirstHidden(configuration: RumConfiguration, eventTarget?: Window): {
timeStamp: RelativeTime;
};
export declare function resetFirstHidden(): void;

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

var stopListeners;
function trackFirstHidden(eventTarget) {
function trackFirstHidden(configuration, eventTarget) {
if (eventTarget === void 0) { eventTarget = window; }

@@ -20,3 +20,3 @@ if (!trackFirstHiddenSingleton) {

};
(stopListeners = (0, browser_core_1.addEventListeners)(eventTarget, ["pagehide" /* DOM_EVENT.PAGE_HIDE */, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */], function (event) {
(stopListeners = (0, browser_core_1.addEventListeners)(configuration, eventTarget, ["pagehide" /* DOM_EVENT.PAGE_HIDE */, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */], function (event) {
if (event.type === 'pagehide' || document.visibilityState === 'hidden') {

@@ -23,0 +23,0 @@ trackFirstHiddenSingleton.timeStamp = event.timeStamp;

import type { Duration, RelativeTime } from '@datadog/browser-core';
import type { RumConfiguration } from '../../configuration';
import type { LifeCycle } from '../../lifeCycle';

@@ -23,3 +24,3 @@ import type { WebVitalTelemetryDebug } from './startWebVitalTelemetryDebug';

}
export declare function trackInitialViewTimings(lifeCycle: LifeCycle, webVitalTelemetryDebug: WebVitalTelemetryDebug, setLoadEvent: (loadEnd: Duration) => void, scheduleViewUpdate: () => void): {
export declare function trackInitialViewTimings(lifeCycle: LifeCycle, configuration: RumConfiguration, webVitalTelemetryDebug: WebVitalTelemetryDebug, setLoadEvent: (loadEnd: Duration) => void, scheduleViewUpdate: () => void): {
stop: () => void;

@@ -39,3 +40,3 @@ timings: Timings;

};
export declare function trackFirstContentfulPaintTiming(lifeCycle: LifeCycle, callback: (fcpTiming: RelativeTime) => void): {
export declare function trackFirstContentfulPaintTiming(lifeCycle: LifeCycle, configuration: RumConfiguration, callback: (fcpTiming: RelativeTime) => void): {
stop: () => void;

@@ -49,3 +50,3 @@ };

*/
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, eventTarget: Window, callback: (lcpTiming: RelativeTime, lcpElement?: Element) => void): {
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, configuration: RumConfiguration, eventTarget: Window, callback: (lcpTiming: RelativeTime, lcpElement?: Element) => void): {
stop: () => void;

@@ -61,3 +62,3 @@ };

*/
export declare function trackFirstInputTimings(lifeCycle: LifeCycle, callback: ({ firstInputDelay, firstInputTime, firstInputTarget, }: {
export declare function trackFirstInputTimings(lifeCycle: LifeCycle, configuration: RumConfiguration, callback: ({ firstInputDelay, firstInputTime, firstInputTarget, }: {
firstInputDelay: Duration;

@@ -64,0 +65,0 @@ firstInputTime: RelativeTime;

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

exports.KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY = 5 * browser_core_1.ONE_MINUTE;
function trackInitialViewTimings(lifeCycle, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) {
function trackInitialViewTimings(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) {
var timings = {};

@@ -27,6 +27,6 @@ function setTimings(newTimings) {

}).stop;
var stopFCPTracking = trackFirstContentfulPaintTiming(lifeCycle, function (firstContentfulPaint) {
var stopFCPTracking = trackFirstContentfulPaintTiming(lifeCycle, configuration, function (firstContentfulPaint) {
return setTimings({ firstContentfulPaint: firstContentfulPaint });
}).stop;
var stopLCPTracking = trackLargestContentfulPaintTiming(lifeCycle, window, function (largestContentfulPaint, lcpElement) {
var stopLCPTracking = trackLargestContentfulPaintTiming(lifeCycle, configuration, window, function (largestContentfulPaint, lcpElement) {
webVitalTelemetryDebug.addWebVitalTelemetryDebug('LCP', lcpElement, largestContentfulPaint);

@@ -37,3 +37,3 @@ setTimings({

}).stop;
var stopFIDTracking = trackFirstInputTimings(lifeCycle, function (_a) {
var stopFIDTracking = trackFirstInputTimings(lifeCycle, configuration, function (_a) {
var firstInputDelay = _a.firstInputDelay, firstInputTime = _a.firstInputTime, firstInputTarget = _a.firstInputTarget;

@@ -83,4 +83,4 @@ webVitalTelemetryDebug.addWebVitalTelemetryDebug('FID', firstInputTarget, firstInputTime);

exports.trackNavigationTimings = trackNavigationTimings;
function trackFirstContentfulPaintTiming(lifeCycle, callback) {
var firstHidden = (0, trackFirstHidden_1.trackFirstHidden)();
function trackFirstContentfulPaintTiming(lifeCycle, configuration, callback) {
var firstHidden = (0, trackFirstHidden_1.trackFirstHidden)(configuration);
var stop = lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {

@@ -106,4 +106,4 @@ var fcpEntry = (0, browser_core_1.find)(entries, function (entry) {

*/
function trackLargestContentfulPaintTiming(lifeCycle, eventTarget, callback) {
var firstHidden = (0, trackFirstHidden_1.trackFirstHidden)();
function trackLargestContentfulPaintTiming(lifeCycle, configuration, eventTarget, callback) {
var firstHidden = (0, trackFirstHidden_1.trackFirstHidden)(configuration);
// Ignore entries that come after the first user interaction. According to the documentation, the

@@ -113,3 +113,3 @@ // browser should not send largest-contentful-paint entries after a user interact with the page,

var firstInteractionTimestamp = Infinity;
var stopEventListener = (0, browser_core_1.addEventListeners)(eventTarget, ["pointerdown" /* DOM_EVENT.POINTER_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */], function (event) {
var stopEventListener = (0, browser_core_1.addEventListeners)(configuration, eventTarget, ["pointerdown" /* DOM_EVENT.POINTER_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */], function (event) {
firstInteractionTimestamp = event.timeStamp;

@@ -144,4 +144,4 @@ }, { capture: true, once: true }).stop;

*/
function trackFirstInputTimings(lifeCycle, callback) {
var firstHidden = (0, trackFirstHidden_1.trackFirstHidden)();
function trackFirstInputTimings(lifeCycle, configuration, callback) {
var firstHidden = (0, trackFirstHidden_1.trackFirstHidden)(configuration);
var stop = lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {

@@ -148,0 +148,0 @@ var firstInputEntry = (0, browser_core_1.find)(entries, function (entry) {

import type { ClocksState, Duration, Observable } from '@datadog/browser-core';
import { noop } from '@datadog/browser-core';
import { ViewLoadingType } from '../../../rawRumEvent.types';

@@ -25,4 +24,4 @@ import type { RumConfiguration } from '../../configuration';

};
export declare function trackScrollMetrics(viewStart: ClocksState, callback: (scrollMetrics: ScrollMetrics) => void, getScrollValues?: typeof computeScrollValues): {
stop: typeof noop;
export declare function trackScrollMetrics(configuration: RumConfiguration, viewStart: ClocksState, callback: (scrollMetrics: ScrollMetrics) => void, getScrollValues?: typeof computeScrollValues): {
stop: () => void;
};

@@ -29,0 +28,0 @@ declare function computeScrollValues(): {

@@ -18,14 +18,12 @@ "use strict";

// This is to ensure that we have the depth data even if the user didn't scroll or if the view is not scrollable.
if ((0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.SCROLLMAP)) {
var _a = computeScrollValues(), scrollHeight = _a.scrollHeight, scrollDepth = _a.scrollDepth, scrollTop = _a.scrollTop;
scrollMetrics = {
maxDepth: scrollDepth,
maxDepthScrollHeight: scrollHeight,
maxDepthTime: newLoadingTime,
maxDepthScrollTop: scrollTop,
};
}
var _a = computeScrollValues(), scrollHeight = _a.scrollHeight, scrollDepth = _a.scrollDepth, scrollTop = _a.scrollTop;
scrollMetrics = {
maxDepth: scrollDepth,
maxDepthScrollHeight: scrollHeight,
maxDepthTime: newLoadingTime,
maxDepthScrollTop: scrollTop,
};
scheduleViewUpdate();
}), stopLoadingTimeTracking = _a.stop, setLoadEvent = _a.setLoadEvent;
var stopScrollMetricsTracking = trackScrollMetrics(viewStart, function (newScrollMetrics) {
var stopScrollMetricsTracking = trackScrollMetrics(configuration, viewStart, function (newScrollMetrics) {
scrollMetrics = newScrollMetrics;

@@ -61,7 +59,4 @@ }, computeScrollValues).stop;

exports.trackViewMetrics = trackViewMetrics;
function trackScrollMetrics(viewStart, callback, getScrollValues) {
function trackScrollMetrics(configuration, viewStart, callback, getScrollValues) {
if (getScrollValues === void 0) { getScrollValues = computeScrollValues; }
if (!(0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.SCROLLMAP)) {
return { stop: browser_core_1.noop };
}
var maxDepth = 0;

@@ -82,3 +77,5 @@ var handleScrollEvent = (0, browser_core_1.throttle)(function () {

}, exports.THROTTLE_SCROLL_DURATION, { leading: false, trailing: true });
var stop = (0, browser_core_1.addEventListener)(window, "scroll" /* DOM_EVENT.SCROLL */, handleScrollEvent.throttled, { passive: true }).stop;
var stop = (0, browser_core_1.addEventListener)(configuration, window, "scroll" /* DOM_EVENT.SCROLL */, handleScrollEvent.throttled, {
passive: true,
}).stop;
return {

@@ -85,0 +82,0 @@ stop: function () {

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

var _c = loadingType === "initial_load" /* ViewLoadingType.INITIAL_LOAD */
? (0, trackInitialViewTimings_1.trackInitialViewTimings)(lifeCycle, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate)
? (0, trackInitialViewTimings_1.trackInitialViewTimings)(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate)
: { scheduleStop: browser_core_1.noop, timings: {} }, scheduleStopInitialViewTimingsTracking = _c.scheduleStop, timings = _c.timings;

@@ -97,0 +97,0 @@ var _d = (0, trackViewEventCounts_1.trackViewEventCounts)(lifeCycle, id, scheduleViewUpdate), scheduleStopEventCountsTracking = _d.scheduleStop, eventCounts = _d.eventCounts;

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

function startRumSessionManager(configuration, lifeCycle) {
var sessionManager = (0, browser_core_1.startSessionManager)(
// TODO - Improve configuration type and remove assertion
configuration.sessionStoreStrategyType, exports.RUM_SESSION_KEY, function (rawTrackingType) { return computeSessionState(configuration, rawTrackingType); });
var sessionManager = (0, browser_core_1.startSessionManager)(configuration, exports.RUM_SESSION_KEY, function (rawTrackingType) {
return computeSessionState(configuration, rawTrackingType);
});
sessionManager.expireObservable.subscribe(function () {

@@ -12,0 +12,0 @@ lifeCycle.notify(7 /* LifeCycleEventType.SESSION_EXPIRED */);

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

});
var batch = new browser_core_1.Batch((0, browser_core_1.createHttpRequest)(endpointBuilder, configuration.batchBytesLimit, reportError), flushController, configuration.messageBytesLimit);
var batch = new browser_core_1.Batch((0, browser_core_1.createHttpRequest)(configuration, endpointBuilder, configuration.batchBytesLimit, reportError), flushController, configuration.messageBytesLimit);
return {

@@ -37,0 +37,0 @@ batch: batch,

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

var featureFlagContexts = startFeatureFlagContexts(lifeCycle);
var pageExitObservable = createPageExitObservable();
var pageExitObservable = createPageExitObservable(configuration);
pageExitObservable.subscribe(function (event) {

@@ -65,3 +65,3 @@ lifeCycle.notify(9 /* LifeCycleEventType.PAGE_EXITED */, event);

var domMutationObservable = createDOMMutationObservable();
var locationChangeObservable = createLocationChangeObservable(location);
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;

@@ -73,3 +73,3 @@ addTelemetryConfiguration(serializeRumConfiguration(initConfiguration));

var _b = startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, webVitalTelemetryDebug, initialViewOptions), addTiming = _b.addTiming, startView = _b.startView;
var addError = startErrorCollection(lifeCycle, pageStateHistory, featureFlagContexts).addError;
var addError = startErrorCollection(lifeCycle, configuration, pageStateHistory, featureFlagContexts).addError;
startRequestCollection(lifeCycle, configuration, session);

@@ -102,3 +102,3 @@ startPerformanceCollection(lifeCycle, configuration);

var urlContexts = startUrlContexts(lifeCycle, locationChangeObservable, location);
var pageStateHistory = startPageStateHistory();
var pageStateHistory = startPageStateHistory(configuration);
var _a = startActionCollection(lifeCycle, domMutationObservable, configuration, pageStateHistory), addAction = _a.addAction, actionContexts = _a.actionContexts;

@@ -105,0 +105,0 @@ startRumAssembly(configuration, lifeCycle, sessionManager, viewContexts, urlContexts, actionContexts, buildCommonContext, reportError);

import { Observable } from '@datadog/browser-core';
import type { RumConfiguration } from '../domain/configuration';
export interface LocationChange {

@@ -6,2 +7,2 @@ oldLocation: Readonly<Location>;

}
export declare function createLocationChangeObservable(location: Location): Observable<LocationChange>;
export declare function createLocationChangeObservable(configuration: RumConfiguration, location: Location): Observable<LocationChange>;
import { addEventListener, instrumentMethodAndCallOriginal, Observable, shallowClone, } from '@datadog/browser-core';
export function createLocationChangeObservable(location) {
export function createLocationChangeObservable(configuration, location) {
var currentLocation = shallowClone(location);
var observable = new Observable(function () {
var stopHistoryTracking = trackHistory(onLocationChange).stop;
var stopHashTracking = trackHash(onLocationChange).stop;
var stopHistoryTracking = trackHistory(configuration, onLocationChange).stop;
var stopHashTracking = trackHash(configuration, onLocationChange).stop;
return function () {

@@ -25,3 +25,3 @@ stopHistoryTracking();

}
function trackHistory(onHistoryChange) {
function trackHistory(configuration, onHistoryChange) {
var stopInstrumentingPushState = instrumentMethodAndCallOriginal(history, 'pushState', {

@@ -33,3 +33,3 @@ after: onHistoryChange,

}).stop;
var removeListener = addEventListener(window, "popstate" /* DOM_EVENT.POP_STATE */, onHistoryChange).stop;
var removeListener = addEventListener(configuration, window, "popstate" /* DOM_EVENT.POP_STATE */, onHistoryChange).stop;
return {

@@ -43,5 +43,5 @@ stop: function () {

}
function trackHash(onHashChange) {
return addEventListener(window, "hashchange" /* DOM_EVENT.HASH_CHANGE */, onHashChange);
function trackHash(configuration, onHashChange) {
return addEventListener(configuration, window, "hashchange" /* DOM_EVENT.HASH_CHANGE */, onHashChange);
}
//# sourceMappingURL=locationChangeObservable.js.map

@@ -68,5 +68,5 @@ import type { Duration, RelativeTime } from '@datadog/browser-core';

export declare function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration): void;
export declare function retrieveInitialDocumentResourceTiming(callback: (timing: RumPerformanceResourceTiming) => void): void;
export declare function retrieveInitialDocumentResourceTiming(configuration: RumConfiguration, callback: (timing: RumPerformanceResourceTiming) => void): void;
export type RelativePerformanceTiming = {
-readonly [key in keyof Omit<PerformanceTiming, 'toJSON'>]: RelativeTime;
};

@@ -13,3 +13,3 @@ import { dateNow, assign, addEventListeners, getRelativeTime, isNumber, monitor, setTimeout, relativeNow, runOnReadyState, addEventListener, } from '@datadog/browser-core';

export function startPerformanceCollection(lifeCycle, configuration) {
retrieveInitialDocumentResourceTiming(function (timing) {
retrieveInitialDocumentResourceTiming(configuration, function (timing) {
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);

@@ -47,3 +47,3 @@ });

// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
addEventListener(performance, 'resourcetimingbufferfull', function () {
addEventListener(configuration, performance, 'resourcetimingbufferfull', function () {
performance.clearResourceTimings();

@@ -54,3 +54,3 @@ });

if (!supportPerformanceTimingEvent('navigation')) {
retrieveNavigationTiming(function (timing) {
retrieveNavigationTiming(configuration, function (timing) {
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);

@@ -60,3 +60,3 @@ });

if (!supportPerformanceTimingEvent('first-input')) {
retrieveFirstInputTiming(function (timing) {
retrieveFirstInputTiming(configuration, function (timing) {
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);

@@ -66,4 +66,4 @@ });

}
export function retrieveInitialDocumentResourceTiming(callback) {
runOnReadyState('interactive', function () {
export function retrieveInitialDocumentResourceTiming(configuration, callback) {
runOnReadyState(configuration, 'interactive', function () {
var timing;

@@ -91,3 +91,3 @@ var forcedAttributes = {

}
function retrieveNavigationTiming(callback) {
function retrieveNavigationTiming(configuration, callback) {
function sendFakeTiming() {

@@ -98,3 +98,3 @@ callback(assign(computeRelativePerformanceTiming(), {

}
runOnReadyState('complete', function () {
runOnReadyState(configuration, 'complete', function () {
// Send it a bit after the actual load event, so the "loadEventEnd" timing is accurate

@@ -108,6 +108,6 @@ setTimeout(sendFakeTiming);

*/
function retrieveFirstInputTiming(callback) {
function retrieveFirstInputTiming(configuration, callback) {
var startTimeStamp = dateNow();
var timingSent = false;
var removeEventListeners = addEventListeners(window, ["click" /* DOM_EVENT.CLICK */, "mousedown" /* DOM_EVENT.MOUSE_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */, "touchstart" /* DOM_EVENT.TOUCH_START */, "pointerdown" /* DOM_EVENT.POINTER_DOWN */], function (evt) {
var removeEventListeners = addEventListeners(configuration, window, ["click" /* DOM_EVENT.CLICK */, "mousedown" /* DOM_EVENT.MOUSE_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */, "touchstart" /* DOM_EVENT.TOUCH_START */, "pointerdown" /* DOM_EVENT.POINTER_DOWN */], function (evt) {
// Only count cancelable events, which should trigger behavior important to the user.

@@ -126,3 +126,3 @@ if (!evt.cancelable) {

if (evt.type === "pointerdown" /* DOM_EVENT.POINTER_DOWN */) {
sendTimingIfPointerIsNotCancelled(timing);
sendTimingIfPointerIsNotCancelled(configuration, timing);
}

@@ -139,4 +139,4 @@ else {

*/
function sendTimingIfPointerIsNotCancelled(timing) {
addEventListeners(window, ["pointerup" /* DOM_EVENT.POINTER_UP */, "pointercancel" /* DOM_EVENT.POINTER_CANCEL */], function (event) {
function sendTimingIfPointerIsNotCancelled(configuration, timing) {
addEventListeners(configuration, window, ["pointerup" /* DOM_EVENT.POINTER_UP */, "pointercancel" /* DOM_EVENT.POINTER_CANCEL */], function (event) {
if (event.type === "pointerup" /* DOM_EVENT.POINTER_UP */) {

@@ -143,0 +143,0 @@ sendTiming(timing);

import { Observable } from '@datadog/browser-core';
import type { RumConfiguration } from '../domain/configuration';
export interface ViewportDimension {

@@ -6,4 +7,4 @@ height: number;

}
export declare function initViewportObservable(): Observable<ViewportDimension>;
export declare function createViewportObservable(): Observable<ViewportDimension>;
export declare function initViewportObservable(configuration: RumConfiguration): Observable<ViewportDimension>;
export declare function createViewportObservable(configuration: RumConfiguration): Observable<ViewportDimension>;
export declare function getViewportDimension(): ViewportDimension;
import { Observable, throttle, addEventListener } from '@datadog/browser-core';
var viewportObservable;
export function initViewportObservable() {
export function initViewportObservable(configuration) {
if (!viewportObservable) {
viewportObservable = createViewportObservable();
viewportObservable = createViewportObservable(configuration);
}
return viewportObservable;
}
export function createViewportObservable() {
export function createViewportObservable(configuration) {
var observable = new Observable(function () {

@@ -14,3 +14,4 @@ var updateDimension = throttle(function () {

}, 200).throttled;
return addEventListener(window, "resize" /* DOM_EVENT.RESIZE */, updateDimension, { capture: true, passive: true }).stop;
return addEventListener(configuration, window, "resize" /* DOM_EVENT.RESIZE */, updateDimension, { capture: true, passive: true })
.stop;
});

@@ -17,0 +18,0 @@ return observable;

@@ -57,3 +57,3 @@ import { combine, isEmptyObject, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, assign, round, } from '@datadog/browser-core';

},
browser_sdk_version: canUseEventBridge() ? "4.46.0" : undefined,
browser_sdk_version: canUseEventBridge() ? "4.47.0" : undefined,
},

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

ci_test: ciTestContext,
display: getDisplayContext(),
display: getDisplayContext(configuration),
};

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

@@ -14,2 +14,3 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core';

excludedActivityUrls?: MatchOption[] | undefined;
workerUrl?: string;
/**

@@ -49,2 +50,3 @@ * @deprecated use allowedTracingUrls instead

excludedActivityUrls: MatchOption[];
workerUrl: string | undefined;
applicationId: string;

@@ -51,0 +53,0 @@ defaultPrivacyLevel: DefaultPrivacyLevel;

@@ -52,2 +52,3 @@ import { getType, arrayFrom, getOrigin, isMatchOption, serializeConfiguration, assign, DefaultPrivacyLevel, display, isPercentage, objectHasValue, validateAndBuildConfiguration, } from '@datadog/browser-core';

excludedActivityUrls: (_f = initConfiguration.excludedActivityUrls) !== null && _f !== void 0 ? _f : [],
workerUrl: initConfiguration.workerUrl,
trackUserInteractions: trackUserInteractions || trackFrustrations,

@@ -176,2 +177,3 @@ trackFrustrations: trackFrustrations,

use_excluded_activity_urls: Array.isArray(configuration.excludedActivityUrls) && configuration.excludedActivityUrls.length > 0,
use_worker_url: !!configuration.workerUrl,
track_frustrations: configuration.trackFrustrations,

@@ -178,0 +180,0 @@ track_views_manually: configuration.trackViewsManually,

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

export declare function getDisplayContext(): {
import type { RumConfiguration } from '../configuration';
export declare function getDisplayContext(configuration: RumConfiguration): {
viewport: {

@@ -3,0 +4,0 @@ width: number;

import { getViewportDimension, initViewportObservable } from '../../browser/viewportObservable';
var viewport;
var stopListeners;
export function getDisplayContext() {
export function getDisplayContext(configuration) {
if (!viewport) {
viewport = getViewportDimension();
stopListeners = initViewportObservable().subscribe(function (viewportDimension) {
stopListeners = initViewportObservable(configuration).subscribe(function (viewportDimension) {
viewport = viewportDimension;

@@ -9,0 +9,0 @@ }).unsubscribe;

import type { Duration, RelativeTime } from '@datadog/browser-core';
import type { RumConfiguration } from '../configuration';
import type { PageStateServerEntry } from '../../rawRumEvent.types';

@@ -23,2 +24,2 @@ export declare const MAX_PAGE_STATE_ENTRIES = 4000;

}
export declare function startPageStateHistory(maxPageStateEntriesSelectable?: number): PageStateHistory;
export declare function startPageStateHistory(configuration: RumConfiguration, maxPageStateEntriesSelectable?: number): PageStateHistory;

@@ -7,3 +7,3 @@ import { elapsed, ValueHistory, SESSION_TIME_OUT_DELAY, toServerDuration, addEventListeners, relativeNow, } from '@datadog/browser-core';

export var PAGE_STATE_CONTEXT_TIME_OUT_DELAY = SESSION_TIME_OUT_DELAY;
export function startPageStateHistory(maxPageStateEntriesSelectable) {
export function startPageStateHistory(configuration, maxPageStateEntriesSelectable) {
if (maxPageStateEntriesSelectable === void 0) { maxPageStateEntriesSelectable = MAX_PAGE_STATE_ENTRIES_SELECTABLE; }

@@ -13,3 +13,3 @@ var pageStateHistory = new ValueHistory(PAGE_STATE_CONTEXT_TIME_OUT_DELAY, MAX_PAGE_STATE_ENTRIES);

addPageState(getPageState(), relativeNow());
var stopEventListeners = addEventListeners(window, [
var stopEventListeners = addEventListeners(configuration, window, [
"pageshow" /* DOM_EVENT.PAGE_SHOW */,

@@ -16,0 +16,0 @@ "focus" /* DOM_EVENT.FOCUS */,

@@ -11,3 +11,3 @@ import { initFetchObservable, initXhrObservable, readBytesFromStream, elapsed, timeStampNow, tryToClone, } from '@datadog/browser-core';

export function trackXhr(lifeCycle, configuration, tracer) {
var subscription = initXhrObservable().subscribe(function (rawContext) {
var subscription = initXhrObservable(configuration).subscribe(function (rawContext) {
var context = rawContext;

@@ -14,0 +14,0 @@ if (!isAllowedRequestUrl(configuration, context.url)) {

@@ -76,3 +76,3 @@ import { cssEscape } from '@datadog/browser-core';

}
return "".concat(element.tagName, ".").concat(cssEscape(className));
return "".concat(cssEscape(element.tagName), ".").concat(cssEscape(className));
}

@@ -82,3 +82,3 @@ }

function getTagNameSelector(element) {
return element.tagName;
return cssEscape(element.tagName);
}

@@ -101,3 +101,3 @@ function getStableAttributeSelector(element, actionNameAttribute) {

if (element.hasAttribute(attributeName)) {
return "".concat(element.tagName, "[").concat(attributeName, "=\"").concat(cssEscape(element.getAttribute(attributeName)), "\"]");
return "".concat(cssEscape(element.tagName), "[").concat(attributeName, "=\"").concat(cssEscape(element.getAttribute(attributeName)), "\"]");
}

@@ -115,3 +115,3 @@ }

}
return "".concat(element.tagName, ":nth-of-type(").concat(elementIndex, ")");
return "".concat(cssEscape(element.tagName), ":nth-of-type(").concat(elementIndex, ")");
}

@@ -118,0 +118,0 @@ function findSelector(element, selectorGetters, predicate, actionNameAttribute, childSelector) {

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

import type { RumConfiguration } from '../../configuration';
export type MouseEventOnElement = PointerEvent & {

@@ -12,4 +13,4 @@ target: Element;

}
export declare function listenActionEvents<ClickContext>({ onPointerDown, onPointerUp }: ActionEventsHooks<ClickContext>): {
export declare function listenActionEvents<ClickContext>(configuration: RumConfiguration, { onPointerDown, onPointerUp }: ActionEventsHooks<ClickContext>): {
stop: () => void;
};
import { addEventListener } from '@datadog/browser-core';
export function listenActionEvents(_a) {
export function listenActionEvents(configuration, _a) {
var onPointerDown = _a.onPointerDown, onPointerUp = _a.onPointerUp;

@@ -11,3 +11,3 @@ var selectionEmptyAtPointerDown;

var listeners = [
addEventListener(window, "pointerdown" /* DOM_EVENT.POINTER_DOWN */, function (event) {
addEventListener(configuration, window, "pointerdown" /* DOM_EVENT.POINTER_DOWN */, function (event) {
if (isValidPointerEvent(event)) {

@@ -22,3 +22,3 @@ selectionEmptyAtPointerDown = isSelectionEmpty();

}, { capture: true }),
addEventListener(window, "selectionchange" /* DOM_EVENT.SELECTION_CHANGE */, function () {
addEventListener(configuration, window, "selectionchange" /* DOM_EVENT.SELECTION_CHANGE */, function () {
if (!selectionEmptyAtPointerDown || !isSelectionEmpty()) {

@@ -28,3 +28,3 @@ userActivity.selection = true;

}, { capture: true }),
addEventListener(window, "pointerup" /* DOM_EVENT.POINTER_UP */, function (event) {
addEventListener(configuration, window, "pointerup" /* DOM_EVENT.POINTER_UP */, function (event) {
if (isValidPointerEvent(event) && clickContext) {

@@ -37,3 +37,3 @@ // Use a scoped variable to make sure the value is not changed by other clicks

}, { capture: true }),
addEventListener(window, "input" /* DOM_EVENT.INPUT */, function () {
addEventListener(configuration, window, "input" /* DOM_EVENT.INPUT */, function () {
userActivity.input = true;

@@ -40,0 +40,0 @@ }, { capture: true }),

@@ -20,3 +20,3 @@ import { includes, timeStampNow, Observable, assign, getRelativeTime, ONE_MINUTE, ValueHistory, generateUUID, clocksNow, ONE_SECOND, elapsed, } from '@datadog/browser-core';

lifeCycle.subscribe(4 /* LifeCycleEventType.VIEW_ENDED */, stopClickChain);
var stopActionEventsListener = listenActionEvents({
var stopActionEventsListener = listenActionEvents(configuration, {
onPointerDown: function (pointerDownEvent) {

@@ -23,0 +23,0 @@ return processPointerDown(configuration, lifeCycle, domMutationObservable, history, pointerDownEvent);

import type { Context, ClocksState } from '@datadog/browser-core';
import type { RumConfiguration } from '../../configuration';
import type { LifeCycle } from '../../lifeCycle';

@@ -12,3 +13,3 @@ import type { FeatureFlagContexts } from '../../contexts/featureFlagContext';

}
export declare function startErrorCollection(lifeCycle: LifeCycle, pageStateHistory: PageStateHistory, featureFlagContexts: FeatureFlagContexts): {
export declare function startErrorCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, pageStateHistory: PageStateHistory, featureFlagContexts: FeatureFlagContexts): {
addError: ({ error, handlingStack, startClocks, context: customerContext }: ProvidedError, savedCommonContext?: CommonContext | undefined) => void;

@@ -15,0 +16,0 @@ };

import { isEmptyObject, assign, ErrorSource, generateUUID, computeRawError, computeStackTrace, Observable, trackRuntimeError, } from '@datadog/browser-core';
import { trackConsoleError } from './trackConsoleError';
import { trackReportError } from './trackReportError';
export function startErrorCollection(lifeCycle, pageStateHistory, featureFlagContexts) {
export function startErrorCollection(lifeCycle, configuration, pageStateHistory, featureFlagContexts) {
var errorObservable = new Observable();
trackConsoleError(errorObservable);
trackRuntimeError(errorObservable);
trackReportError(errorObservable);
trackReportError(configuration, errorObservable);
errorObservable.subscribe(function (error) { return lifeCycle.notify(12 /* LifeCycleEventType.RAW_ERROR_COLLECTED */, { error: error }); });

@@ -10,0 +10,0 @@ return doStartErrorCollection(lifeCycle, pageStateHistory, featureFlagContexts);

import type { Observable, RawError } from '@datadog/browser-core';
export declare function trackReportError(errorObservable: Observable<RawError>): {
import type { RumConfiguration } from '../../configuration';
export declare function trackReportError(configuration: RumConfiguration, errorObservable: Observable<RawError>): {
stop: () => void;
};
import { clocksNow, ErrorSource, initReportObservable, RawReportType } from '@datadog/browser-core';
export function trackReportError(errorObservable) {
var subscription = initReportObservable([RawReportType.cspViolation, RawReportType.intervention]).subscribe(function (reportError) {
export function trackReportError(configuration, errorObservable) {
var subscription = initReportObservable(configuration, [
RawReportType.cspViolation,
RawReportType.intervention,
]).subscribe(function (reportError) {
return errorObservable.notify({

@@ -5,0 +8,0 @@ startClocks: clocksNow(),

import type { RelativeTime } from '@datadog/browser-core';
export declare function trackFirstHidden(eventTarget?: Window): {
import type { RumConfiguration } from '../../configuration';
export declare function trackFirstHidden(configuration: RumConfiguration, eventTarget?: Window): {
timeStamp: RelativeTime;
};
export declare function resetFirstHidden(): void;
import { addEventListeners } from '@datadog/browser-core';
var trackFirstHiddenSingleton;
var stopListeners;
export function trackFirstHidden(eventTarget) {
export function trackFirstHidden(configuration, eventTarget) {
if (eventTarget === void 0) { eventTarget = window; }

@@ -16,3 +16,3 @@ if (!trackFirstHiddenSingleton) {

};
(stopListeners = addEventListeners(eventTarget, ["pagehide" /* DOM_EVENT.PAGE_HIDE */, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */], function (event) {
(stopListeners = addEventListeners(configuration, eventTarget, ["pagehide" /* DOM_EVENT.PAGE_HIDE */, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */], function (event) {
if (event.type === 'pagehide' || document.visibilityState === 'hidden') {

@@ -19,0 +19,0 @@ trackFirstHiddenSingleton.timeStamp = event.timeStamp;

import type { Duration, RelativeTime } from '@datadog/browser-core';
import type { RumConfiguration } from '../../configuration';
import type { LifeCycle } from '../../lifeCycle';

@@ -23,3 +24,3 @@ import type { WebVitalTelemetryDebug } from './startWebVitalTelemetryDebug';

}
export declare function trackInitialViewTimings(lifeCycle: LifeCycle, webVitalTelemetryDebug: WebVitalTelemetryDebug, setLoadEvent: (loadEnd: Duration) => void, scheduleViewUpdate: () => void): {
export declare function trackInitialViewTimings(lifeCycle: LifeCycle, configuration: RumConfiguration, webVitalTelemetryDebug: WebVitalTelemetryDebug, setLoadEvent: (loadEnd: Duration) => void, scheduleViewUpdate: () => void): {
stop: () => void;

@@ -39,3 +40,3 @@ timings: Timings;

};
export declare function trackFirstContentfulPaintTiming(lifeCycle: LifeCycle, callback: (fcpTiming: RelativeTime) => void): {
export declare function trackFirstContentfulPaintTiming(lifeCycle: LifeCycle, configuration: RumConfiguration, callback: (fcpTiming: RelativeTime) => void): {
stop: () => void;

@@ -49,3 +50,3 @@ };

*/
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, eventTarget: Window, callback: (lcpTiming: RelativeTime, lcpElement?: Element) => void): {
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, configuration: RumConfiguration, eventTarget: Window, callback: (lcpTiming: RelativeTime, lcpElement?: Element) => void): {
stop: () => void;

@@ -61,3 +62,3 @@ };

*/
export declare function trackFirstInputTimings(lifeCycle: LifeCycle, callback: ({ firstInputDelay, firstInputTime, firstInputTarget, }: {
export declare function trackFirstInputTimings(lifeCycle: LifeCycle, configuration: RumConfiguration, callback: ({ firstInputDelay, firstInputTime, firstInputTarget, }: {
firstInputDelay: Duration;

@@ -64,0 +65,0 @@ firstInputTime: RelativeTime;

@@ -13,3 +13,3 @@ import { setTimeout, assign, addEventListeners, elapsed, ONE_MINUTE, find, findLast, relativeNow, } from '@datadog/browser-core';

export var KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY = 5 * ONE_MINUTE;
export function trackInitialViewTimings(lifeCycle, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) {
export function trackInitialViewTimings(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) {
var timings = {};

@@ -24,6 +24,6 @@ function setTimings(newTimings) {

}).stop;
var stopFCPTracking = trackFirstContentfulPaintTiming(lifeCycle, function (firstContentfulPaint) {
var stopFCPTracking = trackFirstContentfulPaintTiming(lifeCycle, configuration, function (firstContentfulPaint) {
return setTimings({ firstContentfulPaint: firstContentfulPaint });
}).stop;
var stopLCPTracking = trackLargestContentfulPaintTiming(lifeCycle, window, function (largestContentfulPaint, lcpElement) {
var stopLCPTracking = trackLargestContentfulPaintTiming(lifeCycle, configuration, window, function (largestContentfulPaint, lcpElement) {
webVitalTelemetryDebug.addWebVitalTelemetryDebug('LCP', lcpElement, largestContentfulPaint);

@@ -34,3 +34,3 @@ setTimings({

}).stop;
var stopFIDTracking = trackFirstInputTimings(lifeCycle, function (_a) {
var stopFIDTracking = trackFirstInputTimings(lifeCycle, configuration, function (_a) {
var firstInputDelay = _a.firstInputDelay, firstInputTime = _a.firstInputTime, firstInputTarget = _a.firstInputTarget;

@@ -78,4 +78,4 @@ webVitalTelemetryDebug.addWebVitalTelemetryDebug('FID', firstInputTarget, firstInputTime);

}
export function trackFirstContentfulPaintTiming(lifeCycle, callback) {
var firstHidden = trackFirstHidden();
export function trackFirstContentfulPaintTiming(lifeCycle, configuration, callback) {
var firstHidden = trackFirstHidden(configuration);
var stop = lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {

@@ -100,4 +100,4 @@ var fcpEntry = find(entries, function (entry) {

*/
export function trackLargestContentfulPaintTiming(lifeCycle, eventTarget, callback) {
var firstHidden = trackFirstHidden();
export function trackLargestContentfulPaintTiming(lifeCycle, configuration, eventTarget, callback) {
var firstHidden = trackFirstHidden(configuration);
// Ignore entries that come after the first user interaction. According to the documentation, the

@@ -107,3 +107,3 @@ // browser should not send largest-contentful-paint entries after a user interact with the page,

var firstInteractionTimestamp = Infinity;
var stopEventListener = addEventListeners(eventTarget, ["pointerdown" /* DOM_EVENT.POINTER_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */], function (event) {
var stopEventListener = addEventListeners(configuration, eventTarget, ["pointerdown" /* DOM_EVENT.POINTER_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */], function (event) {
firstInteractionTimestamp = event.timeStamp;

@@ -137,4 +137,4 @@ }, { capture: true, once: true }).stop;

*/
export function trackFirstInputTimings(lifeCycle, callback) {
var firstHidden = trackFirstHidden();
export function trackFirstInputTimings(lifeCycle, configuration, callback) {
var firstHidden = trackFirstHidden(configuration);
var stop = lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {

@@ -141,0 +141,0 @@ var firstInputEntry = find(entries, function (entry) {

import type { ClocksState, Duration, Observable } from '@datadog/browser-core';
import { noop } from '@datadog/browser-core';
import { ViewLoadingType } from '../../../rawRumEvent.types';

@@ -25,4 +24,4 @@ import type { RumConfiguration } from '../../configuration';

};
export declare function trackScrollMetrics(viewStart: ClocksState, callback: (scrollMetrics: ScrollMetrics) => void, getScrollValues?: typeof computeScrollValues): {
stop: typeof noop;
export declare function trackScrollMetrics(configuration: RumConfiguration, viewStart: ClocksState, callback: (scrollMetrics: ScrollMetrics) => void, getScrollValues?: typeof computeScrollValues): {
stop: () => void;
};

@@ -29,0 +28,0 @@ declare function computeScrollValues(): {

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

import { ExperimentalFeature, isExperimentalFeatureEnabled, ONE_SECOND, addEventListener, elapsed, noop, relativeNow, round, throttle, find, } from '@datadog/browser-core';
import { ONE_SECOND, addEventListener, elapsed, noop, relativeNow, round, throttle, find, } from '@datadog/browser-core';
import { supportPerformanceTimingEvent } from '../../../browser/performanceCollection';

@@ -15,14 +15,12 @@ import { waitPageActivityEnd } from '../../waitPageActivityEnd';

// This is to ensure that we have the depth data even if the user didn't scroll or if the view is not scrollable.
if (isExperimentalFeatureEnabled(ExperimentalFeature.SCROLLMAP)) {
var _a = computeScrollValues(), scrollHeight = _a.scrollHeight, scrollDepth = _a.scrollDepth, scrollTop = _a.scrollTop;
scrollMetrics = {
maxDepth: scrollDepth,
maxDepthScrollHeight: scrollHeight,
maxDepthTime: newLoadingTime,
maxDepthScrollTop: scrollTop,
};
}
var _a = computeScrollValues(), scrollHeight = _a.scrollHeight, scrollDepth = _a.scrollDepth, scrollTop = _a.scrollTop;
scrollMetrics = {
maxDepth: scrollDepth,
maxDepthScrollHeight: scrollHeight,
maxDepthTime: newLoadingTime,
maxDepthScrollTop: scrollTop,
};
scheduleViewUpdate();
}), stopLoadingTimeTracking = _a.stop, setLoadEvent = _a.setLoadEvent;
var stopScrollMetricsTracking = trackScrollMetrics(viewStart, function (newScrollMetrics) {
var stopScrollMetricsTracking = trackScrollMetrics(configuration, viewStart, function (newScrollMetrics) {
scrollMetrics = newScrollMetrics;

@@ -57,7 +55,4 @@ }, computeScrollValues).stop;

}
export function trackScrollMetrics(viewStart, callback, getScrollValues) {
export function trackScrollMetrics(configuration, viewStart, callback, getScrollValues) {
if (getScrollValues === void 0) { getScrollValues = computeScrollValues; }
if (!isExperimentalFeatureEnabled(ExperimentalFeature.SCROLLMAP)) {
return { stop: noop };
}
var maxDepth = 0;

@@ -78,3 +73,5 @@ var handleScrollEvent = throttle(function () {

}, THROTTLE_SCROLL_DURATION, { leading: false, trailing: true });
var stop = addEventListener(window, "scroll" /* DOM_EVENT.SCROLL */, handleScrollEvent.throttled, { passive: true }).stop;
var stop = addEventListener(configuration, window, "scroll" /* DOM_EVENT.SCROLL */, handleScrollEvent.throttled, {
passive: true,
}).stop;
return {

@@ -81,0 +78,0 @@ stop: function () {

@@ -90,3 +90,3 @@ import { noop, PageExitReason, shallowClone, assign, elapsed, generateUUID, ONE_MINUTE, throttle, clocksNow, clocksOrigin, timeStampNow, display, looksLikeRelativeTime, setInterval, clearInterval, } from '@datadog/browser-core';

var _c = loadingType === "initial_load" /* ViewLoadingType.INITIAL_LOAD */
? trackInitialViewTimings(lifeCycle, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate)
? trackInitialViewTimings(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate)
: { scheduleStop: noop, timings: {} }, scheduleStopInitialViewTimingsTracking = _c.scheduleStop, timings = _c.timings;

@@ -93,0 +93,0 @@ var _d = trackViewEventCounts(lifeCycle, id, scheduleViewUpdate), scheduleStopEventCountsTracking = _d.scheduleStop, eventCounts = _d.eventCounts;

import { Observable, noop, performDraw, startSessionManager } from '@datadog/browser-core';
export var RUM_SESSION_KEY = 'rum';
export function startRumSessionManager(configuration, lifeCycle) {
var sessionManager = startSessionManager(
// TODO - Improve configuration type and remove assertion
configuration.sessionStoreStrategyType, RUM_SESSION_KEY, function (rawTrackingType) { return computeSessionState(configuration, rawTrackingType); });
var sessionManager = startSessionManager(configuration, RUM_SESSION_KEY, function (rawTrackingType) {
return computeSessionState(configuration, rawTrackingType);
});
sessionManager.expireObservable.subscribe(function () {

@@ -8,0 +8,0 @@ lifeCycle.notify(7 /* LifeCycleEventType.SESSION_EXPIRED */);

@@ -30,3 +30,3 @@ import { createFlushController, Batch, combine, createHttpRequest, isTelemetryReplicationAllowed, } from '@datadog/browser-core';

});
var batch = new Batch(createHttpRequest(endpointBuilder, configuration.batchBytesLimit, reportError), flushController, configuration.messageBytesLimit);
var batch = new Batch(createHttpRequest(configuration, endpointBuilder, configuration.batchBytesLimit, reportError), flushController, configuration.messageBytesLimit);
return {

@@ -33,0 +33,0 @@ batch: batch,

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

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

"dependencies": {
"@datadog/browser-core": "4.46.0"
"@datadog/browser-core": "4.47.0"
},

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

},
"gitHead": "fdd9a6034d8e1460cbb3dfdac188f102de10347f"
"gitHead": "8aa80956202b4b2eb82b15ffd0f815c58679873d"
}

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

const pageExitObservable = createPageExitObservable()
const pageExitObservable = createPageExitObservable(configuration)
pageExitObservable.subscribe((event) => {

@@ -106,3 +106,3 @@ lifeCycle.notify(LifeCycleEventType.PAGE_EXITED, event)

const domMutationObservable = createDOMMutationObservable()
const locationChangeObservable = createLocationChangeObservable(location)
const locationChangeObservable = createLocationChangeObservable(configuration, location)

@@ -138,3 +138,3 @@ const { viewContexts, pageStateHistory, urlContexts, actionContexts, addAction } = startRumEventCollection(

)
const { addError } = startErrorCollection(lifeCycle, pageStateHistory, featureFlagContexts)
const { addError } = startErrorCollection(lifeCycle, configuration, pageStateHistory, featureFlagContexts)

@@ -188,3 +188,3 @@ startRequestCollection(lifeCycle, configuration, session)

const pageStateHistory = startPageStateHistory()
const pageStateHistory = startPageStateHistory(configuration)

@@ -191,0 +191,0 @@ const { addAction, actionContexts } = startActionCollection(

@@ -8,2 +8,3 @@ import {

} from '@datadog/browser-core'
import type { RumConfiguration } from '../domain/configuration'

@@ -15,7 +16,7 @@ export interface LocationChange {

export function createLocationChangeObservable(location: Location) {
export function createLocationChangeObservable(configuration: RumConfiguration, location: Location) {
let currentLocation = shallowClone(location)
const observable = new Observable<LocationChange>(() => {
const { stop: stopHistoryTracking } = trackHistory(onLocationChange)
const { stop: stopHashTracking } = trackHash(onLocationChange)
const { stop: stopHistoryTracking } = trackHistory(configuration, onLocationChange)
const { stop: stopHashTracking } = trackHash(configuration, onLocationChange)
return () => {

@@ -42,3 +43,3 @@ stopHistoryTracking()

function trackHistory(onHistoryChange: () => void) {
function trackHistory(configuration: RumConfiguration, onHistoryChange: () => void) {
const { stop: stopInstrumentingPushState } = instrumentMethodAndCallOriginal(history, 'pushState', {

@@ -50,3 +51,3 @@ after: onHistoryChange,

})
const { stop: removeListener } = addEventListener(window, DOM_EVENT.POP_STATE, onHistoryChange)
const { stop: removeListener } = addEventListener(configuration, window, DOM_EVENT.POP_STATE, onHistoryChange)

@@ -62,4 +63,4 @@ return {

function trackHash(onHashChange: () => void) {
return addEventListener(window, DOM_EVENT.HASH_CHANGE, onHashChange)
function trackHash(configuration: RumConfiguration, onHashChange: () => void) {
return addEventListener(configuration, window, DOM_EVENT.HASH_CHANGE, onHashChange)
}

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

export function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration) {
retrieveInitialDocumentResourceTiming((timing) => {
retrieveInitialDocumentResourceTiming(configuration, (timing) => {
handleRumPerformanceEntries(lifeCycle, configuration, [timing])

@@ -151,3 +151,3 @@ })

// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
addEventListener(performance, 'resourcetimingbufferfull', () => {
addEventListener(configuration, performance, 'resourcetimingbufferfull', () => {
performance.clearResourceTimings()

@@ -158,3 +158,3 @@ })

if (!supportPerformanceTimingEvent('navigation')) {
retrieveNavigationTiming((timing) => {
retrieveNavigationTiming(configuration, (timing) => {
handleRumPerformanceEntries(lifeCycle, configuration, [timing])

@@ -164,3 +164,3 @@ })

if (!supportPerformanceTimingEvent('first-input')) {
retrieveFirstInputTiming((timing) => {
retrieveFirstInputTiming(configuration, (timing) => {
handleRumPerformanceEntries(lifeCycle, configuration, [timing])

@@ -171,4 +171,7 @@ })

export function retrieveInitialDocumentResourceTiming(callback: (timing: RumPerformanceResourceTiming) => void) {
runOnReadyState('interactive', () => {
export function retrieveInitialDocumentResourceTiming(
configuration: RumConfiguration,
callback: (timing: RumPerformanceResourceTiming) => void
) {
runOnReadyState(configuration, 'interactive', () => {
let timing: RumPerformanceResourceTiming

@@ -201,3 +204,6 @@

function retrieveNavigationTiming(callback: (timing: RumPerformanceNavigationTiming) => void) {
function retrieveNavigationTiming(
configuration: RumConfiguration,
callback: (timing: RumPerformanceNavigationTiming) => void
) {
function sendFakeTiming() {

@@ -211,3 +217,3 @@ callback(

runOnReadyState('complete', () => {
runOnReadyState(configuration, 'complete', () => {
// Send it a bit after the actual load event, so the "loadEventEnd" timing is accurate

@@ -222,3 +228,3 @@ setTimeout(sendFakeTiming)

*/
function retrieveFirstInputTiming(callback: (timing: RumFirstInputTiming) => void) {
function retrieveFirstInputTiming(configuration: RumConfiguration, callback: (timing: RumFirstInputTiming) => void) {
const startTimeStamp = dateNow()

@@ -228,2 +234,3 @@ let timingSent = false

const { stop: removeEventListeners } = addEventListeners(
configuration,
window,

@@ -247,3 +254,3 @@ [DOM_EVENT.CLICK, DOM_EVENT.MOUSE_DOWN, DOM_EVENT.KEY_DOWN, DOM_EVENT.TOUCH_START, DOM_EVENT.POINTER_DOWN],

if (evt.type === DOM_EVENT.POINTER_DOWN) {
sendTimingIfPointerIsNotCancelled(timing)
sendTimingIfPointerIsNotCancelled(configuration, timing)
} else {

@@ -262,4 +269,5 @@ sendTiming(timing)

*/
function sendTimingIfPointerIsNotCancelled(timing: RumFirstInputTiming) {
function sendTimingIfPointerIsNotCancelled(configuration: RumConfiguration, timing: RumFirstInputTiming) {
addEventListeners(
configuration,
window,

@@ -266,0 +274,0 @@ [DOM_EVENT.POINTER_UP, DOM_EVENT.POINTER_CANCEL],

import { Observable, throttle, addEventListener, DOM_EVENT } from '@datadog/browser-core'
import type { RumConfiguration } from '../domain/configuration'

@@ -10,5 +11,5 @@ export interface ViewportDimension {

export function initViewportObservable() {
export function initViewportObservable(configuration: RumConfiguration) {
if (!viewportObservable) {
viewportObservable = createViewportObservable()
viewportObservable = createViewportObservable(configuration)
}

@@ -18,3 +19,3 @@ return viewportObservable

export function createViewportObservable() {
export function createViewportObservable(configuration: RumConfiguration) {
const observable = new Observable<ViewportDimension>(() => {

@@ -25,3 +26,4 @@ const { throttled: updateDimension } = throttle(() => {

return addEventListener(window, DOM_EVENT.RESIZE, updateDimension, { capture: true, passive: true }).stop
return addEventListener(configuration, window, DOM_EVENT.RESIZE, updateDimension, { capture: true, passive: true })
.stop
})

@@ -28,0 +30,0 @@

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

ci_test: ciTestContext,
display: getDisplayContext(),
display: getDisplayContext(configuration),
}

@@ -159,0 +159,0 @@

@@ -29,2 +29,3 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core'

excludedActivityUrls?: MatchOption[] | undefined
workerUrl?: string

@@ -76,2 +77,3 @@ // tracing options

excludedActivityUrls: MatchOption[]
workerUrl: string | undefined
applicationId: string

@@ -153,2 +155,3 @@ defaultPrivacyLevel: DefaultPrivacyLevel

excludedActivityUrls: initConfiguration.excludedActivityUrls ?? [],
workerUrl: initConfiguration.workerUrl,
trackUserInteractions: trackUserInteractions || trackFrustrations,

@@ -296,2 +299,3 @@ trackFrustrations,

Array.isArray(configuration.excludedActivityUrls) && configuration.excludedActivityUrls.length > 0,
use_worker_url: !!configuration.workerUrl,
track_frustrations: configuration.trackFrustrations,

@@ -298,0 +302,0 @@ track_views_manually: configuration.trackViewsManually,

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

import type { RumConfiguration } from '../configuration'
import { getViewportDimension, initViewportObservable } from '../../browser/viewportObservable'

@@ -6,6 +7,6 @@

export function getDisplayContext() {
export function getDisplayContext(configuration: RumConfiguration) {
if (!viewport) {
viewport = getViewportDimension()
stopListeners = initViewportObservable().subscribe((viewportDimension) => {
stopListeners = initViewportObservable(configuration).subscribe((viewportDimension) => {
viewport = viewportDimension

@@ -12,0 +13,0 @@ }).unsubscribe

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

} from '@datadog/browser-core'
import type { RumConfiguration } from '../configuration'
import type { PageStateServerEntry } from '../../rawRumEvent.types'

@@ -39,2 +40,3 @@

export function startPageStateHistory(
configuration: RumConfiguration,
maxPageStateEntriesSelectable = MAX_PAGE_STATE_ENTRIES_SELECTABLE

@@ -48,2 +50,3 @@ ): PageStateHistory {

const { stop: stopEventListeners } = addEventListeners(
configuration,
window,

@@ -50,0 +53,0 @@ [

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

export function trackXhr(lifeCycle: LifeCycle, configuration: RumConfiguration, tracer: Tracer) {
const subscription = initXhrObservable().subscribe((rawContext) => {
const subscription = initXhrObservable(configuration).subscribe((rawContext) => {
const context = rawContext as RumXhrStartContext | RumXhrCompleteContext

@@ -76,0 +76,0 @@ if (!isAllowedRequestUrl(configuration, context.url)) {

@@ -102,3 +102,3 @@ import { cssEscape } from '@datadog/browser-core'

return `${element.tagName}.${cssEscape(className)}`
return `${cssEscape(element.tagName)}.${cssEscape(className)}`
}

@@ -109,3 +109,3 @@ }

function getTagNameSelector(element: Element): string {
return element.tagName
return cssEscape(element.tagName)
}

@@ -130,3 +130,3 @@

if (element.hasAttribute(attributeName)) {
return `${element.tagName}[${attributeName}="${cssEscape(element.getAttribute(attributeName)!)}"]`
return `${cssEscape(element.tagName)}[${attributeName}="${cssEscape(element.getAttribute(attributeName)!)}"]`
}

@@ -147,3 +147,3 @@ }

return `${element.tagName}:nth-of-type(${elementIndex})`
return `${cssEscape(element.tagName)}:nth-of-type(${elementIndex})`
}

@@ -150,0 +150,0 @@

import { addEventListener, DOM_EVENT } from '@datadog/browser-core'
import type { RumConfiguration } from '../../configuration'

@@ -14,3 +15,6 @@ export type MouseEventOnElement = PointerEvent & { target: Element }

export function listenActionEvents<ClickContext>({ onPointerDown, onPointerUp }: ActionEventsHooks<ClickContext>) {
export function listenActionEvents<ClickContext>(
configuration: RumConfiguration,
{ onPointerDown, onPointerUp }: ActionEventsHooks<ClickContext>
) {
let selectionEmptyAtPointerDown: boolean

@@ -25,2 +29,3 @@ let userActivity: UserActivity = {

addEventListener(
configuration,
window,

@@ -42,2 +47,3 @@ DOM_EVENT.POINTER_DOWN,

addEventListener(
configuration,
window,

@@ -54,2 +60,3 @@ DOM_EVENT.SELECTION_CHANGE,

addEventListener(
configuration,
window,

@@ -69,2 +76,3 @@ DOM_EVENT.POINTER_UP,

addEventListener(
configuration,
window,

@@ -71,0 +79,0 @@ DOM_EVENT.INPUT,

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

hadActivityOnPointerDown: () => boolean
}>({
}>(configuration, {
onPointerDown: (pointerDownEvent) =>

@@ -86,0 +86,0 @@ processPointerDown(configuration, lifeCycle, domMutationObservable, history, pointerDownEvent),

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

} from '@datadog/browser-core'
import type { RumConfiguration } from '../../configuration'
import type { RawRumErrorEvent } from '../../../rawRumEvent.types'

@@ -34,2 +35,3 @@ import { RumEventType } from '../../../rawRumEvent.types'

lifeCycle: LifeCycle,
configuration: RumConfiguration,
pageStateHistory: PageStateHistory,

@@ -42,3 +44,3 @@ featureFlagContexts: FeatureFlagContexts

trackRuntimeError(errorObservable)
trackReportError(errorObservable)
trackReportError(configuration, errorObservable)

@@ -45,0 +47,0 @@ errorObservable.subscribe((error) => lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error }))

import type { Observable, RawError } from '@datadog/browser-core'
import { clocksNow, ErrorHandling, ErrorSource, initReportObservable, RawReportType } from '@datadog/browser-core'
import type { RumConfiguration } from '../../configuration'
export function trackReportError(errorObservable: Observable<RawError>) {
const subscription = initReportObservable([RawReportType.cspViolation, RawReportType.intervention]).subscribe(
(reportError) =>
errorObservable.notify({
startClocks: clocksNow(),
message: reportError.message,
stack: reportError.stack,
type: reportError.subtype,
source: ErrorSource.REPORT,
handling: ErrorHandling.UNHANDLED,
})
export function trackReportError(configuration: RumConfiguration, errorObservable: Observable<RawError>) {
const subscription = initReportObservable(configuration, [
RawReportType.cspViolation,
RawReportType.intervention,
]).subscribe((reportError) =>
errorObservable.notify({
startClocks: clocksNow(),
message: reportError.message,
stack: reportError.stack,
type: reportError.subtype,
source: ErrorSource.REPORT,
handling: ErrorHandling.UNHANDLED,
})
)

@@ -16,0 +19,0 @@

import type { RelativeTime } from '@datadog/browser-core'
import { addEventListeners, DOM_EVENT } from '@datadog/browser-core'
import type { RumConfiguration } from '../../configuration'

@@ -7,3 +8,3 @@ let trackFirstHiddenSingleton: { timeStamp: RelativeTime } | undefined

export function trackFirstHidden(eventTarget: Window = window) {
export function trackFirstHidden(configuration: RumConfiguration, eventTarget: Window = window) {
if (!trackFirstHiddenSingleton) {

@@ -19,2 +20,3 @@ if (document.visibilityState === 'hidden') {

;({ stop: stopListeners } = addEventListeners(
configuration,
eventTarget,

@@ -21,0 +23,0 @@ [DOM_EVENT.PAGE_HIDE, DOM_EVENT.VISIBILITY_CHANGE],

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

import type { RumConfiguration } from '../../configuration'
import type { LifeCycle } from '../../lifeCycle'

@@ -51,2 +52,3 @@ import { LifeCycleEventType } from '../../lifeCycle'

lifeCycle: LifeCycle,
configuration: RumConfiguration,
webVitalTelemetryDebug: WebVitalTelemetryDebug,

@@ -67,3 +69,3 @@ setLoadEvent: (loadEnd: Duration) => void,

})
const { stop: stopFCPTracking } = trackFirstContentfulPaintTiming(lifeCycle, (firstContentfulPaint) =>
const { stop: stopFCPTracking } = trackFirstContentfulPaintTiming(lifeCycle, configuration, (firstContentfulPaint) =>
setTimings({ firstContentfulPaint })

@@ -73,2 +75,3 @@ )

lifeCycle,
configuration,
window,

@@ -86,2 +89,3 @@ (largestContentfulPaint, lcpElement) => {

lifeCycle,
configuration,
({ firstInputDelay, firstInputTime, firstInputTarget }) => {

@@ -143,4 +147,8 @@ webVitalTelemetryDebug.addWebVitalTelemetryDebug('FID', firstInputTarget, firstInputTime)

export function trackFirstContentfulPaintTiming(lifeCycle: LifeCycle, callback: (fcpTiming: RelativeTime) => void) {
const firstHidden = trackFirstHidden()
export function trackFirstContentfulPaintTiming(
lifeCycle: LifeCycle,
configuration: RumConfiguration,
callback: (fcpTiming: RelativeTime) => void
) {
const firstHidden = trackFirstHidden(configuration)
const { unsubscribe: stop } = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, (entries) => {

@@ -170,6 +178,7 @@ const fcpEntry = find(

lifeCycle: LifeCycle,
configuration: RumConfiguration,
eventTarget: Window,
callback: (lcpTiming: RelativeTime, lcpElement?: Element) => void
) {
const firstHidden = trackFirstHidden()
const firstHidden = trackFirstHidden(configuration)

@@ -181,2 +190,3 @@ // Ignore entries that come after the first user interaction. According to the documentation, the

const { stop: stopEventListener } = addEventListeners(
configuration,
eventTarget,

@@ -225,2 +235,3 @@ [DOM_EVENT.POINTER_DOWN, DOM_EVENT.KEY_DOWN],

lifeCycle: LifeCycle,
configuration: RumConfiguration,
callback: ({

@@ -236,3 +247,3 @@ firstInputDelay,

) {
const firstHidden = trackFirstHidden()
const firstHidden = trackFirstHidden(configuration)

@@ -239,0 +250,0 @@ const { unsubscribe: stop } = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, (entries) => {

import type { ClocksState, Duration, Observable, RelativeTime } from '@datadog/browser-core'
import {
ExperimentalFeature,
isExperimentalFeatureEnabled,
DOM_EVENT,

@@ -66,11 +64,9 @@ ONE_SECOND,

// This is to ensure that we have the depth data even if the user didn't scroll or if the view is not scrollable.
if (isExperimentalFeatureEnabled(ExperimentalFeature.SCROLLMAP)) {
const { scrollHeight, scrollDepth, scrollTop } = computeScrollValues()
const { scrollHeight, scrollDepth, scrollTop } = computeScrollValues()
scrollMetrics = {
maxDepth: scrollDepth,
maxDepthScrollHeight: scrollHeight,
maxDepthTime: newLoadingTime,
maxDepthScrollTop: scrollTop,
}
scrollMetrics = {
maxDepth: scrollDepth,
maxDepthScrollHeight: scrollHeight,
maxDepthTime: newLoadingTime,
maxDepthScrollTop: scrollTop,
}

@@ -82,2 +78,3 @@ scheduleViewUpdate()

const { stop: stopScrollMetricsTracking } = trackScrollMetrics(
configuration,
viewStart,

@@ -123,2 +120,3 @@ (newScrollMetrics) => {

export function trackScrollMetrics(
configuration: RumConfiguration,
viewStart: ClocksState,

@@ -128,5 +126,2 @@ callback: (scrollMetrics: ScrollMetrics) => void,

) {
if (!isExperimentalFeatureEnabled(ExperimentalFeature.SCROLLMAP)) {
return { stop: noop }
}
let maxDepth = 0

@@ -153,3 +148,5 @@ const handleScrollEvent = throttle(

const { stop } = addEventListener(window, DOM_EVENT.SCROLL, handleScrollEvent.throttled, { passive: true })
const { stop } = addEventListener(configuration, window, DOM_EVENT.SCROLL, handleScrollEvent.throttled, {
passive: true,
})

@@ -156,0 +153,0 @@ return {

@@ -215,3 +215,3 @@ import type { Duration, ClocksState, TimeStamp, Observable, Subscription, RelativeTime } from '@datadog/browser-core'

loadingType === ViewLoadingType.INITIAL_LOAD
? trackInitialViewTimings(lifeCycle, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate)
? trackInitialViewTimings(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate)
: { scheduleStop: noop, timings: {} as Timings }

@@ -218,0 +218,0 @@

@@ -38,7 +38,4 @@ import type { RelativeTime } from '@datadog/browser-core'

export function startRumSessionManager(configuration: RumConfiguration, lifeCycle: LifeCycle): RumSessionManager {
const sessionManager = startSessionManager(
// TODO - Improve configuration type and remove assertion
configuration.sessionStoreStrategyType!,
RUM_SESSION_KEY,
(rawTrackingType) => computeSessionState(configuration, rawTrackingType)
const sessionManager = startSessionManager(configuration, RUM_SESSION_KEY, (rawTrackingType) =>
computeSessionState(configuration, rawTrackingType)
)

@@ -45,0 +42,0 @@

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

const batch = new Batch(
createHttpRequest(endpointBuilder, configuration.batchBytesLimit, reportError),
createHttpRequest(configuration, endpointBuilder, configuration.batchBytesLimit, reportError),
flushController,

@@ -80,0 +80,0 @@ configuration.messageBytesLimit

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

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