Socket
Socket
Sign inDemoInstall

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 2.3.1 to 2.4.0

2

cjs/boot/buildEnv.js

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

datacenter: 'us',
sdkVersion: '2.3.1',
sdkVersion: '2.4.0',
};
//# sourceMappingURL=buildEnv.js.map

@@ -9,3 +9,3 @@ import { Configuration } from '@datadog/browser-core';

addError: ({ error, startTime, context: customerContext, source }: import("../domain/rumEventsCollection/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
addTiming: (name: string, inInitialView?: boolean) => void;
addTiming: (name: string, time?: number) => void;
configuration: Configuration;

@@ -21,4 +21,4 @@ lifeCycle: LifeCycle;

parentContexts: import("../domain/parentContexts").ParentContexts;
addTiming: (name: string, inInitialView?: boolean) => void;
addTiming: (name: string, time?: number) => void;
stop(): void;
};

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

assembly_1.startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getCommonContext);
longTaskCollection_1.startLongTaskCollection(lifeCycle, configuration);
longTaskCollection_1.startLongTaskCollection(lifeCycle);
resourceCollection_1.startResourceCollection(lifeCycle, configuration, session);

@@ -52,0 +52,0 @@ var addTiming = viewCollection_1.startViewCollection(lifeCycle, configuration, location).addTiming;

@@ -21,7 +21,7 @@ import { Context, UserConfiguration } from '@datadog/browser-core';

/**
* @deprecated
* @see addAction
* @deprecated use addAction instead
*/
addUserAction: (name: string, context?: object | undefined) => void;
addError: (error: unknown, context?: object | undefined, source?: ProvidedSource) => void;
addTiming: (name: string) => void;
setUser: (newUser: User) => void;

@@ -28,0 +28,0 @@ } & {

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

var user = {};
var getInternalContextStrategy = function () {
return undefined;
var getInternalContextStrategy = function () { return undefined; };
var beforeInitAddTiming = new browser_core_1.BoundedBuffer();
var addTimingStrategy = function (name) {
beforeInitAddTiming.add([name, performance.now()]);
};

@@ -38,8 +40,7 @@ var beforeInitAddAction = new browser_core_1.BoundedBuffer();

}
var configuration;
var addTiming;
;
(_a = startRumImpl(userConfiguration, function () { return ({
user: user,
context: globalContextManager.get(),
}); }), addTiming = _a.addTiming, configuration = _a.configuration, addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, getInternalContextStrategy = _a.getInternalContext);
}); }), addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, addTimingStrategy = _a.addTiming, getInternalContextStrategy = _a.getInternalContext);
beforeInitAddAction.drain(function (_a) {

@@ -53,6 +54,6 @@ var action = _a[0], commonContext = _a[1];

});
if (configuration.isEnabled('custom-timings')) {
;
rumGlobal.addTiming = addTiming;
}
beforeInitAddTiming.drain(function (_a) {
var name = _a[0], time = _a[1];
return addTimingStrategy(name, time);
});
isAlreadyInitialized = true;

@@ -64,5 +65,3 @@ }),

