Socket
Socket
Sign inDemoInstall

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 5.8.0 to 5.9.0

cjs/boot/preStartRum.d.ts

23

cjs/boot/rumPublicApi.d.ts

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

import type { Context, InitConfiguration, User, DeflateWorker, DeflateEncoderStreamId, DeflateEncoder } from '@datadog/browser-core';
import type { Context, User, DeflateWorker, DeflateEncoderStreamId, DeflateEncoder } from '@datadog/browser-core';
import type { LifeCycle } from '../domain/lifeCycle';

@@ -8,5 +8,4 @@ import type { ViewContexts } from '../domain/contexts/viewContexts';

import type { ViewOptions } from '../domain/view/trackViews';
import type { startRum } from './startRum';
import type { StartRum, StartRumResult } from './startRum';
export type RumPublicApi = ReturnType<typeof makeRumPublicApi>;
export type StartRum = typeof startRum;
export interface RecorderApi {

@@ -20,3 +19,3 @@ start: () => void;

}
interface RumPublicApiOptions {
export interface RumPublicApiOptions {
ignoreInitIfSyntheticsWillInjectRum?: boolean;

@@ -26,4 +25,15 @@ startDeflateWorker?: (configuration: RumConfiguration, source: string, onInitializationFailure: () => void) => DeflateWorker | undefined;

}
export declare function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderApi, { ignoreInitIfSyntheticsWillInjectRum, startDeflateWorker, createDeflateEncoder }?: RumPublicApiOptions): {
export interface Strategy {
init: (initConfiguration: RumInitConfiguration) => void;
initConfiguration: RumInitConfiguration | undefined;
getInternalContext: StartRumResult['getInternalContext'];
stopSession: StartRumResult['stopSession'];
addTiming: StartRumResult['addTiming'];
startView: StartRumResult['startView'];
addAction: StartRumResult['addAction'];
addError: StartRumResult['addError'];
addFeatureFlagEvaluation: StartRumResult['addFeatureFlagEvaluation'];
}
export declare function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderApi, options?: RumPublicApiOptions): {
init: (initConfiguration: RumInitConfiguration) => void;
setGlobalContextProperty: (key: any, value: any) => void;

@@ -35,3 +45,3 @@ removeGlobalContextProperty: (key: any) => void;

getInternalContext: (startTime?: number) => import("../domain/contexts/internalContext").InternalContext | undefined;
getInitConfiguration: () => InitConfiguration | undefined;
getInitConfiguration: () => RumInitConfiguration | undefined;
addAction: (name: string, context?: object) => void;

@@ -72,2 +82,1 @@ addError: (error: unknown, context?: object) => void;

};
export {};

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

