Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
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 4.5.0 to 4.6.0

cjs/domain/rumEventsCollection/error/trackReportError.d.ts

4

cjs/boot/rumPublicApi.d.ts

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

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

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

export declare type RumPublicApi = ReturnType<typeof makeRumPublicApi>;
export declare type StartRum = (configuration: RumConfiguration, internalMonitoring: InternalMonitoring, getCommonContext: () => CommonContext, recorderApi: RecorderApi, initialViewName?: string) => StartRumResult;
export declare type StartRum = (configuration: RumConfiguration, getCommonContext: () => CommonContext, recorderApi: RecorderApi, initialViewName?: string) => StartRumResult;
declare type StartRumResult = ReturnType<typeof startRum>;

@@ -12,0 +12,0 @@ export interface RecorderApi {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeRumPublicApi = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../rawRumEvent.types");
var syntheticsContext_1 = require("../domain/syntheticsContext");
var configuration_1 = require("../domain/configuration");
var buildEnv_1 = require("./buildEnv");
function makeRumPublicApi(startRumImpl, recorderApi, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.ignoreInitIfSyntheticsWillInjectRum, ignoreInitIfSyntheticsWillInjectRum = _c === void 0 ? true : _c;
var isAlreadyInitialized = false;
var globalContextManager = browser_core_1.createContextManager();
var globalContextManager = (0, browser_core_1.createContextManager)();
var user = {};

@@ -19,7 +16,7 @@ var getInternalContextStrategy = function () { return undefined; };

var addTimingStrategy = function (name, time) {
if (time === void 0) { time = browser_core_1.timeStampNow(); }
if (time === void 0) { time = (0, browser_core_1.timeStampNow)(); }
bufferApiCalls.add(function () { return addTimingStrategy(name, time); });
};
var startViewStrategy = function (name, startClocks) {
if (startClocks === void 0) { startClocks = browser_core_1.clocksNow(); }
if (startClocks === void 0) { startClocks = (0, browser_core_1.clocksNow)(); }
bufferApiCalls.add(function () { return startViewStrategy(name, startClocks); });

@@ -36,3 +33,3 @@ };

function clonedCommonContext() {
return browser_core_1.deepClone({
return (0, browser_core_1.deepClone)({
context: globalContextManager.get(),

@@ -47,6 +44,6 @@ user: user,

// internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
if (ignoreInitIfSyntheticsWillInjectRum && syntheticsContext_1.willSyntheticsInjectRum()) {
if (ignoreInitIfSyntheticsWillInjectRum && (0, syntheticsContext_1.willSyntheticsInjectRum)()) {
return;
}
if (browser_core_1.canUseEventBridge()) {
if ((0, browser_core_1.canUseEventBridge)()) {
initConfiguration = overrideInitConfigurationForBridge(initConfiguration);

@@ -60,9 +57,8 @@ }

}
var configuration = configuration_1.validateAndBuildRumConfiguration(initConfiguration);
var configuration = (0, configuration_1.validateAndBuildRumConfiguration)(initConfiguration);
if (!configuration) {
return;
}
var internalMonitoring = browser_core_1.startInternalMonitoring(configuration);
if (!configuration.trackViewsManually) {
doStartRum(configuration, internalMonitoring);
doStartRum(configuration);
}

@@ -76,11 +72,11 @@ else {

startViewStrategy = function (name) {
doStartRum(configuration, internalMonitoring, name);
doStartRum(configuration, name);
};
beforeInitCalls.drain();
}
getInitConfigurationStrategy = function () { return browser_core_1.deepClone(initConfiguration); };
getInitConfigurationStrategy = function () { return (0, browser_core_1.deepClone)(initConfiguration); };
isAlreadyInitialized = true;
}
function doStartRum(configuration, internalMonitoring, initialViewName) {
var startRumResults = startRumImpl(configuration, internalMonitoring, function () { return ({
function doStartRum(configuration, initialViewName) {
var startRumResults = startRumImpl(configuration, function () { return ({
user: user,

@@ -94,33 +90,33 @@ context: globalContextManager.get(),

}
var rumPublicApi = browser_core_1.makePublicApi(buildEnv_1.buildEnv, {
init: browser_core_1.monitor(initRum),
addRumGlobalContext: browser_core_1.monitor(globalContextManager.add),
removeRumGlobalContext: browser_core_1.monitor(globalContextManager.remove),
getRumGlobalContext: browser_core_1.monitor(globalContextManager.get),
setRumGlobalContext: browser_core_1.monitor(globalContextManager.set),
getInternalContext: browser_core_1.monitor(function (startTime) { return getInternalContextStrategy(startTime); }),
getInitConfiguration: browser_core_1.monitor(function () { return getInitConfigurationStrategy(); }),
addAction: browser_core_1.monitor(function (name, context) {
var rumPublicApi = (0, browser_core_1.makePublicApi)({
init: (0, browser_core_1.monitor)(initRum),
addRumGlobalContext: (0, browser_core_1.monitor)(globalContextManager.add),
removeRumGlobalContext: (0, browser_core_1.monitor)(globalContextManager.remove),
getRumGlobalContext: (0, browser_core_1.monitor)(globalContextManager.get),
setRumGlobalContext: (0, browser_core_1.monitor)(globalContextManager.set),
getInternalContext: (0, browser_core_1.monitor)(function (startTime) { return getInternalContextStrategy(startTime); }),
getInitConfiguration: (0, browser_core_1.monitor)(function () { return getInitConfigurationStrategy(); }),
addAction: (0, browser_core_1.monitor)(function (name, context) {
addActionStrategy({
name: name,
context: browser_core_1.deepClone(context),
startClocks: browser_core_1.clocksNow(),
type: rawRumEvent_types_1.ActionType.CUSTOM,
context: (0, browser_core_1.deepClone)(context),
startClocks: (0, browser_core_1.clocksNow)(),
type: "custom" /* CUSTOM */,
});
}),
addError: function (error, context) {
var handlingStack = browser_core_1.createHandlingStack();
browser_core_1.callMonitored(function () {
var handlingStack = (0, browser_core_1.createHandlingStack)();
(0, browser_core_1.callMonitored)(function () {
addErrorStrategy({
error: error,
handlingStack: handlingStack,
context: browser_core_1.deepClone(context),
startClocks: browser_core_1.clocksNow(),
context: (0, browser_core_1.deepClone)(context),
startClocks: (0, browser_core_1.clocksNow)(),
});
});
},
addTiming: browser_core_1.monitor(function (name, time) {
addTiming: (0, browser_core_1.monitor)(function (name, time) {
addTimingStrategy(name, time);
}),
setUser: browser_core_1.monitor(function (newUser) {
setUser: (0, browser_core_1.monitor)(function (newUser) {
var sanitizedUser = sanitizeUser(newUser);

@@ -134,10 +130,10 @@ if (sanitizedUser) {

}),
removeUser: browser_core_1.monitor(function () {
removeUser: (0, browser_core_1.monitor)(function () {
user = {};
}),
startView: browser_core_1.monitor(function (name) {
startView: (0, browser_core_1.monitor)(function (name) {
startViewStrategy(name);
}),
startSessionReplayRecording: browser_core_1.monitor(recorderApi.start),
stopSessionReplayRecording: browser_core_1.monitor(recorderApi.stop),
startSessionReplayRecording: (0, browser_core_1.monitor)(recorderApi.start),
stopSessionReplayRecording: (0, browser_core_1.monitor)(recorderApi.stop),
});

@@ -149,3 +145,3 @@ return rumPublicApi;

}
var result = browser_core_1.deepClone(newUser);
var result = (0, browser_core_1.deepClone)(newUser);
if ('id' in result) {

@@ -163,3 +159,3 @@ result.id = String(result.id);

function canHandleSession(initConfiguration) {
if (!browser_core_1.areCookiesAuthorized(browser_core_1.buildCookieOptions(initConfiguration))) {
if (!(0, browser_core_1.areCookiesAuthorized)((0, browser_core_1.buildCookieOptions)(initConfiguration))) {
browser_core_1.display.warn('Cookies are not authorized, we will not send any data.');

@@ -184,3 +180,7 @@ return false;

function overrideInitConfigurationForBridge(initConfiguration) {
return tslib_1.__assign(tslib_1.__assign({}, initConfiguration), { applicationId: '00000000-aaaa-0000-aaaa-000000000000', clientToken: 'empty', sampleRate: 100 });
return (0, browser_core_1.assign)({}, initConfiguration, {
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
clientToken: 'empty',
sampleRate: 100,
});
}

@@ -187,0 +187,0 @@ function isLocalFile() {

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

import type { InternalMonitoring, Observable } from '@datadog/browser-core';
import type { Observable } from '@datadog/browser-core';
import { LifeCycle } from '../domain/lifeCycle';

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

import type { RecorderApi } from './rumPublicApi';
export declare function startRum(configuration: RumConfiguration, internalMonitoring: InternalMonitoring, getCommonContext: () => CommonContext, recorderApi: RecorderApi, initialViewName?: string): {
export declare function startRum(configuration: RumConfiguration, getCommonContext: () => CommonContext, recorderApi: RecorderApi, initialViewName?: string): {
addAction: (action: import("../domain/rumEventsCollection/action/trackActions").CustomAction, savedCommonContext?: CommonContext | undefined) => void;

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

@@ -23,10 +23,8 @@ "use strict";

var locationChangeObservable_1 = require("../browser/locationChangeObservable");
function startRum(configuration, internalMonitoring, getCommonContext, recorderApi, initialViewName) {
function startRum(configuration, getCommonContext, recorderApi, initialViewName) {
var lifeCycle = new lifeCycle_1.LifeCycle();
var session = !browser_core_1.canUseEventBridge() ? rumSessionManager_1.startRumSessionManager(configuration, lifeCycle) : rumSessionManager_1.startRumSessionManagerStub();
var domMutationObservable = domMutationObservable_1.createDOMMutationObservable();
var locationChangeObservable = locationChangeObservable_1.createLocationChangeObservable(location);
var internalMonitoring = startRumInternalMonitoring(configuration);
internalMonitoring.setExternalContextProvider(function () {
var _a;
return browser_core_1.combine({
return (0, browser_core_1.combine)({
application_id: configuration.applicationId,

@@ -38,11 +36,37 @@ session: {

});
internalMonitoring.setTelemetryContextProvider(function () {
var _a, _b, _c;
return ({
application: {
id: configuration.applicationId,
},
session: {
id: (_a = session.findTrackedSession()) === null || _a === void 0 ? void 0 : _a.id,
},
view: {
id: (_b = parentContexts.findView()) === null || _b === void 0 ? void 0 : _b.view.id,
},
action: {
id: (_c = parentContexts.findAction()) === null || _c === void 0 ? void 0 : _c.action.id,
},
});
});
if (!(0, browser_core_1.canUseEventBridge)()) {
(0, startRumBatch_1.startRumBatch)(configuration, lifeCycle, internalMonitoring.telemetryEventObservable);
}
else {
(0, startRumEventBridge_1.startRumEventBridge)(lifeCycle);
}
var session = !(0, browser_core_1.canUseEventBridge)() ? (0, rumSessionManager_1.startRumSessionManager)(configuration, lifeCycle) : (0, rumSessionManager_1.startRumSessionManagerStub)();
var domMutationObservable = (0, domMutationObservable_1.createDOMMutationObservable)();
var locationChangeObservable = (0, locationChangeObservable_1.createLocationChangeObservable)(location);
var _a = startRumEventCollection(lifeCycle, configuration, location, session, locationChangeObservable, getCommonContext), parentContexts = _a.parentContexts, foregroundContexts = _a.foregroundContexts, urlContexts = _a.urlContexts;
longTaskCollection_1.startLongTaskCollection(lifeCycle, session);
resourceCollection_1.startResourceCollection(lifeCycle);
var _b = viewCollection_1.startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, foregroundContexts, recorderApi, initialViewName), addTiming = _b.addTiming, startView = _b.startView;
var addError = errorCollection_1.startErrorCollection(lifeCycle, foregroundContexts).addError;
var addAction = actionCollection_1.startActionCollection(lifeCycle, domMutationObservable, configuration, foregroundContexts).addAction;
requestCollection_1.startRequestCollection(lifeCycle, configuration, session);
performanceCollection_1.startPerformanceCollection(lifeCycle, configuration);
var internalContext = internalContext_1.startInternalContext(configuration.applicationId, session, parentContexts, urlContexts);
(0, longTaskCollection_1.startLongTaskCollection)(lifeCycle, session);
(0, resourceCollection_1.startResourceCollection)(lifeCycle);
var _b = (0, viewCollection_1.startViewCollection)(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, foregroundContexts, recorderApi, initialViewName), addTiming = _b.addTiming, startView = _b.startView;
var addError = (0, errorCollection_1.startErrorCollection)(lifeCycle, foregroundContexts).addError;
var addAction = (0, actionCollection_1.startActionCollection)(lifeCycle, domMutationObservable, configuration, foregroundContexts).addAction;
(0, requestCollection_1.startRequestCollection)(lifeCycle, configuration, session);
(0, performanceCollection_1.startPerformanceCollection)(lifeCycle, configuration);
var internalContext = (0, internalContext_1.startInternalContext)(configuration.applicationId, session, parentContexts, urlContexts);
return {

@@ -60,15 +84,21 @@ addAction: addAction,

exports.startRum = startRum;
function startRumEventCollection(lifeCycle, configuration, location, sessionManager, locationChangeObservable, getCommonContext) {
var parentContexts = parentContexts_1.startParentContexts(lifeCycle);
var urlContexts = urlContexts_1.startUrlContexts(lifeCycle, locationChangeObservable, location);
var foregroundContexts = foregroundContexts_1.startForegroundContexts();
var stopBatch;
if (browser_core_1.canUseEventBridge()) {
startRumEventBridge_1.startRumEventBridge(lifeCycle);
function startRumInternalMonitoring(configuration) {
var _a;
var internalMonitoring = (0, browser_core_1.startInternalMonitoring)(configuration);
if ((0, browser_core_1.canUseEventBridge)()) {
var bridge_1 = (0, browser_core_1.getEventBridge)();
internalMonitoring.monitoringMessageObservable.subscribe(function (message) { return bridge_1.send('internal_log', message); });
internalMonitoring.telemetryEventObservable.subscribe(function (message) { return bridge_1.send('internal_telemetry', message); });
}
else {
;
(stopBatch = startRumBatch_1.startRumBatch(configuration, lifeCycle).stop);
else if (configuration.internalMonitoringEndpointBuilder) {
var batch_1 = (0, browser_core_1.startBatchWithReplica)(configuration, configuration.internalMonitoringEndpointBuilder, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.internalMonitoringEndpointBuilder);
internalMonitoring.monitoringMessageObservable.subscribe(function (message) { return batch_1.add(message); });
}
assembly_1.startRumAssembly(configuration, lifeCycle, sessionManager, parentContexts, urlContexts, getCommonContext);
return internalMonitoring;
}
function startRumEventCollection(lifeCycle, configuration, location, sessionManager, locationChangeObservable, getCommonContext) {
var parentContexts = (0, parentContexts_1.startParentContexts)(lifeCycle);
var urlContexts = (0, urlContexts_1.startUrlContexts)(lifeCycle, locationChangeObservable, location);
var foregroundContexts = (0, foregroundContexts_1.startForegroundContexts)();
(0, assembly_1.startRumAssembly)(configuration, lifeCycle, sessionManager, parentContexts, urlContexts, getCommonContext);
return {

@@ -79,5 +109,2 @@ parentContexts: parentContexts,

stop: function () {
// prevent batch from previous tests to keep running and send unwanted requests
// could be replaced by stopping all the component when they will all have a stop method
stopBatch === null || stopBatch === void 0 ? void 0 : stopBatch();
parentContexts.stop();

@@ -84,0 +111,0 @@ foregroundContexts.stop();

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

}
var observer = new MutationObserver(browser_core_1.monitor(function () { return observable.notify(); }));
var observer = new MutationObserver((0, browser_core_1.monitor)(function () { return observable.notify(); }));
observer.observe(document, {

@@ -14,0 +14,0 @@ attributes: true,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createLocationChangeObservable = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
function createLocationChangeObservable(location) {
var currentLocation = tslib_1.__assign({}, location);
var currentLocation = (0, browser_core_1.shallowClone)(location);
var observable = new browser_core_1.Observable(function () {

@@ -20,3 +19,3 @@ var stopHistoryTracking = trackHistory(onLocationChange).stop;

}
var newLocation = tslib_1.__assign({}, location);
var newLocation = (0, browser_core_1.shallowClone)(location);
observable.notify({

@@ -32,9 +31,9 @@ newLocation: newLocation,

function trackHistory(onHistoryChange) {
var stopInstrumentingPushState = browser_core_1.instrumentMethodAndCallOriginal(history, 'pushState', {
var stopInstrumentingPushState = (0, browser_core_1.instrumentMethodAndCallOriginal)(history, 'pushState', {
after: onHistoryChange,
}).stop;
var stopInstrumentingReplaceState = browser_core_1.instrumentMethodAndCallOriginal(history, 'replaceState', {
var stopInstrumentingReplaceState = (0, browser_core_1.instrumentMethodAndCallOriginal)(history, 'replaceState', {
after: onHistoryChange,
}).stop;
var removeListener = browser_core_1.addEventListener(window, "popstate" /* POP_STATE */, onHistoryChange).stop;
var removeListener = (0, browser_core_1.addEventListener)(window, "popstate" /* POP_STATE */, onHistoryChange).stop;
return {

@@ -49,4 +48,4 @@ stop: function () {

function trackHash(onHashChange) {
return browser_core_1.addEventListener(window, "hashchange" /* HASH_CHANGE */, onHashChange);
return (0, browser_core_1.addEventListener)(window, "hashchange" /* HASH_CHANGE */, onHashChange);
}
//# sourceMappingURL=locationChangeObservable.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.retrieveInitialDocumentResourceTiming = exports.startPerformanceCollection = exports.supportPerformanceEntry = exports.supportPerformanceTimingEvent = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var lifeCycle_1 = require("../domain/lifeCycle");
var resourceUtils_1 = require("../domain/rumEventsCollection/resource/resourceUtils");

@@ -28,6 +26,9 @@ var getDocumentTraceId_1 = require("../domain/tracing/getDocumentTraceId");

if (supportPerformanceObject()) {
handleRumPerformanceEntries(lifeCycle, configuration, performance.getEntries());
var performanceEntries_1 = performance.getEntries();
// Because the performance entry list can be quite large
// delay the computation to prevent the SDK from blocking the main thread on init
setTimeout((0, browser_core_1.monitor)(function () { return handleRumPerformanceEntries(lifeCycle, configuration, performanceEntries_1); }));
}
if (window.PerformanceObserver) {
var handlePerformanceEntryList_1 = browser_core_1.monitor(function (entries) {
var handlePerformanceEntryList_1 = (0, browser_core_1.monitor)(function (entries) {
return handleRumPerformanceEntries(lifeCycle, configuration, entries.getEntries());

@@ -73,3 +74,3 @@ });

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

@@ -79,11 +80,16 @@ var forcedAttributes = {

initiatorType: resourceUtils_1.FAKE_INITIAL_DOCUMENT,
traceId: getDocumentTraceId_1.getDocumentTraceId(document),
traceId: (0, getDocumentTraceId_1.getDocumentTraceId)(document),
};
if (supportPerformanceTimingEvent('navigation') && performance.getEntriesByType('navigation').length > 0) {
var navigationEntry = performance.getEntriesByType('navigation')[0];
timing = tslib_1.__assign(tslib_1.__assign({}, navigationEntry.toJSON()), forcedAttributes);
timing = (0, browser_core_1.assign)(navigationEntry.toJSON(), forcedAttributes);
}
else {
var relativePerformanceTiming = computeRelativePerformanceTiming();
timing = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, relativePerformanceTiming), { decodedBodySize: 0, duration: relativePerformanceTiming.responseEnd, name: window.location.href, startTime: 0 }), forcedAttributes);
timing = (0, browser_core_1.assign)(relativePerformanceTiming, {
decodedBodySize: 0,
duration: relativePerformanceTiming.responseEnd,
name: window.location.href,
startTime: 0,
}, forcedAttributes);
}

@@ -96,7 +102,9 @@ callback(timing);

function sendFakeTiming() {
callback(tslib_1.__assign(tslib_1.__assign({}, computeRelativePerformanceTiming()), { entryType: 'navigation' }));
callback((0, browser_core_1.assign)(computeRelativePerformanceTiming(), {
entryType: 'navigation',
}));
}
browser_core_1.runOnReadyState('complete', function () {
(0, browser_core_1.runOnReadyState)('complete', function () {
// Send it a bit after the actual load event, so the "loadEventEnd" timing is accurate
setTimeout(browser_core_1.monitor(sendFakeTiming));
setTimeout((0, browser_core_1.monitor)(sendFakeTiming));
});

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

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

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

entryType: 'first-input',
processingStart: browser_core_1.relativeNow(),
processingStart: (0, browser_core_1.relativeNow)(),
startTime: evt.timeStamp,

@@ -140,3 +148,3 @@ };

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

@@ -167,7 +175,7 @@ sendTiming(timing);

for (var key in timing) {
if (browser_core_1.isNumber(timing[key])) {
if ((0, browser_core_1.isNumber)(timing[key])) {
var numberKey = key;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
var timingElement = timing[numberKey];
result[numberKey] = timingElement === 0 ? 0 : browser_core_1.getRelativeTime(timingElement);
result[numberKey] = timingElement === 0 ? 0 : (0, browser_core_1.getRelativeTime)(timingElement);
}

@@ -189,3 +197,3 @@ }

if (rumAllowedPerformanceEntries.length) {
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, rumAllowedPerformanceEntries);
lifeCycle.notify(0 /* PERFORMANCE_ENTRIES_COLLECTED */, rumAllowedPerformanceEntries);
}

@@ -197,4 +205,4 @@ }

function isForbiddenResource(configuration, entry) {
return entry.entryType === 'resource' && !resourceUtils_1.isAllowedRequestUrl(configuration, entry.name);
return entry.entryType === 'resource' && !(0, resourceUtils_1.isAllowedRequestUrl)(configuration, entry.name);
}
//# sourceMappingURL=performanceCollection.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startRumAssembly = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../rawRumEvent.types");
var buildEnv_1 = require("../boot/buildEnv");
var syntheticsContext_1 = require("./syntheticsContext");
var ciTestContext_1 = require("./ciTestContext");
var lifeCycle_1 = require("./lifeCycle");
var rumSessionManager_1 = require("./rumSessionManager");
var SessionType;
(function (SessionType) {
SessionType["SYNTHETICS"] = "synthetics";
SessionType["USER"] = "user";
SessionType["CI_TEST"] = "ci_test";
})(SessionType || (SessionType = {}));
var VIEW_EVENTS_MODIFIABLE_FIELD_PATHS = [

@@ -28,3 +17,3 @@ // Fields with sensitive data

];
var OTHER_EVENTS_MODIFIABLE_FIELD_PATHS = tslib_1.__spreadArrays(VIEW_EVENTS_MODIFIABLE_FIELD_PATHS, [
var OTHER_EVENTS_MODIFIABLE_FIELD_PATHS = VIEW_EVENTS_MODIFIABLE_FIELD_PATHS.concat([
// User-customizable field

@@ -36,11 +25,11 @@ 'context',

var reportError = function (error) {
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error });
lifeCycle.notify(14 /* RAW_ERROR_COLLECTED */, { error: error });
};
var eventRateLimiters = (_a = {},
_a[rawRumEvent_types_1.RumEventType.ERROR] = browser_core_1.createEventRateLimiter(rawRumEvent_types_1.RumEventType.ERROR, configuration.eventRateLimiterThreshold, reportError),
_a[rawRumEvent_types_1.RumEventType.ACTION] = browser_core_1.createEventRateLimiter(rawRumEvent_types_1.RumEventType.ACTION, configuration.eventRateLimiterThreshold, reportError),
_a["error" /* ERROR */] = (0, browser_core_1.createEventRateLimiter)("error" /* ERROR */, configuration.eventRateLimiterThreshold, reportError),
_a["action" /* ACTION */] = (0, browser_core_1.createEventRateLimiter)("action" /* ACTION */, configuration.eventRateLimiterThreshold, reportError),
_a);
var syntheticsContext = syntheticsContext_1.getSyntheticsContext();
var ciTestContext = ciTestContext_1.getCiTestContext();
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (_a) {
var syntheticsContext = (0, syntheticsContext_1.getSyntheticsContext)();
var ciTestContext = (0, ciTestContext_1.getCiTestContext)();
lifeCycle.subscribe(12 /* RAW_RUM_EVENT_COLLECTED */, function (_a) {
var startTime = _a.startTime, rawRumEvent = _a.rawRumEvent, domainContext = _a.domainContext, savedCommonContext = _a.savedCommonContext, customerContext = _a.customerContext;

@@ -52,3 +41,3 @@ var viewContext = parentContexts.findView(startTime);

// TODO: stop sending view updates when session is expired
var session = sessionManager.findTrackedSession(rawRumEvent.type !== rawRumEvent_types_1.RumEventType.VIEW ? startTime : undefined);
var session = sessionManager.findTrackedSession(rawRumEvent.type !== "view" /* VIEW */ ? startTime : undefined);
if (session && viewContext && urlContext) {

@@ -60,7 +49,7 @@ var actionContext = parentContexts.findAction(startTime);

format_version: 2,
drift: browser_core_1.currentDrift(),
drift: (0, browser_core_1.currentDrift)(),
session: {
plan: session.hasReplayPlan ? rumSessionManager_1.RumSessionPlan.REPLAY : rumSessionManager_1.RumSessionPlan.LITE,
plan: session.hasReplayPlan ? 2 /* REPLAY */ : 1 /* LITE */,
},
browser_sdk_version: browser_core_1.canUseEventBridge() ? buildEnv_1.buildEnv.sdkVersion : undefined,
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.6.0" : undefined,
},

@@ -70,3 +59,3 @@ application: {

},
date: browser_core_1.timeStampNow(),
date: (0, browser_core_1.timeStampNow)(),
service: configuration.service,

@@ -76,3 +65,3 @@ source: 'browser',

id: session.id,
type: syntheticsContext ? SessionType.SYNTHETICS : ciTestContext ? SessionType.CI_TEST : SessionType.USER,
type: syntheticsContext ? "synthetics" /* SYNTHETICS */ : ciTestContext ? "ci_test" /* CI_TEST */ : "user" /* USER */,
},

@@ -83,5 +72,5 @@ synthetics: syntheticsContext,

var serverRumEvent = (needToAssembleWithAction(rawRumEvent)
? browser_core_1.combine(rumContext, urlContext, viewContext, actionContext, rawRumEvent)
: browser_core_1.combine(rumContext, urlContext, viewContext, rawRumEvent));
serverRumEvent.context = browser_core_1.combine(commonContext.context, customerContext);
? (0, browser_core_1.combine)(rumContext, urlContext, viewContext, actionContext, rawRumEvent)
: (0, browser_core_1.combine)(rumContext, urlContext, viewContext, rawRumEvent));
serverRumEvent.context = (0, browser_core_1.combine)(commonContext.context, customerContext);
if (!('has_replay' in serverRumEvent.session)) {

@@ -91,3 +80,3 @@ ;

}
if (!browser_core_1.isEmptyObject(commonContext.user)) {
if (!(0, browser_core_1.isEmptyObject)(commonContext.user)) {
;

@@ -97,6 +86,6 @@ serverRumEvent.usr = commonContext.user;

if (shouldSend(serverRumEvent, configuration.beforeSend, domainContext, eventRateLimiters)) {
if (browser_core_1.isEmptyObject(serverRumEvent.context)) {
if ((0, browser_core_1.isEmptyObject)(serverRumEvent.context)) {
delete serverRumEvent.context;
}
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
lifeCycle.notify(13 /* RUM_EVENT_COLLECTED */, serverRumEvent);
}

@@ -110,4 +99,4 @@ }

if (beforeSend) {
var result = browser_core_1.limitModification(event, event.type === rawRumEvent_types_1.RumEventType.VIEW ? VIEW_EVENTS_MODIFIABLE_FIELD_PATHS : OTHER_EVENTS_MODIFIABLE_FIELD_PATHS, function (event) { return beforeSend(event, domainContext); });
if (result === false && event.type !== rawRumEvent_types_1.RumEventType.VIEW) {
var result = (0, browser_core_1.limitModification)(event, event.type === "view" /* VIEW */ ? VIEW_EVENTS_MODIFIABLE_FIELD_PATHS : OTHER_EVENTS_MODIFIABLE_FIELD_PATHS, function (event) { return beforeSend(event, domainContext); });
if (result === false && event.type !== "view" /* VIEW */) {
return false;

@@ -123,4 +112,4 @@ }

function needToAssembleWithAction(event) {
return [rawRumEvent_types_1.RumEventType.ERROR, rawRumEvent_types_1.RumEventType.RESOURCE, rawRumEvent_types_1.RumEventType.LONG_TASK].indexOf(event.type) !== -1;
return ["error" /* ERROR */, "resource" /* RESOURCE */, "long_task" /* LONG_TASK */].indexOf(event.type) !== -1;
}
//# sourceMappingURL=assembly.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateAndBuildRumConfiguration = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var buildEnv_1 = require("../boot/buildEnv");
function validateAndBuildRumConfiguration(initConfiguration) {

@@ -13,3 +11,3 @@ var _a, _b;

}
if (initConfiguration.replaySampleRate !== undefined && !browser_core_1.isPercentage(initConfiguration.replaySampleRate)) {
if (initConfiguration.replaySampleRate !== undefined && !(0, browser_core_1.isPercentage)(initConfiguration.replaySampleRate)) {
browser_core_1.display.error('Replay Sample Rate should be a number between 0 and 100');

@@ -28,11 +26,19 @@ return;

}
var baseConfiguration = browser_core_1.validateAndBuildConfiguration(initConfiguration, buildEnv_1.buildEnv);
var baseConfiguration = (0, browser_core_1.validateAndBuildConfiguration)(initConfiguration);
if (!baseConfiguration) {
return;
}
return tslib_1.__assign(tslib_1.__assign({}, baseConfiguration), { applicationId: initConfiguration.applicationId, actionNameAttribute: initConfiguration.actionNameAttribute, replaySampleRate: (_a = initConfiguration.replaySampleRate) !== null && _a !== void 0 ? _a : 100, allowedTracingOrigins: (_b = initConfiguration.allowedTracingOrigins) !== null && _b !== void 0 ? _b : [], trackInteractions: !!initConfiguration.trackInteractions, trackViewsManually: !!initConfiguration.trackViewsManually, defaultPrivacyLevel: browser_core_1.objectHasValue(browser_core_1.DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)
return (0, browser_core_1.assign)({
applicationId: initConfiguration.applicationId,
actionNameAttribute: initConfiguration.actionNameAttribute,
replaySampleRate: (_a = initConfiguration.replaySampleRate) !== null && _a !== void 0 ? _a : 100,
allowedTracingOrigins: (_b = initConfiguration.allowedTracingOrigins) !== null && _b !== void 0 ? _b : [],
trackInteractions: !!initConfiguration.trackInteractions,
trackViewsManually: !!initConfiguration.trackViewsManually,
defaultPrivacyLevel: (0, browser_core_1.objectHasValue)(browser_core_1.DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)
? initConfiguration.defaultPrivacyLevel
: browser_core_1.DefaultPrivacyLevel.MASK_USER_INPUT });
: browser_core_1.DefaultPrivacyLevel.MASK_USER_INPUT,
}, baseConfiguration);
}
exports.validateAndBuildRumConfiguration = validateAndBuildRumConfiguration;
//# sourceMappingURL=configuration.js.map

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

var currentForegroundPeriod = foregroundPeriods[foregroundPeriods.length - 1];
var now = browser_core_1.relativeNow();
var now = (0, browser_core_1.relativeNow)();
if (currentForegroundPeriod !== undefined && currentForegroundPeriod.end === undefined) {

@@ -47,3 +47,3 @@ return;

var currentForegroundPeriod = foregroundPeriods[foregroundPeriods.length - 1];
var now = browser_core_1.relativeNow();
var now = (0, browser_core_1.relativeNow)();
if (currentForegroundPeriod.end !== undefined) {

@@ -56,3 +56,3 @@ return;

function trackFocus(onFocusChange) {
return browser_core_1.addEventListener(window, "focus" /* FOCUS */, function (event) {
return (0, browser_core_1.addEventListener)(window, "focus" /* FOCUS */, function (event) {
if (!event.isTrusted) {

@@ -65,3 +65,3 @@ return;

function trackBlur(onBlurChange) {
return browser_core_1.addEventListener(window, "blur" /* BLUR */, function (event) {
return (0, browser_core_1.addEventListener)(window, "blur" /* BLUR */, function (event) {
if (!event.isTrusted) {

@@ -104,8 +104,8 @@ return;

var startTime = eventStartTime > foregroundPeriod.start ? eventStartTime : foregroundPeriod.start;
var startDuration = browser_core_1.elapsed(eventStartTime, startTime);
var startDuration = (0, browser_core_1.elapsed)(eventStartTime, startTime);
var endTime = foregroundPeriod.end === undefined || eventEndTime < foregroundPeriod.end ? eventEndTime : foregroundPeriod.end;
var endDuration = browser_core_1.elapsed(startTime, endTime);
var endDuration = (0, browser_core_1.elapsed)(startTime, endTime);
filteredForegroundPeriods.unshift({
start: browser_core_1.toServerDuration(startDuration),
duration: browser_core_1.toServerDuration(endDuration),
start: (0, browser_core_1.toServerDuration)(startDuration),
duration: (0, browser_core_1.toServerDuration)(endDuration),
});

@@ -112,0 +112,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startInternalContext = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
/**

@@ -25,3 +25,3 @@ * Internal context keep returning v1 format

: undefined,
view: tslib_1.__assign(tslib_1.__assign({}, viewContext.view), urlContext.view),
view: (0, browser_core_1.assign)({}, viewContext.view, urlContext.view),
};

@@ -28,0 +28,0 @@ }

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

import type { ViewEvent, ViewCreatedEvent, ViewEndedEvent } from './rumEventsCollection/view/trackViews';
export declare enum LifeCycleEventType {
export declare const enum LifeCycleEventType {
PERFORMANCE_ENTRIES_COLLECTED = 0,

@@ -12,0 +12,0 @@ AUTO_ACTION_CREATED = 1,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LifeCycle = exports.LifeCycleEventType = void 0;
var LifeCycleEventType;
(function (LifeCycleEventType) {
LifeCycleEventType[LifeCycleEventType["PERFORMANCE_ENTRIES_COLLECTED"] = 0] = "PERFORMANCE_ENTRIES_COLLECTED";
LifeCycleEventType[LifeCycleEventType["AUTO_ACTION_CREATED"] = 1] = "AUTO_ACTION_CREATED";
LifeCycleEventType[LifeCycleEventType["AUTO_ACTION_COMPLETED"] = 2] = "AUTO_ACTION_COMPLETED";
LifeCycleEventType[LifeCycleEventType["AUTO_ACTION_DISCARDED"] = 3] = "AUTO_ACTION_DISCARDED";
LifeCycleEventType[LifeCycleEventType["VIEW_CREATED"] = 4] = "VIEW_CREATED";
LifeCycleEventType[LifeCycleEventType["VIEW_UPDATED"] = 5] = "VIEW_UPDATED";
LifeCycleEventType[LifeCycleEventType["VIEW_ENDED"] = 6] = "VIEW_ENDED";
LifeCycleEventType[LifeCycleEventType["REQUEST_STARTED"] = 7] = "REQUEST_STARTED";
LifeCycleEventType[LifeCycleEventType["REQUEST_COMPLETED"] = 8] = "REQUEST_COMPLETED";
// The SESSION_EXPIRED lifecycle event has been introduced to represent when a session has expired
// and trigger cleanup tasks related to this, prior to renewing the session. Its implementation is
// slightly naive: it is not triggered as soon as the session is expired, but rather just before
// notifying that the session is renewed. Thus, the session id is already set to the newly renewed
// session.
//
// This implementation is "good enough" for our use-cases. Improving this is not trivial,
// primarily because multiple instances of the SDK may be managing the same session cookie at
// the same time, for example when using Logs and RUM on the same page, or opening multiple tabs
// on the same domain.
LifeCycleEventType[LifeCycleEventType["SESSION_EXPIRED"] = 9] = "SESSION_EXPIRED";
LifeCycleEventType[LifeCycleEventType["SESSION_RENEWED"] = 10] = "SESSION_RENEWED";
LifeCycleEventType[LifeCycleEventType["BEFORE_UNLOAD"] = 11] = "BEFORE_UNLOAD";
LifeCycleEventType[LifeCycleEventType["RAW_RUM_EVENT_COLLECTED"] = 12] = "RAW_RUM_EVENT_COLLECTED";
LifeCycleEventType[LifeCycleEventType["RUM_EVENT_COLLECTED"] = 13] = "RUM_EVENT_COLLECTED";
LifeCycleEventType[LifeCycleEventType["RAW_ERROR_COLLECTED"] = 14] = "RAW_ERROR_COLLECTED";
})(LifeCycleEventType = exports.LifeCycleEventType || (exports.LifeCycleEventType = {}));
exports.LifeCycle = void 0;
var LifeCycle = /** @class */ (function () {

@@ -33,0 +5,0 @@ function LifeCycle() {

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

var browser_core_1 = require("@datadog/browser-core");
var lifeCycle_1 = require("./lifeCycle");
exports.VIEW_CONTEXT_TIME_OUT_DELAY = browser_core_1.SESSION_TIME_OUT_DELAY;

@@ -12,6 +11,6 @@ exports.ACTION_CONTEXT_TIME_OUT_DELAY = 5 * browser_core_1.ONE_MINUTE; // arbitrary

var actionContextHistory = new browser_core_1.ContextHistory(exports.ACTION_CONTEXT_TIME_OUT_DELAY);
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.VIEW_CREATED, function (view) {
lifeCycle.subscribe(4 /* VIEW_CREATED */, function (view) {
viewContextHistory.setCurrent(buildViewContext(view), view.startClocks.relative);
});
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.VIEW_UPDATED, function (view) {
lifeCycle.subscribe(5 /* VIEW_UPDATED */, function (view) {
// A view can be updated after its end. We have to ensure that the view being updated is the

@@ -24,10 +23,10 @@ // most recently created.

});
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.VIEW_ENDED, function (_a) {
lifeCycle.subscribe(6 /* VIEW_ENDED */, function (_a) {
var endClocks = _a.endClocks;
viewContextHistory.closeCurrent(endClocks.relative);
});
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.AUTO_ACTION_CREATED, function (action) {
lifeCycle.subscribe(1 /* AUTO_ACTION_CREATED */, function (action) {
actionContextHistory.setCurrent(buildActionContext(action), action.startClocks.relative);
});
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) {
lifeCycle.subscribe(2 /* AUTO_ACTION_COMPLETED */, function (action) {
if (actionContextHistory.getCurrent()) {

@@ -39,6 +38,6 @@ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands

});
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.AUTO_ACTION_DISCARDED, function () {
lifeCycle.subscribe(3 /* AUTO_ACTION_DISCARDED */, function () {
actionContextHistory.clearCurrent();
});
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.SESSION_RENEWED, function () {
lifeCycle.subscribe(10 /* SESSION_RENEWED */, function () {
viewContextHistory.reset();

@@ -45,0 +44,0 @@ actionContextHistory.reset();

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

var browser_core_1 = require("@datadog/browser-core");
var lifeCycle_1 = require("./lifeCycle");
var resourceUtils_1 = require("./rumEventsCollection/resource/resourceUtils");

@@ -11,3 +10,3 @@ var tracer_1 = require("./tracing/tracer");

function startRequestCollection(lifeCycle, configuration, sessionManager) {
var tracer = tracer_1.startTracer(configuration, sessionManager);
var tracer = (0, tracer_1.startTracer)(configuration, sessionManager);
trackXhr(lifeCycle, configuration, tracer);

@@ -18,5 +17,5 @@ trackFetch(lifeCycle, configuration, tracer);

function trackXhr(lifeCycle, configuration, tracer) {
var subscription = browser_core_1.initXhrObservable().subscribe(function (rawContext) {
var subscription = (0, browser_core_1.initXhrObservable)().subscribe(function (rawContext) {
var context = rawContext;
if (!resourceUtils_1.isAllowedRequestUrl(configuration, context.url)) {
if (!(0, resourceUtils_1.isAllowedRequestUrl)(configuration, context.url)) {
return;

@@ -28,3 +27,3 @@ }

context.requestIndex = getNextRequestIndex();
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.REQUEST_STARTED, {
lifeCycle.notify(7 /* REQUEST_STARTED */, {
requestIndex: context.requestIndex,

@@ -35,3 +34,3 @@ });

tracer.clearTracingIfNeeded(context);
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.REQUEST_COMPLETED, {
lifeCycle.notify(8 /* REQUEST_COMPLETED */, {
duration: context.duration,

@@ -44,3 +43,3 @@ method: context.method,

traceId: context.traceId,
type: browser_core_1.RequestType.XHR,
type: "xhr" /* XHR */,
url: context.url,

@@ -56,5 +55,5 @@ xhr: context.xhr,

function trackFetch(lifeCycle, configuration, tracer) {
var subscription = browser_core_1.initFetchObservable().subscribe(function (rawContext) {
var subscription = (0, browser_core_1.initFetchObservable)().subscribe(function (rawContext) {
var context = rawContext;
if (!resourceUtils_1.isAllowedRequestUrl(configuration, context.url)) {
if (!(0, resourceUtils_1.isAllowedRequestUrl)(configuration, context.url)) {
return;

@@ -66,3 +65,3 @@ }

context.requestIndex = getNextRequestIndex();
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.REQUEST_STARTED, {
lifeCycle.notify(7 /* REQUEST_STARTED */, {
requestIndex: context.requestIndex,

@@ -73,3 +72,3 @@ });

tracer.clearTracingIfNeeded(context);
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.REQUEST_COMPLETED, {
lifeCycle.notify(8 /* REQUEST_COMPLETED */, {
duration: context.duration,

@@ -83,3 +82,3 @@ method: context.method,

traceId: context.traceId,
type: browser_core_1.RequestType.FETCH,
type: "fetch" /* FETCH */,
url: context.url,

@@ -86,0 +85,0 @@ response: context.response,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startActionCollection = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../../../rawRumEvent.types");
var lifeCycle_1 = require("../../lifeCycle");
var trackActions_1 = require("./trackActions");
function startActionCollection(lifeCycle, domMutationObservable, configuration, foregroundContexts) {
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) {
return lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action, foregroundContexts));
lifeCycle.subscribe(2 /* AUTO_ACTION_COMPLETED */, function (action) {
return lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, processAction(action, foregroundContexts));
});
if (configuration.trackInteractions) {
trackActions_1.trackActions(lifeCycle, domMutationObservable, configuration);
(0, trackActions_1.trackActions)(lifeCycle, domMutationObservable, configuration);
}
return {
addAction: function (action, savedCommonContext) {
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, tslib_1.__assign({ savedCommonContext: savedCommonContext }, processAction(action, foregroundContexts)));
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, (0, browser_core_1.assign)({
savedCommonContext: savedCommonContext,
}, processAction(action, foregroundContexts)));
},

@@ -31,3 +30,3 @@ };

id: action.id,
loading_time: browser_core_1.toServerDuration(action.duration),
loading_time: (0, browser_core_1.toServerDuration)(action.duration),
long_task: {

@@ -43,5 +42,5 @@ count: action.counts.longTaskCount,

var customerContext = !isAutoAction(action) ? action.context : undefined;
var actionEvent = browser_core_1.combine({
var actionEvent = (0, browser_core_1.combine)({
action: {
id: browser_core_1.generateUUID(),
id: (0, browser_core_1.generateUUID)(),
target: {

@@ -53,3 +52,3 @@ name: action.name,

date: action.startClocks.timeStamp,
type: rawRumEvent_types_1.RumEventType.ACTION,
type: "action" /* ACTION */,
}, autoActionProperties);

@@ -68,4 +67,4 @@ var inForeground = foregroundContexts.isInForegroundAt(action.startClocks.relative);

function isAutoAction(action) {
return action.type !== rawRumEvent_types_1.ActionType.CUSTOM;
return action.type !== "custom" /* CUSTOM */;
}
//# sourceMappingURL=actionCollection.js.map

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

if (supportsElementClosest()) {
elementWithAttribute = targetElement.closest("[" + programmaticAttribute + "]");
elementWithAttribute = targetElement.closest("[".concat(programmaticAttribute, "]"));
}

@@ -61,3 +61,3 @@ else {

else if (element.id) {
var label = element.ownerDocument && element.ownerDocument.querySelector("label[for=\"" + element.id.replace('"', '\\"') + "\"]");
var label = element.ownerDocument && element.ownerDocument.querySelector("label[for=\"".concat(element.id.replace('"', '\\"'), "\"]"));
return label && getTextualContent(label, userProgrammaticAttribute);

@@ -145,3 +145,3 @@ }

function truncate(s) {
return s.length > 100 ? browser_core_1.safeTruncate(s, 100) + " [...]" : s;
return s.length > 100 ? "".concat((0, browser_core_1.safeTruncate)(s, 100), " [...]") : s;
}

@@ -177,5 +177,5 @@ function getElementById(refElement, id) {

// remove the text of elements with programmatic attribute value
removeTextFromElements("[" + DEFAULT_PROGRAMMATIC_ATTRIBUTE + "]");
removeTextFromElements("[".concat(DEFAULT_PROGRAMMATIC_ATTRIBUTE, "]"));
if (userProgrammaticAttribute) {
removeTextFromElements("[" + userProgrammaticAttribute + "]");
removeTextFromElements("[".concat(userProgrammaticAttribute, "]"));
}

@@ -204,3 +204,3 @@ return text_1;

function supportsInnerTextScriptAndStyleRemoval() {
return !browser_core_1.isIE();
return !(0, browser_core_1.isIE)();
}

@@ -207,0 +207,0 @@ /**

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

var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../../../rawRumEvent.types");
var lifeCycle_1 = require("../../lifeCycle");
var trackEventCounts_1 = require("../../trackEventCounts");

@@ -17,14 +15,14 @@ var waitIdlePage_1 = require("../../waitIdlePage");

// New views trigger the discard of the current pending Action
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.VIEW_CREATED, function () {
lifeCycle.subscribe(4 /* VIEW_CREATED */, function () {
action.discardCurrent();
});
var stopListener = browser_core_1.addEventListener(window, "click" /* CLICK */, function (event) {
var stopListener = (0, browser_core_1.addEventListener)(window, "click" /* CLICK */, function (event) {
if (!(event.target instanceof Element)) {
return;
}
var name = getActionNameFromElement_1.getActionNameFromElement(event.target, actionNameAttribute);
var name = (0, getActionNameFromElement_1.getActionNameFromElement)(event.target, actionNameAttribute);
if (!name) {
return;
}
action.create(rawRumEvent_types_1.ActionType.CLICK, name, event);
action.create("click" /* CLICK */, name, event);
}, { capture: true }).stop;

@@ -50,5 +48,5 @@ return {

currentAction = pendingAutoAction;
(stopWaitingIdlePage = waitIdlePage_1.waitIdlePage(lifeCycle, domMutationObservable, function (event) {
(stopWaitingIdlePage = (0, waitIdlePage_1.waitIdlePage)(lifeCycle, domMutationObservable, function (event) {
if (event.hadActivity) {
var duration = browser_core_1.elapsed(pendingAutoAction.startClocks.timeStamp, event.end);
var duration = (0, browser_core_1.elapsed)(pendingAutoAction.startClocks.timeStamp, event.end);
if (duration >= 0) {

@@ -82,10 +80,10 @@ pendingAutoAction.complete(duration);

this.event = event;
this.id = browser_core_1.generateUUID();
this.startClocks = browser_core_1.clocksNow();
this.eventCountsSubscription = trackEventCounts_1.trackEventCounts(lifeCycle);
this.lifeCycle.notify(lifeCycle_1.LifeCycleEventType.AUTO_ACTION_CREATED, { id: this.id, startClocks: this.startClocks });
this.id = (0, browser_core_1.generateUUID)();
this.startClocks = (0, browser_core_1.clocksNow)();
this.eventCountsSubscription = (0, trackEventCounts_1.trackEventCounts)(lifeCycle);
this.lifeCycle.notify(1 /* AUTO_ACTION_CREATED */, { id: this.id, startClocks: this.startClocks });
}
PendingAutoAction.prototype.complete = function (duration) {
var eventCounts = this.eventCountsSubscription.eventCounts;
this.lifeCycle.notify(lifeCycle_1.LifeCycleEventType.AUTO_ACTION_COMPLETED, {
this.lifeCycle.notify(2 /* AUTO_ACTION_COMPLETED */, {
counts: {

@@ -106,3 +104,3 @@ errorCount: eventCounts.errorCount,

PendingAutoAction.prototype.discard = function () {
this.lifeCycle.notify(lifeCycle_1.LifeCycleEventType.AUTO_ACTION_DISCARDED);
this.lifeCycle.notify(3 /* AUTO_ACTION_DISCARDED */);
this.eventCountsSubscription.stop();

@@ -109,0 +107,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.doStartErrorCollection = exports.startErrorCollection = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../../../rawRumEvent.types");
var lifeCycle_1 = require("../../lifeCycle");
var trackConsoleError_1 = require("./trackConsoleError");
var trackReportError_1 = require("./trackReportError");
function startErrorCollection(lifeCycle, foregroundContexts) {
var errorObservable = new browser_core_1.Observable();
trackConsoleError_1.trackConsoleError(errorObservable);
browser_core_1.trackRuntimeError(errorObservable);
errorObservable.subscribe(function (error) { return lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error }); });
(0, trackConsoleError_1.trackConsoleError)(errorObservable);
(0, browser_core_1.trackRuntimeError)(errorObservable);
(0, trackReportError_1.trackReportError)(errorObservable);
errorObservable.subscribe(function (error) { return lifeCycle.notify(14 /* RAW_ERROR_COLLECTED */, { error: error }); });
return doStartErrorCollection(lifeCycle, foregroundContexts);

@@ -18,6 +17,8 @@ }

function doStartErrorCollection(lifeCycle, foregroundContexts) {
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RAW_ERROR_COLLECTED, function (_a) {
lifeCycle.subscribe(14 /* RAW_ERROR_COLLECTED */, function (_a) {
var error = _a.error, customerContext = _a.customerContext, savedCommonContext = _a.savedCommonContext;
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, tslib_1.__assign({ customerContext: customerContext,
savedCommonContext: savedCommonContext }, processError(error, foregroundContexts)));
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, (0, browser_core_1.assign)({
customerContext: customerContext,
savedCommonContext: savedCommonContext,
}, processError(error, foregroundContexts)));
});

@@ -28,3 +29,3 @@ return {

var rawError = computeRawError(error, handlingStack, startClocks);
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_ERROR_COLLECTED, {
lifeCycle.notify(14 /* RAW_ERROR_COLLECTED */, {
customerContext: customerContext,

@@ -39,4 +40,9 @@ savedCommonContext: savedCommonContext,

function computeRawError(error, handlingStack, startClocks) {
var stackTrace = error instanceof Error ? browser_core_1.computeStackTrace(error) : undefined;
return tslib_1.__assign(tslib_1.__assign({ startClocks: startClocks, source: browser_core_1.ErrorSource.CUSTOM, originalError: error }, browser_core_1.formatUnknownError(stackTrace, error, 'Provided', handlingStack)), { handling: browser_core_1.ErrorHandling.HANDLED });
var stackTrace = error instanceof Error ? (0, browser_core_1.computeStackTrace)(error) : undefined;
return (0, browser_core_1.assign)({
startClocks: startClocks,
source: browser_core_1.ErrorSource.CUSTOM,
originalError: error,
handling: "handled" /* HANDLED */,
}, (0, browser_core_1.formatUnknownError)(stackTrace, error, 'Provided', handlingStack));
}

@@ -47,11 +53,4 @@ function processError(error, foregroundContexts) {

error: {
id: browser_core_1.generateUUID(),
id: (0, browser_core_1.generateUUID)(),
message: error.message,
resource: error.resource
? {
method: error.resource.method,
status_code: error.resource.statusCode,
url: error.resource.url,
}
: undefined,
source: error.source,

@@ -64,3 +63,3 @@ stack: error.stack,

},
type: rawRumEvent_types_1.RumEventType.ERROR,
type: "error" /* ERROR */,
};

@@ -67,0 +66,0 @@ var inForeground = foregroundContexts.isInForegroundAt(error.startClocks.relative);

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

function trackConsoleError(errorObservable) {
var subscription = browser_core_1.initConsoleObservable([browser_core_1.ConsoleApiName.error]).subscribe(function (consoleError) {
var subscription = (0, browser_core_1.initConsoleObservable)([browser_core_1.ConsoleApiName.error]).subscribe(function (consoleError) {
return errorObservable.notify({
startClocks: browser_core_1.clocksNow(),
startClocks: (0, browser_core_1.clocksNow)(),
message: consoleError.message,
stack: consoleError.stack,
source: browser_core_1.ErrorSource.CONSOLE,
handling: browser_core_1.ErrorHandling.HANDLED,
handling: "handled" /* HANDLED */,
handlingStack: consoleError.handlingStack,

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

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

var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../../../rawRumEvent.types");
var lifeCycle_1 = require("../../lifeCycle");
function startLongTaskCollection(lifeCycle, sessionManager) {
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {

@@ -19,12 +17,12 @@ var entry = entries_1[_i];

}
var startClocks = browser_core_1.relativeToClocks(entry.startTime);
var startClocks = (0, browser_core_1.relativeToClocks)(entry.startTime);
var rawRumEvent = {
date: startClocks.timeStamp,
long_task: {
id: browser_core_1.generateUUID(),
duration: browser_core_1.toServerDuration(entry.duration),
id: (0, browser_core_1.generateUUID)(),
duration: (0, browser_core_1.toServerDuration)(entry.duration),
},
type: rawRumEvent_types_1.RumEventType.LONG_TASK,
type: "long_task" /* LONG_TASK */,
};
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, {
rawRumEvent: rawRumEvent,

@@ -31,0 +29,0 @@ startTime: startClocks.relative,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startResourceCollection = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var performanceCollection_1 = require("../../../browser/performanceCollection");
var rawRumEvent_types_1 = require("../../../rawRumEvent.types");
var lifeCycle_1 = require("../../lifeCycle");
var matchRequestTiming_1 = require("./matchRequestTiming");
var resourceUtils_1 = require("./resourceUtils");
function startResourceCollection(lifeCycle) {
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.REQUEST_COMPLETED, function (request) {
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request));
lifeCycle.subscribe(8 /* REQUEST_COMPLETED */, function (request) {
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, processRequest(request));
});
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
var entry = entries_1[_i];
if (entry.entryType === 'resource' && !resourceUtils_1.isRequestKind(entry)) {
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processResourceEntry(entry));
if (entry.entryType === 'resource' && !(0, resourceUtils_1.isRequestKind)(entry)) {
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, processResourceEntry(entry));
}

@@ -26,13 +23,13 @@ }

function processRequest(request) {
var type = request.type === browser_core_1.RequestType.XHR ? browser_core_1.ResourceType.XHR : browser_core_1.ResourceType.FETCH;
var matchingTiming = matchRequestTiming_1.matchRequestTiming(request);
var startClocks = matchingTiming ? browser_core_1.relativeToClocks(matchingTiming.startTime) : request.startClocks;
var type = request.type === "xhr" /* XHR */ ? "xhr" /* XHR */ : "fetch" /* FETCH */;
var matchingTiming = (0, matchRequestTiming_1.matchRequestTiming)(request);
var startClocks = matchingTiming ? (0, browser_core_1.relativeToClocks)(matchingTiming.startTime) : request.startClocks;
var correspondingTimingOverrides = matchingTiming ? computePerformanceEntryMetrics(matchingTiming) : undefined;
var tracingInfo = computeRequestTracingInfo(request);
var resourceEvent = browser_core_1.combine({
var resourceEvent = (0, browser_core_1.combine)({
date: startClocks.timeStamp,
resource: {
id: browser_core_1.generateUUID(),
id: (0, browser_core_1.generateUUID)(),
type: type,
duration: browser_core_1.toServerDuration(request.duration),
duration: (0, browser_core_1.toServerDuration)(request.duration),
method: request.method,

@@ -42,3 +39,3 @@ status_code: request.status,

},
type: rawRumEvent_types_1.RumEventType.RESOURCE,
type: "resource" /* RESOURCE */,
}, tracingInfo, correspondingTimingOverrides);

@@ -59,14 +56,14 @@ return {

function processResourceEntry(entry) {
var type = resourceUtils_1.computeResourceKind(entry);
var type = (0, resourceUtils_1.computeResourceKind)(entry);
var entryMetrics = computePerformanceEntryMetrics(entry);
var tracingInfo = computeEntryTracingInfo(entry);
var startClocks = browser_core_1.relativeToClocks(entry.startTime);
var resourceEvent = browser_core_1.combine({
var startClocks = (0, browser_core_1.relativeToClocks)(entry.startTime);
var resourceEvent = (0, browser_core_1.combine)({
date: startClocks.timeStamp,
resource: {
id: browser_core_1.generateUUID(),
id: (0, browser_core_1.generateUUID)(),
type: type,
url: entry.name,
},
type: rawRumEvent_types_1.RumEventType.RESOURCE,
type: "resource" /* RESOURCE */,
}, tracingInfo, entryMetrics);

@@ -83,3 +80,6 @@ return {

return {
resource: tslib_1.__assign({ duration: resourceUtils_1.computePerformanceResourceDuration(timing), size: resourceUtils_1.computeSize(timing) }, resourceUtils_1.computePerformanceResourceDetails(timing)),
resource: (0, browser_core_1.assign)({
duration: (0, resourceUtils_1.computePerformanceResourceDuration)(timing),
size: (0, resourceUtils_1.computeSize)(timing),
}, (0, resourceUtils_1.computePerformanceResourceDetails)(timing)),
};

@@ -103,3 +103,3 @@ }

function toPerformanceEntryRepresentation(entry) {
if (performanceCollection_1.supportPerformanceEntry() && entry instanceof PerformanceEntry) {
if ((0, performanceCollection_1.supportPerformanceEntry)() && entry instanceof PerformanceEntry) {
entry.toJSON();

@@ -106,0 +106,0 @@ }

@@ -15,3 +15,3 @@ import type { ServerDuration } from '@datadog/browser-core';

export declare const FAKE_INITIAL_DOCUMENT = "initial_document";
export declare function computeResourceKind(timing: RumPerformanceResourceTiming): ResourceType | ResourceType.OTHER;
export declare function computeResourceKind(timing: RumPerformanceResourceTiming): ResourceType;
export declare function isRequestKind(timing: RumPerformanceResourceTiming): boolean;

@@ -18,0 +18,0 @@ export declare function computePerformanceResourceDuration(entry: RumPerformanceResourceTiming): ServerDuration;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAllowedRequestUrl = exports.computeSize = exports.toValidEntry = exports.computePerformanceResourceDetails = exports.computePerformanceResourceDuration = exports.isRequestKind = exports.computeResourceKind = exports.FAKE_INITIAL_DOCUMENT = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
exports.FAKE_INITIAL_DOCUMENT = 'initial_document';
var RESOURCE_TYPES = [
[browser_core_1.ResourceType.DOCUMENT, function (initiatorType) { return exports.FAKE_INITIAL_DOCUMENT === initiatorType; }],
[browser_core_1.ResourceType.XHR, function (initiatorType) { return 'xmlhttprequest' === initiatorType; }],
[browser_core_1.ResourceType.FETCH, function (initiatorType) { return 'fetch' === initiatorType; }],
[browser_core_1.ResourceType.BEACON, function (initiatorType) { return 'beacon' === initiatorType; }],
[browser_core_1.ResourceType.CSS, function (_, path) { return /\.css$/i.test(path); }],
[browser_core_1.ResourceType.JS, function (_, path) { return /\.js$/i.test(path); }],
["document" /* DOCUMENT */, function (initiatorType) { return exports.FAKE_INITIAL_DOCUMENT === initiatorType; }],
["xhr" /* XHR */, function (initiatorType) { return 'xmlhttprequest' === initiatorType; }],
["fetch" /* FETCH */, function (initiatorType) { return 'fetch' === initiatorType; }],
["beacon" /* BEACON */, function (initiatorType) { return 'beacon' === initiatorType; }],
["css" /* CSS */, function (_, path) { return /\.css$/i.test(path); }],
["js" /* JS */, function (_, path) { return /\.js$/i.test(path); }],
[
browser_core_1.ResourceType.IMAGE,
"image" /* IMAGE */,
function (initiatorType, path) {
return browser_core_1.includes(['image', 'img', 'icon'], initiatorType) || /\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i.exec(path) !== null;
return (0, browser_core_1.includes)(['image', 'img', 'icon'], initiatorType) || /\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i.exec(path) !== null;
},
],
[browser_core_1.ResourceType.FONT, function (_, path) { return /\.(woff|eot|woff2|ttf)$/i.exec(path) !== null; }],
["font" /* FONT */, function (_, path) { return /\.(woff|eot|woff2|ttf)$/i.exec(path) !== null; }],
[
browser_core_1.ResourceType.MEDIA,
"media" /* MEDIA */,
function (initiatorType, path) {
return browser_core_1.includes(['audio', 'video'], initiatorType) || /\.(mp3|mp4)$/i.exec(path) !== null;
return (0, browser_core_1.includes)(['audio', 'video'], initiatorType) || /\.(mp3|mp4)$/i.exec(path) !== null;
},

@@ -30,7 +29,7 @@ ],

var url = timing.name;
if (!browser_core_1.isValidUrl(url)) {
browser_core_1.addMonitoringMessage("Failed to construct URL for \"" + timing.name + "\"");
return browser_core_1.ResourceType.OTHER;
if (!(0, browser_core_1.isValidUrl)(url)) {
(0, browser_core_1.addMonitoringMessage)("Failed to construct URL for \"".concat(timing.name, "\""));
return "other" /* OTHER */;
}
var path = browser_core_1.getPathName(url);
var path = (0, browser_core_1.getPathName)(url);
for (var _i = 0, RESOURCE_TYPES_1 = RESOURCE_TYPES; _i < RESOURCE_TYPES_1.length; _i++) {

@@ -42,3 +41,3 @@ var _a = RESOURCE_TYPES_1[_i], type = _a[0], isType = _a[1];

}
return browser_core_1.ResourceType.OTHER;
return "other" /* OTHER */;
}

@@ -66,5 +65,5 @@ exports.computeResourceKind = computeResourceKind;

if (duration === 0 && startTime < responseEnd) {
return browser_core_1.toServerDuration(browser_core_1.elapsed(startTime, responseEnd));
return (0, browser_core_1.toServerDuration)((0, browser_core_1.elapsed)(startTime, responseEnd));
}
return browser_core_1.toServerDuration(duration);
return (0, browser_core_1.toServerDuration)(duration);
}

@@ -124,4 +123,6 @@ exports.computePerformanceResourceDuration = computePerformanceResourceDuration;

}
return tslib_1.__assign(tslib_1.__assign({}, entry), { redirectEnd: redirectEnd,
redirectStart: redirectStart });
return (0, browser_core_1.assign)({}, entry, {
redirectEnd: redirectEnd,
redirectStart: redirectStart,
});
}

@@ -135,4 +136,4 @@ exports.toValidEntry = toValidEntry;

return {
duration: browser_core_1.toServerDuration(browser_core_1.elapsed(start, end)),
start: browser_core_1.toServerDuration(browser_core_1.elapsed(origin, start)),
duration: (0, browser_core_1.toServerDuration)((0, browser_core_1.elapsed)(start, end)),
start: (0, browser_core_1.toServerDuration)((0, browser_core_1.elapsed)(origin, start)),
};

@@ -139,0 +140,0 @@ }

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

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

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.trackFirstInputTimings = exports.trackLargestContentfulPaintTiming = exports.trackFirstContentfulPaintTiming = exports.trackNavigationTimings = exports.trackInitialViewTimings = exports.TIMING_MAXIMUM_DELAY = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var lifeCycle_1 = require("../../lifeCycle");
var trackFirstHidden_1 = require("./trackFirstHidden");

@@ -12,5 +10,5 @@ // Discard LCP and FCP timings above a certain delay to avoid incorrect data

function trackInitialViewTimings(lifeCycle, callback) {
var timings;
var timings = {};
function setTimings(newTimings) {
timings = tslib_1.__assign(tslib_1.__assign({}, timings), newTimings);
(0, browser_core_1.assign)(timings, newTimings);
callback(timings);

@@ -45,3 +43,3 @@ }

function trackNavigationTimings(lifeCycle, callback) {
var stop = lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
var stop = lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {

@@ -63,5 +61,5 @@ var entry = entries_1[_i];

function trackFirstContentfulPaintTiming(lifeCycle, callback) {
var firstHidden = trackFirstHidden_1.trackFirstHidden();
var stop = lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
var fcpEntry = browser_core_1.find(entries, function (entry) {
var firstHidden = (0, trackFirstHidden_1.trackFirstHidden)();
var stop = lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
var fcpEntry = (0, browser_core_1.find)(entries, function (entry) {
return entry.entryType === 'paint' &&

@@ -86,3 +84,3 @@ entry.name === 'first-contentful-paint' &&

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

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

var firstInteractionTimestamp = Infinity;
var stopEventListener = browser_core_1.addEventListeners(emitter, ["pointerdown" /* POINTER_DOWN */, "keydown" /* KEY_DOWN */], function (event) {
var stopEventListener = (0, browser_core_1.addEventListeners)(emitter, ["pointerdown" /* POINTER_DOWN */, "keydown" /* KEY_DOWN */], function (event) {
firstInteractionTimestamp = event.timeStamp;
}, { capture: true, once: true }).stop;
var unsubscribeLifeCycle = lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
var lcpEntry = browser_core_1.findLast(entries, function (entry) {
var unsubscribeLifeCycle = lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
var lcpEntry = (0, browser_core_1.findLast)(entries, function (entry) {
return entry.entryType === 'largest-contentful-paint' &&

@@ -124,9 +122,9 @@ entry.startTime < firstInteractionTimestamp &&

function trackFirstInputTimings(lifeCycle, callback) {
var firstHidden = trackFirstHidden_1.trackFirstHidden();
var stop = lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
var firstInputEntry = browser_core_1.find(entries, function (entry) {
var firstHidden = (0, trackFirstHidden_1.trackFirstHidden)();
var stop = lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
var firstInputEntry = (0, browser_core_1.find)(entries, function (entry) {
return entry.entryType === 'first-input' && entry.startTime < firstHidden.timeStamp;
});
if (firstInputEntry) {
var firstInputDelay = browser_core_1.elapsed(firstInputEntry.startTime, firstInputEntry.processingStart);
var firstInputDelay = (0, browser_core_1.elapsed)(firstInputEntry.startTime, firstInputEntry.processingStart);
callback({

@@ -133,0 +131,0 @@ // Ensure firstInputDelay to be positive, see

@@ -6,4 +6,2 @@ "use strict";

var performanceCollection_1 = require("../../../browser/performanceCollection");
var rawRumEvent_types_1 = require("../../../rawRumEvent.types");
var lifeCycle_1 = require("../../lifeCycle");
var trackEventCounts_1 = require("../../trackEventCounts");

@@ -20,3 +18,3 @@ var waitIdlePage_1 = require("../../waitIdlePage");

};
var stopEventCountsTracking = trackEventCounts_1.trackEventCounts(lifeCycle, function (newEventCounts) {
var stopEventCountsTracking = (0, trackEventCounts_1.trackEventCounts)(lifeCycle, function (newEventCounts) {
viewMetrics.eventCounts = newEventCounts;

@@ -52,3 +50,3 @@ scheduleViewUpdate();

function trackLoadingTime(lifeCycle, domMutationObservable, loadType, viewStart, callback) {
var isWaitingForLoadEvent = loadType === rawRumEvent_types_1.ViewLoadingType.INITIAL_LOAD;
var isWaitingForLoadEvent = loadType === "initial_load" /* INITIAL_LOAD */;
var isWaitingForActivityLoadingTime = true;

@@ -61,7 +59,7 @@ var loadingTimeCandidates = [];

}
var stop = waitIdlePage_1.waitIdlePage(lifeCycle, domMutationObservable, function (event) {
var stop = (0, waitIdlePage_1.waitIdlePage)(lifeCycle, domMutationObservable, function (event) {
if (isWaitingForActivityLoadingTime) {
isWaitingForActivityLoadingTime = false;
if (event.hadActivity) {
loadingTimeCandidates.push(browser_core_1.elapsed(viewStart.timeStamp, event.end));
loadingTimeCandidates.push((0, browser_core_1.elapsed)(viewStart.timeStamp, event.end));
}

@@ -102,3 +100,3 @@ invokeCallbackIfAllCandidatesAreReceived();

var window = slidingSessionWindow();
var stop = lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
var stop = lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {

@@ -110,3 +108,3 @@ var entry = entries_1[_i];

maxClsValue = window.value();
callback(browser_core_1.round(maxClsValue, 4));
callback((0, browser_core_1.round)(maxClsValue, 4));
}

@@ -145,4 +143,4 @@ }

function isLayoutShiftSupported() {
return performanceCollection_1.supportPerformanceTimingEvent('layout-shift');
return (0, performanceCollection_1.supportPerformanceTimingEvent)('layout-shift');
}
//# sourceMappingURL=trackViewMetrics.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.trackViews = exports.SESSION_KEEP_ALIVE_INTERVAL = exports.THROTTLE_VIEW_UPDATE_PERIOD = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../../../rawRumEvent.types");
var lifeCycle_1 = require("../../lifeCycle");
var trackInitialViewTimings_1 = require("./trackInitialViewTimings");

@@ -21,4 +18,4 @@ var trackViewMetrics_1 = require("./trackViewMetrics");

function trackInitialView(name) {
var initialView = newView(lifeCycle, domMutationObservable, location, rawRumEvent_types_1.ViewLoadingType.INITIAL_LOAD, browser_core_1.clocksOrigin(), name);
var stop = trackInitialViewTimings_1.trackInitialViewTimings(lifeCycle, function (timings) {
var initialView = newView(lifeCycle, domMutationObservable, location, "initial_load" /* INITIAL_LOAD */, (0, browser_core_1.clocksOrigin)(), name);
var stop = (0, trackInitialViewTimings_1.trackInitialViewTimings)(lifeCycle, function (timings) {
initialView.updateTimings(timings);

@@ -30,6 +27,6 @@ initialView.scheduleUpdate();

function trackViewChange(startClocks, name) {
return newView(lifeCycle, domMutationObservable, location, rawRumEvent_types_1.ViewLoadingType.ROUTE_CHANGE, startClocks, name);
return newView(lifeCycle, domMutationObservable, location, "route_change" /* ROUTE_CHANGE */, startClocks, name);
}
function startViewLifeCycle() {
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.SESSION_RENEWED, function () {
lifeCycle.subscribe(10 /* SESSION_RENEWED */, function () {
// do not trigger view update to avoid wrong data

@@ -41,3 +38,3 @@ currentView.end();

// End the current view on page unload
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.BEFORE_UNLOAD, function () {
lifeCycle.subscribe(11 /* BEFORE_UNLOAD */, function () {
currentView.end();

@@ -47,3 +44,3 @@ currentView.triggerUpdate();

// Session keep alive
var keepAliveInterval = window.setInterval(browser_core_1.monitor(function () {
var keepAliveInterval = window.setInterval((0, browser_core_1.monitor)(function () {
currentView.triggerUpdate();

@@ -70,3 +67,3 @@ }), exports.SESSION_KEEP_ALIVE_INTERVAL);

addTiming: function (name, time) {
if (time === void 0) { time = browser_core_1.timeStampNow(); }
if (time === void 0) { time = (0, browser_core_1.timeStampNow)(); }
currentView.addTiming(name, time);

@@ -90,5 +87,5 @@ currentView.scheduleUpdate();

function newView(lifeCycle, domMutationObservable, initialLocation, loadingType, startClocks, name) {
if (startClocks === void 0) { startClocks = browser_core_1.clocksNow(); }
if (startClocks === void 0) { startClocks = (0, browser_core_1.clocksNow)(); }
// Setup initial values
var id = browser_core_1.generateUUID();
var id = (0, browser_core_1.generateUUID)();
var timings = {};

@@ -98,9 +95,9 @@ var customTimings = {};

var endClocks;
var location = tslib_1.__assign({}, initialLocation);
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.VIEW_CREATED, { id: id, name: name, startClocks: startClocks });
var location = (0, browser_core_1.shallowClone)(initialLocation);
lifeCycle.notify(4 /* VIEW_CREATED */, { id: id, name: name, startClocks: startClocks });
// Update the view every time the measures are changing
var _a = browser_core_1.throttle(browser_core_1.monitor(triggerViewUpdate), exports.THROTTLE_VIEW_UPDATE_PERIOD, {
var _a = (0, browser_core_1.throttle)((0, browser_core_1.monitor)(triggerViewUpdate), exports.THROTTLE_VIEW_UPDATE_PERIOD, {
leading: false,
}), scheduleViewUpdate = _a.throttled, cancelScheduleViewUpdate = _a.cancel;
var _b = trackViewMetrics_1.trackViewMetrics(lifeCycle, domMutationObservable, scheduleViewUpdate, loadingType, startClocks), setLoadEvent = _b.setLoadEvent, stopViewMetricsTracking = _b.stop, viewMetrics = _b.viewMetrics;
var _b = (0, trackViewMetrics_1.trackViewMetrics)(lifeCycle, domMutationObservable, scheduleViewUpdate, loadingType, startClocks), setLoadEvent = _b.setLoadEvent, stopViewMetricsTracking = _b.stop, viewMetrics = _b.viewMetrics;
// Initial view update

@@ -110,4 +107,5 @@ triggerViewUpdate();

documentVersion += 1;
var currentEnd = endClocks === undefined ? browser_core_1.timeStampNow() : endClocks.timeStamp;
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.VIEW_UPDATED, tslib_1.__assign(tslib_1.__assign({}, viewMetrics), { customTimings: customTimings,
var currentEnd = endClocks === undefined ? (0, browser_core_1.timeStampNow)() : endClocks.timeStamp;
lifeCycle.notify(5 /* VIEW_UPDATED */, (0, browser_core_1.assign)({
customTimings: customTimings,
documentVersion: documentVersion,

@@ -119,3 +117,6 @@ id: id,

startClocks: startClocks,
timings: timings, duration: browser_core_1.elapsed(startClocks.timeStamp, currentEnd), isActive: endClocks === undefined }));
timings: timings,
duration: (0, browser_core_1.elapsed)(startClocks.timeStamp, currentEnd),
isActive: endClocks === undefined,
}, viewMetrics));
}

@@ -126,6 +127,6 @@ return {

end: function (clocks) {
if (clocks === void 0) { clocks = browser_core_1.clocksNow(); }
if (clocks === void 0) { clocks = (0, browser_core_1.clocksNow)(); }
endClocks = clocks;
stopViewMetricsTracking();
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.VIEW_ENDED, { endClocks: endClocks });
lifeCycle.notify(6 /* VIEW_ENDED */, { endClocks: endClocks });
},

@@ -144,3 +145,3 @@ triggerUpdate: function () {

addTiming: function (name, time) {
var relativeTime = browser_core_1.looksLikeRelativeTime(time) ? time : browser_core_1.elapsed(startClocks.timeStamp, time);
var relativeTime = (0, browser_core_1.looksLikeRelativeTime)(time) ? time : (0, browser_core_1.elapsed)(startClocks.timeStamp, time);
customTimings[sanitizeTiming(name)] = relativeTime;

@@ -156,3 +157,3 @@ },

if (sanitized !== name) {
browser_core_1.display.warn("Invalid timing name: " + name + ", sanitized to: " + sanitized);
browser_core_1.display.warn("Invalid timing name: ".concat(name, ", sanitized to: ").concat(sanitized));
}

@@ -159,0 +160,0 @@ return sanitized;

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

var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../../../rawRumEvent.types");
var lifeCycle_1 = require("../../lifeCycle");
var trackViews_1 = require("./trackViews");
function startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, foregroundContexts, recorderApi, initialViewName) {
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.VIEW_UPDATED, function (view) {
return lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processViewUpdate(view, foregroundContexts, recorderApi));
lifeCycle.subscribe(5 /* VIEW_UPDATED */, function (view) {
return lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, processViewUpdate(view, foregroundContexts, recorderApi));
});
return trackViews_1.trackViews(location, lifeCycle, domMutationObservable, locationChangeObservable, !configuration.trackViewsManually, initialViewName);
return (0, trackViews_1.trackViews)(location, lifeCycle, domMutationObservable, locationChangeObservable, !configuration.trackViewsManually, initialViewName);
}

@@ -24,3 +22,3 @@ exports.startViewCollection = startViewCollection;

date: view.startClocks.timeStamp,
type: rawRumEvent_types_1.RumEventType.VIEW,
type: "view" /* VIEW */,
view: {

@@ -31,16 +29,16 @@ action: {

cumulative_layout_shift: view.cumulativeLayoutShift,
dom_complete: browser_core_1.toServerDuration(view.timings.domComplete),
dom_content_loaded: browser_core_1.toServerDuration(view.timings.domContentLoaded),
dom_interactive: browser_core_1.toServerDuration(view.timings.domInteractive),
dom_complete: (0, browser_core_1.toServerDuration)(view.timings.domComplete),
dom_content_loaded: (0, browser_core_1.toServerDuration)(view.timings.domContentLoaded),
dom_interactive: (0, browser_core_1.toServerDuration)(view.timings.domInteractive),
error: {
count: view.eventCounts.errorCount,
},
first_contentful_paint: browser_core_1.toServerDuration(view.timings.firstContentfulPaint),
first_input_delay: browser_core_1.toServerDuration(view.timings.firstInputDelay),
first_input_time: browser_core_1.toServerDuration(view.timings.firstInputTime),
first_contentful_paint: (0, browser_core_1.toServerDuration)(view.timings.firstContentfulPaint),
first_input_delay: (0, browser_core_1.toServerDuration)(view.timings.firstInputDelay),
first_input_time: (0, browser_core_1.toServerDuration)(view.timings.firstInputTime),
is_active: view.isActive,
name: view.name,
largest_contentful_paint: browser_core_1.toServerDuration(view.timings.largestContentfulPaint),
load_event: browser_core_1.toServerDuration(view.timings.loadEvent),
loading_time: discardNegativeDuration(browser_core_1.toServerDuration(view.loadingTime)),
largest_contentful_paint: (0, browser_core_1.toServerDuration)(view.timings.largestContentfulPaint),
load_event: (0, browser_core_1.toServerDuration)(view.timings.loadEvent),
loading_time: discardNegativeDuration((0, browser_core_1.toServerDuration)(view.loadingTime)),
loading_type: view.loadingType,

@@ -53,3 +51,3 @@ long_task: {

},
time_spent: browser_core_1.toServerDuration(view.duration),
time_spent: (0, browser_core_1.toServerDuration)(view.duration),
in_foreground_periods: foregroundContexts.selectInForegroundPeriodsFor(view.startClocks.relative, view.duration),

@@ -61,4 +59,4 @@ },

};
if (!browser_core_1.isEmptyObject(view.customTimings)) {
viewEvent.view.custom_timings = browser_core_1.mapValues(view.customTimings, browser_core_1.toServerDuration);
if (!(0, browser_core_1.isEmptyObject)(view.customTimings)) {
viewEvent.view.custom_timings = (0, browser_core_1.mapValues)(view.customTimings, browser_core_1.toServerDuration);
}

@@ -74,4 +72,4 @@ return {

function discardNegativeDuration(duration) {
return browser_core_1.isNumber(duration) && duration < 0 ? undefined : duration;
return (0, browser_core_1.isNumber)(duration) && duration < 0 ? undefined : duration;
}
//# sourceMappingURL=viewCollection.js.map

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

};
export declare enum RumSessionPlan {
export declare const enum RumSessionPlan {
LITE = 1,
REPLAY = 2
}
export declare enum RumTrackingType {
export declare const enum RumTrackingType {
NOT_TRACKED = "0",

@@ -20,0 +20,0 @@ TRACKED_REPLAY = "1",

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startRumSessionManagerStub = exports.startRumSessionManager = exports.RumTrackingType = exports.RumSessionPlan = exports.RUM_SESSION_KEY = void 0;
exports.startRumSessionManagerStub = exports.startRumSessionManager = exports.RUM_SESSION_KEY = void 0;
var browser_core_1 = require("@datadog/browser-core");
var lifeCycle_1 = require("./lifeCycle");
exports.RUM_SESSION_KEY = 'rum';
var RumSessionPlan;
(function (RumSessionPlan) {
RumSessionPlan[RumSessionPlan["LITE"] = 1] = "LITE";
RumSessionPlan[RumSessionPlan["REPLAY"] = 2] = "REPLAY";
})(RumSessionPlan = exports.RumSessionPlan || (exports.RumSessionPlan = {}));
var RumTrackingType;
(function (RumTrackingType) {
RumTrackingType["NOT_TRACKED"] = "0";
// Note: the "tracking type" value (stored in the session cookie) does not match the "session
// plan" value (sent in RUM events). This is expected, and was done to keep retrocompatibility
// with active sessions when upgrading the SDK.
RumTrackingType["TRACKED_REPLAY"] = "1";
RumTrackingType["TRACKED_LITE"] = "2";
})(RumTrackingType = exports.RumTrackingType || (exports.RumTrackingType = {}));
function startRumSessionManager(configuration, lifeCycle) {
var sessionManager = browser_core_1.startSessionManager(configuration.cookieOptions, exports.RUM_SESSION_KEY, function (rawTrackingType) {
var sessionManager = (0, browser_core_1.startSessionManager)(configuration.cookieOptions, exports.RUM_SESSION_KEY, function (rawTrackingType) {
return computeSessionState(configuration, rawTrackingType);
});
sessionManager.expireObservable.subscribe(function () {
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.SESSION_EXPIRED);
lifeCycle.notify(9 /* SESSION_EXPIRED */);
});
sessionManager.renewObservable.subscribe(function () {
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.SESSION_RENEWED);
lifeCycle.notify(10 /* SESSION_RENEWED */);
});

@@ -39,4 +24,4 @@ return {

id: session.id,
hasReplayPlan: session.trackingType === RumTrackingType.TRACKED_REPLAY,
hasLitePlan: session.trackingType === RumTrackingType.TRACKED_LITE,
hasReplayPlan: session.trackingType === "1" /* TRACKED_REPLAY */,
hasLitePlan: session.trackingType === "2" /* TRACKED_LITE */,
};

@@ -67,10 +52,10 @@ },

}
else if (!browser_core_1.performDraw(configuration.sampleRate)) {
trackingType = RumTrackingType.NOT_TRACKED;
else if (!(0, browser_core_1.performDraw)(configuration.sampleRate)) {
trackingType = "0" /* NOT_TRACKED */;
}
else if (!browser_core_1.performDraw(configuration.replaySampleRate)) {
trackingType = RumTrackingType.TRACKED_LITE;
else if (!(0, browser_core_1.performDraw)(configuration.replaySampleRate)) {
trackingType = "2" /* TRACKED_LITE */;
}
else {
trackingType = RumTrackingType.TRACKED_REPLAY;
trackingType = "1" /* TRACKED_REPLAY */;
}

@@ -83,9 +68,9 @@ return {

function hasValidRumSession(trackingType) {
return (trackingType === RumTrackingType.NOT_TRACKED ||
trackingType === RumTrackingType.TRACKED_REPLAY ||
trackingType === RumTrackingType.TRACKED_LITE);
return (trackingType === "0" /* NOT_TRACKED */ ||
trackingType === "1" /* TRACKED_REPLAY */ ||
trackingType === "2" /* TRACKED_LITE */);
}
function isTypeTracked(rumSessionType) {
return rumSessionType === RumTrackingType.TRACKED_LITE || rumSessionType === RumTrackingType.TRACKED_REPLAY;
return rumSessionType === "2" /* TRACKED_LITE */ || rumSessionType === "1" /* TRACKED_REPLAY */;
}
//# sourceMappingURL=rumSessionManager.js.map

@@ -9,4 +9,4 @@ "use strict";

function getSyntheticsContext() {
var testId = window._DATADOG_SYNTHETICS_PUBLIC_ID || browser_core_1.getCookie(exports.SYNTHETICS_TEST_ID_COOKIE_NAME);
var resultId = window._DATADOG_SYNTHETICS_RESULT_ID || browser_core_1.getCookie(exports.SYNTHETICS_RESULT_ID_COOKIE_NAME);
var testId = window._DATADOG_SYNTHETICS_PUBLIC_ID || (0, browser_core_1.getCookie)(exports.SYNTHETICS_TEST_ID_COOKIE_NAME);
var resultId = window._DATADOG_SYNTHETICS_RESULT_ID || (0, browser_core_1.getCookie)(exports.SYNTHETICS_RESULT_ID_COOKIE_NAME);
if (typeof testId === 'string' && typeof resultId === 'string') {

@@ -22,5 +22,5 @@ return {

function willSyntheticsInjectRum() {
return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM || browser_core_1.getCookie(exports.SYNTHETICS_INJECTS_RUM_COOKIE_NAME));
return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM || (0, browser_core_1.getCookie)(exports.SYNTHETICS_INJECTS_RUM_COOKIE_NAME));
}
exports.willSyntheticsInjectRum = willSyntheticsInjectRum;
//# sourceMappingURL=syntheticsContext.js.map

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

}
return createDocumentTraceData(browser_core_1.findCommaSeparatedValue(comment, 'trace-id'), browser_core_1.findCommaSeparatedValue(comment, 'trace-time'));
return createDocumentTraceData((0, browser_core_1.findCommaSeparatedValue)(comment, 'trace-id'), (0, browser_core_1.findCommaSeparatedValue)(comment, 'trace-time'));
}

@@ -28,0 +28,0 @@ exports.getDocumentTraceDataFromComment = getDocumentTraceDataFromComment;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TraceIdentifier = exports.isTracingSupported = exports.startTracer = exports.clearTracingIfNeeded = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");

@@ -44,3 +43,3 @@ /**

else {
context.init = tslib_1.__assign({}, context.init);
context.init = (0, browser_core_1.shallowClone)(context.init);
var headers_1 = [];

@@ -62,3 +61,3 @@ if (context.init.headers instanceof Headers) {

}
context.init.headers = headers_1.concat(browser_core_1.objectEntries(tracingHeaders));
context.init.headers = headers_1.concat((0, browser_core_1.objectEntries)(tracingHeaders));
}

@@ -86,3 +85,3 @@ });

function isAllowedUrl(configuration, requestUrl) {
var requestOrigin = browser_core_1.getOrigin(requestUrl);
var requestOrigin = (0, browser_core_1.getOrigin)(requestUrl);
for (var _i = 0, _a = configuration.allowedTracingOrigins; _i < _a.length; _i++) {

@@ -89,0 +88,0 @@ var allowedOrigin = _a[_i];

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

var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../rawRumEvent.types");
var lifeCycle_1 = require("./lifeCycle");
function trackEventCounts(lifeCycle, callback) {

@@ -16,18 +14,18 @@ if (callback === void 0) { callback = browser_core_1.noop; }

};
var subscription = lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RUM_EVENT_COLLECTED, function (_a) {
var subscription = lifeCycle.subscribe(13 /* RUM_EVENT_COLLECTED */, function (_a) {
var type = _a.type;
switch (type) {
case rawRumEvent_types_1.RumEventType.ERROR:
case "error" /* ERROR */:
eventCounts.errorCount += 1;
callback(eventCounts);
break;
case rawRumEvent_types_1.RumEventType.ACTION:
case "action" /* ACTION */:
eventCounts.userActionCount += 1;
callback(eventCounts);
break;
case rawRumEvent_types_1.RumEventType.LONG_TASK:
case "long_task" /* LONG_TASK */:
eventCounts.longTaskCount += 1;
callback(eventCounts);
break;
case rawRumEvent_types_1.RumEventType.RESOURCE:
case "resource" /* RESOURCE */:
eventCounts.resourceCount += 1;

@@ -34,0 +32,0 @@ callback(eventCounts);

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

var browser_core_1 = require("@datadog/browser-core");
var lifeCycle_1 = require("./lifeCycle");
/**

@@ -16,7 +15,7 @@ * We want to attach to an event:

var previousViewUrl;
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.VIEW_ENDED, function (_a) {
lifeCycle.subscribe(6 /* VIEW_ENDED */, function (_a) {
var endClocks = _a.endClocks;
urlContextHistory.closeCurrent(endClocks.relative);
});
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.VIEW_CREATED, function (_a) {
lifeCycle.subscribe(4 /* VIEW_CREATED */, function (_a) {
var startClocks = _a.startClocks;

@@ -34,3 +33,3 @@ var viewUrl = location.href;

if (current) {
var changeTime = browser_core_1.relativeNow();
var changeTime = (0, browser_core_1.relativeNow)();
urlContextHistory.closeCurrent(changeTime);

@@ -37,0 +36,0 @@ urlContextHistory.setCurrent(buildUrlContext({

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

var browser_core_1 = require("@datadog/browser-core");
var lifeCycle_1 = require("./lifeCycle");
// Delay to wait for a page activity to validate the tracking process

@@ -49,5 +48,5 @@ exports.PAGE_ACTIVITY_VALIDATION_DELAY = 100;

var hasCompleted = false;
var validationTimeoutId = setTimeout(browser_core_1.monitor(function () { return complete({ hadActivity: false }); }), exports.PAGE_ACTIVITY_VALIDATION_DELAY);
var validationTimeoutId = setTimeout((0, browser_core_1.monitor)(function () { return complete({ hadActivity: false }); }), exports.PAGE_ACTIVITY_VALIDATION_DELAY);
var maxDurationTimeoutId = maxDuration &&
setTimeout(browser_core_1.monitor(function () { return complete({ hadActivity: true, end: browser_core_1.timeStampNow() }); }), maxDuration);
setTimeout((0, browser_core_1.monitor)(function () { return complete({ hadActivity: true, end: (0, browser_core_1.timeStampNow)() }); }), maxDuration);
var pageActivitySubscription = pageActivityObservable.subscribe(function (_a) {

@@ -57,5 +56,5 @@ var isBusy = _a.isBusy;

clearTimeout(idleTimeoutId);
var lastChangeTime = browser_core_1.timeStampNow();
var lastChangeTime = (0, browser_core_1.timeStampNow)();
if (!isBusy) {
idleTimeoutId = setTimeout(browser_core_1.monitor(function () { return complete({ hadActivity: true, end: lastChangeTime }); }), exports.PAGE_ACTIVITY_END_DELAY);
idleTimeoutId = setTimeout((0, browser_core_1.monitor)(function () { return complete({ hadActivity: true, end: lastChangeTime }); }), exports.PAGE_ACTIVITY_END_DELAY);
}

@@ -85,3 +84,3 @@ });

var pendingRequestsCount = 0;
subscriptions.push(domMutationObservable.subscribe(function () { return notifyPageActivity(pendingRequestsCount); }), lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
subscriptions.push(domMutationObservable.subscribe(function () { return notifyPageActivity(pendingRequestsCount); }), lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
if (entries.some(function (_a) {

@@ -93,3 +92,3 @@ var entryType = _a.entryType;

}
}), lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.REQUEST_STARTED, function (startEvent) {
}), lifeCycle.subscribe(7 /* REQUEST_STARTED */, function (startEvent) {
if (firstRequestIndex === undefined) {

@@ -99,3 +98,3 @@ firstRequestIndex = startEvent.requestIndex;

notifyPageActivity(++pendingRequestsCount);
}), lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.REQUEST_COMPLETED, function (request) {
}), lifeCycle.subscribe(8 /* REQUEST_COMPLETED */, function (request) {
// If the request started before the tracking start, ignore it

@@ -102,0 +101,0 @@ if (firstRequestIndex === undefined || request.requestIndex < firstRequestIndex) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMutationObserverConstructor = exports.RumSessionPlan = exports.LifeCycleEventType = exports.LifeCycle = exports.startRum = exports.makeRumPublicApi = void 0;
exports.getMutationObserverConstructor = exports.LifeCycle = exports.startRum = exports.makeRumPublicApi = void 0;
var rumPublicApi_1 = require("./boot/rumPublicApi");

@@ -10,7 +10,4 @@ Object.defineProperty(exports, "makeRumPublicApi", { enumerable: true, get: function () { return rumPublicApi_1.makeRumPublicApi; } });

Object.defineProperty(exports, "LifeCycle", { enumerable: true, get: function () { return lifeCycle_1.LifeCycle; } });
Object.defineProperty(exports, "LifeCycleEventType", { enumerable: true, get: function () { return lifeCycle_1.LifeCycleEventType; } });
var rumSessionManager_1 = require("./domain/rumSessionManager");
Object.defineProperty(exports, "RumSessionPlan", { enumerable: true, get: function () { return rumSessionManager_1.RumSessionPlan; } });
var domMutationObservable_1 = require("./browser/domMutationObservable");
Object.defineProperty(exports, "getMutationObserverConstructor", { enumerable: true, get: function () { return domMutationObservable_1.getMutationObserverConstructor; } });
//# sourceMappingURL=index.js.map
import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp } from '@datadog/browser-core';
import type { RumSessionPlan } from './domain/rumSessionManager';
export declare enum RumEventType {
export declare const enum RumEventType {
ACTION = "action",

@@ -41,7 +41,2 @@ ERROR = "error",

error: {
resource?: {
url: string;
status_code: number;
method: string;
};
id: string;

@@ -99,3 +94,3 @@ type?: string;

}
export declare enum ViewLoadingType {
export declare const enum ViewLoadingType {
INITIAL_LOAD = "initial_load",

@@ -141,3 +136,3 @@ ROUTE_CHANGE = "route_change"

}
export declare enum ActionType {
export declare const enum ActionType {
CLICK = "click",

@@ -144,0 +139,0 @@ CUSTOM = "custom"

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionType = exports.ViewLoadingType = exports.RumEventType = void 0;
var RumEventType;
(function (RumEventType) {
RumEventType["ACTION"] = "action";
RumEventType["ERROR"] = "error";
RumEventType["LONG_TASK"] = "long_task";
RumEventType["VIEW"] = "view";
RumEventType["RESOURCE"] = "resource";
})(RumEventType = exports.RumEventType || (exports.RumEventType = {}));
var ViewLoadingType;
(function (ViewLoadingType) {
ViewLoadingType["INITIAL_LOAD"] = "initial_load";
ViewLoadingType["ROUTE_CHANGE"] = "route_change";
})(ViewLoadingType = exports.ViewLoadingType || (exports.ViewLoadingType = {}));
var ActionType;
(function (ActionType) {
ActionType["CLICK"] = "click";
ActionType["CUSTOM"] = "custom";
})(ActionType = exports.ActionType || (exports.ActionType = {}));
//# sourceMappingURL=rawRumEvent.types.js.map

@@ -119,3 +119,3 @@ /**

*/
readonly source: 'network' | 'source' | 'console' | 'logger' | 'agent' | 'webview' | 'custom';
readonly source: 'network' | 'source' | 'console' | 'logger' | 'agent' | 'webview' | 'custom' | 'report';
/**

@@ -122,0 +122,0 @@ * Stacktrace of the error

@@ -0,5 +1,4 @@

import type { Context, TelemetryEvent, Observable } from '@datadog/browser-core';
import type { RumConfiguration } from '../domain/configuration';
import type { LifeCycle } from '../domain/lifeCycle';
export declare function startRumBatch(configuration: RumConfiguration, lifeCycle: LifeCycle): {
stop: () => void;
};
export declare function startRumBatch(configuration: RumConfiguration, lifeCycle: LifeCycle, telemetryEventObservable: Observable<TelemetryEvent & Context>): void;

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

var browser_core_1 = require("@datadog/browser-core");
var lifeCycle_1 = require("../domain/lifeCycle");
var rawRumEvent_types_1 = require("../rawRumEvent.types");
function startRumBatch(configuration, lifeCycle) {
function startRumBatch(configuration, lifeCycle, telemetryEventObservable) {
var batch = makeRumBatch(configuration, lifeCycle);
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
if (serverRumEvent.type === rawRumEvent_types_1.RumEventType.VIEW) {
lifeCycle.subscribe(13 /* RUM_EVENT_COLLECTED */, function (serverRumEvent) {
if (serverRumEvent.type === "view" /* VIEW */) {
batch.upsert(serverRumEvent, serverRumEvent.view.id);

@@ -18,5 +16,3 @@ }

});
return {
stop: function () { return batch.stop(); },
};
telemetryEventObservable.subscribe(function (event) { return batch.add(event); });
}

@@ -26,3 +22,3 @@ exports.startRumBatch = startRumBatch;

var primaryBatch = createRumBatch(configuration.rumEndpointBuilder, function () {
return lifeCycle.notify(lifeCycle_1.LifeCycleEventType.BEFORE_UNLOAD);
return lifeCycle.notify(11 /* BEFORE_UNLOAD */);
});

@@ -38,10 +34,6 @@ var replicaBatch;

function withReplicaApplicationId(message) {
return browser_core_1.combine(message, { application: { id: replica.applicationId } });
return (0, browser_core_1.combine)(message, { application: { id: replica.applicationId } });
}
var stopped = false;
return {
add: function (message) {
if (stopped) {
return;
}
primaryBatch.add(message);

@@ -52,9 +44,3 @@ if (replicaBatch) {

},
stop: function () {
stopped = true;
},
upsert: function (message, key) {
if (stopped) {
return;
}
primaryBatch.upsert(message, key);

@@ -61,0 +47,0 @@ if (replicaBatch) {

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

var browser_core_1 = require("@datadog/browser-core");
var lifeCycle_1 = require("../domain/lifeCycle");
function startRumEventBridge(lifeCycle) {
var bridge = browser_core_1.getEventBridge();
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
var bridge = (0, browser_core_1.getEventBridge)();
lifeCycle.subscribe(13 /* RUM_EVENT_COLLECTED */, function (serverRumEvent) {
bridge.send('rum', serverRumEvent);

@@ -11,0 +10,0 @@ });

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

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

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

export declare type RumPublicApi = ReturnType<typeof makeRumPublicApi>;
export declare type StartRum = (configuration: RumConfiguration, internalMonitoring: InternalMonitoring, getCommonContext: () => CommonContext, recorderApi: RecorderApi, initialViewName?: string) => StartRumResult;
export declare type StartRum = (configuration: RumConfiguration, getCommonContext: () => CommonContext, recorderApi: RecorderApi, initialViewName?: string) => StartRumResult;
declare type StartRumResult = ReturnType<typeof startRum>;

@@ -12,0 +12,0 @@ export interface RecorderApi {

@@ -1,7 +0,4 @@

import { __assign } from "tslib";
import { BoundedBuffer, buildCookieOptions, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, areCookiesAuthorized, startInternalMonitoring, } from '@datadog/browser-core';
import { ActionType } from '../rawRumEvent.types';
import { assign, BoundedBuffer, buildCookieOptions, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, areCookiesAuthorized, } from '@datadog/browser-core';
import { willSyntheticsInjectRum } from '../domain/syntheticsContext';
import { validateAndBuildRumConfiguration } from '../domain/configuration';
import { buildEnv } from './buildEnv';
export function makeRumPublicApi(startRumImpl, recorderApi, _a) {

@@ -58,5 +55,4 @@ var _b = _a === void 0 ? {} : _a, _c = _b.ignoreInitIfSyntheticsWillInjectRum, ignoreInitIfSyntheticsWillInjectRum = _c === void 0 ? true : _c;

}
var internalMonitoring = startInternalMonitoring(configuration);
if (!configuration.trackViewsManually) {
doStartRum(configuration, internalMonitoring);
doStartRum(configuration);
}

@@ -70,3 +66,3 @@ else {

startViewStrategy = function (name) {
doStartRum(configuration, internalMonitoring, name);
doStartRum(configuration, name);
};

@@ -78,4 +74,4 @@ beforeInitCalls.drain();

}
function doStartRum(configuration, internalMonitoring, initialViewName) {
var startRumResults = startRumImpl(configuration, internalMonitoring, function () { return ({
function doStartRum(configuration, initialViewName) {
var startRumResults = startRumImpl(configuration, function () { return ({
user: user,

@@ -89,3 +85,3 @@ context: globalContextManager.get(),

}
var rumPublicApi = makePublicApi(buildEnv, {
var rumPublicApi = makePublicApi({
init: monitor(initRum),

@@ -103,3 +99,3 @@ addRumGlobalContext: monitor(globalContextManager.add),

startClocks: clocksNow(),
type: ActionType.CUSTOM,
type: "custom" /* CUSTOM */,
});

@@ -177,3 +173,7 @@ }),

function overrideInitConfigurationForBridge(initConfiguration) {
return __assign(__assign({}, initConfiguration), { applicationId: '00000000-aaaa-0000-aaaa-000000000000', clientToken: 'empty', sampleRate: 100 });
return assign({}, initConfiguration, {
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
clientToken: 'empty',
sampleRate: 100,
});
}

@@ -180,0 +180,0 @@ function isLocalFile() {

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

import type { InternalMonitoring, Observable } from '@datadog/browser-core';
import type { Observable } from '@datadog/browser-core';
import { LifeCycle } from '../domain/lifeCycle';

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

import type { RecorderApi } from './rumPublicApi';
export declare function startRum(configuration: RumConfiguration, internalMonitoring: InternalMonitoring, getCommonContext: () => CommonContext, recorderApi: RecorderApi, initialViewName?: string): {
export declare function startRum(configuration: RumConfiguration, getCommonContext: () => CommonContext, recorderApi: RecorderApi, initialViewName?: string): {
addAction: (action: import("../domain/rumEventsCollection/action/trackActions").CustomAction, savedCommonContext?: CommonContext | undefined) => void;

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

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

import { combine, canUseEventBridge } from '@datadog/browser-core';
import { startInternalMonitoring, combine, canUseEventBridge, startBatchWithReplica, getEventBridge, } from '@datadog/browser-core';
import { createDOMMutationObservable } from '../browser/domMutationObservable';

@@ -20,7 +20,5 @@ import { startPerformanceCollection } from '../browser/performanceCollection';

import { createLocationChangeObservable } from '../browser/locationChangeObservable';
export function startRum(configuration, internalMonitoring, getCommonContext, recorderApi, initialViewName) {
export function startRum(configuration, getCommonContext, recorderApi, initialViewName) {
var lifeCycle = new LifeCycle();
var session = !canUseEventBridge() ? startRumSessionManager(configuration, lifeCycle) : startRumSessionManagerStub();
var domMutationObservable = createDOMMutationObservable();
var locationChangeObservable = createLocationChangeObservable(location);
var internalMonitoring = startRumInternalMonitoring(configuration);
internalMonitoring.setExternalContextProvider(function () {

@@ -35,2 +33,28 @@ var _a;

});
internalMonitoring.setTelemetryContextProvider(function () {
var _a, _b, _c;
return ({
application: {
id: configuration.applicationId,
},
session: {
id: (_a = session.findTrackedSession()) === null || _a === void 0 ? void 0 : _a.id,
},
view: {
id: (_b = parentContexts.findView()) === null || _b === void 0 ? void 0 : _b.view.id,
},
action: {
id: (_c = parentContexts.findAction()) === null || _c === void 0 ? void 0 : _c.action.id,
},
});
});
if (!canUseEventBridge()) {
startRumBatch(configuration, lifeCycle, internalMonitoring.telemetryEventObservable);
}
else {
startRumEventBridge(lifeCycle);
}
var session = !canUseEventBridge() ? startRumSessionManager(configuration, lifeCycle) : startRumSessionManagerStub();
var domMutationObservable = createDOMMutationObservable();
var locationChangeObservable = createLocationChangeObservable(location);
var _a = startRumEventCollection(lifeCycle, configuration, location, session, locationChangeObservable, getCommonContext), parentContexts = _a.parentContexts, foregroundContexts = _a.foregroundContexts, urlContexts = _a.urlContexts;

@@ -56,2 +80,16 @@ startLongTaskCollection(lifeCycle, session);

}
function startRumInternalMonitoring(configuration) {
var _a;
var internalMonitoring = startInternalMonitoring(configuration);
if (canUseEventBridge()) {
var bridge_1 = getEventBridge();
internalMonitoring.monitoringMessageObservable.subscribe(function (message) { return bridge_1.send('internal_log', message); });
internalMonitoring.telemetryEventObservable.subscribe(function (message) { return bridge_1.send('internal_telemetry', message); });
}
else if (configuration.internalMonitoringEndpointBuilder) {
var batch_1 = startBatchWithReplica(configuration, configuration.internalMonitoringEndpointBuilder, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.internalMonitoringEndpointBuilder);
internalMonitoring.monitoringMessageObservable.subscribe(function (message) { return batch_1.add(message); });
}
return internalMonitoring;
}
export function startRumEventCollection(lifeCycle, configuration, location, sessionManager, locationChangeObservable, getCommonContext) {

@@ -61,10 +99,2 @@ var parentContexts = startParentContexts(lifeCycle);

var foregroundContexts = startForegroundContexts();
var stopBatch;
if (canUseEventBridge()) {
startRumEventBridge(lifeCycle);
}
else {
;
(stopBatch = startRumBatch(configuration, lifeCycle).stop);
}
startRumAssembly(configuration, lifeCycle, sessionManager, parentContexts, urlContexts, getCommonContext);

@@ -76,5 +106,2 @@ return {

stop: function () {
// prevent batch from previous tests to keep running and send unwanted requests
// could be replaced by stopping all the component when they will all have a stop method
stopBatch === null || stopBatch === void 0 ? void 0 : stopBatch();
parentContexts.stop();

@@ -81,0 +108,0 @@ foregroundContexts.stop();

@@ -1,5 +0,4 @@

import { __assign } from "tslib";
import { addEventListener, instrumentMethodAndCallOriginal, Observable } from '@datadog/browser-core';
import { addEventListener, instrumentMethodAndCallOriginal, Observable, shallowClone, } from '@datadog/browser-core';
export function createLocationChangeObservable(location) {
var currentLocation = __assign({}, location);
var currentLocation = shallowClone(location);
var observable = new Observable(function () {

@@ -17,3 +16,3 @@ var stopHistoryTracking = trackHistory(onLocationChange).stop;

}
var newLocation = __assign({}, location);
var newLocation = shallowClone(location);
observable.notify({

@@ -20,0 +19,0 @@ newLocation: newLocation,

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

import { __assign } from "tslib";
import { addEventListeners, getRelativeTime, isNumber, monitor, relativeNow, runOnReadyState, } from '@datadog/browser-core';
import { LifeCycleEventType } from '../domain/lifeCycle';
import { assign, addEventListeners, getRelativeTime, isNumber, monitor, relativeNow, runOnReadyState, } from '@datadog/browser-core';
import { FAKE_INITIAL_DOCUMENT, isAllowedRequestUrl } from '../domain/rumEventsCollection/resource/resourceUtils';

@@ -23,3 +21,6 @@ import { getDocumentTraceId } from '../domain/tracing/getDocumentTraceId';

if (supportPerformanceObject()) {
handleRumPerformanceEntries(lifeCycle, configuration, performance.getEntries());
var performanceEntries_1 = performance.getEntries();
// Because the performance entry list can be quite large
// delay the computation to prevent the SDK from blocking the main thread on init
setTimeout(monitor(function () { return handleRumPerformanceEntries(lifeCycle, configuration, performanceEntries_1); }));
}

@@ -76,7 +77,12 @@ if (window.PerformanceObserver) {

var navigationEntry = performance.getEntriesByType('navigation')[0];
timing = __assign(__assign({}, navigationEntry.toJSON()), forcedAttributes);
timing = assign(navigationEntry.toJSON(), forcedAttributes);
}
else {
var relativePerformanceTiming = computeRelativePerformanceTiming();
timing = __assign(__assign(__assign({}, relativePerformanceTiming), { decodedBodySize: 0, duration: relativePerformanceTiming.responseEnd, name: window.location.href, startTime: 0 }), forcedAttributes);
timing = assign(relativePerformanceTiming, {
decodedBodySize: 0,
duration: relativePerformanceTiming.responseEnd,
name: window.location.href,
startTime: 0,
}, forcedAttributes);
}

@@ -88,3 +94,5 @@ callback(timing);

function sendFakeTiming() {
callback(__assign(__assign({}, computeRelativePerformanceTiming()), { entryType: 'navigation' }));
callback(assign(computeRelativePerformanceTiming(), {
entryType: 'navigation',
}));
}

@@ -177,3 +185,3 @@ runOnReadyState('complete', function () {

if (rumAllowedPerformanceEntries.length) {
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, rumAllowedPerformanceEntries);
lifeCycle.notify(0 /* PERFORMANCE_ENTRIES_COLLECTED */, rumAllowedPerformanceEntries);
}

@@ -180,0 +188,0 @@ }

@@ -1,15 +0,4 @@

import { __spreadArrays } from "tslib";
import { combine, isEmptyObject, limitModification, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, } from '@datadog/browser-core';
import { RumEventType } from '../rawRumEvent.types';
import { buildEnv } from '../boot/buildEnv';
import { getSyntheticsContext } from './syntheticsContext';
import { getCiTestContext } from './ciTestContext';
import { LifeCycleEventType } from './lifeCycle';
import { RumSessionPlan } from './rumSessionManager';
var SessionType;
(function (SessionType) {
SessionType["SYNTHETICS"] = "synthetics";
SessionType["USER"] = "user";
SessionType["CI_TEST"] = "ci_test";
})(SessionType || (SessionType = {}));
var VIEW_EVENTS_MODIFIABLE_FIELD_PATHS = [

@@ -25,3 +14,3 @@ // Fields with sensitive data

];
var OTHER_EVENTS_MODIFIABLE_FIELD_PATHS = __spreadArrays(VIEW_EVENTS_MODIFIABLE_FIELD_PATHS, [
var OTHER_EVENTS_MODIFIABLE_FIELD_PATHS = VIEW_EVENTS_MODIFIABLE_FIELD_PATHS.concat([
// User-customizable field

@@ -33,11 +22,11 @@ 'context',

var reportError = function (error) {
lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error });
lifeCycle.notify(14 /* RAW_ERROR_COLLECTED */, { error: error });
};
var eventRateLimiters = (_a = {},
_a[RumEventType.ERROR] = createEventRateLimiter(RumEventType.ERROR, configuration.eventRateLimiterThreshold, reportError),
_a[RumEventType.ACTION] = createEventRateLimiter(RumEventType.ACTION, configuration.eventRateLimiterThreshold, reportError),
_a["error" /* ERROR */] = createEventRateLimiter("error" /* ERROR */, configuration.eventRateLimiterThreshold, reportError),
_a["action" /* ACTION */] = createEventRateLimiter("action" /* ACTION */, configuration.eventRateLimiterThreshold, reportError),
_a);
var syntheticsContext = getSyntheticsContext();
var ciTestContext = getCiTestContext();
lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (_a) {
lifeCycle.subscribe(12 /* RAW_RUM_EVENT_COLLECTED */, function (_a) {
var startTime = _a.startTime, rawRumEvent = _a.rawRumEvent, domainContext = _a.domainContext, savedCommonContext = _a.savedCommonContext, customerContext = _a.customerContext;

@@ -49,3 +38,3 @@ var viewContext = parentContexts.findView(startTime);

// TODO: stop sending view updates when session is expired
var session = sessionManager.findTrackedSession(rawRumEvent.type !== RumEventType.VIEW ? startTime : undefined);
var session = sessionManager.findTrackedSession(rawRumEvent.type !== "view" /* VIEW */ ? startTime : undefined);
if (session && viewContext && urlContext) {

@@ -59,5 +48,5 @@ var actionContext = parentContexts.findAction(startTime);

session: {
plan: session.hasReplayPlan ? RumSessionPlan.REPLAY : RumSessionPlan.LITE,
plan: session.hasReplayPlan ? 2 /* REPLAY */ : 1 /* LITE */,
},
browser_sdk_version: canUseEventBridge() ? buildEnv.sdkVersion : undefined,
browser_sdk_version: canUseEventBridge() ? "4.6.0" : undefined,
},

@@ -72,3 +61,3 @@ application: {

id: session.id,
type: syntheticsContext ? SessionType.SYNTHETICS : ciTestContext ? SessionType.CI_TEST : SessionType.USER,
type: syntheticsContext ? "synthetics" /* SYNTHETICS */ : ciTestContext ? "ci_test" /* CI_TEST */ : "user" /* USER */,
},

@@ -94,3 +83,3 @@ synthetics: syntheticsContext,

}
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
lifeCycle.notify(13 /* RUM_EVENT_COLLECTED */, serverRumEvent);
}

@@ -103,4 +92,4 @@ }

if (beforeSend) {
var result = limitModification(event, event.type === RumEventType.VIEW ? VIEW_EVENTS_MODIFIABLE_FIELD_PATHS : OTHER_EVENTS_MODIFIABLE_FIELD_PATHS, function (event) { return beforeSend(event, domainContext); });
if (result === false && event.type !== RumEventType.VIEW) {
var result = limitModification(event, event.type === "view" /* VIEW */ ? VIEW_EVENTS_MODIFIABLE_FIELD_PATHS : OTHER_EVENTS_MODIFIABLE_FIELD_PATHS, function (event) { return beforeSend(event, domainContext); });
if (result === false && event.type !== "view" /* VIEW */) {
return false;

@@ -116,4 +105,4 @@ }

function needToAssembleWithAction(event) {
return [RumEventType.ERROR, RumEventType.RESOURCE, RumEventType.LONG_TASK].indexOf(event.type) !== -1;
return ["error" /* ERROR */, "resource" /* RESOURCE */, "long_task" /* LONG_TASK */].indexOf(event.type) !== -1;
}
//# sourceMappingURL=assembly.js.map

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

import { __assign } from "tslib";
import { DefaultPrivacyLevel, display, isPercentage, objectHasValue, validateAndBuildConfiguration, } from '@datadog/browser-core';
import { buildEnv } from '../boot/buildEnv';
import { assign, DefaultPrivacyLevel, display, isPercentage, objectHasValue, validateAndBuildConfiguration, } from '@datadog/browser-core';
export function validateAndBuildRumConfiguration(initConfiguration) {

@@ -24,10 +22,18 @@ var _a, _b;

}
var baseConfiguration = validateAndBuildConfiguration(initConfiguration, buildEnv);
var baseConfiguration = validateAndBuildConfiguration(initConfiguration);
if (!baseConfiguration) {
return;
}
return __assign(__assign({}, baseConfiguration), { applicationId: initConfiguration.applicationId, actionNameAttribute: initConfiguration.actionNameAttribute, replaySampleRate: (_a = initConfiguration.replaySampleRate) !== null && _a !== void 0 ? _a : 100, allowedTracingOrigins: (_b = initConfiguration.allowedTracingOrigins) !== null && _b !== void 0 ? _b : [], trackInteractions: !!initConfiguration.trackInteractions, trackViewsManually: !!initConfiguration.trackViewsManually, defaultPrivacyLevel: objectHasValue(DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)
return assign({
applicationId: initConfiguration.applicationId,
actionNameAttribute: initConfiguration.actionNameAttribute,
replaySampleRate: (_a = initConfiguration.replaySampleRate) !== null && _a !== void 0 ? _a : 100,
allowedTracingOrigins: (_b = initConfiguration.allowedTracingOrigins) !== null && _b !== void 0 ? _b : [],
trackInteractions: !!initConfiguration.trackInteractions,
trackViewsManually: !!initConfiguration.trackViewsManually,
defaultPrivacyLevel: objectHasValue(DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)
? initConfiguration.defaultPrivacyLevel
: DefaultPrivacyLevel.MASK_USER_INPUT });
: DefaultPrivacyLevel.MASK_USER_INPUT,
}, baseConfiguration);
}
//# sourceMappingURL=configuration.js.map

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

import { __assign } from "tslib";
import { assign } from '@datadog/browser-core';
/**

@@ -22,3 +22,3 @@ * Internal context keep returning v1 format

: undefined,
view: __assign(__assign({}, viewContext.view), urlContext.view),
view: assign({}, viewContext.view, urlContext.view),
};

@@ -25,0 +25,0 @@ }

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

import type { ViewEvent, ViewCreatedEvent, ViewEndedEvent } from './rumEventsCollection/view/trackViews';
export declare enum LifeCycleEventType {
export declare const enum LifeCycleEventType {
PERFORMANCE_ENTRIES_COLLECTED = 0,

@@ -12,0 +12,0 @@ AUTO_ACTION_CREATED = 1,

@@ -1,29 +0,1 @@

export var LifeCycleEventType;
(function (LifeCycleEventType) {
LifeCycleEventType[LifeCycleEventType["PERFORMANCE_ENTRIES_COLLECTED"] = 0] = "PERFORMANCE_ENTRIES_COLLECTED";
LifeCycleEventType[LifeCycleEventType["AUTO_ACTION_CREATED"] = 1] = "AUTO_ACTION_CREATED";
LifeCycleEventType[LifeCycleEventType["AUTO_ACTION_COMPLETED"] = 2] = "AUTO_ACTION_COMPLETED";
LifeCycleEventType[LifeCycleEventType["AUTO_ACTION_DISCARDED"] = 3] = "AUTO_ACTION_DISCARDED";
LifeCycleEventType[LifeCycleEventType["VIEW_CREATED"] = 4] = "VIEW_CREATED";
LifeCycleEventType[LifeCycleEventType["VIEW_UPDATED"] = 5] = "VIEW_UPDATED";
LifeCycleEventType[LifeCycleEventType["VIEW_ENDED"] = 6] = "VIEW_ENDED";
LifeCycleEventType[LifeCycleEventType["REQUEST_STARTED"] = 7] = "REQUEST_STARTED";
LifeCycleEventType[LifeCycleEventType["REQUEST_COMPLETED"] = 8] = "REQUEST_COMPLETED";
// The SESSION_EXPIRED lifecycle event has been introduced to represent when a session has expired
// and trigger cleanup tasks related to this, prior to renewing the session. Its implementation is
// slightly naive: it is not triggered as soon as the session is expired, but rather just before
// notifying that the session is renewed. Thus, the session id is already set to the newly renewed
// session.
//
// This implementation is "good enough" for our use-cases. Improving this is not trivial,
// primarily because multiple instances of the SDK may be managing the same session cookie at
// the same time, for example when using Logs and RUM on the same page, or opening multiple tabs
// on the same domain.
LifeCycleEventType[LifeCycleEventType["SESSION_EXPIRED"] = 9] = "SESSION_EXPIRED";
LifeCycleEventType[LifeCycleEventType["SESSION_RENEWED"] = 10] = "SESSION_RENEWED";
LifeCycleEventType[LifeCycleEventType["BEFORE_UNLOAD"] = 11] = "BEFORE_UNLOAD";
LifeCycleEventType[LifeCycleEventType["RAW_RUM_EVENT_COLLECTED"] = 12] = "RAW_RUM_EVENT_COLLECTED";
LifeCycleEventType[LifeCycleEventType["RUM_EVENT_COLLECTED"] = 13] = "RUM_EVENT_COLLECTED";
LifeCycleEventType[LifeCycleEventType["RAW_ERROR_COLLECTED"] = 14] = "RAW_ERROR_COLLECTED";
})(LifeCycleEventType || (LifeCycleEventType = {}));
var LifeCycle = /** @class */ (function () {

@@ -30,0 +2,0 @@ function LifeCycle() {

import { ONE_MINUTE, SESSION_TIME_OUT_DELAY, ContextHistory } from '@datadog/browser-core';
import { LifeCycleEventType } from './lifeCycle';
export var VIEW_CONTEXT_TIME_OUT_DELAY = SESSION_TIME_OUT_DELAY;

@@ -8,6 +7,6 @@ export var ACTION_CONTEXT_TIME_OUT_DELAY = 5 * ONE_MINUTE; // arbitrary

var actionContextHistory = new ContextHistory(ACTION_CONTEXT_TIME_OUT_DELAY);
lifeCycle.subscribe(LifeCycleEventType.VIEW_CREATED, function (view) {
lifeCycle.subscribe(4 /* VIEW_CREATED */, function (view) {
viewContextHistory.setCurrent(buildViewContext(view), view.startClocks.relative);
});
lifeCycle.subscribe(LifeCycleEventType.VIEW_UPDATED, function (view) {
lifeCycle.subscribe(5 /* VIEW_UPDATED */, function (view) {
// A view can be updated after its end. We have to ensure that the view being updated is the

@@ -20,10 +19,10 @@ // most recently created.

});
lifeCycle.subscribe(LifeCycleEventType.VIEW_ENDED, function (_a) {
lifeCycle.subscribe(6 /* VIEW_ENDED */, function (_a) {
var endClocks = _a.endClocks;
viewContextHistory.closeCurrent(endClocks.relative);
});
lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_CREATED, function (action) {
lifeCycle.subscribe(1 /* AUTO_ACTION_CREATED */, function (action) {
actionContextHistory.setCurrent(buildActionContext(action), action.startClocks.relative);
});
lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) {
lifeCycle.subscribe(2 /* AUTO_ACTION_COMPLETED */, function (action) {
if (actionContextHistory.getCurrent()) {

@@ -35,6 +34,6 @@ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands

});
lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_DISCARDED, function () {
lifeCycle.subscribe(3 /* AUTO_ACTION_DISCARDED */, function () {
actionContextHistory.clearCurrent();
});
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {
lifeCycle.subscribe(10 /* SESSION_RENEWED */, function () {
viewContextHistory.reset();

@@ -41,0 +40,0 @@ actionContextHistory.reset();

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

import { RequestType, initFetchObservable, initXhrObservable } from '@datadog/browser-core';
import { LifeCycleEventType } from './lifeCycle';
import { initFetchObservable, initXhrObservable } from '@datadog/browser-core';
import { isAllowedRequestUrl } from './rumEventsCollection/resource/resourceUtils';

@@ -21,3 +20,3 @@ import { startTracer } from './tracing/tracer';

context.requestIndex = getNextRequestIndex();
lifeCycle.notify(LifeCycleEventType.REQUEST_STARTED, {
lifeCycle.notify(7 /* REQUEST_STARTED */, {
requestIndex: context.requestIndex,

@@ -28,3 +27,3 @@ });

tracer.clearTracingIfNeeded(context);
lifeCycle.notify(LifeCycleEventType.REQUEST_COMPLETED, {
lifeCycle.notify(8 /* REQUEST_COMPLETED */, {
duration: context.duration,

@@ -37,3 +36,3 @@ method: context.method,

traceId: context.traceId,
type: RequestType.XHR,
type: "xhr" /* XHR */,
url: context.url,

@@ -57,3 +56,3 @@ xhr: context.xhr,

context.requestIndex = getNextRequestIndex();
lifeCycle.notify(LifeCycleEventType.REQUEST_STARTED, {
lifeCycle.notify(7 /* REQUEST_STARTED */, {
requestIndex: context.requestIndex,

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

tracer.clearTracingIfNeeded(context);
lifeCycle.notify(LifeCycleEventType.REQUEST_COMPLETED, {
lifeCycle.notify(8 /* REQUEST_COMPLETED */, {
duration: context.duration,

@@ -74,3 +73,3 @@ method: context.method,

traceId: context.traceId,
type: RequestType.FETCH,
type: "fetch" /* FETCH */,
url: context.url,

@@ -77,0 +76,0 @@ response: context.response,

@@ -1,9 +0,6 @@

import { __assign } from "tslib";
import { combine, toServerDuration, generateUUID } from '@datadog/browser-core';
import { ActionType, RumEventType } from '../../../rawRumEvent.types';
import { LifeCycleEventType } from '../../lifeCycle';
import { assign, combine, toServerDuration, generateUUID } from '@datadog/browser-core';
import { trackActions } from './trackActions';
export function startActionCollection(lifeCycle, domMutationObservable, configuration, foregroundContexts) {
lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) {
return lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action, foregroundContexts));
lifeCycle.subscribe(2 /* AUTO_ACTION_COMPLETED */, function (action) {
return lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, processAction(action, foregroundContexts));
});

@@ -15,3 +12,5 @@ if (configuration.trackInteractions) {

addAction: function (action, savedCommonContext) {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, __assign({ savedCommonContext: savedCommonContext }, processAction(action, foregroundContexts)));
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, assign({
savedCommonContext: savedCommonContext,
}, processAction(action, foregroundContexts)));
},

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

date: action.startClocks.timeStamp,
type: RumEventType.ACTION,
type: "action" /* ACTION */,
}, autoActionProperties);

@@ -63,4 +62,4 @@ var inForeground = foregroundContexts.isInForegroundAt(action.startClocks.relative);

function isAutoAction(action) {
return action.type !== ActionType.CUSTOM;
return action.type !== "custom" /* CUSTOM */;
}
//# sourceMappingURL=actionCollection.js.map

@@ -27,3 +27,3 @@ import { safeTruncate, isIE } from '@datadog/browser-core';

if (supportsElementClosest()) {
elementWithAttribute = targetElement.closest("[" + programmaticAttribute + "]");
elementWithAttribute = targetElement.closest("[".concat(programmaticAttribute, "]"));
}

@@ -57,3 +57,3 @@ else {

else if (element.id) {
var label = element.ownerDocument && element.ownerDocument.querySelector("label[for=\"" + element.id.replace('"', '\\"') + "\"]");
var label = element.ownerDocument && element.ownerDocument.querySelector("label[for=\"".concat(element.id.replace('"', '\\"'), "\"]"));
return label && getTextualContent(label, userProgrammaticAttribute);

@@ -141,3 +141,3 @@ }

function truncate(s) {
return s.length > 100 ? safeTruncate(s, 100) + " [...]" : s;
return s.length > 100 ? "".concat(safeTruncate(s, 100), " [...]") : s;
}

@@ -173,5 +173,5 @@ function getElementById(refElement, id) {

// remove the text of elements with programmatic attribute value
removeTextFromElements("[" + DEFAULT_PROGRAMMATIC_ATTRIBUTE + "]");
removeTextFromElements("[".concat(DEFAULT_PROGRAMMATIC_ATTRIBUTE, "]"));
if (userProgrammaticAttribute) {
removeTextFromElements("[" + userProgrammaticAttribute + "]");
removeTextFromElements("[".concat(userProgrammaticAttribute, "]"));
}

@@ -178,0 +178,0 @@ return text_1;

import { addEventListener, generateUUID, clocksNow, ONE_SECOND, elapsed } from '@datadog/browser-core';
import { ActionType } from '../../../rawRumEvent.types';
import { LifeCycleEventType } from '../../lifeCycle';
import { trackEventCounts } from '../../trackEventCounts';

@@ -13,3 +11,3 @@ import { waitIdlePage } from '../../waitIdlePage';

// New views trigger the discard of the current pending Action
lifeCycle.subscribe(LifeCycleEventType.VIEW_CREATED, function () {
lifeCycle.subscribe(4 /* VIEW_CREATED */, function () {
action.discardCurrent();

@@ -25,3 +23,3 @@ });

}
action.create(ActionType.CLICK, name, event);
action.create("click" /* CLICK */, name, event);
}, { capture: true }).stop;

@@ -80,7 +78,7 @@ return {

this.eventCountsSubscription = trackEventCounts(lifeCycle);
this.lifeCycle.notify(LifeCycleEventType.AUTO_ACTION_CREATED, { id: this.id, startClocks: this.startClocks });
this.lifeCycle.notify(1 /* AUTO_ACTION_CREATED */, { id: this.id, startClocks: this.startClocks });
}
PendingAutoAction.prototype.complete = function (duration) {
var eventCounts = this.eventCountsSubscription.eventCounts;
this.lifeCycle.notify(LifeCycleEventType.AUTO_ACTION_COMPLETED, {
this.lifeCycle.notify(2 /* AUTO_ACTION_COMPLETED */, {
counts: {

@@ -101,3 +99,3 @@ errorCount: eventCounts.errorCount,

PendingAutoAction.prototype.discard = function () {
this.lifeCycle.notify(LifeCycleEventType.AUTO_ACTION_DISCARDED);
this.lifeCycle.notify(3 /* AUTO_ACTION_DISCARDED */);
this.eventCountsSubscription.stop();

@@ -104,0 +102,0 @@ };

@@ -1,6 +0,4 @@

import { __assign } from "tslib";
import { computeStackTrace, formatUnknownError, ErrorSource, generateUUID, ErrorHandling, Observable, trackRuntimeError, } from '@datadog/browser-core';
import { RumEventType } from '../../../rawRumEvent.types';
import { LifeCycleEventType } from '../../lifeCycle';
import { assign, computeStackTrace, formatUnknownError, ErrorSource, generateUUID, Observable, trackRuntimeError, } from '@datadog/browser-core';
import { trackConsoleError } from './trackConsoleError';
import { trackReportError } from './trackReportError';
export function startErrorCollection(lifeCycle, foregroundContexts) {

@@ -10,10 +8,13 @@ var errorObservable = new Observable();

trackRuntimeError(errorObservable);
errorObservable.subscribe(function (error) { return lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error }); });
trackReportError(errorObservable);
errorObservable.subscribe(function (error) { return lifeCycle.notify(14 /* RAW_ERROR_COLLECTED */, { error: error }); });
return doStartErrorCollection(lifeCycle, foregroundContexts);
}
export function doStartErrorCollection(lifeCycle, foregroundContexts) {
lifeCycle.subscribe(LifeCycleEventType.RAW_ERROR_COLLECTED, function (_a) {
lifeCycle.subscribe(14 /* RAW_ERROR_COLLECTED */, function (_a) {
var error = _a.error, customerContext = _a.customerContext, savedCommonContext = _a.savedCommonContext;
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, __assign({ customerContext: customerContext,
savedCommonContext: savedCommonContext }, processError(error, foregroundContexts)));
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, assign({
customerContext: customerContext,
savedCommonContext: savedCommonContext,
}, processError(error, foregroundContexts)));
});

@@ -24,3 +25,3 @@ return {

var rawError = computeRawError(error, handlingStack, startClocks);
lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, {
lifeCycle.notify(14 /* RAW_ERROR_COLLECTED */, {
customerContext: customerContext,

@@ -35,3 +36,8 @@ savedCommonContext: savedCommonContext,

var stackTrace = error instanceof Error ? computeStackTrace(error) : undefined;
return __assign(__assign({ startClocks: startClocks, source: ErrorSource.CUSTOM, originalError: error }, formatUnknownError(stackTrace, error, 'Provided', handlingStack)), { handling: ErrorHandling.HANDLED });
return assign({
startClocks: startClocks,
source: ErrorSource.CUSTOM,
originalError: error,
handling: "handled" /* HANDLED */,
}, formatUnknownError(stackTrace, error, 'Provided', handlingStack));
}

@@ -44,9 +50,2 @@ function processError(error, foregroundContexts) {

message: error.message,
resource: error.resource
? {
method: error.resource.method,
status_code: error.resource.statusCode,
url: error.resource.url,
}
: undefined,
source: error.source,

@@ -59,3 +58,3 @@ stack: error.stack,

},
type: RumEventType.ERROR,
type: "error" /* ERROR */,
};

@@ -62,0 +61,0 @@ var inForeground = foregroundContexts.isInForegroundAt(error.startClocks.relative);

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

import { clocksNow, ErrorHandling, initConsoleObservable, ErrorSource, ConsoleApiName } from '@datadog/browser-core';
import { clocksNow, initConsoleObservable, ErrorSource, ConsoleApiName } from '@datadog/browser-core';
export function trackConsoleError(errorObservable) {

@@ -9,3 +9,3 @@ var subscription = initConsoleObservable([ConsoleApiName.error]).subscribe(function (consoleError) {

source: ErrorSource.CONSOLE,
handling: ErrorHandling.HANDLED,
handling: "handled" /* HANDLED */,
handlingStack: consoleError.handlingStack,

@@ -12,0 +12,0 @@ });

import { toServerDuration, relativeToClocks, generateUUID } from '@datadog/browser-core';
import { RumEventType } from '../../../rawRumEvent.types';
import { LifeCycleEventType } from '../../lifeCycle';
export function startLongTaskCollection(lifeCycle, sessionManager) {
lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {

@@ -22,5 +20,5 @@ var entry = entries_1[_i];

},
type: RumEventType.LONG_TASK,
type: "long_task" /* LONG_TASK */,
};
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, {
rawRumEvent: rawRumEvent,

@@ -27,0 +25,0 @@ startTime: startClocks.relative,

@@ -1,17 +0,14 @@

import { __assign } from "tslib";
import { combine, generateUUID, RequestType, ResourceType, toServerDuration, relativeToClocks, } from '@datadog/browser-core';
import { combine, generateUUID, toServerDuration, relativeToClocks, assign, } from '@datadog/browser-core';
import { supportPerformanceEntry } from '../../../browser/performanceCollection';
import { RumEventType } from '../../../rawRumEvent.types';
import { LifeCycleEventType } from '../../lifeCycle';
import { matchRequestTiming } from './matchRequestTiming';
import { computePerformanceResourceDetails, computePerformanceResourceDuration, computeResourceKind, computeSize, isRequestKind, } from './resourceUtils';
export function startResourceCollection(lifeCycle) {
lifeCycle.subscribe(LifeCycleEventType.REQUEST_COMPLETED, function (request) {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request));
lifeCycle.subscribe(8 /* REQUEST_COMPLETED */, function (request) {
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, processRequest(request));
});
lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
var entry = entries_1[_i];
if (entry.entryType === 'resource' && !isRequestKind(entry)) {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processResourceEntry(entry));
lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, processResourceEntry(entry));
}

@@ -22,3 +19,3 @@ }

function processRequest(request) {
var type = request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH;
var type = request.type === "xhr" /* XHR */ ? "xhr" /* XHR */ : "fetch" /* FETCH */;
var matchingTiming = matchRequestTiming(request);

@@ -38,3 +35,3 @@ var startClocks = matchingTiming ? relativeToClocks(matchingTiming.startTime) : request.startClocks;

},
type: RumEventType.RESOURCE,
type: "resource" /* RESOURCE */,
}, tracingInfo, correspondingTimingOverrides);

@@ -66,3 +63,3 @@ return {

},
type: RumEventType.RESOURCE,
type: "resource" /* RESOURCE */,
}, tracingInfo, entryMetrics);

@@ -79,3 +76,6 @@ return {

return {
resource: __assign({ duration: computePerformanceResourceDuration(timing), size: computeSize(timing) }, computePerformanceResourceDetails(timing)),
resource: assign({
duration: computePerformanceResourceDuration(timing),
size: computeSize(timing),
}, computePerformanceResourceDetails(timing)),
};

@@ -82,0 +82,0 @@ }

@@ -15,3 +15,3 @@ import type { ServerDuration } from '@datadog/browser-core';

export declare const FAKE_INITIAL_DOCUMENT = "initial_document";
export declare function computeResourceKind(timing: RumPerformanceResourceTiming): ResourceType | ResourceType.OTHER;
export declare function computeResourceKind(timing: RumPerformanceResourceTiming): ResourceType;
export declare function isRequestKind(timing: RumPerformanceResourceTiming): boolean;

@@ -18,0 +18,0 @@ export declare function computePerformanceResourceDuration(entry: RumPerformanceResourceTiming): ServerDuration;

@@ -1,13 +0,12 @@

import { __assign } from "tslib";
import { addMonitoringMessage, elapsed, getPathName, includes, isValidUrl, ResourceType, toServerDuration, } from '@datadog/browser-core';
import { assign, addMonitoringMessage, elapsed, getPathName, includes, isValidUrl, toServerDuration, } from '@datadog/browser-core';
export var FAKE_INITIAL_DOCUMENT = 'initial_document';
var RESOURCE_TYPES = [
[ResourceType.DOCUMENT, function (initiatorType) { return FAKE_INITIAL_DOCUMENT === initiatorType; }],
[ResourceType.XHR, function (initiatorType) { return 'xmlhttprequest' === initiatorType; }],
[ResourceType.FETCH, function (initiatorType) { return 'fetch' === initiatorType; }],
[ResourceType.BEACON, function (initiatorType) { return 'beacon' === initiatorType; }],
[ResourceType.CSS, function (_, path) { return /\.css$/i.test(path); }],
[ResourceType.JS, function (_, path) { return /\.js$/i.test(path); }],
["document" /* DOCUMENT */, function (initiatorType) { return FAKE_INITIAL_DOCUMENT === initiatorType; }],
["xhr" /* XHR */, function (initiatorType) { return 'xmlhttprequest' === initiatorType; }],
["fetch" /* FETCH */, function (initiatorType) { return 'fetch' === initiatorType; }],
["beacon" /* BEACON */, function (initiatorType) { return 'beacon' === initiatorType; }],
["css" /* CSS */, function (_, path) { return /\.css$/i.test(path); }],
["js" /* JS */, function (_, path) { return /\.js$/i.test(path); }],
[
ResourceType.IMAGE,
"image" /* IMAGE */,
function (initiatorType, path) {

@@ -17,5 +16,5 @@ return includes(['image', 'img', 'icon'], initiatorType) || /\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i.exec(path) !== null;

],
[ResourceType.FONT, function (_, path) { return /\.(woff|eot|woff2|ttf)$/i.exec(path) !== null; }],
["font" /* FONT */, function (_, path) { return /\.(woff|eot|woff2|ttf)$/i.exec(path) !== null; }],
[
ResourceType.MEDIA,
"media" /* MEDIA */,
function (initiatorType, path) {

@@ -29,4 +28,4 @@ return includes(['audio', 'video'], initiatorType) || /\.(mp3|mp4)$/i.exec(path) !== null;

if (!isValidUrl(url)) {
addMonitoringMessage("Failed to construct URL for \"" + timing.name + "\"");
return ResourceType.OTHER;
addMonitoringMessage("Failed to construct URL for \"".concat(timing.name, "\""));
return "other" /* OTHER */;
}

@@ -40,3 +39,3 @@ var path = getPathName(url);

}
return ResourceType.OTHER;
return "other" /* OTHER */;
}

@@ -117,4 +116,6 @@ function areInOrder() {

}
return __assign(__assign({}, entry), { redirectEnd: redirectEnd,
redirectStart: redirectStart });
return assign({}, entry, {
redirectEnd: redirectEnd,
redirectStart: redirectStart,
});
}

@@ -121,0 +122,0 @@ function hasRedirection(entry) {

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

import { __assign } from "tslib";
import { addEventListeners, elapsed, ONE_MINUTE, find, findLast } from '@datadog/browser-core';
import { LifeCycleEventType } from '../../lifeCycle';
import { assign, addEventListeners, elapsed, ONE_MINUTE, find, findLast } from '@datadog/browser-core';
import { trackFirstHidden } from './trackFirstHidden';

@@ -9,5 +7,5 @@ // Discard LCP and FCP timings above a certain delay to avoid incorrect data

export function trackInitialViewTimings(lifeCycle, callback) {
var timings;
var timings = {};
function setTimings(newTimings) {
timings = __assign(__assign({}, timings), newTimings);
assign(timings, newTimings);
callback(timings);

@@ -41,3 +39,3 @@ }

export function trackNavigationTimings(lifeCycle, callback) {
var stop = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
var stop = lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {

@@ -59,3 +57,3 @@ var entry = entries_1[_i];

var firstHidden = trackFirstHidden();
var stop = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
var stop = lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
var fcpEntry = find(entries, function (entry) {

@@ -88,3 +86,3 @@ return entry.entryType === 'paint' &&

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

@@ -117,3 +115,3 @@ return entry.entryType === 'largest-contentful-paint' &&

var firstHidden = trackFirstHidden();
var stop = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
var stop = lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
var firstInputEntry = find(entries, function (entry) {

@@ -120,0 +118,0 @@ return entry.entryType === 'first-input' && entry.startTime < firstHidden.timeStamp;

import { noop, round, ONE_SECOND, elapsed } from '@datadog/browser-core';
import { supportPerformanceTimingEvent } from '../../../browser/performanceCollection';
import { ViewLoadingType } from '../../../rawRumEvent.types';
import { LifeCycleEventType } from '../../lifeCycle';
import { trackEventCounts } from '../../trackEventCounts';

@@ -46,3 +44,3 @@ import { waitIdlePage } from '../../waitIdlePage';

function trackLoadingTime(lifeCycle, domMutationObservable, loadType, viewStart, callback) {
var isWaitingForLoadEvent = loadType === ViewLoadingType.INITIAL_LOAD;
var isWaitingForLoadEvent = loadType === "initial_load" /* INITIAL_LOAD */;
var isWaitingForActivityLoadingTime = true;

@@ -95,3 +93,3 @@ var loadingTimeCandidates = [];

var window = slidingSessionWindow();
var stop = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
var stop = lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {

@@ -98,0 +96,0 @@ var entry = entries_1[_i];

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

import { __assign } from "tslib";
import { elapsed, generateUUID, monitor, ONE_MINUTE, throttle, clocksNow, clocksOrigin, timeStampNow, display, looksLikeRelativeTime, } from '@datadog/browser-core';
import { ViewLoadingType } from '../../../rawRumEvent.types';
import { LifeCycleEventType } from '../../lifeCycle';
import { shallowClone, assign, elapsed, generateUUID, monitor, ONE_MINUTE, throttle, clocksNow, clocksOrigin, timeStampNow, display, looksLikeRelativeTime, } from '@datadog/browser-core';
import { trackInitialViewTimings } from './trackInitialViewTimings';

@@ -18,3 +15,3 @@ import { trackViewMetrics } from './trackViewMetrics';

function trackInitialView(name) {
var initialView = newView(lifeCycle, domMutationObservable, location, ViewLoadingType.INITIAL_LOAD, clocksOrigin(), name);
var initialView = newView(lifeCycle, domMutationObservable, location, "initial_load" /* INITIAL_LOAD */, clocksOrigin(), name);
var stop = trackInitialViewTimings(lifeCycle, function (timings) {

@@ -27,6 +24,6 @@ initialView.updateTimings(timings);

function trackViewChange(startClocks, name) {
return newView(lifeCycle, domMutationObservable, location, ViewLoadingType.ROUTE_CHANGE, startClocks, name);
return newView(lifeCycle, domMutationObservable, location, "route_change" /* ROUTE_CHANGE */, startClocks, name);
}
function startViewLifeCycle() {
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {
lifeCycle.subscribe(10 /* SESSION_RENEWED */, function () {
// do not trigger view update to avoid wrong data

@@ -38,3 +35,3 @@ currentView.end();

// End the current view on page unload
lifeCycle.subscribe(LifeCycleEventType.BEFORE_UNLOAD, function () {
lifeCycle.subscribe(11 /* BEFORE_UNLOAD */, function () {
currentView.end();

@@ -91,4 +88,4 @@ currentView.triggerUpdate();

var endClocks;
var location = __assign({}, initialLocation);
lifeCycle.notify(LifeCycleEventType.VIEW_CREATED, { id: id, name: name, startClocks: startClocks });
var location = shallowClone(initialLocation);
lifeCycle.notify(4 /* VIEW_CREATED */, { id: id, name: name, startClocks: startClocks });
// Update the view every time the measures are changing

@@ -104,3 +101,4 @@ var _a = throttle(monitor(triggerViewUpdate), THROTTLE_VIEW_UPDATE_PERIOD, {

var currentEnd = endClocks === undefined ? timeStampNow() : endClocks.timeStamp;
lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, __assign(__assign({}, viewMetrics), { customTimings: customTimings,
lifeCycle.notify(5 /* VIEW_UPDATED */, assign({
customTimings: customTimings,
documentVersion: documentVersion,

@@ -112,3 +110,6 @@ id: id,

startClocks: startClocks,
timings: timings, duration: elapsed(startClocks.timeStamp, currentEnd), isActive: endClocks === undefined }));
timings: timings,
duration: elapsed(startClocks.timeStamp, currentEnd),
isActive: endClocks === undefined,
}, viewMetrics));
}

@@ -122,3 +123,3 @@ return {

stopViewMetricsTracking();
lifeCycle.notify(LifeCycleEventType.VIEW_ENDED, { endClocks: endClocks });
lifeCycle.notify(6 /* VIEW_ENDED */, { endClocks: endClocks });
},

@@ -148,3 +149,3 @@ triggerUpdate: function () {

if (sanitized !== name) {
display.warn("Invalid timing name: " + name + ", sanitized to: " + sanitized);
display.warn("Invalid timing name: ".concat(name, ", sanitized to: ").concat(sanitized));
}

@@ -151,0 +152,0 @@ return sanitized;

import { isEmptyObject, mapValues, toServerDuration, isNumber } from '@datadog/browser-core';
import { RumEventType } from '../../../rawRumEvent.types';
import { LifeCycleEventType } from '../../lifeCycle';
import { trackViews } from './trackViews';
export function startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, foregroundContexts, recorderApi, initialViewName) {
lifeCycle.subscribe(LifeCycleEventType.VIEW_UPDATED, function (view) {
return lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processViewUpdate(view, foregroundContexts, recorderApi));
lifeCycle.subscribe(5 /* VIEW_UPDATED */, function (view) {
return lifeCycle.notify(12 /* RAW_RUM_EVENT_COLLECTED */, processViewUpdate(view, foregroundContexts, recorderApi));
});

@@ -19,3 +17,3 @@ return trackViews(location, lifeCycle, domMutationObservable, locationChangeObservable, !configuration.trackViewsManually, initialViewName);

date: view.startClocks.timeStamp,
type: RumEventType.VIEW,
type: "view" /* VIEW */,
view: {

@@ -22,0 +20,0 @@ action: {

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

};
export declare enum RumSessionPlan {
export declare const enum RumSessionPlan {
LITE = 1,
REPLAY = 2
}
export declare enum RumTrackingType {
export declare const enum RumTrackingType {
NOT_TRACKED = "0",

@@ -20,0 +20,0 @@ TRACKED_REPLAY = "1",

import { performDraw, startSessionManager } from '@datadog/browser-core';
import { LifeCycleEventType } from './lifeCycle';
export var RUM_SESSION_KEY = 'rum';
export var RumSessionPlan;
(function (RumSessionPlan) {
RumSessionPlan[RumSessionPlan["LITE"] = 1] = "LITE";
RumSessionPlan[RumSessionPlan["REPLAY"] = 2] = "REPLAY";
})(RumSessionPlan || (RumSessionPlan = {}));
export var RumTrackingType;
(function (RumTrackingType) {
RumTrackingType["NOT_TRACKED"] = "0";
// Note: the "tracking type" value (stored in the session cookie) does not match the "session
// plan" value (sent in RUM events). This is expected, and was done to keep retrocompatibility
// with active sessions when upgrading the SDK.
RumTrackingType["TRACKED_REPLAY"] = "1";
RumTrackingType["TRACKED_LITE"] = "2";
})(RumTrackingType || (RumTrackingType = {}));
export function startRumSessionManager(configuration, lifeCycle) {

@@ -23,6 +8,6 @@ var sessionManager = startSessionManager(configuration.cookieOptions, RUM_SESSION_KEY, function (rawTrackingType) {

sessionManager.expireObservable.subscribe(function () {
lifeCycle.notify(LifeCycleEventType.SESSION_EXPIRED);
lifeCycle.notify(9 /* SESSION_EXPIRED */);
});
sessionManager.renewObservable.subscribe(function () {
lifeCycle.notify(LifeCycleEventType.SESSION_RENEWED);
lifeCycle.notify(10 /* SESSION_RENEWED */);
});

@@ -37,4 +22,4 @@ return {

id: session.id,
hasReplayPlan: session.trackingType === RumTrackingType.TRACKED_REPLAY,
hasLitePlan: session.trackingType === RumTrackingType.TRACKED_LITE,
hasReplayPlan: session.trackingType === "1" /* TRACKED_REPLAY */,
hasLitePlan: session.trackingType === "2" /* TRACKED_LITE */,
};

@@ -64,9 +49,9 @@ },

else if (!performDraw(configuration.sampleRate)) {
trackingType = RumTrackingType.NOT_TRACKED;
trackingType = "0" /* NOT_TRACKED */;
}
else if (!performDraw(configuration.replaySampleRate)) {
trackingType = RumTrackingType.TRACKED_LITE;
trackingType = "2" /* TRACKED_LITE */;
}
else {
trackingType = RumTrackingType.TRACKED_REPLAY;
trackingType = "1" /* TRACKED_REPLAY */;
}

@@ -79,9 +64,9 @@ return {

function hasValidRumSession(trackingType) {
return (trackingType === RumTrackingType.NOT_TRACKED ||
trackingType === RumTrackingType.TRACKED_REPLAY ||
trackingType === RumTrackingType.TRACKED_LITE);
return (trackingType === "0" /* NOT_TRACKED */ ||
trackingType === "1" /* TRACKED_REPLAY */ ||
trackingType === "2" /* TRACKED_LITE */);
}
function isTypeTracked(rumSessionType) {
return rumSessionType === RumTrackingType.TRACKED_LITE || rumSessionType === RumTrackingType.TRACKED_REPLAY;
return rumSessionType === "2" /* TRACKED_LITE */ || rumSessionType === "1" /* TRACKED_REPLAY */;
}
//# sourceMappingURL=rumSessionManager.js.map

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

import { __assign } from "tslib";
import { getOrigin, objectEntries } from '@datadog/browser-core';
import { getOrigin, objectEntries, shallowClone } from '@datadog/browser-core';
/**

@@ -40,3 +39,3 @@ * Clear tracing information to avoid incomplete traces. Ideally, we should do it when the the

else {
context.init = __assign({}, context.init);
context.init = shallowClone(context.init);
var headers_1 = [];

@@ -43,0 +42,0 @@ if (context.init.headers instanceof Headers) {

import { noop } from '@datadog/browser-core';
import { RumEventType } from '../rawRumEvent.types';
import { LifeCycleEventType } from './lifeCycle';
export function trackEventCounts(lifeCycle, callback) {

@@ -12,18 +10,18 @@ if (callback === void 0) { callback = noop; }

};
var subscription = lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, function (_a) {
var subscription = lifeCycle.subscribe(13 /* RUM_EVENT_COLLECTED */, function (_a) {
var type = _a.type;
switch (type) {
case RumEventType.ERROR:
case "error" /* ERROR */:
eventCounts.errorCount += 1;
callback(eventCounts);
break;
case RumEventType.ACTION:
case "action" /* ACTION */:
eventCounts.userActionCount += 1;
callback(eventCounts);
break;
case RumEventType.LONG_TASK:
case "long_task" /* LONG_TASK */:
eventCounts.longTaskCount += 1;
callback(eventCounts);
break;
case RumEventType.RESOURCE:
case "resource" /* RESOURCE */:
eventCounts.resourceCount += 1;

@@ -30,0 +28,0 @@ callback(eventCounts);

import { SESSION_TIME_OUT_DELAY, relativeNow, ContextHistory } from '@datadog/browser-core';
import { LifeCycleEventType } from './lifeCycle';
/**

@@ -12,7 +11,7 @@ * We want to attach to an event:

var previousViewUrl;
lifeCycle.subscribe(LifeCycleEventType.VIEW_ENDED, function (_a) {
lifeCycle.subscribe(6 /* VIEW_ENDED */, function (_a) {
var endClocks = _a.endClocks;
urlContextHistory.closeCurrent(endClocks.relative);
});
lifeCycle.subscribe(LifeCycleEventType.VIEW_CREATED, function (_a) {
lifeCycle.subscribe(4 /* VIEW_CREATED */, function (_a) {
var startClocks = _a.startClocks;

@@ -19,0 +18,0 @@ var viewUrl = location.href;

import { monitor, Observable, timeStampNow } from '@datadog/browser-core';
import { LifeCycleEventType } from './lifeCycle';
// Delay to wait for a page activity to validate the tracking process

@@ -77,3 +76,3 @@ export var PAGE_ACTIVITY_VALIDATION_DELAY = 100;

var pendingRequestsCount = 0;
subscriptions.push(domMutationObservable.subscribe(function () { return notifyPageActivity(pendingRequestsCount); }), lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, function (entries) {
subscriptions.push(domMutationObservable.subscribe(function () { return notifyPageActivity(pendingRequestsCount); }), lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
if (entries.some(function (_a) {

@@ -85,3 +84,3 @@ var entryType = _a.entryType;

}
}), lifeCycle.subscribe(LifeCycleEventType.REQUEST_STARTED, function (startEvent) {
}), lifeCycle.subscribe(7 /* REQUEST_STARTED */, function (startEvent) {
if (firstRequestIndex === undefined) {

@@ -91,3 +90,3 @@ firstRequestIndex = startEvent.requestIndex;

notifyPageActivity(++pendingRequestsCount);
}), lifeCycle.subscribe(LifeCycleEventType.REQUEST_COMPLETED, function (request) {
}), lifeCycle.subscribe(8 /* REQUEST_COMPLETED */, function (request) {
// If the request started before the tracking start, ignore it

@@ -94,0 +93,0 @@ if (firstRequestIndex === undefined || request.requestIndex < firstRequestIndex) {

export { makeRumPublicApi } from './boot/rumPublicApi';
export { startRum } from './boot/startRum';
export { LifeCycle, LifeCycleEventType } from './domain/lifeCycle';
export { RumSessionPlan } from './domain/rumSessionManager';
export { LifeCycle } from './domain/lifeCycle';
export { getMutationObserverConstructor } from './browser/domMutationObservable';
//# sourceMappingURL=index.js.map
import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp } from '@datadog/browser-core';
import type { RumSessionPlan } from './domain/rumSessionManager';
export declare enum RumEventType {
export declare const enum RumEventType {
ACTION = "action",

@@ -41,7 +41,2 @@ ERROR = "error",

error: {
resource?: {
url: string;
status_code: number;
method: string;
};
id: string;

@@ -99,3 +94,3 @@ type?: string;

}
export declare enum ViewLoadingType {
export declare const enum ViewLoadingType {
INITIAL_LOAD = "initial_load",

@@ -141,3 +136,3 @@ ROUTE_CHANGE = "route_change"

}
export declare enum ActionType {
export declare const enum ActionType {
CLICK = "click",

@@ -144,0 +139,0 @@ CUSTOM = "custom"

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

export var RumEventType;
(function (RumEventType) {
RumEventType["ACTION"] = "action";
RumEventType["ERROR"] = "error";
RumEventType["LONG_TASK"] = "long_task";
RumEventType["VIEW"] = "view";
RumEventType["RESOURCE"] = "resource";
})(RumEventType || (RumEventType = {}));
export var ViewLoadingType;
(function (ViewLoadingType) {
ViewLoadingType["INITIAL_LOAD"] = "initial_load";
ViewLoadingType["ROUTE_CHANGE"] = "route_change";
})(ViewLoadingType || (ViewLoadingType = {}));
export var ActionType;
(function (ActionType) {
ActionType["CLICK"] = "click";
ActionType["CUSTOM"] = "custom";
})(ActionType || (ActionType = {}));
export {};
//# sourceMappingURL=rawRumEvent.types.js.map

@@ -119,3 +119,3 @@ /**

*/
readonly source: 'network' | 'source' | 'console' | 'logger' | 'agent' | 'webview' | 'custom';
readonly source: 'network' | 'source' | 'console' | 'logger' | 'agent' | 'webview' | 'custom' | 'report';
/**

@@ -122,0 +122,0 @@ * Stacktrace of the error

@@ -0,5 +1,4 @@

import type { Context, TelemetryEvent, Observable } from '@datadog/browser-core';
import type { RumConfiguration } from '../domain/configuration';
import type { LifeCycle } from '../domain/lifeCycle';
export declare function startRumBatch(configuration: RumConfiguration, lifeCycle: LifeCycle): {
stop: () => void;
};
export declare function startRumBatch(configuration: RumConfiguration, lifeCycle: LifeCycle, telemetryEventObservable: Observable<TelemetryEvent & Context>): void;
import { Batch, combine, HttpRequest } from '@datadog/browser-core';
import { LifeCycleEventType } from '../domain/lifeCycle';
import { RumEventType } from '../rawRumEvent.types';
export function startRumBatch(configuration, lifeCycle) {
export function startRumBatch(configuration, lifeCycle, telemetryEventObservable) {
var batch = makeRumBatch(configuration, lifeCycle);
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
if (serverRumEvent.type === RumEventType.VIEW) {
lifeCycle.subscribe(13 /* RUM_EVENT_COLLECTED */, function (serverRumEvent) {
if (serverRumEvent.type === "view" /* VIEW */) {
batch.upsert(serverRumEvent, serverRumEvent.view.id);

@@ -14,9 +12,7 @@ }

});
return {
stop: function () { return batch.stop(); },
};
telemetryEventObservable.subscribe(function (event) { return batch.add(event); });
}
function makeRumBatch(configuration, lifeCycle) {
var primaryBatch = createRumBatch(configuration.rumEndpointBuilder, function () {
return lifeCycle.notify(LifeCycleEventType.BEFORE_UNLOAD);
return lifeCycle.notify(11 /* BEFORE_UNLOAD */);
});

@@ -34,8 +30,4 @@ var replicaBatch;

}
var stopped = false;
return {
add: function (message) {
if (stopped) {
return;
}
primaryBatch.add(message);

@@ -46,9 +38,3 @@ if (replicaBatch) {

},
stop: function () {
stopped = true;
},
upsert: function (message, key) {
if (stopped) {
return;
}
primaryBatch.upsert(message, key);

@@ -55,0 +41,0 @@ if (replicaBatch) {

import { getEventBridge } from '@datadog/browser-core';
import { LifeCycleEventType } from '../domain/lifeCycle';
export function startRumEventBridge(lifeCycle) {
var bridge = getEventBridge();
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
lifeCycle.subscribe(13 /* RUM_EVENT_COLLECTED */, function (serverRumEvent) {
bridge.send('rum', serverRumEvent);

@@ -7,0 +6,0 @@ });

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

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

"dependencies": {
"@datadog/browser-core": "4.5.0",
"tslib": "^1.10.0"
"@datadog/browser-core": "4.6.0"
},

@@ -27,3 +26,3 @@ "devDependencies": {

},
"gitHead": "8224cb0d3343d276c677a9378e4e1bd7fdd22aa0"
"gitHead": "27bd7d9dd6bea2b2674a46f44d50df5bf15324d1"
}

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

expect(startRumSpy).toHaveBeenCalled()
expect(startRumSpy.calls.argsFor(0)[4]).toEqual('foo')
expect(startRumSpy.calls.argsFor(0)[3]).toEqual('foo')
expect(recorderApiOnRumStartSpy).toHaveBeenCalled()

@@ -618,3 +618,3 @@ expect(startViewSpy).not.toHaveBeenCalled()

expect(startRumSpy).toHaveBeenCalled()
expect(startRumSpy.calls.argsFor(0)[4]).toEqual('foo')
expect(startRumSpy.calls.argsFor(0)[3]).toEqual('foo')
expect(recorderApiOnRumStartSpy).toHaveBeenCalled()

@@ -630,3 +630,3 @@ expect(startViewSpy).not.toHaveBeenCalled()

expect(startRumSpy).toHaveBeenCalled()
expect(startRumSpy.calls.argsFor(0)[4]).toEqual('foo')
expect(startRumSpy.calls.argsFor(0)[3]).toEqual('foo')
expect(recorderApiOnRumStartSpy).toHaveBeenCalled()

@@ -676,3 +676,3 @@ expect(startViewSpy).toHaveBeenCalled()

function getCommonContext() {
return startRumSpy.calls.argsFor(0)[2]()
return startRumSpy.calls.argsFor(0)[1]()
}

@@ -679,0 +679,0 @@

@@ -1,3 +0,4 @@

import type { Context, InitConfiguration, InternalMonitoring, TimeStamp, RelativeTime } from '@datadog/browser-core'
import type { Context, InitConfiguration, TimeStamp, RelativeTime } from '@datadog/browser-core'
import {
assign,
BoundedBuffer,

@@ -16,3 +17,2 @@ buildCookieOptions,

areCookiesAuthorized,
startInternalMonitoring,
} from '@datadog/browser-core'

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

import type { startRum } from './startRum'
import { buildEnv } from './buildEnv'

@@ -35,3 +34,2 @@ export type RumPublicApi = ReturnType<typeof makeRumPublicApi>

configuration: RumConfiguration,
internalMonitoring: InternalMonitoring,
getCommonContext: () => CommonContext,

@@ -118,6 +116,4 @@ recorderApi: RecorderApi,

const internalMonitoring = startInternalMonitoring(configuration)
if (!configuration.trackViewsManually) {
doStartRum(configuration, internalMonitoring)
doStartRum(configuration)
} else {

@@ -131,3 +127,3 @@ // drain beforeInitCalls by buffering them until we start RUM

startViewStrategy = (name) => {
doStartRum(configuration, internalMonitoring, name)
doStartRum(configuration, name)
}

@@ -141,10 +137,5 @@ beforeInitCalls.drain()

function doStartRum(
configuration: RumConfiguration,
internalMonitoring: InternalMonitoring,
initialViewName?: string
) {
function doStartRum(configuration: RumConfiguration, initialViewName?: string) {
const startRumResults = startRumImpl(
configuration,
internalMonitoring,
() => ({

@@ -176,3 +167,3 @@ user,

const rumPublicApi = makePublicApi(buildEnv, {
const rumPublicApi = makePublicApi({
init: monitor(initRum),

@@ -278,8 +269,7 @@

function overrideInitConfigurationForBridge<C extends InitConfiguration>(initConfiguration: C): C {
return {
...initConfiguration,
return assign({}, initConfiguration, {
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
clientToken: 'empty',
sampleRate: 100,
}
})
}

@@ -286,0 +276,0 @@

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

import type { RelativeTime, Observable, Context } from '@datadog/browser-core'
import type { RelativeTime, Observable } from '@datadog/browser-core'
import { noop, relativeNow, isIE } from '@datadog/browser-core'

@@ -16,3 +16,2 @@ import type { RumSessionManagerMock } from '../../test/mockRumSessionManager'

import type { RumSessionManager } from '..'
import { initEventBridgeStub, deleteEventBridgeStub } from '../../../core/test/specHelper'
import type { RumConfiguration } from '../domain/configuration'

@@ -277,38 +276,1 @@ import { startRumEventCollection } from './startRum'

})
describe('startRumEventCollection', () => {
let setupBuilder: TestSetupBuilder
let sendSpy: jasmine.Spy<(msg: string) => void>
beforeEach(() => {
const eventBridgeStub = initEventBridgeStub()
sendSpy = spyOn(eventBridgeStub, 'send')
setupBuilder = setupBuilder = setup().beforeBuild(
({ location, lifeCycle, configuration, sessionManager, locationChangeObservable }) =>
startRumEventCollection(lifeCycle, configuration, location, sessionManager, locationChangeObservable, () => ({
context: {},
user: {},
}))
)
})
afterEach(() => {
deleteEventBridgeStub()
setupBuilder.cleanup()
})
it('should send bridge event when bridge is present', () => {
const { lifeCycle } = setupBuilder.build()
const collectedRumEvent = { type: 'action' } as RumEvent & Context
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, collectedRumEvent)
const [message] = sendSpy.calls.mostRecent().args
const parsedMessage = JSON.parse(message)
expect(parsedMessage).toEqual({
eventType: 'rum',
event: jasmine.objectContaining({ type: 'action' }),
})
})
})

@@ -1,3 +0,9 @@

import type { InternalMonitoring, Observable } from '@datadog/browser-core'
import { combine, canUseEventBridge } from '@datadog/browser-core'
import type { Observable, MonitoringMessage, TelemetryEvent } from '@datadog/browser-core'
import {
startInternalMonitoring,
combine,
canUseEventBridge,
startBatchWithReplica,
getEventBridge,
} from '@datadog/browser-core'
import { createDOMMutationObservable } from '../browser/domMutationObservable'

@@ -29,3 +35,2 @@ import { startPerformanceCollection } from '../browser/performanceCollection'

configuration: RumConfiguration,
internalMonitoring: InternalMonitoring,
getCommonContext: () => CommonContext,

@@ -36,6 +41,4 @@ recorderApi: RecorderApi,

const lifeCycle = new LifeCycle()
const session = !canUseEventBridge() ? startRumSessionManager(configuration, lifeCycle) : startRumSessionManagerStub()
const domMutationObservable = createDOMMutationObservable()
const locationChangeObservable = createLocationChangeObservable(location)
const internalMonitoring = startRumInternalMonitoring(configuration)
internalMonitoring.setExternalContextProvider(() =>

@@ -53,3 +56,27 @@ combine(

)
internalMonitoring.setTelemetryContextProvider(() => ({
application: {
id: configuration.applicationId,
},
session: {
id: session.findTrackedSession()?.id,
},
view: {
id: parentContexts.findView()?.view.id,
},
action: {
id: parentContexts.findAction()?.action.id,
},
}))
if (!canUseEventBridge()) {
startRumBatch(configuration, lifeCycle, internalMonitoring.telemetryEventObservable)
} else {
startRumEventBridge(lifeCycle)
}
const session = !canUseEventBridge() ? startRumSessionManager(configuration, lifeCycle) : startRumSessionManagerStub()
const domMutationObservable = createDOMMutationObservable()
const locationChangeObservable = createLocationChangeObservable(location)
const { parentContexts, foregroundContexts, urlContexts } = startRumEventCollection(

@@ -96,2 +123,19 @@ lifeCycle,

function startRumInternalMonitoring(configuration: RumConfiguration) {
const internalMonitoring = startInternalMonitoring(configuration)
if (canUseEventBridge()) {
const bridge = getEventBridge<'internal_log' | 'internal_telemetry', MonitoringMessage | TelemetryEvent>()!
internalMonitoring.monitoringMessageObservable.subscribe((message) => bridge.send('internal_log', message))
internalMonitoring.telemetryEventObservable.subscribe((message) => bridge.send('internal_telemetry', message))
} else if (configuration.internalMonitoringEndpointBuilder) {
const batch = startBatchWithReplica(
configuration,
configuration.internalMonitoringEndpointBuilder,
configuration.replica?.internalMonitoringEndpointBuilder
)
internalMonitoring.monitoringMessageObservable.subscribe((message) => batch.add(message))
}
return internalMonitoring
}
export function startRumEventCollection(

@@ -109,10 +153,2 @@ lifeCycle: LifeCycle,

let stopBatch: () => void
if (canUseEventBridge()) {
startRumEventBridge(lifeCycle)
} else {
;({ stop: stopBatch } = startRumBatch(configuration, lifeCycle))
}
startRumAssembly(configuration, lifeCycle, sessionManager, parentContexts, urlContexts, getCommonContext)

@@ -125,5 +161,2 @@

stop: () => {
// prevent batch from previous tests to keep running and send unwanted requests
// could be replaced by stopping all the component when they will all have a stop method
stopBatch?.()
parentContexts.stop()

@@ -130,0 +163,0 @@ foregroundContexts.stop()

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

import { addEventListener, DOM_EVENT, instrumentMethodAndCallOriginal, Observable } from '@datadog/browser-core'
import {
addEventListener,
DOM_EVENT,
instrumentMethodAndCallOriginal,
Observable,
shallowClone,
} from '@datadog/browser-core'

@@ -9,3 +15,3 @@ export interface LocationChange {

export function createLocationChangeObservable(location: Location) {
let currentLocation = { ...location }
let currentLocation = shallowClone(location)
const observable = new Observable<LocationChange>(() => {

@@ -24,3 +30,3 @@ const { stop: stopHistoryTracking } = trackHistory(onLocationChange)

}
const newLocation = { ...location }
const newLocation = shallowClone(location)
observable.notify({

@@ -27,0 +33,0 @@ newLocation,

import type { Duration, RelativeTime, TimeStamp } from '@datadog/browser-core'
import {
assign,
addEventListeners,

@@ -11,2 +12,3 @@ DOM_EVENT,

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

@@ -113,4 +115,8 @@ import type { LifeCycle } from '../domain/lifeCycle'

if (supportPerformanceObject()) {
handleRumPerformanceEntries(lifeCycle, configuration, performance.getEntries())
const performanceEntries = performance.getEntries()
// Because the performance entry list can be quite large
// delay the computation to prevent the SDK from blocking the main thread on init
setTimeout(monitor(() => handleRumPerformanceEntries(lifeCycle, configuration, performanceEntries)))
}
if (window.PerformanceObserver) {

@@ -170,13 +176,15 @@ const handlePerformanceEntryList = monitor((entries: PerformanceObserverEntryList) =>

const navigationEntry = performance.getEntriesByType('navigation')[0]
timing = { ...navigationEntry.toJSON(), ...forcedAttributes }
timing = assign(navigationEntry.toJSON(), forcedAttributes)
} else {
const relativePerformanceTiming = computeRelativePerformanceTiming()
timing = {
...relativePerformanceTiming,
decodedBodySize: 0,
duration: relativePerformanceTiming.responseEnd,
name: window.location.href,
startTime: 0 as RelativeTime,
...forcedAttributes,
}
timing = assign(
relativePerformanceTiming,
{
decodedBodySize: 0,
duration: relativePerformanceTiming.responseEnd,
name: window.location.href,
startTime: 0 as RelativeTime,
},
forcedAttributes
)
}

@@ -189,6 +197,7 @@ callback(timing)

function sendFakeTiming() {
callback({
...computeRelativePerformanceTiming(),
entryType: 'navigation',
})
callback(
assign(computeRelativePerformanceTiming(), {
entryType: 'navigation' as const,
})
)
}

@@ -195,0 +204,0 @@

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

expect(serverRumEvents[0].view.id).toBe('aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee')
expect(displaySpy).toHaveBeenCalledWith(`Can't dismiss view events using beforeSend!`)
expect(displaySpy).toHaveBeenCalledWith("Can't dismiss view events using beforeSend!")
})

@@ -282,0 +282,0 @@ })

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

import { RumEventType } from '../rawRumEvent.types'
import { RumEvent } from '../rumEvent.types'
import { buildEnv } from '../boot/buildEnv'
import type { RumEvent } from '../rumEvent.types'
import { getSyntheticsContext } from './syntheticsContext'

@@ -36,3 +35,6 @@ import { getCiTestContext } from './ciTestContext'

enum SessionType {
// replaced at build time
declare const __BUILD_ENV__SDK_VERSION__: string
const enum SessionType {
SYNTHETICS = 'synthetics',

@@ -54,7 +56,6 @@ USER = 'user',

const OTHER_EVENTS_MODIFIABLE_FIELD_PATHS = [
...VIEW_EVENTS_MODIFIABLE_FIELD_PATHS,
const OTHER_EVENTS_MODIFIABLE_FIELD_PATHS = VIEW_EVENTS_MODIFIABLE_FIELD_PATHS.concat([
// User-customizable field
'context',
]
])

@@ -110,3 +111,3 @@ type Mutable<T> = { -readonly [P in keyof T]: T[P] }

},
browser_sdk_version: canUseEventBridge() ? buildEnv.sdkVersion : undefined,
browser_sdk_version: canUseEventBridge() ? __BUILD_ENV__SDK_VERSION__ : undefined,
},

@@ -113,0 +114,0 @@ application: {

import type { Configuration, InitConfiguration } from '@datadog/browser-core'
import {
assign,
DefaultPrivacyLevel,

@@ -9,3 +10,2 @@ display,

} from '@datadog/browser-core'
import { buildEnv } from '../boot/buildEnv'
import type { RumEventDomainContext } from '../domainContext.types'

@@ -71,3 +71,3 @@ import type { RumEvent } from '../rumEvent.types'

const baseConfiguration = validateAndBuildConfiguration(initConfiguration, buildEnv)
const baseConfiguration = validateAndBuildConfiguration(initConfiguration)
if (!baseConfiguration) {

@@ -77,15 +77,16 @@ return

return {
...baseConfiguration,
applicationId: initConfiguration.applicationId,
actionNameAttribute: initConfiguration.actionNameAttribute,
replaySampleRate: initConfiguration.replaySampleRate ?? 100,
allowedTracingOrigins: initConfiguration.allowedTracingOrigins ?? [],
trackInteractions: !!initConfiguration.trackInteractions,
trackViewsManually: !!initConfiguration.trackViewsManually,
defaultPrivacyLevel: objectHasValue(DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)
? initConfiguration.defaultPrivacyLevel
: DefaultPrivacyLevel.MASK_USER_INPUT,
}
return assign(
{
applicationId: initConfiguration.applicationId,
actionNameAttribute: initConfiguration.actionNameAttribute,
replaySampleRate: initConfiguration.replaySampleRate ?? 100,
allowedTracingOrigins: initConfiguration.allowedTracingOrigins ?? [],
trackInteractions: !!initConfiguration.trackInteractions,
trackViewsManually: !!initConfiguration.trackViewsManually,
defaultPrivacyLevel: objectHasValue(DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)
? initConfiguration.defaultPrivacyLevel
: DefaultPrivacyLevel.MASK_USER_INPUT,
},
baseConfiguration
)
}
import type { RelativeTime } from '@datadog/browser-core'
import { assign } from '@datadog/browser-core'
import type { InternalContext } from '../rawRumEvent.types'

@@ -32,6 +33,3 @@ import type { ParentContexts } from './parentContexts'

: undefined,
view: {
...viewContext.view,
...urlContext.view,
},
view: assign({}, viewContext.view, urlContext.view),
}

@@ -38,0 +36,0 @@ }

@@ -10,3 +10,3 @@ import type { Context, RawError, RelativeTime, Subscription } from '@datadog/browser-core'

export enum LifeCycleEventType {
export const enum LifeCycleEventType {
PERFORMANCE_ENTRIES_COLLECTED,

@@ -13,0 +13,0 @@ AUTO_ACTION_CREATED,

@@ -12,9 +12,4 @@ import { isIE, RequestType } from '@datadog/browser-core'

const configuration: RumConfiguration = {
...validateAndBuildRumConfiguration({ clientToken: 'xxx', applicationId: 'xxx' })!,
...SPEC_ENDPOINTS,
maxBatchSize: 1,
}
describe('collect fetch', () => {
let configuration: RumConfiguration
const FAKE_URL = 'http://fake-url/'

@@ -31,2 +26,7 @@ let fetchStub: FetchStub

}
configuration = {
...validateAndBuildRumConfiguration({ clientToken: 'xxx', applicationId: 'xxx' })!,
...SPEC_ENDPOINTS,
maxBatchSize: 1,
}
fetchStubManager = stubFetch()

@@ -143,2 +143,3 @@

describe('collect xhr', () => {
let configuration: RumConfiguration
let startSpy: jasmine.Spy<(requestStartEvent: RequestStartEvent) => void>

@@ -153,2 +154,7 @@ let completeSpy: jasmine.Spy<(requestCompleteEvent: RequestCompleteEvent) => void>

}
configuration = {
...validateAndBuildRumConfiguration({ clientToken: 'xxx', applicationId: 'xxx' })!,
...SPEC_ENDPOINTS,
maxBatchSize: 1,
}
stubXhrManager = stubXhr()

@@ -155,0 +161,0 @@ startSpy = jasmine.createSpy('requestStart')

import type { Observable } from '@datadog/browser-core'
import { combine, toServerDuration, generateUUID } from '@datadog/browser-core'
import { assign, combine, toServerDuration, generateUUID } from '@datadog/browser-core'
import type { CommonContext, RawRumActionEvent } from '../../../rawRumEvent.types'

@@ -28,6 +29,11 @@ import { ActionType, RumEventType } from '../../../rawRumEvent.types'

addAction: (action: CustomAction, savedCommonContext?: CommonContext) => {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {
savedCommonContext,
...processAction(action, foregroundContexts),
})
lifeCycle.notify(
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
assign(
{
savedCommonContext,
},
processAction(action, foregroundContexts)
)
)
},

@@ -34,0 +40,0 @@ }

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

message: 'foo',
resource: undefined,
source: ErrorSource.CUSTOM,

@@ -129,8 +128,3 @@ stack: jasmine.stringMatching('Error: foo'),

message: 'hello',
resource: {
method: 'GET',
statusCode: 500,
url: 'url',
},
source: ErrorSource.NETWORK,
source: ErrorSource.CUSTOM,
stack: 'bar',

@@ -149,8 +143,3 @@ startClocks: { relative: 1234 as RelativeTime, timeStamp: 123456789 as TimeStamp },

message: 'hello',
resource: {
method: 'GET',
status_code: 500,
url: 'url',
},
source: ErrorSource.NETWORK,
source: ErrorSource.CUSTOM,
stack: 'bar',

@@ -157,0 +146,0 @@ handling_stack: undefined,

import type { Context, RawError, ClocksState } from '@datadog/browser-core'
import {
assign,
computeStackTrace,

@@ -17,2 +18,3 @@ formatUnknownError,

import { trackConsoleError } from './trackConsoleError'
import { trackReportError } from './trackReportError'

@@ -31,2 +33,3 @@ export interface ProvidedError {

trackRuntimeError(errorObservable)
trackReportError(errorObservable)

@@ -40,7 +43,12 @@ errorObservable.subscribe((error) => lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error }))

lifeCycle.subscribe(LifeCycleEventType.RAW_ERROR_COLLECTED, ({ error, customerContext, savedCommonContext }) => {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {
customerContext,
savedCommonContext,
...processError(error, foregroundContexts),
})
lifeCycle.notify(
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
assign(
{
customerContext,
savedCommonContext,
},
processError(error, foregroundContexts)
)
)
})

@@ -65,9 +73,11 @@

const stackTrace = error instanceof Error ? computeStackTrace(error) : undefined
return {
startClocks,
source: ErrorSource.CUSTOM,
originalError: error,
...formatUnknownError(stackTrace, error, 'Provided', handlingStack),
handling: ErrorHandling.HANDLED,
}
return assign(
{
startClocks,
source: ErrorSource.CUSTOM,
originalError: error,
handling: ErrorHandling.HANDLED,
},
formatUnknownError(stackTrace, error, 'Provided', handlingStack)
)
}

@@ -84,9 +94,2 @@

message: error.message,
resource: error.resource
? {
method: error.resource.method,
status_code: error.resource.statusCode,
url: error.resource.url,
}
: undefined,
source: error.source,

@@ -93,0 +96,0 @@ stack: error.stack,

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

relativeToClocks,
assign,
} from '@datadog/browser-core'

@@ -114,7 +115,9 @@ import type { RumPerformanceEntry, RumPerformanceResourceTiming } from '../../../browser/performanceCollection'

return {
resource: {
duration: computePerformanceResourceDuration(timing),
size: computeSize(timing),
...computePerformanceResourceDetails(timing),
},
resource: assign(
{
duration: computePerformanceResourceDuration(timing),
size: computeSize(timing),
},
computePerformanceResourceDetails(timing)
),
}

@@ -121,0 +124,0 @@ }

@@ -295,7 +295,11 @@ import type { Duration, RelativeTime, ServerDuration } from '@datadog/browser-core'

describe('shouldTrackResource', () => {
const configuration: RumConfiguration = {
...validateAndBuildRumConfiguration({ clientToken: 'xxx', applicationId: 'xxx' })!,
...SPEC_ENDPOINTS,
}
let configuration: RumConfiguration
beforeEach(() => {
configuration = {
...validateAndBuildRumConfiguration({ clientToken: 'xxx', applicationId: 'xxx' })!,
...SPEC_ENDPOINTS,
}
})
it('should exclude requests on intakes endpoints', () => {

@@ -302,0 +306,0 @@ expect(isAllowedRequestUrl(configuration, 'https://rum-intake.com/v1/input/abcde?foo=bar')).toBe(false)

import type { RelativeTime, ServerDuration } from '@datadog/browser-core'
import {
assign,
addMonitoringMessage,

@@ -11,2 +12,3 @@ elapsed,

} from '@datadog/browser-core'
import type { RumPerformanceResourceTiming } from '../../../browser/performanceCollection'

@@ -178,7 +180,6 @@

return {
...entry,
return assign({}, entry, {
redirectEnd,
redirectStart,
}
})
}

@@ -185,0 +186,0 @@

import type { Duration, EventEmitter, RelativeTime } from '@datadog/browser-core'
import { addEventListeners, DOM_EVENT, elapsed, ONE_MINUTE, find, findLast } from '@datadog/browser-core'
import { assign, addEventListeners, DOM_EVENT, elapsed, ONE_MINUTE, find, findLast } from '@datadog/browser-core'
import type { LifeCycle } from '../../lifeCycle'

@@ -28,5 +29,5 @@ import { LifeCycleEventType } from '../../lifeCycle'

export function trackInitialViewTimings(lifeCycle: LifeCycle, callback: (timings: Timings) => void) {
let timings: Timings | undefined
const timings: Timings = {}
function setTimings(newTimings: Partial<Timings>) {
timings = { ...timings, ...newTimings }
assign(timings, newTimings)
callback(timings)

@@ -33,0 +34,0 @@ }

import type { Duration, ClocksState, TimeStamp, Observable, Subscription, RelativeTime } from '@datadog/browser-core'
import {
shallowClone,
assign,
elapsed,

@@ -14,2 +16,3 @@ generateUUID,

} from '@datadog/browser-core'
import type { ViewCustomTimings } from '../../../rawRumEvent.types'

@@ -166,3 +169,3 @@ import { ViewLoadingType } from '../../../rawRumEvent.types'

let endClocks: ClocksState | undefined
const location = { ...initialLocation }
const location = shallowClone(initialLocation)

@@ -192,15 +195,20 @@ lifeCycle.notify(LifeCycleEventType.VIEW_CREATED, { id, name, startClocks })

const currentEnd = endClocks === undefined ? timeStampNow() : endClocks.timeStamp
lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, {
...viewMetrics,
customTimings,
documentVersion,
id,
name,
loadingType,
location,
startClocks,
timings,
duration: elapsed(startClocks.timeStamp, currentEnd),
isActive: endClocks === undefined,
})
lifeCycle.notify(
LifeCycleEventType.VIEW_UPDATED,
assign(
{
customTimings,
documentVersion,
id,
name,
loadingType,
location,
startClocks,
timings,
duration: elapsed(startClocks.timeStamp, currentEnd),
isActive: endClocks === undefined,
},
viewMetrics
)
)
}

@@ -207,0 +215,0 @@

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

export enum RumSessionPlan {
export const enum RumSessionPlan {
LITE = 1,

@@ -25,3 +25,3 @@ REPLAY = 2,

export enum RumTrackingType {
export const enum RumTrackingType {
NOT_TRACKED = '0',

@@ -28,0 +28,0 @@ // Note: the "tracking type" value (stored in the session cookie) does not match the "session

@@ -7,2 +7,3 @@ import { isIE, objectEntries } from '@datadog/browser-core'

import type { RumFetchCompleteContext, RumFetchStartContext, RumXhrStartContext } from '../requestCollection'
import type { RumConfiguration } from '../configuration'
import { validateAndBuildRumConfiguration } from '../configuration'

@@ -12,8 +13,3 @@ import { startTracer, TraceIdentifier } from './tracer'

describe('tracer', () => {
const configuration = validateAndBuildRumConfiguration({
clientToken: 'xxx',
applicationId: 'xxx',
allowedTracingOrigins: [window.location.origin],
service: 'service',
})!
let configuration: RumConfiguration
const ALLOWED_DOMAIN_CONTEXT: Partial<RumXhrStartContext | RumFetchStartContext> = {

@@ -29,2 +25,8 @@ url: window.location.origin,

beforeEach(() => {
configuration = validateAndBuildRumConfiguration({
clientToken: 'xxx',
applicationId: 'xxx',
allowedTracingOrigins: [window.location.origin],
service: 'service',
})!
setupBuilder = setup()

@@ -31,0 +33,0 @@ sessionManager = createRumSessionManagerMock()

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

import { getOrigin, objectEntries } from '@datadog/browser-core'
import { getOrigin, objectEntries, shallowClone } from '@datadog/browser-core'
import type { RumConfiguration } from '../configuration'

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

} else {
context.init = { ...context.init }
context.init = shallowClone(context.init)
const headers: string[][] = []

@@ -59,0 +59,0 @@ if (context.init.headers instanceof Headers) {

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

export enum RumEventType {
export const enum RumEventType {
ACTION = 'action',

@@ -54,7 +54,2 @@ ERROR = 'error',

error: {
resource?: {
url: string
status_code: number
method: string
}
id: string

@@ -115,3 +110,3 @@ type?: string

export enum ViewLoadingType {
export const enum ViewLoadingType {
INITIAL_LOAD = 'initial_load',

@@ -163,3 +158,3 @@ ROUTE_CHANGE = 'route_change',

export enum ActionType {
export const enum ActionType {
CLICK = 'click',

@@ -166,0 +161,0 @@ CUSTOM = 'custom',

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

*/
readonly source: 'network' | 'source' | 'console' | 'logger' | 'agent' | 'webview' | 'custom'
readonly source: 'network' | 'source' | 'console' | 'logger' | 'agent' | 'webview' | 'custom' | 'report'
/**

@@ -124,0 +124,0 @@ * Stacktrace of the error

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

import type { Context, EndpointBuilder } from '@datadog/browser-core'
import type { Context, EndpointBuilder, TelemetryEvent, Observable } from '@datadog/browser-core'
import { Batch, combine, HttpRequest } from '@datadog/browser-core'

@@ -9,3 +9,7 @@ import type { RumConfiguration } from '../domain/configuration'

export function startRumBatch(configuration: RumConfiguration, lifeCycle: LifeCycle) {
export function startRumBatch(
configuration: RumConfiguration,
lifeCycle: LifeCycle,
telemetryEventObservable: Observable<TelemetryEvent & Context>
) {
const batch = makeRumBatch(configuration, lifeCycle)

@@ -21,5 +25,3 @@

return {
stop: () => batch.stop(),
}
telemetryEventObservable.subscribe((event) => batch.add(event))
}

@@ -29,3 +31,2 @@

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

@@ -60,8 +61,4 @@ }

let stopped = false
return {
add: (message: Context) => {
if (stopped) {
return
}
primaryBatch.add(message)

@@ -72,9 +69,3 @@ if (replicaBatch) {

},
stop: () => {
stopped = true
},
upsert: (message: Context, key: string) => {
if (stopped) {
return
}
primaryBatch.upsert(message, key)

@@ -81,0 +72,0 @@ if (replicaBatch) {

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

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