setRumGlobalContext: browser_core_1.monitor(globalContextManager.set),
getInternalContext: browser_core_1.monitor(function (startTime) {
return getInternalContextStrategy(startTime);
}),
getInternalContext: browser_core_1.monitor(function (startTime) { return getInternalContextStrategy(startTime); }),
addAction: browser_core_1.monitor(function (name, context) {

@@ -77,4 +76,3 @@ addActionStrategy({

/**
* @deprecated
* @see addAction
* @deprecated use addAction instead
*/

@@ -101,2 +99,5 @@ addUserAction: function (name, context) {

}),
addTiming: browser_core_1.monitor(function (name) {
addTimingStrategy(name);
}),
setUser: browser_core_1.monitor(function (newUser) {

@@ -103,0 +104,0 @@ var sanitizedUser = sanitizeUser(newUser);

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

if (browserWindow.Zone) {
// eslint-disable-next-line no-underscore-dangle
var symbol = browserWindow.Zone.__symbol__('MutationObserver');

@@ -22,0 +23,0 @@ constructor = browserWindow[symbol];

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

if (window.PerformanceObserver) {
var observer = new PerformanceObserver(browser_core_1.monitor(function (entries) { return handlePerformanceEntries(lifeCycle, configuration, entries.getEntries()); }));
var observer = new PerformanceObserver(browser_core_1.monitor(function (entries) {
return handlePerformanceEntries(lifeCycle, configuration, entries.getEntries());
}));
var entryTypes = [

@@ -28,0 +30,0 @@ 'resource',

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

_dd: {
formatVersion: 2,
format_version: 2,
},

@@ -44,6 +44,5 @@ application: {

};
var assembledRumEvent = needToAssembleWithAction(rawRumEvent)
var serverRumEvent = (needToAssembleWithAction(rawRumEvent)
? browser_core_1.combine(rumContext, viewContext, actionContext, rawRumEvent)
: browser_core_1.combine(rumContext, viewContext, rawRumEvent);
var serverRumEvent = browser_core_1.withSnakeCaseKeys(assembledRumEvent);
: browser_core_1.combine(rumContext, viewContext, rawRumEvent));
var context = browser_core_1.combine(commonContext.context, customerContext);

@@ -54,2 +53,3 @@ if (!browser_core_1.isEmptyObject(context)) {

if (!browser_core_1.isEmptyObject(commonContext.user)) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
;

@@ -61,3 +61,3 @@ serverRumEvent.usr = commonContext.user;

}
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RUM_EVENT_COLLECTED, { assembledRumEvent: assembledRumEvent, serverRumEvent: serverRumEvent });
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
}

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

function getSessionType() {
// eslint-disable-next-line no-underscore-dangle
return window._DATADOG_SYNTHETICS_BROWSER === undefined ? SessionType.USER : SessionType.SYNTHETICS;
}
//# sourceMappingURL=assembly.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var browser_core_1 = require("@datadog/browser-core");
/**

@@ -14,3 +13,12 @@ * Internal context keep returning v1 format

var actionContext = parentContexts.findAction(startTime);
return browser_core_1.withSnakeCaseKeys(browser_core_1.combine({ applicationId: applicationId }, { sessionId: viewContext.session.id, view: viewContext.view }, actionContext ? { userAction: { id: actionContext.action.id } } : undefined));
return {
application_id: applicationId,
session_id: viewContext.session.id,
user_action: actionContext
? {
id: actionContext.action.id,
}
: undefined,
view: viewContext.view,
};
}

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

import { Context } from '@datadog/browser-core';
import { RumPerformanceEntry } from '../browser/performanceCollection';
import { AssembledRumEvent, CommonContext, RawRumEvent } from '../rawRumEvent.types';
import { CommonContext, RawRumEvent } from '../rawRumEvent.types';
import { RumEvent } from '../rumEvent.types';

@@ -24,3 +24,3 @@ import { RequestCompleteEvent, RequestStartEvent } from './requestCollection';

export interface Subscription {
unsubscribe(): void;
unsubscribe: () => void;
}

@@ -43,6 +43,3 @@ export declare class LifeCycle {

}): void;
notify(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, data: {
assembledRumEvent: AssembledRumEvent;
serverRumEvent: RumEvent & Context;
}): void;
notify(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, data: RumEvent & Context): void;
subscribe(eventType: LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, callback: (data: RumPerformanceEntry) => void): Subscription;

@@ -62,6 +59,3 @@ subscribe(eventType: LifeCycleEventType.REQUEST_STARTED, callback: (data: RequestStartEvent) => void): Subscription;

}) => void): Subscription;
subscribe(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, callback: (data: {
assembledRumEvent: AssembledRumEvent;
serverRumEvent: RumEvent & Context;
}) => void): Subscription;
subscribe(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, callback: (data: RumEvent & Context) => void): Subscription;
}

@@ -98,8 +98,4 @@ "use strict";

return {
findAction: function (startTime) {
return findContext(buildCurrentActionContext, previousActions, currentAction, startTime);
},
findView: function (startTime) {
return findContext(buildCurrentViewContext, previousViews, currentView, startTime);
},
findAction: function (startTime) { return findContext(buildCurrentActionContext, previousActions, currentAction, startTime); },
findView: function (startTime) { return findContext(buildCurrentViewContext, previousViews, currentView, startTime); },
stop: function () {

@@ -106,0 +102,0 @@ window.clearInterval(clearOldContextsInterval);

@@ -6,3 +6,3 @@ import { Configuration } from '@datadog/browser-core';

export declare function startActionCollection(lifeCycle: LifeCycle, configuration: Configuration): {
addAction(action: CustomAction, savedCommonContext?: CommonContext | undefined): void;
addAction: (action: CustomAction, savedCommonContext?: CommonContext | undefined) => void;
};

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

id: action.id,
loadingTime: browser_core_1.msToNs(action.duration),
longTask: {
loading_time: browser_core_1.msToNs(action.duration),
long_task: {
count: action.counts.longTaskCount,

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

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

];
var fallbackStrategies = [
function (element) {
return getTextualContent(element);
},
];
var fallbackStrategies = [function (element) { return getTextualContent(element); }];
/**

@@ -148,3 +144,2 @@ * Iterates over the target element and its parent, using the strategies list to get an action name.

// document.getElementById won't work.
// tslint:disable-next-line: no-null-keyword
return refElement.ownerDocument ? refElement.ownerDocument.getElementById(id) : null;

@@ -162,3 +157,3 @@ }

var elementsTextToRemove = element.querySelectorAll('script, style');
// tslint:disable-next-line: prefer-for-of
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (var i = 0; i < elementsTextToRemove.length; i += 1) {

@@ -165,0 +160,0 @@ var innerText = elementsTextToRemove[i].innerText;

@@ -12,6 +12,6 @@ import { Configuration, Context, Observable, RawError } from '@datadog/browser-core';

export declare function startErrorCollection(lifeCycle: LifeCycle, configuration: Configuration): {
addError({ error, startTime, context: customerContext, source }: ProvidedError, savedCommonContext?: CommonContext | undefined): void;
addError: ({ error, startTime, context: customerContext, source }: ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
};
export declare function doStartErrorCollection(lifeCycle: LifeCycle, configuration: Configuration, observable: Observable<RawError>): {
addError({ error, startTime, context: customerContext, source }: ProvidedError, savedCommonContext?: CommonContext | undefined): void;
addError: ({ error, startTime, context: customerContext, source }: ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
};

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

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

@@ -35,0 +41,0 @@ stack: error.stack,

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

import { Configuration } from '@datadog/browser-core';
import { LifeCycle } from '../../lifeCycle';
export declare function startLongTaskCollection(lifeCycle: LifeCycle, configuration: Configuration): void;
export declare function startLongTaskCollection(lifeCycle: LifeCycle): void;

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

var lifeCycle_1 = require("../../lifeCycle");
function startLongTaskCollection(lifeCycle, configuration) {
function startLongTaskCollection(lifeCycle) {
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entry) {

@@ -14,3 +14,3 @@ if (entry.entryType !== 'longtask') {

date: browser_core_1.getTimestamp(entry.startTime),
longTask: {
long_task: {
duration: browser_core_1.msToNs(entry.duration),

@@ -17,0 +17,0 @@ },

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

method: request.method,
statusCode: request.status,
status_code: request.status,
url: request.url,

@@ -68,4 +68,4 @@ },

_dd: {
spanId: request.spanId.toDecimalString(),
traceId: request.traceId.toDecimalString(),
span_id: request.spanId.toDecimalString(),
trace_id: request.traceId.toDecimalString(),
},

@@ -76,4 +76,4 @@ resource: { id: browser_core_1.generateUUID() },

function computeEntryTracingInfo(entry) {
return entry.traceId ? { _dd: { traceId: entry.traceId } } : undefined;
return entry.traceId ? { _dd: { trace_id: entry.traceId } } : undefined;
}
//# sourceMappingURL=resourceCollection.js.map

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

ssl?: PerformanceResourceDetailsElement;
firstByte: PerformanceResourceDetailsElement;
first_byte: PerformanceResourceDetailsElement;
download: PerformanceResourceDetailsElement;

@@ -15,0 +15,0 @@ }

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

[browser_core_1.ResourceType.BEACON, function (initiatorType) { return 'beacon' === initiatorType; }],
[browser_core_1.ResourceType.CSS, function (_, path) { return path.match(/\.css$/i) !== null; }],
[browser_core_1.ResourceType.JS, function (_, path) { return path.match(/\.js$/i) !== null; }],
[browser_core_1.ResourceType.CSS, function (_, path) { return /\.css$/i.test(path); }],
[browser_core_1.ResourceType.JS, function (_, path) { return /\.js$/i.test(path); }],
[
browser_core_1.ResourceType.IMAGE,
function (initiatorType, path) {
return browser_core_1.includes(['image', 'img', 'icon'], initiatorType) || path.match(/\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i) !== null;
return 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 path.match(/\.(woff|eot|woff2|ttf)$/i) !== null; }],
[browser_core_1.ResourceType.FONT, function (_, path) { return /\.(woff|eot|woff2|ttf)$/i.exec(path) !== null; }],
[
browser_core_1.ResourceType.MEDIA,
function (initiatorType, path) {
return browser_core_1.includes(['audio', 'video'], initiatorType) || path.match(/\.(mp3|mp4)$/i) !== null;
return browser_core_1.includes(['audio', 'video'], initiatorType) || /\.(mp3|mp4)$/i.exec(path) !== null;
},

@@ -77,3 +77,3 @@ ],

download: formatTiming(startTime, responseStart, responseEnd),
firstByte: formatTiming(startTime, requestStart, responseStart),
first_byte: formatTiming(startTime, requestStart, responseStart),
};

@@ -80,0 +80,0 @@ // Make sure a connection occurred

@@ -14,3 +14,3 @@ import { EventEmitter } from '@datadog/browser-core';

export declare function trackTimings(lifeCycle: LifeCycle, callback: (timings: Timings) => void): {
stop(): void;
stop: () => void;
};

@@ -30,3 +30,3 @@ export declare function trackNavigationTimings(lifeCycle: LifeCycle, callback: (newTimings: Partial<Timings>) => void): {

export declare function trackLargestContentfulPaint(lifeCycle: LifeCycle, emitter: EventEmitter, callback: (value: number) => void): {
stop(): void;
stop: () => void;
};

@@ -33,0 +33,0 @@ /**

@@ -35,4 +35,4 @@ import { LifeCycle } from '../../lifeCycle';

export declare function trackViews(location: Location, lifeCycle: LifeCycle): {
addTiming(name: string, inInitialView?: boolean): void;
stop(): void;
addTiming: (name: string, time?: number) => void;
stop: () => void;
};

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

return {
addTiming: function (name, inInitialView) {
if (inInitialView === void 0) { inInitialView = false; }
var view = inInitialView ? initialView : currentView;
view.addTiming(name);
view.triggerUpdate();
addTiming: function (name, time) {
if (time === void 0) { time = performance.now(); }
currentView.addTiming(name, time);
currentView.triggerUpdate();
},

@@ -155,4 +154,4 @@ stop: function () {

},
addTiming: function (name) {
customTimings[name] = performance.now() - startTime;
addTiming: function (name, time) {
customTimings[name] = time - startTime;
},

@@ -172,2 +171,3 @@ updateLocation: function (newLocation) {

function trackHistory(onHistoryChange) {
// eslint-disable-next-line @typescript-eslint/unbound-method
var originalPushState = history.pushState;

@@ -178,2 +178,3 @@ history.pushState = browser_core_1.monitor(function () {

});
// eslint-disable-next-line @typescript-eslint/unbound-method
var originalReplaceState = history.replaceState;

@@ -180,0 +181,0 @@ history.replaceState = browser_core_1.monitor(function () {

import { Configuration } from '@datadog/browser-core';
import { LifeCycle } from '../../lifeCycle';
export declare function startViewCollection(lifeCycle: LifeCycle, configuration: Configuration, location: Location): {
addTiming(name: string, inInitialView?: boolean): void;
stop(): void;
addTiming: (name: string, time?: number) => void;
stop: () => void;
};

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

_dd: {
documentVersion: view.documentVersion,
document_version: view.documentVersion,
},

@@ -26,18 +26,18 @@ date: browser_core_1.getTimestamp(view.startTime),

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

@@ -48,7 +48,7 @@ },

},
timeSpent: browser_core_1.msToNs(view.duration),
time_spent: browser_core_1.msToNs(view.duration),
},
};
if (!browser_core_1.isEmptyObject(view.customTimings)) {
viewEvent.view.customTimings = browser_core_1.mapValues(view.customTimings, browser_core_1.msToNs);
viewEvent.view.custom_timings = browser_core_1.mapValues(view.customTimings, browser_core_1.msToNs);
}

@@ -55,0 +55,0 @@ return {

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

// value is not an array or string (here, a NodeList).
// tslint:disable-next-line: prefer-for-of
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (var i = 0; i < document.childNodes.length; i += 1) {

@@ -70,3 +70,3 @@ var comment = getTraceCommentFromNode(document.childNodes[i]);

if (node && isCommentNode(node)) {
var match = node.data.match(/^\s*DATADOG;(.*?)\s*$/);
var match = /^\s*DATADOG;(.*?)\s*$/.exec(node.data);
if (match) {

@@ -73,0 +73,0 @@ return match[1];

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

}
/* tslint:disable:no-bitwise */
/* eslint-disable no-bitwise */
var TraceIdentifier = /** @class */ (function () {

@@ -129,3 +129,3 @@ function TraceIdentifier() {

exports.TraceIdentifier = TraceIdentifier;
/* tslint:enable:no-bitwise */
/* eslint-enable no-bitwise */
//# sourceMappingURL=tracer.js.map

@@ -9,3 +9,3 @@ import { LifeCycle } from './lifeCycle';

export declare function trackEventCounts(lifeCycle: LifeCycle, callback?: (eventCounts: EventCounts) => void): {
stop(): void;
stop: () => void;
eventCounts: {

@@ -12,0 +12,0 @@ errorCount: number;

@@ -10,10 +10,10 @@ import { Observable } from '@datadog/browser-core';

export declare function waitIdlePageActivity(lifeCycle: LifeCycle, completionCallback: (hadActivity: boolean, endTime: number) => void): {
stop(): void;
stop: () => void;
};
export declare function trackPageActivities(lifeCycle: LifeCycle): {
observable: Observable<PageActivityEvent>;
stop(): void;
stop: () => void;
};
export declare function waitPageActivitiesCompletion(pageActivitiesObservable: Observable<PageActivityEvent>, stopPageActivitiesTracking: () => void, completionCallback: (hadActivity: boolean, endTime: number) => void): {
stop(): void;
stop: () => void;
};

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

var stopWaitPageActivitiesCompletion = waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActivitiesTracking, completionCallback).stop;
function stop() {
var stop = function () {
stopWaitPageActivitiesCompletion();
stopPageActivitiesTracking();
}
};
return { stop: stop };

@@ -98,3 +98,3 @@ }

});
function stop() {
var stop = function () {
hasCompleted = true;

@@ -105,3 +105,3 @@ clearTimeout(validationTimeoutId);

stopPageActivitiesTracking();
}
};
function complete(hadActivity, endTime) {

@@ -108,0 +108,0 @@ if (hasCompleted) {

@@ -21,3 +21,3 @@ import { Context, ErrorSource, ResourceType } from '@datadog/browser-core';

method?: string;
statusCode?: number;
status_code?: number;
size?: number;

@@ -28,8 +28,8 @@ redirect?: PerformanceResourceDetailsElement;

ssl?: PerformanceResourceDetailsElement;
firstByte?: PerformanceResourceDetailsElement;
first_byte?: PerformanceResourceDetailsElement;
download?: PerformanceResourceDetailsElement;
};
_dd?: {
traceId: string;
spanId?: string;
trace_id: string;
span_id?: string;
};

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

url: string;
statusCode: number;
status_code: number;
method: string;

@@ -57,23 +57,23 @@ };

view: {
loadingType: ViewLoadingType;
firstContentfulPaint?: number;
firstInputDelay?: number;
firstInputTime?: number;
cumulativeLayoutShift?: number;
customTimings?: ViewCustomTimings;
largestContentfulPaint?: number;
domInteractive?: number;
domContentLoaded?: number;
domComplete?: number;
loadEvent?: number;
loadingTime?: number;
timeSpent: number;
isActive: boolean;
loading_type: ViewLoadingType;
first_contentful_paint?: number;
first_input_delay?: number;
first_input_time?: number;
cumulative_layout_shift?: number;
custom_timings?: ViewCustomTimings;
largest_contentful_paint?: number;
dom_interactive?: number;
dom_content_loaded?: number;
dom_complete?: number;
load_event?: number;
loading_time?: number;
time_spent: number;
is_active: boolean;
error: Count;
action: Count;
longTask: Count;
long_task: Count;
resource: Count;
};
_dd: {
documentVersion: number;
document_version: number;
};

@@ -87,3 +87,3 @@ }

type: RumEventType.LONG_TASK;
longTask: {
long_task: {
duration: number;

@@ -98,5 +98,5 @@ };

type: ActionType;
loadingTime?: number;
loading_time?: number;
error?: Count;
longTask?: Count;
long_task?: Count;
resource?: Count;

@@ -120,3 +120,3 @@ target: {

_dd: {
formatVersion: 2;
format_version: 2;
};

@@ -139,3 +139,2 @@ }

}
export declare type AssembledRumEvent = (RawRumErrorEvent & ActionContext & ViewContext & RumContext) | (RawRumResourceEvent & ActionContext & ViewContext & RumContext) | (RawRumViewEvent & ViewContext & RumContext) | (RawRumLongTaskEvent & ActionContext & ViewContext & RumContext) | (RawRumActionEvent & ViewContext & RumContext);
export interface InternalContext {

@@ -142,0 +141,0 @@ application_id: string;

"use strict";
/* tslint:disable */
/* eslint-disable */
/**

@@ -4,0 +4,0 @@ * DO NOT MODIFY IT BY HAND. Run `yarn rum-events-format:sync` instead.

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

var batch = makeRumBatch(configuration, lifeCycle);
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RUM_EVENT_COLLECTED, function (_a) {
var assembledRumEvent = _a.assembledRumEvent, serverRumEvent = _a.serverRumEvent;
if (assembledRumEvent.type === rawRumEvent_types_1.RumEventType.VIEW) {
batch.upsert(serverRumEvent, assembledRumEvent.view.id);
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
if (serverRumEvent.type === rawRumEvent_types_1.RumEventType.VIEW) {
batch.upsert(serverRumEvent, serverRumEvent.view.id);
}

@@ -14,0 +13,0 @@ else {

export var buildEnv = {
buildMode: 'release',
datacenter: 'us',
sdkVersion: '2.3.1',
sdkVersion: '2.4.0',
};
//# sourceMappingURL=buildEnv.js.map

@@ -9,3 +9,3 @@ import { Configuration } from '@datadog/browser-core';

addError: ({ error, startTime, context: customerContext, source }: import("../domain/rumEventsCollection/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
addTiming: (name: string, inInitialView?: boolean) => void;
addTiming: (name: string, time?: number) => void;
configuration: Configuration;

@@ -21,4 +21,4 @@ lifeCycle: LifeCycle;

parentContexts: import("../domain/parentContexts").ParentContexts;
addTiming: (name: string, inInitialView?: boolean) => void;
addTiming: (name: string, time?: number) => void;
stop(): void;
};

@@ -46,3 +46,3 @@ import { combine, commonInit } from '@datadog/browser-core';

startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getCommonContext);
startLongTaskCollection(lifeCycle, configuration);
startLongTaskCollection(lifeCycle);
startResourceCollection(lifeCycle, configuration, session);

@@ -49,0 +49,0 @@ var addTiming = startViewCollection(lifeCycle, configuration, location).addTiming;

@@ -21,7 +21,7 @@ import { Context, UserConfiguration } from '@datadog/browser-core';

/**
* @deprecated
* @see addAction
* @deprecated use addAction instead
*/
addUserAction: (name: string, context?: object | undefined) => void;
addError: (error: unknown, context?: object | undefined, source?: ProvidedSource) => void;
addTiming: (name: string) => void;
setUser: (newUser: User) => void;

@@ -28,0 +28,0 @@ } & {

@@ -7,4 +7,6 @@ import { BoundedBuffer, buildCookieOptions, checkCookiesAuthorized, checkIsNotLocalFile, createContextManager, deepClone, ErrorSource, isPercentage, makePublicApi, monitor, } from '@datadog/browser-core';

var user = {};
var getInternalContextStrategy = function () {
return undefined;
var getInternalContextStrategy = function () { return undefined; };
var beforeInitAddTiming = new BoundedBuffer();
var addTimingStrategy = function (name) {
beforeInitAddTiming.add([name, performance.now()]);
};

@@ -36,8 +38,7 @@ var beforeInitAddAction = new BoundedBuffer();

}
var configuration;
var addTiming;
;
(_a = startRumImpl(userConfiguration, function () { return ({
user: user,
context: globalContextManager.get(),
}); }), addTiming = _a.addTiming, configuration = _a.configuration, addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, getInternalContextStrategy = _a.getInternalContext);
}); }), addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, addTimingStrategy = _a.addTiming, getInternalContextStrategy = _a.getInternalContext);
beforeInitAddAction.drain(function (_a) {

@@ -51,6 +52,6 @@ var action = _a[0], commonContext = _a[1];

});
if (configuration.isEnabled('custom-timings')) {
;
rumGlobal.addTiming = addTiming;
}
beforeInitAddTiming.drain(function (_a) {
var name = _a[0], time = _a[1];
return addTimingStrategy(name, time);
});
isAlreadyInitialized = true;

@@ -62,5 +63,3 @@ }),