var browser_core_1 = require("@datadog/browser-core");
var configuration_1 = require("../domain/configuration");
var commonContext_1 = require("../domain/contexts/commonContext");
var preStartRum_1 = require("./preStartRum");
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, startDeflateWorker = _b.startDeflateWorker, createDeflateEncoder = _b.createDeflateEncoder;
var isAlreadyInitialized = false;
function makeRumPublicApi(startRumImpl, recorderApi, options) {
if (options === void 0) { options = {}; }
var customerDataTrackerManager = (0, browser_core_1.createCustomerDataTrackerManager)(0 /* CustomerDataCompressionStatus.Unknown */);

@@ -18,83 +17,3 @@ var globalContextManager = (0, browser_core_1.createContextManager)(customerDataTrackerManager.getOrCreateTracker(2 /* CustomerDataType.GlobalContext */));

}
var getInternalContextStrategy = function () { return undefined; };
var getInitConfigurationStrategy = function () { return undefined; };
var stopSessionStrategy = browser_core_1.noop;
var bufferApiCalls = new browser_core_1.BoundedBuffer();
var addTimingStrategy = function (name, time) {
if (time === void 0) { time = (0, browser_core_1.timeStampNow)(); }
bufferApiCalls.add(function () { return addTimingStrategy(name, time); });
};
var startViewStrategy = function (options, startClocks) {
if (startClocks === void 0) { startClocks = (0, browser_core_1.clocksNow)(); }
bufferApiCalls.add(function () { return startViewStrategy(options, startClocks); });
};
var addActionStrategy = function (action, commonContext) {
if (commonContext === void 0) { commonContext = getCommonContext(); }
bufferApiCalls.add(function () { return addActionStrategy(action, commonContext); });
};
var addErrorStrategy = function (providedError, commonContext) {
if (commonContext === void 0) { commonContext = getCommonContext(); }
bufferApiCalls.add(function () { return addErrorStrategy(providedError, commonContext); });
};
var addFeatureFlagEvaluationStrategy = function (key, value) {
bufferApiCalls.add(function () { return addFeatureFlagEvaluationStrategy(key, value); });
};
var deflateWorker;
function initRum(initConfiguration) {
if (!initConfiguration) {
browser_core_1.display.error('Missing configuration');
return;
}
// This function should be available, regardless of initialization success.
getInitConfigurationStrategy = function () { return (0, browser_core_1.deepClone)(initConfiguration); };
// If we are in a Synthetics test configured to automatically inject a RUM instance, we want to
// completely discard the customer application RUM instance by ignoring their init() call. But,
// we should not ignore the init() call from the Synthetics-injected RUM instance, so the
// internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
if (ignoreInitIfSyntheticsWillInjectRum && (0, browser_core_1.willSyntheticsInjectRum)()) {
return;
}
var eventBridgeAvailable = (0, browser_core_1.canUseEventBridge)();
if (eventBridgeAvailable) {
initConfiguration = overrideInitConfigurationForBridge(initConfiguration);
}
if (!canInitRum(initConfiguration)) {
return;
}
var configuration = (0, configuration_1.validateAndBuildRumConfiguration)(initConfiguration);
if (!configuration) {
return;
}
if (!eventBridgeAvailable && !configuration.sessionStoreStrategyType) {
browser_core_1.display.warn('No storage available for session. We will not send any data.');
return;
}
if (configuration.compressIntakeRequests && !eventBridgeAvailable && startDeflateWorker) {
deflateWorker = startDeflateWorker(configuration, 'Datadog RUM',
// Worker initialization can fail asynchronously, especially in Firefox where even CSP
// issues are reported asynchronously. For now, the SDK will continue its execution even if
// data won't be sent to Datadog. We could improve this behavior in the future.
browser_core_1.noop);
if (!deflateWorker) {
// `startDeflateWorker` should have logged an error message explaining the issue
return;
}
}
if (!configuration.trackViewsManually) {
doStartRum(initConfiguration, configuration);
}
else {
// drain beforeInitCalls by buffering them until we start RUM
// if we get a startView, drain re-buffered calls before continuing to drain beforeInitCalls
// in order to ensure that calls are processed in order
var beforeInitCalls = bufferApiCalls;
bufferApiCalls = new browser_core_1.BoundedBuffer();
startViewStrategy = function (options) {
doStartRum(initConfiguration, configuration, options);
};
beforeInitCalls.drain();
}
isAlreadyInitialized = true;
}
function doStartRum(initConfiguration, configuration, initialViewOptions) {
var strategy = (0, preStartRum_1.createPreStartStrategy)(options, getCommonContext, function (initConfiguration, configuration, deflateWorker, initialViewOptions) {
if (initConfiguration.storeContextsAcrossPages) {

@@ -105,15 +24,15 @@ (0, browser_core_1.storeContextManager)(configuration, globalContextManager, RUM_STORAGE_KEY, 2 /* CustomerDataType.GlobalContext */);

customerDataTrackerManager.setCompressionStatus(deflateWorker ? 1 /* CustomerDataCompressionStatus.Enabled */ : 2 /* CustomerDataCompressionStatus.Disabled */);
var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && createDeflateEncoder
? function (streamId) { return createDeflateEncoder(configuration, deflateWorker, streamId); }
var startRumResult = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && options.createDeflateEncoder
? function (streamId) { return options.createDeflateEncoder(configuration, deflateWorker, streamId); }
: browser_core_1.createIdentityEncoder);
(startViewStrategy = startRumResults.startView, addActionStrategy = startRumResults.addAction, addErrorStrategy = startRumResults.addError, addTimingStrategy = startRumResults.addTiming, addFeatureFlagEvaluationStrategy = startRumResults.addFeatureFlagEvaluation, getInternalContextStrategy = startRumResults.getInternalContext, stopSessionStrategy = startRumResults.stopSession);
recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts, deflateWorker);
bufferApiCalls.drain();
}
recorderApi.onRumStart(startRumResult.lifeCycle, configuration, startRumResult.session, startRumResult.viewContexts, deflateWorker);
strategy = createPostStartStrategy(initConfiguration, startRumResult);
return startRumResult;
});
var startView = (0, browser_core_1.monitor)(function (options) {
var sanitizedOptions = typeof options === 'object' ? options : { name: options };
startViewStrategy(sanitizedOptions);
strategy.startView(sanitizedOptions);
});
var rumPublicApi = (0, browser_core_1.makePublicApi)({
init: (0, browser_core_1.monitor)(initRum),
init: (0, browser_core_1.monitor)(function (initConfiguration) { return strategy.init(initConfiguration); }),
setGlobalContextProperty: (0, browser_core_1.monitor)(function (key, value) { return globalContextManager.setContextProperty(key, value); }),

@@ -124,6 +43,6 @@ removeGlobalContextProperty: (0, browser_core_1.monitor)(function (key) { return globalContextManager.removeContextProperty(key); }),

clearGlobalContext: (0, browser_core_1.monitor)(function () { return globalContextManager.clearContext(); }),
getInternalContext: (0, browser_core_1.monitor)(function (startTime) { return getInternalContextStrategy(startTime); }),
getInitConfiguration: (0, browser_core_1.monitor)(function () { return getInitConfigurationStrategy(); }),
getInternalContext: (0, browser_core_1.monitor)(function (startTime) { return strategy.getInternalContext(startTime); }),
getInitConfiguration: (0, browser_core_1.monitor)(function () { return (0, browser_core_1.deepClone)(strategy.initConfiguration); }),
addAction: (0, browser_core_1.monitor)(function (name, context) {
addActionStrategy({
strategy.addAction({
name: (0, browser_core_1.sanitize)(name),

@@ -138,3 +57,3 @@ context: (0, browser_core_1.sanitize)(context),

(0, browser_core_1.callMonitored)(function () {
addErrorStrategy({
strategy.addError({
error: error, // Do not sanitize error here, it is needed unserialized by computeRawError()

@@ -160,3 +79,3 @@ handlingStack: handlingStack,

// TODO: next major decide to drop relative time support or update its behaviour
addTimingStrategy((0, browser_core_1.sanitize)(name), time);
strategy.addTiming((0, browser_core_1.sanitize)(name), time);
}),

@@ -178,3 +97,3 @@ setUser: (0, browser_core_1.monitor)(function (newUser) {

stopSession: (0, browser_core_1.monitor)(function () {
stopSessionStrategy();
strategy.stopSession();
}),

@@ -185,3 +104,3 @@ /**

addFeatureFlagEvaluation: (0, browser_core_1.monitor)(function (key, value) {
addFeatureFlagEvaluationStrategy((0, browser_core_1.sanitize)(key), (0, browser_core_1.sanitize)(value));
strategy.addFeatureFlagEvaluation((0, browser_core_1.sanitize)(key), (0, browser_core_1.sanitize)(value));
}),

@@ -193,20 +112,12 @@ getSessionReplayLink: (0, browser_core_1.monitor)(function () { return recorderApi.getSessionReplayLink(); }),

return rumPublicApi;
function canInitRum(initConfiguration) {
if (isAlreadyInitialized) {
if (!initConfiguration.silentMultipleInit) {
browser_core_1.display.error('DD_RUM is already initialized.');
}
return false;
}
return true;
}
function overrideInitConfigurationForBridge(initConfiguration) {
return (0, browser_core_1.assign)({}, initConfiguration, {
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
clientToken: 'empty',
sessionSampleRate: 100,
});
}
}
exports.makeRumPublicApi = makeRumPublicApi;
function createPostStartStrategy(initConfiguration, startRumResult) {
return (0, browser_core_1.assign)({
init: function (initConfiguration) {
(0, browser_core_1.displayAlreadyInitializedError)('DD_RUM', initConfiguration);
},
initConfiguration: initConfiguration,
}, startRumResult);
}
//# sourceMappingURL=rumPublicApi.js.map

@@ -9,2 +9,4 @@ import type { Observable, RawError, DeflateEncoderStreamId, Encoder, CustomerDataTrackerManager } from '@datadog/browser-core';

import type { RecorderApi } from './rumPublicApi';
export type StartRum = typeof startRum;
export type StartRumResult = ReturnType<StartRum>;
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, getCommonContext: () => CommonContext, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder): {

@@ -11,0 +13,0 @@ addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;

@@ -79,3 +79,4 @@ "use strict";

(0, requestCollection_1.startRequestCollection)(lifeCycle, configuration, session);
(0, performanceCollection_1.startPerformanceCollection)(lifeCycle, configuration);
var stopPerformanceCollection = (0, performanceCollection_1.startPerformanceCollection)(lifeCycle, configuration).stop;
cleanupTasks.push(stopPerformanceCollection);
var internalContext = (0, internalContext_1.startInternalContext)(configuration.applicationId, session, viewContexts, actionContexts, urlContexts);

@@ -82,0 +83,0 @@ return {

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

export declare function supportPerformanceTimingEvent(entryType: RumPerformanceEntryType): boolean;
export declare function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration): void;
export declare function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration): {
stop: () => void;
};
export declare function retrieveInitialDocumentResourceTiming(configuration: RumConfiguration, callback: (timing: RumPerformanceResourceTiming) => void): void;

@@ -108,0 +110,0 @@ export type RelativePerformanceTiming = {

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

function startPerformanceCollection(lifeCycle, configuration) {
var cleanupTasks = [];
retrieveInitialDocumentResourceTiming(configuration, function (timing) {

@@ -70,2 +71,3 @@ handleRumPerformanceEntries(lifeCycle, configuration, [timing]);

});
cleanupTasks.push(function () { return observer.disconnect(); });
});

@@ -78,9 +80,11 @@ }

}
var mainObserver = new PerformanceObserver(handlePerformanceEntryList_1);
mainObserver.observe({ entryTypes: mainEntries });
var mainObserver_1 = new PerformanceObserver(handlePerformanceEntryList_1);
mainObserver_1.observe({ entryTypes: mainEntries });
cleanupTasks.push(function () { return mainObserver_1.disconnect(); });
if (supportPerformanceObject() && 'addEventListener' in performance) {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
(0, browser_core_1.addEventListener)(configuration, performance, 'resourcetimingbufferfull', function () {
var removePerformanceListener = (0, browser_core_1.addEventListener)(configuration, performance, 'resourcetimingbufferfull', function () {
performance.clearResourceTimings();
});
}).stop;
cleanupTasks.push(removePerformanceListener);
}

@@ -94,6 +98,12 @@ }

if (!supportPerformanceTimingEvent(RumPerformanceEntryType.FIRST_INPUT)) {
retrieveFirstInputTiming(configuration, function (timing) {
var stopFirstInputTiming = retrieveFirstInputTiming(configuration, function (timing) {
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);
});
}).stop;
cleanupTasks.push(stopFirstInputTiming);
}
return {
stop: function () {
cleanupTasks.forEach(function (task) { return task(); });
},
};
}

@@ -169,2 +179,3 @@ exports.startPerformanceCollection = startPerformanceCollection;

}, { passive: true, capture: true }).stop;
return { stop: removeEventListeners };
/**

@@ -171,0 +182,0 @@ * Pointer events are a special case, because they can trigger main or compositor thread behavior.

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

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

@@ -62,0 +62,0 @@ application: {

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

function trackLargestContentfulPaint(lifeCycle, configuration, firstHidden, eventTarget, callback) {
// Ignore entries that come after the first user interaction. According to the documentation, the
// Ignore entries that come after the first user interaction. According to the documentation, the
// browser should not send largest-contentful-paint entries after a user interact with the page,

@@ -27,2 +27,3 @@ // but the web-vitals reference implementation uses this as a safeguard.

}, { capture: true, once: true }).stop;
var biggestLcpSize = 0;
var unsubscribeLifeCycle = lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {

@@ -33,3 +34,6 @@ var lcpEntry = (0, browser_core_1.findLast)(entries, function (entry) {

entry.startTime < firstHidden.timeStamp &&
entry.startTime < exports.LCP_MAXIMUM_DELAY;
entry.startTime < exports.LCP_MAXIMUM_DELAY &&
// Ensure to get the LCP entry with the biggest size, see
// https://bugs.chromium.org/p/chromium/issues/detail?id=1516655
entry.size > biggestLcpSize;
});

@@ -50,2 +54,3 @@ if (lcpEntry) {

});
biggestLcpSize = lcpEntry.size;
}

@@ -52,0 +57,0 @@ }).unsubscribe;

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

export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi';
export { RumPublicApi, makeRumPublicApi, RecorderApi } from './boot/rumPublicApi';
export { StartRum } from './boot/startRum';
export { RumEvent, RumActionEvent, CommonProperties, RumErrorEvent, RumViewEvent, RumResourceEvent, RumLongTaskEvent, } from './rumEvent.types';

@@ -3,0 +4,0 @@ export { RumLongTaskEventDomainContext, RumErrorEventDomainContext, RumOtherResourceEventDomainContext, RumXhrResourceEventDomainContext, RumFetchResourceEventDomainContext, RumActionEventDomainContext, RumViewEventDomainContext, RumEventDomainContext, } from './domainContext.types';

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

import type { Context, InitConfiguration, User, DeflateWorker, DeflateEncoderStreamId, DeflateEncoder } from '@datadog/browser-core';
import type { Context, User, DeflateWorker, DeflateEncoderStreamId, DeflateEncoder } from '@datadog/browser-core';
import type { LifeCycle } from '../domain/lifeCycle';

@@ -8,5 +8,4 @@ import type { ViewContexts } from '../domain/contexts/viewContexts';

import type { ViewOptions } from '../domain/view/trackViews';
import type { startRum } from './startRum';
import type { StartRum, StartRumResult } from './startRum';
export type RumPublicApi = ReturnType<typeof makeRumPublicApi>;
export type StartRum = typeof startRum;
export interface RecorderApi {

@@ -20,3 +19,3 @@ start: () => void;

}
interface RumPublicApiOptions {
export interface RumPublicApiOptions {
ignoreInitIfSyntheticsWillInjectRum?: boolean;

@@ -26,4 +25,15 @@ startDeflateWorker?: (configuration: RumConfiguration, source: string, onInitializationFailure: () => void) => DeflateWorker | undefined;

}
export declare function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderApi, { ignoreInitIfSyntheticsWillInjectRum, startDeflateWorker, createDeflateEncoder }?: RumPublicApiOptions): {
export interface Strategy {
init: (initConfiguration: RumInitConfiguration) => void;
initConfiguration: RumInitConfiguration | undefined;
getInternalContext: StartRumResult['getInternalContext'];
stopSession: StartRumResult['stopSession'];
addTiming: StartRumResult['addTiming'];
startView: StartRumResult['startView'];
addAction: StartRumResult['addAction'];
addError: StartRumResult['addError'];
addFeatureFlagEvaluation: StartRumResult['addFeatureFlagEvaluation'];
}
export declare function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderApi, options?: RumPublicApiOptions): {
init: (initConfiguration: RumInitConfiguration) => void;
setGlobalContextProperty: (key: any, value: any) => void;

@@ -35,3 +45,3 @@ removeGlobalContextProperty: (key: any) => void;

getInternalContext: (startTime?: number) => import("../domain/contexts/internalContext").InternalContext | undefined;
getInitConfiguration: () => InitConfiguration | undefined;
getInitConfiguration: () => RumInitConfiguration | undefined;
addAction: (name: string, context?: object) => void;

@@ -72,2 +82,1 @@ addError: (error: unknown, context?: object) => void;

};
export {};

@@ -1,8 +0,7 @@

import { noop, willSyntheticsInjectRum, assign, BoundedBuffer, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, checkUser, sanitizeUser, sanitize, createIdentityEncoder, createCustomerDataTrackerManager, storeContextManager, } from '@datadog/browser-core';
import { validateAndBuildRumConfiguration } from '../domain/configuration';
import { assign, createContextManager, deepClone, makePublicApi, monitor, clocksNow, callMonitored, createHandlingStack, checkUser, sanitizeUser, sanitize, createIdentityEncoder, createCustomerDataTrackerManager, storeContextManager, displayAlreadyInitializedError, } from '@datadog/browser-core';
import { buildCommonContext } from '../domain/contexts/commonContext';
import { createPreStartStrategy } from './preStartRum';
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, startDeflateWorker = _b.startDeflateWorker, createDeflateEncoder = _b.createDeflateEncoder;
var isAlreadyInitialized = false;
export function makeRumPublicApi(startRumImpl, recorderApi, options) {
if (options === void 0) { options = {}; }
var customerDataTrackerManager = createCustomerDataTrackerManager(0 /* CustomerDataCompressionStatus.Unknown */);

@@ -14,83 +13,3 @@ var globalContextManager = createContextManager(customerDataTrackerManager.getOrCreateTracker(2 /* CustomerDataType.GlobalContext */));

}
var getInternalContextStrategy = function () { return undefined; };
var getInitConfigurationStrategy = function () { return undefined; };
var stopSessionStrategy = noop;
var bufferApiCalls = new BoundedBuffer();
var addTimingStrategy = function (name, time) {
if (time === void 0) { time = timeStampNow(); }
bufferApiCalls.add(function () { return addTimingStrategy(name, time); });
};
var startViewStrategy = function (options, startClocks) {
if (startClocks === void 0) { startClocks = clocksNow(); }
bufferApiCalls.add(function () { return startViewStrategy(options, startClocks); });
};
var addActionStrategy = function (action, commonContext) {
if (commonContext === void 0) { commonContext = getCommonContext(); }
bufferApiCalls.add(function () { return addActionStrategy(action, commonContext); });
};
var addErrorStrategy = function (providedError, commonContext) {
if (commonContext === void 0) { commonContext = getCommonContext(); }
bufferApiCalls.add(function () { return addErrorStrategy(providedError, commonContext); });
};
var addFeatureFlagEvaluationStrategy = function (key, value) {
bufferApiCalls.add(function () { return addFeatureFlagEvaluationStrategy(key, value); });
};
var deflateWorker;
function initRum(initConfiguration) {
if (!initConfiguration) {
display.error('Missing configuration');
return;
}
// This function should be available, regardless of initialization success.
getInitConfigurationStrategy = function () { return deepClone(initConfiguration); };
// If we are in a Synthetics test configured to automatically inject a RUM instance, we want to
// completely discard the customer application RUM instance by ignoring their init() call. But,
// we should not ignore the init() call from the Synthetics-injected RUM instance, so the
// internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
if (ignoreInitIfSyntheticsWillInjectRum && willSyntheticsInjectRum()) {
return;
}
var eventBridgeAvailable = canUseEventBridge();
if (eventBridgeAvailable) {
initConfiguration = overrideInitConfigurationForBridge(initConfiguration);
}
if (!canInitRum(initConfiguration)) {
return;
}
var configuration = validateAndBuildRumConfiguration(initConfiguration);
if (!configuration) {
return;
}
if (!eventBridgeAvailable && !configuration.sessionStoreStrategyType) {
display.warn('No storage available for session. We will not send any data.');
return;
}
if (configuration.compressIntakeRequests && !eventBridgeAvailable && startDeflateWorker) {
deflateWorker = startDeflateWorker(configuration, 'Datadog RUM',
// Worker initialization can fail asynchronously, especially in Firefox where even CSP
// issues are reported asynchronously. For now, the SDK will continue its execution even if
// data won't be sent to Datadog. We could improve this behavior in the future.
noop);
if (!deflateWorker) {
// `startDeflateWorker` should have logged an error message explaining the issue
return;
}
}
if (!configuration.trackViewsManually) {
doStartRum(initConfiguration, configuration);
}
else {
// drain beforeInitCalls by buffering them until we start RUM
// if we get a startView, drain re-buffered calls before continuing to drain beforeInitCalls
// in order to ensure that calls are processed in order
var beforeInitCalls = bufferApiCalls;
bufferApiCalls = new BoundedBuffer();
startViewStrategy = function (options) {
doStartRum(initConfiguration, configuration, options);
};
beforeInitCalls.drain();
}
isAlreadyInitialized = true;
}
function doStartRum(initConfiguration, configuration, initialViewOptions) {
var strategy = createPreStartStrategy(options, getCommonContext, function (initConfiguration, configuration, deflateWorker, initialViewOptions) {
if (initConfiguration.storeContextsAcrossPages) {

@@ -101,15 +20,15 @@ storeContextManager(configuration, globalContextManager, RUM_STORAGE_KEY, 2 /* CustomerDataType.GlobalContext */);

customerDataTrackerManager.setCompressionStatus(deflateWorker ? 1 /* CustomerDataCompressionStatus.Enabled */ : 2 /* CustomerDataCompressionStatus.Disabled */);
var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && createDeflateEncoder
? function (streamId) { return createDeflateEncoder(configuration, deflateWorker, streamId); }
var startRumResult = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && options.createDeflateEncoder
? function (streamId) { return options.createDeflateEncoder(configuration, deflateWorker, streamId); }
: createIdentityEncoder);
(startViewStrategy = startRumResults.startView, addActionStrategy = startRumResults.addAction, addErrorStrategy = startRumResults.addError, addTimingStrategy = startRumResults.addTiming, addFeatureFlagEvaluationStrategy = startRumResults.addFeatureFlagEvaluation, getInternalContextStrategy = startRumResults.getInternalContext, stopSessionStrategy = startRumResults.stopSession);
recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts, deflateWorker);
bufferApiCalls.drain();
}
recorderApi.onRumStart(startRumResult.lifeCycle, configuration, startRumResult.session, startRumResult.viewContexts, deflateWorker);
strategy = createPostStartStrategy(initConfiguration, startRumResult);
return startRumResult;
});
var startView = monitor(function (options) {
var sanitizedOptions = typeof options === 'object' ? options : { name: options };
startViewStrategy(sanitizedOptions);
strategy.startView(sanitizedOptions);
});
var rumPublicApi = makePublicApi({
init: monitor(initRum),
init: monitor(function (initConfiguration) { return strategy.init(initConfiguration); }),
setGlobalContextProperty: monitor(function (key, value) { return globalContextManager.setContextProperty(key, value); }),

@@ -120,6 +39,6 @@ removeGlobalContextProperty: monitor(function (key) { return globalContextManager.removeContextProperty(key); }),

clearGlobalContext: monitor(function () { return globalContextManager.clearContext(); }),
getInternalContext: monitor(function (startTime) { return getInternalContextStrategy(startTime); }),
getInitConfiguration: monitor(function () { return getInitConfigurationStrategy(); }),
getInternalContext: monitor(function (startTime) { return strategy.getInternalContext(startTime); }),
getInitConfiguration: monitor(function () { return deepClone(strategy.initConfiguration); }),
addAction: monitor(function (name, context) {
addActionStrategy({
strategy.addAction({
name: sanitize(name),

@@ -134,3 +53,3 @@ context: sanitize(context),

callMonitored(function () {
addErrorStrategy({
strategy.addError({
error: error, // Do not sanitize error here, it is needed unserialized by computeRawError()

@@ -156,3 +75,3 @@ handlingStack: handlingStack,

// TODO: next major decide to drop relative time support or update its behaviour
addTimingStrategy(sanitize(name), time);
strategy.addTiming(sanitize(name), time);
}),

@@ -174,3 +93,3 @@ setUser: monitor(function (newUser) {

stopSession: monitor(function () {
stopSessionStrategy();
strategy.stopSession();
}),

@@ -181,3 +100,3 @@ /**

addFeatureFlagEvaluation: monitor(function (key, value) {
addFeatureFlagEvaluationStrategy(sanitize(key), sanitize(value));
strategy.addFeatureFlagEvaluation(sanitize(key), sanitize(value));
}),

@@ -189,19 +108,11 @@ getSessionReplayLink: monitor(function () { return recorderApi.getSessionReplayLink(); }),

return rumPublicApi;
function canInitRum(initConfiguration) {
if (isAlreadyInitialized) {
if (!initConfiguration.silentMultipleInit) {
display.error('DD_RUM is already initialized.');
}
return false;
}
return true;
}
function overrideInitConfigurationForBridge(initConfiguration) {
return assign({}, initConfiguration, {
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
clientToken: 'empty',
sessionSampleRate: 100,
});
}
}
function createPostStartStrategy(initConfiguration, startRumResult) {
return assign({
init: function (initConfiguration) {
displayAlreadyInitializedError('DD_RUM', initConfiguration);
},
initConfiguration: initConfiguration,
}, startRumResult);
}
//# sourceMappingURL=rumPublicApi.js.map

@@ -9,2 +9,4 @@ import type { Observable, RawError, DeflateEncoderStreamId, Encoder, CustomerDataTrackerManager } from '@datadog/browser-core';

import type { RecorderApi } from './rumPublicApi';
export type StartRum = typeof startRum;
export type StartRumResult = ReturnType<StartRum>;
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, getCommonContext: () => CommonContext, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder): {

@@ -11,0 +13,0 @@ addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;

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

startRequestCollection(lifeCycle, configuration, session);
startPerformanceCollection(lifeCycle, configuration);
var stopPerformanceCollection = startPerformanceCollection(lifeCycle, configuration).stop;
cleanupTasks.push(stopPerformanceCollection);
var internalContext = startInternalContext(configuration.applicationId, session, viewContexts, actionContexts, urlContexts);

@@ -79,0 +80,0 @@ return {

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

export declare function supportPerformanceTimingEvent(entryType: RumPerformanceEntryType): boolean;
export declare function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration): void;
export declare function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration): {
stop: () => void;
};
export declare function retrieveInitialDocumentResourceTiming(configuration: RumConfiguration, callback: (timing: RumPerformanceResourceTiming) => void): void;

@@ -108,0 +110,0 @@ export type RelativePerformanceTiming = {

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

export function startPerformanceCollection(lifeCycle, configuration) {
var cleanupTasks = [];
retrieveInitialDocumentResourceTiming(configuration, function (timing) {

@@ -66,2 +67,3 @@ handleRumPerformanceEntries(lifeCycle, configuration, [timing]);

});
cleanupTasks.push(function () { return observer.disconnect(); });
});

@@ -74,9 +76,11 @@ }

}
var mainObserver = new PerformanceObserver(handlePerformanceEntryList_1);
mainObserver.observe({ entryTypes: mainEntries });
var mainObserver_1 = new PerformanceObserver(handlePerformanceEntryList_1);
mainObserver_1.observe({ entryTypes: mainEntries });
cleanupTasks.push(function () { return mainObserver_1.disconnect(); });
if (supportPerformanceObject() && 'addEventListener' in performance) {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
addEventListener(configuration, performance, 'resourcetimingbufferfull', function () {
var removePerformanceListener = addEventListener(configuration, performance, 'resourcetimingbufferfull', function () {
performance.clearResourceTimings();
});
}).stop;
cleanupTasks.push(removePerformanceListener);
}

@@ -90,6 +94,12 @@ }

if (!supportPerformanceTimingEvent(RumPerformanceEntryType.FIRST_INPUT)) {
retrieveFirstInputTiming(configuration, function (timing) {
var stopFirstInputTiming = retrieveFirstInputTiming(configuration, function (timing) {
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);
});
}).stop;
cleanupTasks.push(stopFirstInputTiming);
}
return {
stop: function () {
cleanupTasks.forEach(function (task) { return task(); });
},
};
}

@@ -163,2 +173,3 @@ export function retrieveInitialDocumentResourceTiming(configuration, callback) {

}, { passive: true, capture: true }).stop;
return { stop: removeEventListeners };
/**

@@ -165,0 +176,0 @@ * Pointer events are a special case, because they can trigger main or compositor thread behavior.

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

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

@@ -59,0 +59,0 @@ application: {

@@ -16,3 +16,3 @@ import { DOM_EVENT, ExperimentalFeature, ONE_MINUTE, addEventListeners, addTelemetryDebug, findLast, isExperimentalFeatureEnabled, relativeNow, } from '@datadog/browser-core';

export function trackLargestContentfulPaint(lifeCycle, configuration, firstHidden, eventTarget, callback) {
// Ignore entries that come after the first user interaction. According to the documentation, the
// Ignore entries that come after the first user interaction. According to the documentation, the
// browser should not send largest-contentful-paint entries after a user interact with the page,

@@ -24,2 +24,3 @@ // but the web-vitals reference implementation uses this as a safeguard.

}, { capture: true, once: true }).stop;
var biggestLcpSize = 0;
var unsubscribeLifeCycle = lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {

@@ -30,3 +31,6 @@ var lcpEntry = findLast(entries, function (entry) {

entry.startTime < firstHidden.timeStamp &&
entry.startTime < LCP_MAXIMUM_DELAY;
entry.startTime < LCP_MAXIMUM_DELAY &&
// Ensure to get the LCP entry with the biggest size, see
// https://bugs.chromium.org/p/chromium/issues/detail?id=1516655
entry.size > biggestLcpSize;
});

@@ -47,2 +51,3 @@ if (lcpEntry) {

});
biggestLcpSize = lcpEntry.size;
}

@@ -49,0 +54,0 @@ }).unsubscribe;

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

export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi';
export { RumPublicApi, makeRumPublicApi, RecorderApi } from './boot/rumPublicApi';
export { StartRum } from './boot/startRum';
export { RumEvent, RumActionEvent, CommonProperties, RumErrorEvent, RumViewEvent, RumResourceEvent, RumLongTaskEvent, } from './rumEvent.types';

@@ -3,0 +4,0 @@ export { RumLongTaskEventDomainContext, RumErrorEventDomainContext, RumOtherResourceEventDomainContext, RumXhrResourceEventDomainContext, RumFetchResourceEventDomainContext, RumActionEventDomainContext, RumViewEventDomainContext, RumEventDomainContext, } from './domainContext.types';

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

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

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

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

},
"gitHead": "450e621c48d00e8f50c97d6cc12c4ae7a7989daf"
"gitHead": "465eecbc937d9ee15e2f0c03c5c574fe3e909aed"
}
import type {
Context,
InitConfiguration,
TimeStamp,

@@ -12,7 +11,4 @@ RelativeTime,

import {
noop,
CustomerDataType,
willSyntheticsInjectRum,
assign,
BoundedBuffer,
createContextManager,

@@ -23,7 +19,4 @@ deepClone,

clocksNow,
timeStampNow,
display,
callMonitored,
createHandlingStack,
canUseEventBridge,
checkUser,

@@ -36,2 +29,3 @@ sanitizeUser,

storeContextManager,
displayAlreadyInitializedError,
} from '@datadog/browser-core'

@@ -44,13 +38,9 @@ import type { LifeCycle } from '../domain/lifeCycle'

import type { RumConfiguration, RumInitConfiguration } from '../domain/configuration'
import { validateAndBuildRumConfiguration } from '../domain/configuration'
import type { ViewOptions } from '../domain/view/trackViews'
import { buildCommonContext } from '../domain/contexts/commonContext'
import type { startRum } from './startRum'
import { createPreStartStrategy } from './preStartRum'
import type { StartRum, StartRumResult } from './startRum'
export type RumPublicApi = ReturnType<typeof makeRumPublicApi>
export type StartRum = typeof startRum
type StartRumResult = ReturnType<typeof startRum>
export interface RecorderApi {

@@ -70,3 +60,4 @@ start: () => void

}
interface RumPublicApiOptions {
export interface RumPublicApiOptions {
ignoreInitIfSyntheticsWillInjectRum?: boolean

@@ -87,9 +78,15 @@ startDeflateWorker?: (

export function makeRumPublicApi(
startRumImpl: StartRum,
recorderApi: RecorderApi,
{ ignoreInitIfSyntheticsWillInjectRum = true, startDeflateWorker, createDeflateEncoder }: RumPublicApiOptions = {}
) {
let isAlreadyInitialized = false
export interface Strategy {
init: (initConfiguration: RumInitConfiguration) => void
initConfiguration: RumInitConfiguration | undefined
getInternalContext: StartRumResult['getInternalContext']
stopSession: StartRumResult['stopSession']
addTiming: StartRumResult['addTiming']
startView: StartRumResult['startView']
addAction: StartRumResult['addAction']
addError: StartRumResult['addError']
addFeatureFlagEvaluation: StartRumResult['addFeatureFlagEvaluation']
}
export function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderApi, options: RumPublicApiOptions = {}) {
const customerDataTrackerManager = createCustomerDataTrackerManager(CustomerDataCompressionStatus.Unknown)

@@ -105,139 +102,42 @@ const globalContextManager = createContextManager(

let getInternalContextStrategy: StartRumResult['getInternalContext'] = () => undefined
let getInitConfigurationStrategy = (): InitConfiguration | undefined => undefined
let stopSessionStrategy: () => void = noop
let strategy = createPreStartStrategy(
options,
getCommonContext,
let bufferApiCalls = new BoundedBuffer()
let addTimingStrategy: StartRumResult['addTiming'] = (name, time = timeStampNow()) => {
bufferApiCalls.add(() => addTimingStrategy(name, time))
}
let startViewStrategy: StartRumResult['startView'] = (options, startClocks = clocksNow()) => {
bufferApiCalls.add(() => startViewStrategy(options, startClocks))
}
let addActionStrategy: StartRumResult['addAction'] = (action, commonContext = getCommonContext()) => {
bufferApiCalls.add(() => addActionStrategy(action, commonContext))
}
let addErrorStrategy: StartRumResult['addError'] = (providedError, commonContext = getCommonContext()) => {
bufferApiCalls.add(() => addErrorStrategy(providedError, commonContext))
}
(initConfiguration, configuration, deflateWorker, initialViewOptions) => {
if (initConfiguration.storeContextsAcrossPages) {
storeContextManager(configuration, globalContextManager, RUM_STORAGE_KEY, CustomerDataType.GlobalContext)
storeContextManager(configuration, userContextManager, RUM_STORAGE_KEY, CustomerDataType.User)
}
let addFeatureFlagEvaluationStrategy: StartRumResult['addFeatureFlagEvaluation'] = (key: string, value: any) => {
bufferApiCalls.add(() => addFeatureFlagEvaluationStrategy(key, value))
}
customerDataTrackerManager.setCompressionStatus(
deflateWorker ? CustomerDataCompressionStatus.Enabled : CustomerDataCompressionStatus.Disabled
)
let deflateWorker: DeflateWorker | undefined
const startRumResult = startRumImpl(
initConfiguration,
configuration,
recorderApi,
customerDataTrackerManager,
getCommonContext,
initialViewOptions,
deflateWorker && options.createDeflateEncoder
? (streamId) => options.createDeflateEncoder!(configuration, deflateWorker, streamId)
: createIdentityEncoder
)
function initRum(initConfiguration: RumInitConfiguration) {
if (!initConfiguration) {
display.error('Missing configuration')
return
}
// This function should be available, regardless of initialization success.
getInitConfigurationStrategy = () => deepClone<InitConfiguration>(initConfiguration)
// If we are in a Synthetics test configured to automatically inject a RUM instance, we want to
// completely discard the customer application RUM instance by ignoring their init() call. But,
// we should not ignore the init() call from the Synthetics-injected RUM instance, so the
// internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
if (ignoreInitIfSyntheticsWillInjectRum && willSyntheticsInjectRum()) {
return
}
const eventBridgeAvailable = canUseEventBridge()
if (eventBridgeAvailable) {
initConfiguration = overrideInitConfigurationForBridge(initConfiguration)
}
if (!canInitRum(initConfiguration)) {
return
}
const configuration = validateAndBuildRumConfiguration(initConfiguration)
if (!configuration) {
return
}
if (!eventBridgeAvailable && !configuration.sessionStoreStrategyType) {
display.warn('No storage available for session. We will not send any data.')
return
}
if (configuration.compressIntakeRequests && !eventBridgeAvailable && startDeflateWorker) {
deflateWorker = startDeflateWorker(
recorderApi.onRumStart(
startRumResult.lifeCycle,
configuration,
'Datadog RUM',
// Worker initialization can fail asynchronously, especially in Firefox where even CSP
// issues are reported asynchronously. For now, the SDK will continue its execution even if
// data won't be sent to Datadog. We could improve this behavior in the future.
noop
startRumResult.session,
startRumResult.viewContexts,
deflateWorker
)
if (!deflateWorker) {
// `startDeflateWorker` should have logged an error message explaining the issue
return
}
}
if (!configuration.trackViewsManually) {
doStartRum(initConfiguration, configuration)
} else {
// drain beforeInitCalls by buffering them until we start RUM
// if we get a startView, drain re-buffered calls before continuing to drain beforeInitCalls
// in order to ensure that calls are processed in order
const beforeInitCalls = bufferApiCalls
bufferApiCalls = new BoundedBuffer()
strategy = createPostStartStrategy(initConfiguration, startRumResult)
startViewStrategy = (options) => {
doStartRum(initConfiguration, configuration, options)
}
beforeInitCalls.drain()
return startRumResult
}
)
isAlreadyInitialized = true
}
function doStartRum(
initConfiguration: RumInitConfiguration,
configuration: RumConfiguration,
initialViewOptions?: ViewOptions
) {
if (initConfiguration.storeContextsAcrossPages) {
storeContextManager(configuration, globalContextManager, RUM_STORAGE_KEY, CustomerDataType.GlobalContext)
storeContextManager(configuration, userContextManager, RUM_STORAGE_KEY, CustomerDataType.User)
}
customerDataTrackerManager.setCompressionStatus(
deflateWorker ? CustomerDataCompressionStatus.Enabled : CustomerDataCompressionStatus.Disabled
)
const startRumResults = startRumImpl(
initConfiguration,
configuration,
recorderApi,
customerDataTrackerManager,
getCommonContext,
initialViewOptions,
deflateWorker && createDeflateEncoder
? (streamId) => createDeflateEncoder(configuration, deflateWorker!, streamId)
: createIdentityEncoder
)
;({
startView: startViewStrategy,
addAction: addActionStrategy,
addError: addErrorStrategy,
addTiming: addTimingStrategy,
addFeatureFlagEvaluation: addFeatureFlagEvaluationStrategy,
getInternalContext: getInternalContextStrategy,
stopSession: stopSessionStrategy,
} = startRumResults)
recorderApi.onRumStart(
startRumResults.lifeCycle,
configuration,
startRumResults.session,
startRumResults.viewContexts,
deflateWorker
)
bufferApiCalls.drain()
}
const startView: {

@@ -248,7 +148,7 @@ (name?: string): void

const sanitizedOptions = typeof options === 'object' ? options : { name: options }
startViewStrategy(sanitizedOptions)
strategy.startView(sanitizedOptions)
})
const rumPublicApi = makePublicApi({
init: monitor(initRum),
init: monitor((initConfiguration: RumInitConfiguration) => strategy.init(initConfiguration)),

@@ -265,7 +165,8 @@ setGlobalContextProperty: monitor((key, value) => globalContextManager.setContextProperty(key, value)),

getInternalContext: monitor((startTime?: number) => getInternalContextStrategy(startTime)),
getInitConfiguration: monitor(() => getInitConfigurationStrategy()),
getInternalContext: monitor((startTime?: number) => strategy.getInternalContext(startTime)),
getInitConfiguration: monitor(() => deepClone(strategy.initConfiguration)),
addAction: monitor((name: string, context?: object) => {
addActionStrategy({
strategy.addAction({
name: sanitize(name)!,

@@ -281,3 +182,3 @@ context: sanitize(context) as Context,

callMonitored(() => {
addErrorStrategy({
strategy.addError({
error, // Do not sanitize error here, it is needed unserialized by computeRawError()

@@ -304,3 +205,3 @@ handlingStack,

// TODO: next major decide to drop relative time support or update its behaviour
addTimingStrategy(sanitize(name)!, time as RelativeTime | TimeStamp | undefined)
strategy.addTiming(sanitize(name)!, time as RelativeTime | TimeStamp | undefined)
}),

@@ -328,3 +229,3 @@

stopSession: monitor(() => {
stopSessionStrategy()
strategy.stopSession()
}),

@@ -336,3 +237,3 @@

addFeatureFlagEvaluation: monitor((key: string, value: any) => {
addFeatureFlagEvaluationStrategy(sanitize(key)!, sanitize(value))
strategy.addFeatureFlagEvaluation(sanitize(key)!, sanitize(value))
}),

@@ -346,20 +247,14 @@

return rumPublicApi
}
function canInitRum(initConfiguration: RumInitConfiguration) {
if (isAlreadyInitialized) {
if (!initConfiguration.silentMultipleInit) {
display.error('DD_RUM is already initialized.')
}
return false
}
return true
}
function overrideInitConfigurationForBridge<C extends InitConfiguration>(initConfiguration: C): C {
return assign({}, initConfiguration, {
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
clientToken: 'empty',
sessionSampleRate: 100,
})
}
function createPostStartStrategy(initConfiguration: RumInitConfiguration, startRumResult: StartRumResult): Strategy {
return assign(
{
init: (initConfiguration: RumInitConfiguration) => {
displayAlreadyInitializedError('DD_RUM', initConfiguration)
},
initConfiguration,
},
startRumResult
)
}

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

export type StartRum = typeof startRum
export type StartRumResult = ReturnType<StartRum>
export function startRum(

@@ -159,3 +162,4 @@ initConfiguration: RumInitConfiguration,

startRequestCollection(lifeCycle, configuration, session)
startPerformanceCollection(lifeCycle, configuration)
const { stop: stopPerformanceCollection } = startPerformanceCollection(lifeCycle, configuration)
cleanupTasks.push(stopPerformanceCollection)

@@ -162,0 +166,0 @@ const internalContext = startInternalContext(

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

export function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration) {
const cleanupTasks: Array<() => void> = []
retrieveInitialDocumentResourceTiming(configuration, (timing) => {

@@ -199,2 +200,3 @@ handleRumPerformanceEntries(lifeCycle, configuration, [timing])

})
cleanupTasks.push(() => observer.disconnect())
})

@@ -209,8 +211,15 @@ } catch (e) {

mainObserver.observe({ entryTypes: mainEntries })
cleanupTasks.push(() => mainObserver.disconnect())
if (supportPerformanceObject() && 'addEventListener' in performance) {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
addEventListener(configuration, performance, 'resourcetimingbufferfull', () => {
performance.clearResourceTimings()
})
const { stop: removePerformanceListener } = addEventListener(
configuration,
performance,
'resourcetimingbufferfull',
() => {
performance.clearResourceTimings()
}
)
cleanupTasks.push(removePerformanceListener)
}

@@ -224,6 +233,12 @@ }

if (!supportPerformanceTimingEvent(RumPerformanceEntryType.FIRST_INPUT)) {
retrieveFirstInputTiming(configuration, (timing) => {
const { stop: stopFirstInputTiming } = retrieveFirstInputTiming(configuration, (timing) => {
handleRumPerformanceEntries(lifeCycle, configuration, [timing])
})
cleanupTasks.push(stopFirstInputTiming)
}
return {
stop: () => {
cleanupTasks.forEach((task) => task())
},
}
}

@@ -324,2 +339,4 @@

return { stop: removeEventListeners }
/**

@@ -326,0 +343,0 @@ * Pointer events are a special case, because they can trigger main or compositor thread behavior.

@@ -152,3 +152,3 @@ import { noop, ONE_MINUTE } from '@datadog/browser-core'

function computeViewInteractionCount() {
return getInteractionCount()! - previousInteractionCount
return getInteractionCount() - previousInteractionCount
}

@@ -155,0 +155,0 @@

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

) {
// Ignore entries that come after the first user interaction. According to the documentation, the
// Ignore entries that come after the first user interaction. According to the documentation, the
// browser should not send largest-contentful-paint entries after a user interact with the page,

@@ -62,2 +62,3 @@ // but the web-vitals reference implementation uses this as a safeguard.

let biggestLcpSize = 0
const { unsubscribe: unsubscribeLifeCycle } = lifeCycle.subscribe(

@@ -72,3 +73,6 @@ LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED,

entry.startTime < firstHidden.timeStamp &&
entry.startTime < LCP_MAXIMUM_DELAY
entry.startTime < LCP_MAXIMUM_DELAY &&
// Ensure to get the LCP entry with the biggest size, see
// https://bugs.chromium.org/p/chromium/issues/detail?id=1516655
entry.size > biggestLcpSize
)

@@ -96,2 +100,3 @@

})
biggestLcpSize = lcpEntry.size
}

@@ -98,0 +103,0 @@ }

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

export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi'
export { RumPublicApi, makeRumPublicApi, RecorderApi } from './boot/rumPublicApi'
export { StartRum } from './boot/startRum'
export {

@@ -3,0 +4,0 @@ RumEvent,

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