setRumGlobalContext: monitor(globalContextManager.set),
getInternalContext: monitor(function (startTime) {
return getInternalContextStrategy(startTime);
}),
getInternalContext: monitor(function (startTime) { return getInternalContextStrategy(startTime); }),
addAction: monitor(function (name, context) {

@@ -75,4 +74,3 @@ addActionStrategy({

/**
* @deprecated
* @see addAction
* @deprecated use addAction instead
*/

@@ -99,2 +97,5 @@ addUserAction: function (name, context) {

}),
addTiming: monitor(function (name) {
addTimingStrategy(name);
}),
setUser: monitor(function (newUser) {

@@ -101,0 +102,0 @@ var sanitizedUser = sanitizeUser(newUser);

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

if (browserWindow.Zone) {
// eslint-disable-next-line no-underscore-dangle
var symbol = browserWindow.Zone.__symbol__('MutationObserver');

@@ -20,0 +21,0 @@ constructor = browserWindow[symbol];

@@ -22,3 +22,5 @@ import { __assign } from "tslib";

if (window.PerformanceObserver) {
var observer = new PerformanceObserver(monitor(function (entries) { return handlePerformanceEntries(lifeCycle, configuration, entries.getEntries()); }));
var observer = new PerformanceObserver(monitor(function (entries) {
return handlePerformanceEntries(lifeCycle, configuration, entries.getEntries());
}));
var entryTypes = [

@@ -25,0 +27,0 @@ 'resource',

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

import { combine, isEmptyObject, limitModification, withSnakeCaseKeys, } from '@datadog/browser-core';
import { combine, isEmptyObject, limitModification } from '@datadog/browser-core';
import { RumEventType, } from '../rawRumEvent.types';

@@ -27,3 +27,3 @@ import { LifeCycleEventType } from './lifeCycle';

_dd: {
formatVersion: 2,
format_version: 2,
},

@@ -42,6 +42,5 @@ application: {

};
var assembledRumEvent = needToAssembleWithAction(rawRumEvent)
var serverRumEvent = (needToAssembleWithAction(rawRumEvent)
? combine(rumContext, viewContext, actionContext, rawRumEvent)
: combine(rumContext, viewContext, rawRumEvent);
var serverRumEvent = withSnakeCaseKeys(assembledRumEvent);
: combine(rumContext, viewContext, rawRumEvent));
var context = combine(commonContext.context, customerContext);

@@ -52,2 +51,3 @@ if (!isEmptyObject(context)) {

if (!isEmptyObject(commonContext.user)) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
;

@@ -59,3 +59,3 @@ serverRumEvent.usr = commonContext.user;

}
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, { assembledRumEvent: assembledRumEvent, serverRumEvent: serverRumEvent });
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
}

@@ -68,4 +68,5 @@ });

function getSessionType() {
// eslint-disable-next-line no-underscore-dangle
return window._DATADOG_SYNTHETICS_BROWSER === undefined ? SessionType.USER : SessionType.SYNTHETICS;
}
//# sourceMappingURL=assembly.js.map

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

import { combine, withSnakeCaseKeys } from '@datadog/browser-core';
/**

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

var actionContext = parentContexts.findAction(startTime);
return withSnakeCaseKeys(combine({ applicationId: applicationId }, { sessionId: viewContext.session.id, view: viewContext.view }, actionContext ? { userAction: { id: actionContext.action.id } } : undefined));
return {
application_id: applicationId,
session_id: viewContext.session.id,
user_action: actionContext
? {
id: actionContext.action.id,
}
: undefined,
view: viewContext.view,
};
}

@@ -15,0 +23,0 @@ },

import { Context } from '@datadog/browser-core';
import { RumPerformanceEntry } from '../browser/performanceCollection';
import { AssembledRumEvent, CommonContext, RawRumEvent } from '../rawRumEvent.types';
import { CommonContext, RawRumEvent } from '../rawRumEvent.types';
import { RumEvent } from '../rumEvent.types';

@@ -24,3 +24,3 @@ import { RequestCompleteEvent, RequestStartEvent } from './requestCollection';

export interface Subscription {
unsubscribe(): void;
unsubscribe: () => void;
}

@@ -43,6 +43,3 @@ export declare class LifeCycle {

}): void;
notify(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, data: {
assembledRumEvent: AssembledRumEvent;
serverRumEvent: RumEvent & Context;
}): void;
notify(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, data: RumEvent & Context): void;
subscribe(eventType: LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, callback: (data: RumPerformanceEntry) => void): Subscription;

@@ -62,6 +59,3 @@ subscribe(eventType: LifeCycleEventType.REQUEST_STARTED, callback: (data: RequestStartEvent) => void): Subscription;

}) => void): Subscription;
subscribe(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, callback: (data: {
assembledRumEvent: AssembledRumEvent;
serverRumEvent: RumEvent & Context;
}) => void): Subscription;
subscribe(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, callback: (data: RumEvent & Context) => void): Subscription;
}

@@ -96,8 +96,4 @@ import { monitor, ONE_MINUTE, SESSION_TIME_OUT_DELAY } from '@datadog/browser-core';

return {
findAction: function (startTime) {
return findContext(buildCurrentActionContext, previousActions, currentAction, startTime);
},
findView: function (startTime) {
return findContext(buildCurrentViewContext, previousViews, currentView, startTime);
},
findAction: function (startTime) { return findContext(buildCurrentActionContext, previousActions, currentAction, startTime); },
findView: function (startTime) { return findContext(buildCurrentViewContext, previousViews, currentView, startTime); },
stop: function () {

@@ -104,0 +100,0 @@ window.clearInterval(clearOldContextsInterval);

@@ -6,3 +6,3 @@ import { Configuration } from '@datadog/browser-core';

export declare function startActionCollection(lifeCycle: LifeCycle, configuration: Configuration): {
addAction(action: CustomAction, savedCommonContext?: CommonContext | undefined): void;
addAction: (action: CustomAction, savedCommonContext?: CommonContext | undefined) => void;
};

@@ -27,4 +27,4 @@ import { __assign } from "tslib";

id: action.id,
loadingTime: msToNs(action.duration),
longTask: {
loading_time: msToNs(action.duration),
long_task: {
count: action.counts.longTaskCount,

@@ -31,0 +31,0 @@ },

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

];
var fallbackStrategies = [
function (element) {
return getTextualContent(element);
},
];
var fallbackStrategies = [function (element) { return getTextualContent(element); }];
/**

@@ -145,3 +141,2 @@ * Iterates over the target element and its parent, using the strategies list to get an action name.

// document.getElementById won't work.
// tslint:disable-next-line: no-null-keyword
return refElement.ownerDocument ? refElement.ownerDocument.getElementById(id) : null;

@@ -159,3 +154,3 @@ }

var elementsTextToRemove = element.querySelectorAll('script, style');
// tslint:disable-next-line: prefer-for-of
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (var i = 0; i < elementsTextToRemove.length; i += 1) {

@@ -162,0 +157,0 @@ var innerText = elementsTextToRemove[i].innerText;

@@ -12,6 +12,6 @@ import { Configuration, Context, Observable, RawError } from '@datadog/browser-core';

export declare function startErrorCollection(lifeCycle: LifeCycle, configuration: Configuration): {
addError({ error, startTime, context: customerContext, source }: ProvidedError, savedCommonContext?: CommonContext | undefined): void;
addError: ({ error, startTime, context: customerContext, source }: ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
};
export declare function doStartErrorCollection(lifeCycle: LifeCycle, configuration: Configuration, observable: Observable<RawError>): {
addError({ error, startTime, context: customerContext, source }: ProvidedError, savedCommonContext?: CommonContext | undefined): void;
addError: ({ error, startTime, context: customerContext, source }: ProvidedError, savedCommonContext?: CommonContext | undefined) => void;
};

@@ -28,3 +28,9 @@ import { __assign } from "tslib";

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

@@ -31,0 +37,0 @@ stack: error.stack,

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

import { Configuration } from '@datadog/browser-core';
import { LifeCycle } from '../../lifeCycle';
export declare function startLongTaskCollection(lifeCycle: LifeCycle, configuration: Configuration): void;
export declare function startLongTaskCollection(lifeCycle: LifeCycle): void;
import { getTimestamp, msToNs } from '@datadog/browser-core';
import { RumEventType } from '../../../rawRumEvent.types';
import { LifeCycleEventType } from '../../lifeCycle';
export function startLongTaskCollection(lifeCycle, configuration) {
export function startLongTaskCollection(lifeCycle) {
lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entry) {

@@ -11,3 +11,3 @@ if (entry.entryType !== 'longtask') {

date: getTimestamp(entry.startTime),
longTask: {
long_task: {
duration: msToNs(entry.duration),

@@ -14,0 +14,0 @@ },

@@ -31,3 +31,3 @@ import { __assign } from "tslib";

method: request.method,
statusCode: request.status,
status_code: request.status,
url: request.url,

@@ -65,4 +65,4 @@ },

_dd: {
spanId: request.spanId.toDecimalString(),
traceId: request.traceId.toDecimalString(),
span_id: request.spanId.toDecimalString(),
trace_id: request.traceId.toDecimalString(),
},

@@ -73,4 +73,4 @@ resource: { id: generateUUID() },

function computeEntryTracingInfo(entry) {
return entry.traceId ? { _dd: { traceId: entry.traceId } } : undefined;
return entry.traceId ? { _dd: { trace_id: entry.traceId } } : undefined;
}
//# sourceMappingURL=resourceCollection.js.map

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

ssl?: PerformanceResourceDetailsElement;
firstByte: PerformanceResourceDetailsElement;
first_byte: PerformanceResourceDetailsElement;
download: PerformanceResourceDetailsElement;

@@ -15,0 +15,0 @@ }

@@ -9,15 +9,15 @@ import { __assign } from "tslib";

[ResourceType.BEACON, function (initiatorType) { return 'beacon' === initiatorType; }],
[ResourceType.CSS, function (_, path) { return path.match(/\.css$/i) !== null; }],
[ResourceType.JS, function (_, path) { return path.match(/\.js$/i) !== null; }],
[ResourceType.CSS, function (_, path) { return /\.css$/i.test(path); }],
[ResourceType.JS, function (_, path) { return /\.js$/i.test(path); }],
[
ResourceType.IMAGE,
function (initiatorType, path) {
return includes(['image', 'img', 'icon'], initiatorType) || path.match(/\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i) !== null;
return includes(['image', 'img', 'icon'], initiatorType) || /\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i.exec(path) !== null;
},
],
[ResourceType.FONT, function (_, path) { return path.match(/\.(woff|eot|woff2|ttf)$/i) !== null; }],
[ResourceType.FONT, function (_, path) { return /\.(woff|eot|woff2|ttf)$/i.exec(path) !== null; }],
[
ResourceType.MEDIA,
function (initiatorType, path) {
return includes(['audio', 'video'], initiatorType) || path.match(/\.(mp3|mp4)$/i) !== null;
return includes(['audio', 'video'], initiatorType) || /\.(mp3|mp4)$/i.exec(path) !== null;
},

@@ -72,3 +72,3 @@ ],

download: formatTiming(startTime, responseStart, responseEnd),
firstByte: formatTiming(startTime, requestStart, responseStart),
first_byte: formatTiming(startTime, requestStart, responseStart),
};

@@ -75,0 +75,0 @@ // Make sure a connection occurred

@@ -14,3 +14,3 @@ import { EventEmitter } from '@datadog/browser-core';

export declare function trackTimings(lifeCycle: LifeCycle, callback: (timings: Timings) => void): {
stop(): void;
stop: () => void;
};

@@ -30,3 +30,3 @@ export declare function trackNavigationTimings(lifeCycle: LifeCycle, callback: (newTimings: Partial<Timings>) => void): {

export declare function trackLargestContentfulPaint(lifeCycle: LifeCycle, emitter: EventEmitter, callback: (value: number) => void): {
stop(): void;
stop: () => void;
};

@@ -33,0 +33,0 @@ /**

@@ -35,4 +35,4 @@ import { LifeCycle } from '../../lifeCycle';

export declare function trackViews(location: Location, lifeCycle: LifeCycle): {
addTiming(name: string, inInitialView?: boolean): void;
stop(): void;
addTiming: (name: string, time?: number) => void;
stop: () => void;
};
import { __assign } from "tslib";
import { addEventListener, DOM_EVENT, generateUUID, monitor, noop, ONE_MINUTE, throttle, } from '@datadog/browser-core';
import { addEventListener, DOM_EVENT, generateUUID, monitor, noop, ONE_MINUTE, throttle } from '@datadog/browser-core';
import { supportPerformanceTimingEvent } from '../../../browser/performanceCollection';

@@ -53,7 +53,6 @@ import { LifeCycleEventType } from '../../lifeCycle';

return {
addTiming: function (name, inInitialView) {
if (inInitialView === void 0) { inInitialView = false; }
var view = inInitialView ? initialView : currentView;
view.addTiming(name);
view.triggerUpdate();
addTiming: function (name, time) {
if (time === void 0) { time = performance.now(); }
currentView.addTiming(name, time);
currentView.triggerUpdate();
},

@@ -152,4 +151,4 @@ stop: function () {

},
addTiming: function (name) {
customTimings[name] = performance.now() - startTime;
addTiming: function (name, time) {
customTimings[name] = time - startTime;
},

@@ -169,2 +168,3 @@ updateLocation: function (newLocation) {

function trackHistory(onHistoryChange) {
// eslint-disable-next-line @typescript-eslint/unbound-method
var originalPushState = history.pushState;

@@ -175,2 +175,3 @@ history.pushState = monitor(function () {

});
// eslint-disable-next-line @typescript-eslint/unbound-method
var originalReplaceState = history.replaceState;

@@ -177,0 +178,0 @@ history.replaceState = monitor(function () {

import { Configuration } from '@datadog/browser-core';
import { LifeCycle } from '../../lifeCycle';
export declare function startViewCollection(lifeCycle: LifeCycle, configuration: Configuration, location: Location): {
addTiming(name: string, inInitialView?: boolean): void;
stop(): void;
addTiming: (name: string, time?: number) => void;
stop: () => void;
};

@@ -14,3 +14,3 @@ import { getTimestamp, isEmptyObject, mapValues, msToNs } from '@datadog/browser-core';

_dd: {
documentVersion: view.documentVersion,
document_version: view.documentVersion,
},

@@ -23,18 +23,18 @@ date: getTimestamp(view.startTime),

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

@@ -45,7 +45,7 @@ },

},
timeSpent: msToNs(view.duration),
time_spent: msToNs(view.duration),
},
};
if (!isEmptyObject(view.customTimings)) {
viewEvent.view.customTimings = mapValues(view.customTimings, msToNs);
viewEvent.view.custom_timings = mapValues(view.customTimings, msToNs);
}

@@ -52,0 +52,0 @@ return {

@@ -36,3 +36,3 @@ import { findCommaSeparatedValue, ONE_MINUTE } from '@datadog/browser-core';

// value is not an array or string (here, a NodeList).
// tslint:disable-next-line: prefer-for-of
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (var i = 0; i < document.childNodes.length; i += 1) {

@@ -63,3 +63,3 @@ var comment = getTraceCommentFromNode(document.childNodes[i]);

if (node && isCommentNode(node)) {
var match = node.data.match(/^\s*DATADOG;(.*?)\s*$/);
var match = /^\s*DATADOG;(.*?)\s*$/.exec(node.data);
if (match) {

@@ -66,0 +66,0 @@ return match[1];

@@ -86,3 +86,3 @@ import { __assign } from "tslib";

}
/* tslint:disable:no-bitwise */
/* eslint-disable no-bitwise */
var TraceIdentifier = /** @class */ (function () {

@@ -124,3 +124,3 @@ function TraceIdentifier() {

export { TraceIdentifier };
/* tslint:enable:no-bitwise */
/* eslint-enable no-bitwise */
//# sourceMappingURL=tracer.js.map

@@ -9,3 +9,3 @@ import { LifeCycle } from './lifeCycle';

export declare function trackEventCounts(lifeCycle: LifeCycle, callback?: (eventCounts: EventCounts) => void): {
stop(): void;
stop: () => void;
eventCounts: {

@@ -12,0 +12,0 @@ errorCount: number;

@@ -10,10 +10,10 @@ import { Observable } from '@datadog/browser-core';

export declare function waitIdlePageActivity(lifeCycle: LifeCycle, completionCallback: (hadActivity: boolean, endTime: number) => void): {
stop(): void;
stop: () => void;
};
export declare function trackPageActivities(lifeCycle: LifeCycle): {
observable: Observable<PageActivityEvent>;
stop(): void;
stop: () => void;
};
export declare function waitPageActivitiesCompletion(pageActivitiesObservable: Observable<PageActivityEvent>, stopPageActivitiesTracking: () => void, completionCallback: (hadActivity: boolean, endTime: number) => void): {
stop(): void;
stop: () => void;
};

@@ -12,6 +12,6 @@ import { monitor, Observable } from '@datadog/browser-core';

var stopWaitPageActivitiesCompletion = waitPageActivitiesCompletion(pageActivitiesObservable, stopPageActivitiesTracking, completionCallback).stop;
function stop() {
var stop = function () {
stopWaitPageActivitiesCompletion();
stopPageActivitiesTracking();
}
};
return { stop: stop };

@@ -94,3 +94,3 @@ }

});
function stop() {
var stop = function () {
hasCompleted = true;

@@ -101,3 +101,3 @@ clearTimeout(validationTimeoutId);

stopPageActivitiesTracking();
}
};
function complete(hadActivity, endTime) {

@@ -104,0 +104,0 @@ if (hasCompleted) {

@@ -21,3 +21,3 @@ import { Context, ErrorSource, ResourceType } from '@datadog/browser-core';

method?: string;
statusCode?: number;
status_code?: number;
size?: number;

@@ -28,8 +28,8 @@ redirect?: PerformanceResourceDetailsElement;

ssl?: PerformanceResourceDetailsElement;
firstByte?: PerformanceResourceDetailsElement;
first_byte?: PerformanceResourceDetailsElement;
download?: PerformanceResourceDetailsElement;
};
_dd?: {
traceId: string;
spanId?: string;
trace_id: string;
span_id?: string;
};

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

url: string;
statusCode: number;
status_code: number;
method: string;

@@ -57,23 +57,23 @@ };

view: {
loadingType: ViewLoadingType;
firstContentfulPaint?: number;
firstInputDelay?: number;
firstInputTime?: number;
cumulativeLayoutShift?: number;
customTimings?: ViewCustomTimings;
largestContentfulPaint?: number;
domInteractive?: number;
domContentLoaded?: number;
domComplete?: number;
loadEvent?: number;
loadingTime?: number;
timeSpent: number;
isActive: boolean;
loading_type: ViewLoadingType;
first_contentful_paint?: number;
first_input_delay?: number;
first_input_time?: number;
cumulative_layout_shift?: number;
custom_timings?: ViewCustomTimings;
largest_contentful_paint?: number;
dom_interactive?: number;
dom_content_loaded?: number;
dom_complete?: number;
load_event?: number;
loading_time?: number;
time_spent: number;
is_active: boolean;
error: Count;
action: Count;
longTask: Count;
long_task: Count;
resource: Count;
};
_dd: {
documentVersion: number;
document_version: number;
};

@@ -87,3 +87,3 @@ }

type: RumEventType.LONG_TASK;
longTask: {
long_task: {
duration: number;

@@ -98,5 +98,5 @@ };

type: ActionType;
loadingTime?: number;
loading_time?: number;
error?: Count;
longTask?: Count;
long_task?: Count;
resource?: Count;

@@ -120,3 +120,3 @@ target: {

_dd: {
formatVersion: 2;
format_version: 2;
};

@@ -139,3 +139,2 @@ }

}
export declare type AssembledRumEvent = (RawRumErrorEvent & ActionContext & ViewContext & RumContext) | (RawRumResourceEvent & ActionContext & ViewContext & RumContext) | (RawRumViewEvent & ViewContext & RumContext) | (RawRumLongTaskEvent & ActionContext & ViewContext & RumContext) | (RawRumActionEvent & ViewContext & RumContext);
export interface InternalContext {

@@ -142,0 +141,0 @@ application_id: string;

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

/* tslint:disable */
/* eslint-disable */
/**

@@ -3,0 +3,0 @@ * DO NOT MODIFY IT BY HAND. Run `yarn rum-events-format:sync` instead.

@@ -6,6 +6,5 @@ import { Batch, combine, HttpRequest } from '@datadog/browser-core';

var batch = makeRumBatch(configuration, lifeCycle);
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, function (_a) {
var assembledRumEvent = _a.assembledRumEvent, serverRumEvent = _a.serverRumEvent;
if (assembledRumEvent.type === RumEventType.VIEW) {
batch.upsert(serverRumEvent, assembledRumEvent.view.id);
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
if (serverRumEvent.type === RumEventType.VIEW) {
batch.upsert(serverRumEvent, serverRumEvent.view.id);
}

@@ -12,0 +11,0 @@ else {

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

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

"dependencies": {
"@datadog/browser-core": "2.3.1",
"@datadog/browser-core": "2.4.0",
"tslib": "^1.10.0"

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

},
"gitHead": "0945f79292357d1db56e96a88be7736cc4a83e6d"
"gitHead": "844d5bf3ed057c99bc381903430226ed4ddb7ac5"
}

@@ -12,3 +12,3 @@ import { isIE } from '@datadog/browser-core'

const serverRumEvents: RumEvent[] = []
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, ({ serverRumEvent }) => {
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, (serverRumEvent) => {
serverRumEvents.push(serverRumEvent)

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

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

import { combine, commonInit, Configuration, Context } from '@datadog/browser-core'
import { combine, commonInit, Configuration } from '@datadog/browser-core'
import { startDOMMutationCollection } from '../browser/domMutationCollection'

@@ -27,4 +27,4 @@ import { startPerformanceCollection } from '../browser/performanceCollection'

internalMonitoring.setExternalContextProvider(() => {
return combine(
internalMonitoring.setExternalContextProvider(() =>
combine(
{

@@ -36,3 +36,3 @@ application_id: userConfiguration.applicationId,

)
})
)

@@ -77,3 +77,3 @@ const { parentContexts, addError, addAction, addTiming } = startRumEventCollection(

startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getCommonContext)
startLongTaskCollection(lifeCycle, configuration)
startLongTaskCollection(lifeCycle)
startResourceCollection(lifeCycle, configuration, session)

@@ -80,0 +80,0 @@ const { addTiming } = startViewCollection(lifeCycle, configuration, location)

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

import { Configuration, ErrorSource, ONE_SECOND } from '@datadog/browser-core'
import { ErrorSource, ONE_SECOND } from '@datadog/browser-core'
import { setup, TestSetupBuilder } from '../../test/specHelper'

@@ -6,5 +6,2 @@ import { ActionType } from '../domain/rumEventsCollection/action/trackActions'

const configuration: Partial<Configuration> = {
isEnabled: () => false,
}
const noopStartRum = (): ReturnType<StartRum> => ({

@@ -14,3 +11,3 @@ addAction: () => undefined,

addTiming: () => undefined,
configuration: configuration as Configuration,
configuration: {} as any,
getInternalContext: () => undefined,

@@ -375,3 +372,2 @@ lifeCycle: {} as any,

it('should sanitize predefined properties', () => {
// tslint:disable-next-line:no-null-keyword
const user = { id: null, name: 2, email: { bar: 'qux' } }

@@ -393,3 +389,2 @@ publicApi.setUser(user as any)

publicApi.setUser(2 as any)
// tslint:disable-next-line:no-null-keyword
publicApi.setUser(null as any)

@@ -404,3 +399,3 @@ publicApi.setUser(undefined as any)

let errorSpy: jasmine.Spy<() => void>
let rumGlobal: RumPublicApi
let publicApi: RumPublicApi
let setupBuilder: TestSetupBuilder

@@ -411,9 +406,5 @@

errorSpy = spyOn(console, 'error')
const otherConfiguration: Partial<Configuration> = {
isEnabled: () => true,
}
rumGlobal = makeRumPublicApi(() => ({
publicApi = makeRumPublicApi(() => ({
...noopStartRum(),
addTiming: addTimingSpy,
configuration: otherConfiguration as Configuration,
}))

@@ -427,7 +418,24 @@ setupBuilder = setup()

it('should allow to add custom timing before init', () => {
const { clock } = setupBuilder.withFakeClock().build()
clock.tick(10)
publicApi.addTiming('foo')
expect(addTimingSpy).not.toHaveBeenCalled()
clock.tick(20)
publicApi.init(DEFAULT_INIT_CONFIGURATION)
expect(addTimingSpy.calls.argsFor(0)[0]).toEqual('foo')
expect(addTimingSpy.calls.argsFor(0)[1]).toEqual(10)
})
it('should add custom timings', () => {
rumGlobal.init(DEFAULT_INIT_CONFIGURATION)
// tslint:disable-next-line: no-unsafe-any
;(rumGlobal as any).addTiming('foo')
publicApi.init(DEFAULT_INIT_CONFIGURATION)
publicApi.addTiming('foo')
expect(addTimingSpy.calls.argsFor(0)[0]).toEqual('foo')
expect(addTimingSpy.calls.argsFor(0)[1]).toBeUndefined()
expect(errorSpy).not.toHaveBeenCalled()

@@ -434,0 +442,0 @@ })

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

checkIsNotLocalFile,
Configuration,
Context,

@@ -38,4 +37,7 @@ createContextManager,

let getInternalContextStrategy: ReturnType<StartRum>['getInternalContext'] = () => {
return undefined
let getInternalContextStrategy: ReturnType<StartRum>['getInternalContext'] = () => undefined
const beforeInitAddTiming = new BoundedBuffer<[string, number]>()
let addTimingStrategy: ReturnType<StartRum>['addTiming'] = (name) => {
beforeInitAddTiming.add([name, performance.now()])
}

@@ -73,9 +75,6 @@

let configuration: Configuration
let addTiming: ReturnType<StartRum>['addTiming']
;({
addTiming,
configuration,
addAction: addActionStrategy,
addError: addErrorStrategy,
addTiming: addTimingStrategy,
getInternalContext: getInternalContextStrategy,

@@ -88,7 +87,4 @@ } = startRumImpl(userConfiguration, () => ({

beforeInitAddError.drain(([error, commonContext]) => addErrorStrategy(error, commonContext))
beforeInitAddTiming.drain(([name, time]) => addTimingStrategy(name, time))
if (configuration.isEnabled('custom-timings')) {
;(rumGlobal as any).addTiming = addTiming
}
isAlreadyInitialized = true

@@ -104,5 +100,3 @@ }),

getInternalContext: monitor((startTime?: number) => {
return getInternalContextStrategy(startTime)
}),
getInternalContext: monitor((startTime?: number) => getInternalContextStrategy(startTime)),

@@ -119,4 +113,3 @@ addAction: monitor((name: string, context?: object) => {

/**
* @deprecated
* @see addAction
* @deprecated use addAction instead
*/

@@ -132,3 +125,3 @@ addUserAction: (name: string, context?: object) => {

} else {
console.error(`DD_RUM.addError: Invalid source '${source}'`)
console.error(`DD_RUM.addError: Invalid source '${source as string}'`)
checkedSource = ErrorSource.CUSTOM

@@ -144,2 +137,6 @@ }

addTiming: monitor((name: string) => {
addTimingStrategy(name)
}),
setUser: monitor((newUser: User) => {

@@ -146,0 +143,0 @@ const sanitizedUser = sanitizeUser(newUser)

@@ -98,3 +98,2 @@ import { isIE } from '@datadog/browser-core'

(root) => {
// tslint:disable-next-line: no-null-keyword
root.insertBefore(root.childNodes[0], null)

@@ -101,0 +100,0 @@ },

@@ -29,2 +29,3 @@ import { monitor } from '@datadog/browser-core'

if (browserWindow.Zone) {
// eslint-disable-next-line no-underscore-dangle
const symbol = browserWindow.Zone.__symbol__('MutationObserver')

@@ -31,0 +32,0 @@ constructor = browserWindow[symbol as any] as any

@@ -108,3 +108,5 @@ import {

const observer = new PerformanceObserver(
monitor((entries) => handlePerformanceEntries(lifeCycle, configuration, entries.getEntries()))
monitor((entries: PerformanceObserverEntryList) =>
handlePerformanceEntries(lifeCycle, configuration, entries.getEntries())
)
)

@@ -111,0 +113,0 @@ const entryTypes = [

@@ -5,3 +5,3 @@ import { DEFAULT_CONFIGURATION, noop } from '@datadog/browser-core'

import { CommonContext, RumEventType } from '../rawRumEvent.types'
import { RumActionEvent, RumEvent, RumLongTaskEvent } from '../rumEvent.types'
import { RumActionEvent, RumEvent } from '../rumEvent.types'
import { startRumAssembly } from './assembly'

@@ -60,3 +60,3 @@ import { LifeCycle, LifeCycleEventType } from './lifeCycle'

serverRumEvents = []
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, ({ serverRumEvent }) =>
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, (serverRumEvent) =>
serverRumEvents.push(serverRumEvent)

@@ -71,11 +71,2 @@ )

describe('events', () => {
it('should have snake cased attributes', () => {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {
rawRumEvent: createRawRumEvent(RumEventType.LONG_TASK, { longTask: { duration: 2 } }),
startTime: 0,
})
expect((serverRumEvents[0] as RumLongTaskEvent).long_task.duration).toBe(2)
})
it('should allow modification on sensitive field', () => {

@@ -117,11 +108,2 @@ beforeSend = (event: RumEvent) => (event.view.url = 'modified')

it('should be snake cased', () => {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW, undefined),
startTime: 0,
})
expect(serverRumEvents[0]._dd.format_version).toBe(2)
})
it('should be overwritten by event attributes', () => {

@@ -174,12 +156,2 @@ lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {

it('should not be automatically snake cased', () => {
commonContext.context = { fooBar: 'foo' }
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
startTime: 0,
})
expect((serverRumEvents[0].context as any).fooBar).toEqual('foo')
})
it('should ignore the current global context when a saved global context is provided', () => {

@@ -223,12 +195,2 @@ commonContext.context = { replacedContext: 'b', addedContext: 'x' }

it('should not be automatically snake cased', () => {
commonContext.user = { fooBar: 'foo' }
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
startTime: 0,
})
expect(serverRumEvents[0].usr!.fooBar).toEqual('foo')
})
it('should ignore the current user when a saved common context user is provided', () => {

@@ -261,12 +223,2 @@ commonContext.user = { replacedAttribute: 'b', addedAttribute: 'x' }

})
it('should not be automatically snake cased', () => {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {
customerContext: { fooBar: 'foo' },
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
startTime: 0,
})
expect((serverRumEvents[0].context as any).fooBar).toEqual('foo')
})
})

@@ -273,0 +225,0 @@

@@ -0,10 +1,3 @@

import { combine, Configuration, Context, isEmptyObject, limitModification } from '@datadog/browser-core'
import {
combine,
Configuration,
Context,
isEmptyObject,
limitModification,
withSnakeCaseKeys,
} from '@datadog/browser-core'
import {
CommonContext,

@@ -60,3 +53,3 @@ RawRumErrorEvent,

_dd: {
formatVersion: 2,
format_version: 2,
},

@@ -75,6 +68,5 @@ application: {

}
const assembledRumEvent = needToAssembleWithAction(rawRumEvent)
const serverRumEvent = (needToAssembleWithAction(rawRumEvent)
? combine(rumContext, viewContext, actionContext, rawRumEvent)
: combine(rumContext, viewContext, rawRumEvent)
const serverRumEvent = withSnakeCaseKeys(assembledRumEvent) as RumEvent & Context
: combine(rumContext, viewContext, rawRumEvent)) as RumEvent & Context

@@ -87,2 +79,3 @@ const context = combine(commonContext.context, customerContext)

if (!isEmptyObject(commonContext.user)) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
;(serverRumEvent.usr as RumEvent['usr']) = commonContext.user as User & Context

@@ -94,3 +87,3 @@ }

}
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, { assembledRumEvent, serverRumEvent })
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent)
}

@@ -108,3 +101,4 @@ }

function getSessionType() {
// eslint-disable-next-line no-underscore-dangle
return (window as BrowserWindow)._DATADOG_SYNTHETICS_BROWSER === undefined ? SessionType.USER : SessionType.SYNTHETICS
}

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

import { combine, withSnakeCaseKeys } from '@datadog/browser-core'
import { InternalContext } from '../rawRumEvent.types'

@@ -12,13 +11,16 @@ import { ParentContexts } from './parentContexts'

return {
get: (startTime?: number) => {
get: (startTime?: number): InternalContext | undefined => {
const viewContext = parentContexts.findView(startTime)
if (session.isTracked() && viewContext && viewContext.session.id) {
const actionContext = parentContexts.findAction(startTime)
return (withSnakeCaseKeys(
combine(
{ applicationId },
{ sessionId: viewContext.session.id, view: viewContext.view },
actionContext ? { userAction: { id: actionContext.action.id } } : undefined
)
) as unknown) as InternalContext
return {
application_id: applicationId,
session_id: viewContext.session.id,
user_action: actionContext
? {
id: actionContext.action.id,
}
: undefined,
view: viewContext.view,
}
}

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

import { Context } from '@datadog/browser-core'
import { RumPerformanceEntry } from '../browser/performanceCollection'
import { AssembledRumEvent, CommonContext, RawRumEvent } from '../rawRumEvent.types'
import { CommonContext, RawRumEvent } from '../rawRumEvent.types'
import { RumEvent } from '../rumEvent.types'

@@ -26,3 +26,3 @@ import { RequestCompleteEvent, RequestStartEvent } from './requestCollection'

export interface Subscription {
unsubscribe(): void
unsubscribe: () => void
}

@@ -56,6 +56,3 @@

): void
notify(
eventType: LifeCycleEventType.RUM_EVENT_COLLECTED,
data: { assembledRumEvent: AssembledRumEvent; serverRumEvent: RumEvent & Context }
): void
notify(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, data: RumEvent & Context): void
notify(eventType: LifeCycleEventType, data?: any) {

@@ -103,3 +100,3 @@ const eventCallbacks = this.callbacks[eventType]

eventType: LifeCycleEventType.RUM_EVENT_COLLECTED,
callback: (data: { assembledRumEvent: AssembledRumEvent; serverRumEvent: RumEvent & Context }) => void
callback: (data: RumEvent & Context) => void
): Subscription

@@ -106,0 +103,0 @@ subscribe(eventType: LifeCycleEventType, callback: (data?: any) => void) {

@@ -134,8 +134,4 @@ import { monitor, ONE_MINUTE, SESSION_TIME_OUT_DELAY } from '@datadog/browser-core'

return {
findAction: (startTime) => {
return findContext(buildCurrentActionContext, previousActions, currentAction, startTime)
},
findView: (startTime) => {
return findContext(buildCurrentViewContext, previousViews, currentView, startTime)
},
findAction: (startTime) => findContext(buildCurrentActionContext, previousActions, currentAction, startTime),
findView: (startTime) => findContext(buildCurrentViewContext, previousViews, currentView, startTime),
stop: () => {

@@ -142,0 +138,0 @@ window.clearInterval(clearOldContextsInterval)

import {
Configuration,
DEFAULT_CONFIGURATION,
FetchProxy,
FetchStub,

@@ -30,3 +29,2 @@ FetchStubManager,

let fetchStubManager: FetchStubManager
let fetchProxy: FetchProxy
let startSpy: jasmine.Spy<(requestStartEvent: RequestStartEvent) => void>

@@ -50,7 +48,7 @@ let completeSpy: jasmine.Spy<(requestCompleteEvent: RequestCompleteEvent) => void>

}
fetchProxy = trackFetch(lifeCycle, configuration as Configuration, tracerStub as Tracer)
trackFetch(lifeCycle, configuration as Configuration, tracerStub as Tracer)
fetchStub = window.fetch as FetchStub
window.onunhandledrejection = (ev: PromiseRejectionEvent) => {
throw new Error(`unhandled rejected promise \n ${ev.reason}`)
throw new Error(`unhandled rejected promise \n ${ev.reason as string}`)
}

@@ -62,3 +60,2 @@ })

resetFetchProxy()
// tslint:disable-next-line:no-null-keyword
window.onunhandledrejection = null

@@ -65,0 +62,0 @@ })

@@ -46,4 +46,4 @@ import { setup, TestSetupBuilder } from '../../../../test/specHelper'

id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
loadingTime: 100 * 1e6,
longTask: {
loading_time: 100 * 1e6,
long_task: {
count: 10,

@@ -50,0 +50,0 @@ },

import { combine, Configuration, getTimestamp, msToNs } from '@datadog/browser-core'
import { CommonContext, RawRumActionEvent, RumEventType } from '../../../rawRumEvent.types'
import { CommonContext, RumEventType } from '../../../rawRumEvent.types'
import { LifeCycle, LifeCycleEventType } from '../../lifeCycle'

@@ -16,3 +16,3 @@ import { ActionType, AutoAction, CustomAction, trackActions } from './trackActions'

return {
addAction(action: CustomAction, savedCommonContext?: CommonContext) {
addAction: (action: CustomAction, savedCommonContext?: CommonContext) => {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {

@@ -34,4 +34,4 @@ savedCommonContext,

id: action.id,
loadingTime: msToNs(action.duration),
longTask: {
loading_time: msToNs(action.duration),
long_task: {
count: action.counts.longTaskCount,

@@ -46,3 +46,3 @@ },

const customerContext = !isAutoAction(action) ? action.context : undefined
const actionEvent: RawRumActionEvent = combine(
const actionEvent = combine(
{

@@ -49,0 +49,0 @@ action: {

@@ -61,7 +61,7 @@ import { getActionNameFromElement } from './getActionNameFromElement'

getActionNameFromElement(
// tslint:disable-next-line max-line-length
// eslint-disable-next-line max-len
element`<div>Foooooooooooooooooo baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz</div>`
)
).toBe(
// tslint:disable-next-line max-line-length
// eslint-disable-next-line max-len
'Foooooooooooooooooo baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa [...]'

@@ -68,0 +68,0 @@ )

@@ -106,7 +106,3 @@ import { safeTruncate } from '@datadog/browser-core'

const fallbackStrategies: NameStrategy[] = [
(element) => {
return getTextualContent(element)
},
]
const fallbackStrategies: NameStrategy[] = [(element) => getTextualContent(element)]

@@ -158,3 +154,2 @@ /**

// document.getElementById won't work.
// tslint:disable-next-line: no-null-keyword
return refElement.ownerDocument ? refElement.ownerDocument.getElementById(id) : null

@@ -174,3 +169,3 @@ }

const elementsTextToRemove: NodeListOf<HTMLElement> = element.querySelectorAll('script, style')
// tslint:disable-next-line: prefer-for-of
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < elementsTextToRemove.length; i += 1) {

@@ -177,0 +172,0 @@ const innerText = elementsTextToRemove[i].innerText

@@ -23,3 +23,3 @@ import { DOM_EVENT } from '@datadog/browser-core'

events,
pushEvent(event: T) {
pushEvent: (event: T) => {
events.push(event)

@@ -152,5 +152,3 @@ },

.withFakeClock()
.beforeBuild(({ lifeCycle }) => {
return trackActions(lifeCycle)
})
.beforeBuild(({ lifeCycle }) => trackActions(lifeCycle))
})

@@ -198,3 +196,3 @@

expect(events.length).toBe(1)
const action = events[0] as AutoAction
const action = events[0]
expect(action.counts).toEqual({

@@ -201,0 +199,0 @@ errorCount: 2,

@@ -120,3 +120,3 @@ import { ErrorSource, Observable, RawError } from '@datadog/browser-core'

method: 'GET',
statusCode: 500,
status_code: 500,
url: 'url',

@@ -123,0 +123,0 @@ },

@@ -35,6 +35,6 @@ import {

return {
addError(
addError: (
{ error, startTime, context: customerContext, source }: ProvidedError,
savedCommonContext?: CommonContext
) {
) => {
const rawError = computeRawError(error, startTime, source)

@@ -60,3 +60,9 @@ lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, {

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

@@ -63,0 +69,0 @@ stack: error.stack,

@@ -15,4 +15,4 @@ import { setup, TestSetupBuilder } from '../../../../test/specHelper'

})
.beforeBuild(({ lifeCycle, configuration }) => {
startLongTaskCollection(lifeCycle, configuration)
.beforeBuild(({ lifeCycle }) => {
startLongTaskCollection(lifeCycle)
})

@@ -49,3 +49,3 @@ })

date: jasmine.any(Number),
longTask: {
long_task: {
duration: 100 * 1e6,

@@ -52,0 +52,0 @@ },

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

import { Configuration, getTimestamp, msToNs } from '@datadog/browser-core'
import { getTimestamp, msToNs } from '@datadog/browser-core'
import { RawRumLongTaskEvent, RumEventType } from '../../../rawRumEvent.types'
import { LifeCycle, LifeCycleEventType } from '../../lifeCycle'
export function startLongTaskCollection(lifeCycle: LifeCycle, configuration: Configuration) {
export function startLongTaskCollection(lifeCycle: LifeCycle) {
lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, (entry) => {

@@ -12,3 +12,3 @@ if (entry.entryType !== 'longtask') {

date: getTimestamp(entry.startTime),
longTask: {
long_task: {
duration: msToNs(entry.duration),

@@ -15,0 +15,0 @@ },

@@ -77,3 +77,3 @@ import { RequestType, ResourceType } from '@datadog/browser-core'

method: 'GET',
statusCode: 200,
status_code: 200,
type: ResourceType.XHR,

@@ -198,6 +198,6 @@ url: 'https://resource.com/valid',

)
// eslint-disable-next-line no-underscore-dangle
const traceInfo = (rawRumEvents[0].rawRumEvent as RawRumResourceEvent)._dd!
expect(traceInfo).toBeDefined()
expect(traceInfo.traceId).toBe('1234')
expect(traceInfo.trace_id).toBe('1234')
})

@@ -214,7 +214,7 @@

)
// eslint-disable-next-line no-underscore-dangle
const traceInfo = (rawRumEvents[0].rawRumEvent as RawRumResourceEvent)._dd!
expect(traceInfo).toBeDefined()
expect(traceInfo.traceId).toBeDefined()
expect(traceInfo.spanId).toBeDefined()
expect(traceInfo.trace_id).toBeDefined()
expect(traceInfo.span_id).toBeDefined()
})

@@ -221,0 +221,0 @@ })

@@ -54,3 +54,3 @@ import {

method: request.method,
statusCode: request.status,
status_code: request.status,
url: request.url,

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

_dd: {
spanId: request.spanId!.toDecimalString(),
traceId: request.traceId!.toDecimalString(),
span_id: request.spanId!.toDecimalString(),
trace_id: request.traceId!.toDecimalString(),
},

@@ -112,3 +112,3 @@ resource: { id: generateUUID() },

function computeEntryTracingInfo(entry: RumPerformanceResourceTiming) {
return entry.traceId ? { _dd: { traceId: entry.traceId } } : undefined
return entry.traceId ? { _dd: { trace_id: entry.traceId } } : undefined
}

@@ -99,3 +99,3 @@ import { Configuration, DEFAULT_CONFIGURATION, SPEC_ENDPOINTS } from '@datadog/browser-core'

download: { start: 40e6, duration: 10e6 },
firstByte: { start: 10e6, duration: 30e6 },
first_byte: { start: 10e6, duration: 30e6 },
redirect: { start: 0, duration: 1e6 },

@@ -119,3 +119,3 @@ ssl: { start: 6e6, duration: 1e6 },

download: { start: 40e6, duration: 10e6 },
firstByte: { start: 10e6, duration: 30e6 },
first_byte: { start: 10e6, duration: 30e6 },
ssl: { start: 6e6, duration: 1e6 },

@@ -137,3 +137,3 @@ })

download: { start: 40e6, duration: 10e6 },
firstByte: { start: 10e6, duration: 30e6 },
first_byte: { start: 10e6, duration: 30e6 },
redirect: { start: 0, duration: 1e6 },

@@ -155,3 +155,3 @@ ssl: { start: 6e6, duration: 1e6 },

download: { start: 40e6, duration: 10e6 },
firstByte: { start: 10e6, duration: 30e6 },
first_byte: { start: 10e6, duration: 30e6 },
redirect: { start: 0, duration: 1e6 },

@@ -175,3 +175,3 @@ })

download: { start: 40e6, duration: 10e6 },
firstByte: { start: 10e6, duration: 30e6 },
first_byte: { start: 10e6, duration: 30e6 },
redirect: { start: 0, duration: 1e6 },

@@ -195,3 +195,3 @@ })

download: { start: 40e6, duration: 10e6 },
firstByte: { start: 10e6, duration: 30e6 },
first_byte: { start: 10e6, duration: 30e6 },
redirect: { start: 0, duration: 1e6 },

@@ -262,3 +262,3 @@ })

download: { start: 30e6, duration: 10e6 },
firstByte: { start: 0, duration: 30e6 },
first_byte: { start: 0, duration: 30e6 },
})

@@ -279,3 +279,3 @@ })

download: { start: 40e6, duration: 10e6 },
firstByte: { start: 10e6, duration: 30e6 },
first_byte: { start: 10e6, duration: 30e6 },
redirect: { start: 0, duration: 2e6 },

@@ -282,0 +282,0 @@ ssl: { start: 6e6, duration: 1e6 },

@@ -23,3 +23,3 @@ import {

ssl?: PerformanceResourceDetailsElement
firstByte: PerformanceResourceDetailsElement
first_byte: PerformanceResourceDetailsElement
download: PerformanceResourceDetailsElement

@@ -35,14 +35,14 @@ }

[ResourceType.BEACON, (initiatorType: string) => 'beacon' === initiatorType],
[ResourceType.CSS, (_: string, path: string) => path.match(/\.css$/i) !== null],
[ResourceType.JS, (_: string, path: string) => path.match(/\.js$/i) !== null],
[ResourceType.CSS, (_: string, path: string) => /\.css$/i.test(path)],
[ResourceType.JS, (_: string, path: string) => /\.js$/i.test(path)],
[
ResourceType.IMAGE,
(initiatorType: string, path: string) =>
includes(['image', 'img', 'icon'], initiatorType) || path.match(/\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i) !== null,
includes(['image', 'img', 'icon'], initiatorType) || /\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i.exec(path) !== null,
],
[ResourceType.FONT, (_: string, path: string) => path.match(/\.(woff|eot|woff2|ttf)$/i) !== null],
[ResourceType.FONT, (_: string, path: string) => /\.(woff|eot|woff2|ttf)$/i.exec(path) !== null],
[
ResourceType.MEDIA,
(initiatorType: string, path: string) =>
includes(['audio', 'video'], initiatorType) || path.match(/\.(mp3|mp4)$/i) !== null,
includes(['audio', 'video'], initiatorType) || /\.(mp3|mp4)$/i.exec(path) !== null,
],

@@ -115,3 +115,3 @@ ]

download: formatTiming(startTime, responseStart, responseEnd),
firstByte: formatTiming(startTime, requestStart, responseStart),
first_byte: formatTiming(startTime, requestStart, responseStart),
}

@@ -118,0 +118,0 @@

@@ -51,5 +51,3 @@ import { createNewEvent, DOM_EVENT, restorePageVisibility, setPageVisibility } from '@datadog/browser-core'

timingsCallback = jasmine.createSpy()
setupBuilder = setup().beforeBuild(({ lifeCycle }) => {
return trackTimings(lifeCycle, timingsCallback)
})
setupBuilder = setup().beforeBuild(({ lifeCycle }) => trackTimings(lifeCycle, timingsCallback))
})

@@ -87,5 +85,3 @@

navigationTimingsCallback = jasmine.createSpy()
setupBuilder = setup().beforeBuild(({ lifeCycle }) => {
return trackNavigationTimings(lifeCycle, navigationTimingsCallback)
})
setupBuilder = setup().beforeBuild(({ lifeCycle }) => trackNavigationTimings(lifeCycle, navigationTimingsCallback))
})

@@ -118,5 +114,3 @@

fcpCallback = jasmine.createSpy()
setupBuilder = setup().beforeBuild(({ lifeCycle }) => {
return trackFirstContentfulPaint(lifeCycle, fcpCallback)
})
setupBuilder = setup().beforeBuild(({ lifeCycle }) => trackFirstContentfulPaint(lifeCycle, fcpCallback))
resetFirstHidden()

@@ -156,5 +150,3 @@ })

emitter = document.createElement('div')
setupBuilder = setup().beforeBuild(({ lifeCycle }) => {
return trackLargestContentfulPaint(lifeCycle, emitter, lcpCallback)
})
setupBuilder = setup().beforeBuild(({ lifeCycle }) => trackLargestContentfulPaint(lifeCycle, emitter, lcpCallback))
resetFirstHidden()

@@ -204,5 +196,3 @@ })

fitCallback = jasmine.createSpy()
setupBuilder = setup().beforeBuild(({ lifeCycle }) => {
return trackFirstInputTimings(lifeCycle, fitCallback)
})
setupBuilder = setup().beforeBuild(({ lifeCycle }) => trackFirstInputTimings(lifeCycle, fitCallback))
resetFirstHidden()

@@ -209,0 +199,0 @@ })

@@ -40,3 +40,3 @@ import { addEventListeners, DOM_EVENT, EventEmitter } from '@datadog/browser-core'

return {
stop() {
stop: () => {
stopNavigationTracking()

@@ -95,3 +95,3 @@ stopFCPTracking()

// but the web-vitals reference implementation uses this as a safeguard.
let firstInteractionTimestamp: number = Infinity
let firstInteractionTimestamp = Infinity
const { stop: stopEventListener } = addEventListeners(

@@ -120,3 +120,3 @@ emitter,

return {
stop() {
stop: () => {
stopEventListener()

@@ -123,0 +123,0 @@ unsubcribeLifeCycle()

@@ -55,5 +55,4 @@ import { createRawRumEvent } from '../../../../test/fixtures'

function mockGetElementById() {
return spyOn(document, 'getElementById').and.callFake((elementId: string) => {
return (elementId === ('testHashValue' as unknown)) as any
})
const fakeGetElementById = (elementId: string) => ((elementId === 'testHashValue') as any) as HTMLElement
return spyOn(document, 'getElementById').and.callFake(fakeGetElementById)
}

@@ -778,5 +777,5 @@

isLayoutShiftSupported = true
spyOnProperty(PerformanceObserver, 'supportedEntryTypes', 'get').and.callFake(() => {
return isLayoutShiftSupported ? ['layout-shift'] : []
})
spyOnProperty(PerformanceObserver, 'supportedEntryTypes', 'get').and.callFake(() =>
isLayoutShiftSupported ? ['layout-shift'] : []
)
})

@@ -839,3 +838,3 @@

let getViewEvent: (index: number) => View
let addTiming: (name: string, inInitialView?: boolean, time?: number) => void
let addTiming: (name: string, time?: number) => void

@@ -863,3 +862,3 @@ beforeEach(() => {

clock.tick(20)
addTiming('foo', false)
addTiming('foo')

@@ -871,23 +870,9 @@ const event = getViewEvent(3)

it('should add custom timing to initial view', () => {
const { clock } = setupBuilder.build()
clock.tick(20)
history.pushState({}, '', '/bar')
const initialViewId = getViewEvent(0).id
clock.tick(20)
addTiming('foo', true)
const event = getViewEvent(3)
expect(event.id).toEqual(initialViewId)
expect(event.customTimings).toEqual({ foo: 40 })
})
it('should add multiple custom timings', () => {
const { clock } = setupBuilder.build()
clock.tick(20)
addTiming('foo', false)
addTiming('foo')
clock.tick(10)
addTiming('bar', false)
addTiming('bar')

@@ -904,6 +889,6 @@ const event = getViewEvent(2)

clock.tick(20)
addTiming('foo', false)
addTiming('foo')
clock.tick(10)
addTiming('bar', false)
addTiming('bar')

@@ -917,3 +902,3 @@ let event = getViewEvent(2)

clock.tick(20)
addTiming('foo', false)
addTiming('foo')

@@ -926,2 +911,12 @@ event = getViewEvent(3)

})
it('should add custom timing with a specific time', () => {
setupBuilder.build()
addTiming('foo', 1234)
expect(getViewEvent(1).customTimings).toEqual({
foo: 1234,
})
})
})

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

import {
addEventListener,
DOM_EVENT,
generateUUID,
monitor,
msToNs,
noop,
ONE_MINUTE,
throttle,
} from '@datadog/browser-core'
import { addEventListener, DOM_EVENT, generateUUID, monitor, noop, ONE_MINUTE, throttle } from '@datadog/browser-core'

@@ -100,8 +91,7 @@ import { supportPerformanceTimingEvent } from '../../../browser/performanceCollection'

return {
addTiming(name: string, inInitialView = false) {
const view = inInitialView ? initialView : currentView
view.addTiming(name)
view.triggerUpdate()
addTiming: (name: string, time = performance.now()) => {
currentView.addTiming(name, time)
currentView.triggerUpdate()
},
stop() {
stop: () => {
stopTimingsTracking()

@@ -218,4 +208,4 @@ currentView.end()

},
addTiming(name: string) {
customTimings[name] = performance.now() - startTime
addTiming(name: string, time: number) {
customTimings[name] = time - startTime
},

@@ -237,2 +227,3 @@ updateLocation(newLocation: Location) {

function trackHistory(onHistoryChange: () => void) {
// eslint-disable-next-line @typescript-eslint/unbound-method
const originalPushState = history.pushState

@@ -243,2 +234,3 @@ history.pushState = monitor(function (this: History['pushState']) {

})
// eslint-disable-next-line @typescript-eslint/unbound-method
const originalReplaceState = history.replaceState

@@ -268,3 +260,3 @@ history.replaceState = monitor(function (this: History['replaceState']) {

return {
setLoadEvent(loadEvent: number) {
setLoadEvent: (loadEvent: number) => {
if (isWaitingForLoadEvent) {

@@ -276,3 +268,3 @@ isWaitingForLoadEvent = false

},
setActivityLoadingTime(activityLoadingTime: number | undefined) {
setActivityLoadingTime: (activityLoadingTime: number | undefined) => {
if (isWaitingForActivityLoadingTime) {

@@ -279,0 +271,0 @@ isWaitingForActivityLoadingTime = false

import { setup, TestSetupBuilder } from '../../../../test/specHelper'
import { RumEventType } from '../../../rawRumEvent.types'
import { LifeCycleEventType } from '../../lifeCycle'
import { View, ViewLoadingType } from './trackViews'
import { ViewLoadingType } from './trackViews'
import { startViewCollection } from './viewCollection'

@@ -64,3 +64,3 @@

_dd: {
documentVersion: 3,
document_version: 3,
},

@@ -73,22 +73,22 @@ date: jasmine.any(Number),

},
cumulativeLayoutShift: 1,
customTimings: {
cumulative_layout_shift: 1,
custom_timings: {
bar: 20 * 1e6,
foo: 10 * 1e6,
},
domComplete: 10 * 1e6,
domContentLoaded: 10 * 1e6,
domInteractive: 10 * 1e6,
dom_complete: 10 * 1e6,
dom_content_loaded: 10 * 1e6,
dom_interactive: 10 * 1e6,
error: {
count: 10,
},
firstContentfulPaint: 10 * 1e6,
firstInputDelay: 12 * 1e6,
firstInputTime: 10 * 1e6,
isActive: false,
largestContentfulPaint: 10 * 1e6,
loadEvent: 10 * 1e6,
loadingTime: 20 * 1e6,
loadingType: ViewLoadingType.INITIAL_LOAD,
longTask: {
first_contentful_paint: 10 * 1e6,
first_input_delay: 12 * 1e6,
first_input_time: 10 * 1e6,
is_active: false,
largest_contentful_paint: 10 * 1e6,
load_event: 10 * 1e6,
loading_time: 20 * 1e6,
loading_type: ViewLoadingType.INITIAL_LOAD,
long_task: {
count: 10,

@@ -99,3 +99,3 @@ },

},
timeSpent: 100 * 1e6,
time_spent: 100 * 1e6,
},

@@ -102,0 +102,0 @@ })

@@ -17,3 +17,3 @@ import { Configuration, getTimestamp, isEmptyObject, mapValues, msToNs } from '@datadog/browser-core'

_dd: {
documentVersion: view.documentVersion,
document_version: view.documentVersion,
},

@@ -26,18 +26,18 @@ date: getTimestamp(view.startTime),

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

@@ -48,7 +48,7 @@ },

},
timeSpent: msToNs(view.duration),
time_spent: msToNs(view.duration),
},
}
if (!isEmptyObject(view.customTimings)) {
viewEvent.view.customTimings = mapValues(view.customTimings, msToNs)
viewEvent.view.custom_timings = mapValues(view.customTimings, msToNs)
}

@@ -55,0 +55,0 @@ return {

@@ -56,3 +56,3 @@ import { findCommaSeparatedValue, ONE_MINUTE } from '@datadog/browser-core'

// value is not an array or string (here, a NodeList).
// tslint:disable-next-line: prefer-for-of
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < document.childNodes.length; i += 1) {

@@ -85,3 +85,3 @@ const comment = getTraceCommentFromNode(document.childNodes[i])

if (node && isCommentNode(node)) {
const match = node.data.match(/^\s*DATADOG;(.*?)\s*$/)
const match = /^\s*DATADOG;(.*?)\s*$/.exec(node.data)
if (match) {

@@ -88,0 +88,0 @@ return match[1]

@@ -44,3 +44,2 @@ import { Configuration, DEFAULT_CONFIGURATION, isIE, objectEntries } from '@datadog/browser-core'

},
// tslint:disable-next-line: no-object-literal-type-assertion
headers: {} as XhrStub['headers'],

@@ -47,0 +46,0 @@ }

@@ -106,3 +106,3 @@ import { Configuration, getOrigin, objectEntries } from '@datadog/browser-core'

/* tslint:disable:no-bitwise */
/* eslint-disable no-bitwise */
export class TraceIdentifier {

@@ -152,2 +152,2 @@ private buffer: Uint8Array = new Uint8Array(8)

}
/* tslint:enable:no-bitwise */
/* eslint-enable no-bitwise */

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

return {
stop() {
stop: () => {
subscription.unsubscribe()

@@ -45,0 +45,0 @@ },

@@ -50,3 +50,3 @@ import { noop, Observable } from '@datadog/browser-core'

events,
pushEvent(event: T) {
pushEvent: (event: T) => {
events.push(event)

@@ -106,4 +106,4 @@ },

describe('requests', () => {
function makeFakeRequestCompleteEvent(requestIndex: number): RequestCompleteEvent {
return { requestIndex } as any
function makeFakeRequestCompleteEvent(requestIndex: number) {
return { requestIndex } as RequestCompleteEvent
}

@@ -110,0 +110,0 @@ it('emits an activity event when a request starts', () => {

@@ -18,3 +18,3 @@ import { monitor, Observable } from '@datadog/browser-core'

completionCallback: (hadActivity: boolean, endTime: number) => void
): { stop(): void } {
) {
const { observable: pageActivitiesObservable, stop: stopPageActivitiesTracking } = trackPageActivities(lifeCycle)

@@ -28,3 +28,3 @@

function stop() {
const stop = () => {
stopWaitPageActivitiesCompletion()

@@ -61,3 +61,5 @@ stopPageActivitiesTracking()

// after MAX_DURATION, it has been validated.
export function trackPageActivities(lifeCycle: LifeCycle): { observable: Observable<PageActivityEvent>; stop(): void } {
export function trackPageActivities(
lifeCycle: LifeCycle
): { observable: Observable<PageActivityEvent>; stop: () => void } {
const observable = new Observable<PageActivityEvent>()

@@ -108,3 +110,3 @@ const subscriptions: Subscription[] = []

observable,
stop() {
stop: () => {
subscriptions.forEach((s) => s.unsubscribe())

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

completionCallback: (hadActivity: boolean, endTime: number) => void
): { stop(): void } {
): { stop: () => void } {
let idleTimeoutId: ReturnType<typeof setTimeout>

@@ -145,3 +147,3 @@ let hasCompleted = false

function stop() {
const stop = () => {
hasCompleted = true

@@ -148,0 +150,0 @@ clearTimeout(validationTimeoutId)

@@ -23,3 +23,3 @@ import { Context, ErrorSource, ResourceType } from '@datadog/browser-core'

method?: string
statusCode?: number
status_code?: number
size?: number

@@ -30,8 +30,8 @@ redirect?: PerformanceResourceDetailsElement

ssl?: PerformanceResourceDetailsElement
firstByte?: PerformanceResourceDetailsElement
first_byte?: PerformanceResourceDetailsElement
download?: PerformanceResourceDetailsElement
}
_dd?: {
traceId: string
spanId?: string // not available for initial document tracing
trace_id: string
span_id?: string // not available for initial document tracing
}

@@ -46,3 +46,3 @@ }

url: string
statusCode: number
status_code: number
method: string

@@ -61,23 +61,23 @@ }

view: {
loadingType: ViewLoadingType
firstContentfulPaint?: number
firstInputDelay?: number
firstInputTime?: number
cumulativeLayoutShift?: number
customTimings?: ViewCustomTimings
largestContentfulPaint?: number
domInteractive?: number
domContentLoaded?: number
domComplete?: number
loadEvent?: number
loadingTime?: number
timeSpent: number
isActive: boolean
loading_type: ViewLoadingType
first_contentful_paint?: number
first_input_delay?: number
first_input_time?: number
cumulative_layout_shift?: number
custom_timings?: ViewCustomTimings
largest_contentful_paint?: number
dom_interactive?: number
dom_content_loaded?: number
dom_complete?: number
load_event?: number
loading_time?: number
time_spent: number
is_active: boolean
error: Count
action: Count
longTask: Count
long_task: Count
resource: Count
}
_dd: {
documentVersion: number
document_version: number
}

@@ -93,3 +93,3 @@ }

type: RumEventType.LONG_TASK
longTask: {
long_task: {
duration: number

@@ -105,5 +105,5 @@ }

type: ActionType
loadingTime?: number
loading_time?: number
error?: Count
longTask?: Count
long_task?: Count
resource?: Count

@@ -134,3 +134,3 @@ target: {

_dd: {
formatVersion: 2
format_version: 2
}

@@ -156,9 +156,2 @@ }

export type AssembledRumEvent =
| (RawRumErrorEvent & ActionContext & ViewContext & RumContext)
| (RawRumResourceEvent & ActionContext & ViewContext & RumContext)
| (RawRumViewEvent & ViewContext & RumContext)
| (RawRumLongTaskEvent & ActionContext & ViewContext & RumContext)
| (RawRumActionEvent & ViewContext & RumContext)
export interface InternalContext {

@@ -165,0 +158,0 @@ application_id: string

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

/* tslint:disable */
/* eslint-disable */
/**

@@ -3,0 +3,0 @@ * DO NOT MODIFY IT BY HAND. Run `yarn rum-events-format:sync` instead.

import { Batch, combine, Configuration, Context, HttpRequest } from '@datadog/browser-core'
import { LifeCycle, LifeCycleEventType } from '../domain/lifeCycle'
import { AssembledRumEvent, RumEventType } from '../rawRumEvent.types'
import { RumEventType } from '../rawRumEvent.types'
import { RumEvent } from '../rumEvent.types'

@@ -9,18 +9,9 @@

lifeCycle.subscribe(
LifeCycleEventType.RUM_EVENT_COLLECTED,
({
assembledRumEvent,
serverRumEvent,
}: {
assembledRumEvent: AssembledRumEvent
serverRumEvent: RumEvent & Context
}) => {
if (assembledRumEvent.type === RumEventType.VIEW) {
batch.upsert(serverRumEvent, assembledRumEvent.view.id)
} else {
batch.add(serverRumEvent)
}
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, (serverRumEvent: RumEvent & Context) => {
if (serverRumEvent.type === RumEventType.VIEW) {
batch.upsert(serverRumEvent, serverRumEvent.view.id)
} else {
batch.add(serverRumEvent)
}
)
})

@@ -27,0 +18,0 @@ return {

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