@datadog/browser-rum-core
Advanced tools
Comparing version 2.10.0 to 2.11.1
@@ -7,4 +7,4 @@ "use strict"; | ||
datacenter: 'us', | ||
sdkVersion: '2.10.0', | ||
sdkVersion: '2.11.1', | ||
}; | ||
//# sourceMappingURL=buildEnv.js.map |
@@ -10,2 +10,3 @@ import { Configuration } from '@datadog/browser-core'; | ||
addTiming: (name: string, time?: import("@datadog/browser-core").TimeStamp) => void; | ||
startView: (name?: string | undefined, startClocks?: import("@datadog/browser-core").ClocksState | undefined) => void; | ||
configuration: Configuration; | ||
@@ -17,8 +18,5 @@ lifeCycle: LifeCycle; | ||
}; | ||
export declare function startRumEventCollection(applicationId: string, location: Location, lifeCycle: LifeCycle, configuration: Configuration, session: RumSession, getCommonContext: () => CommonContext): { | ||
addAction: (action: import("../domain/rumEventsCollection/action/trackActions").CustomAction, savedCommonContext?: CommonContext | undefined) => void; | ||
addError: ({ error, startClocks, context: customerContext, source }: import("../domain/rumEventsCollection/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void; | ||
export declare function startRumEventCollection(applicationId: string, lifeCycle: LifeCycle, configuration: Configuration, session: RumSession, getCommonContext: () => CommonContext): { | ||
parentContexts: import("../domain/parentContexts").ParentContexts; | ||
addTiming: (name: string, time?: import("@datadog/browser-core").TimeStamp) => void; | ||
stop(): void; | ||
stop: () => void; | ||
}; |
@@ -29,3 +29,8 @@ "use strict"; | ||
}); | ||
var _b = startRumEventCollection(userConfiguration.applicationId, location, lifeCycle, configuration, session, getCommonContext), parentContexts = _b.parentContexts, addError = _b.addError, addAction = _b.addAction, addTiming = _b.addTiming; | ||
var parentContexts = startRumEventCollection(userConfiguration.applicationId, lifeCycle, configuration, session, getCommonContext).parentContexts; | ||
longTaskCollection_1.startLongTaskCollection(lifeCycle); | ||
resourceCollection_1.startResourceCollection(lifeCycle, session); | ||
var _b = viewCollection_1.startViewCollection(lifeCycle, location), addTiming = _b.addTiming, startView = _b.startView; | ||
var addError = errorCollection_1.startErrorCollection(lifeCycle, configuration).addError; | ||
var addAction = actionCollection_1.startActionCollection(lifeCycle, configuration).addAction; | ||
requestCollection_1.startRequestCollection(lifeCycle, configuration); | ||
@@ -39,2 +44,3 @@ performanceCollection_1.startPerformanceCollection(lifeCycle, configuration); | ||
addTiming: addTiming, | ||
startView: startView, | ||
configuration: configuration, | ||
@@ -48,18 +54,9 @@ lifeCycle: lifeCycle, | ||
exports.startRum = startRum; | ||
function startRumEventCollection(applicationId, location, lifeCycle, configuration, session, getCommonContext) { | ||
function startRumEventCollection(applicationId, lifeCycle, configuration, session, getCommonContext) { | ||
var parentContexts = parentContexts_1.startParentContexts(lifeCycle, session); | ||
var batch = batch_1.startRumBatch(configuration, lifeCycle); | ||
assembly_1.startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getCommonContext); | ||
longTaskCollection_1.startLongTaskCollection(lifeCycle); | ||
resourceCollection_1.startResourceCollection(lifeCycle, session); | ||
var _a = viewCollection_1.startViewCollection(lifeCycle, location), addTiming = _a.addTiming, stopViewCollection = _a.stop; | ||
var addError = errorCollection_1.startErrorCollection(lifeCycle, configuration).addError; | ||
var addAction = actionCollection_1.startActionCollection(lifeCycle, configuration).addAction; | ||
return { | ||
addAction: addAction, | ||
addError: addError, | ||
parentContexts: parentContexts, | ||
addTiming: addTiming, | ||
stop: function () { | ||
stopViewCollection(); | ||
// prevent batch from previous tests to keep running and send unwanted requests | ||
@@ -66,0 +63,0 @@ // could be replaced by stopping all the component when they will all have a stop method |
@@ -11,13 +11,18 @@ "use strict"; | ||
var getInternalContextStrategy = function () { return undefined; }; | ||
var beforeInitAddTiming = new browser_core_1.BoundedBuffer(); | ||
var beforeInitApiCalls = new browser_core_1.BoundedBuffer(); | ||
var addTimingStrategy = function (name) { | ||
beforeInitAddTiming.add([name, browser_core_1.timeStampNow()]); | ||
var time = browser_core_1.timeStampNow(); | ||
beforeInitApiCalls.add(function () { return addTimingStrategy(name, time); }); | ||
}; | ||
var beforeInitAddAction = new browser_core_1.BoundedBuffer(); | ||
var startViewStrategy = function (name) { | ||
var startClocks = browser_core_1.clocksNow(); | ||
beforeInitApiCalls.add(function () { return startViewStrategy(name, startClocks); }); | ||
}; | ||
var addActionStrategy = function (action) { | ||
beforeInitAddAction.add([action, clonedCommonContext()]); | ||
var commonContext = clonedCommonContext(); | ||
beforeInitApiCalls.add(function () { return addActionStrategy(action, commonContext); }); | ||
}; | ||
var beforeInitAddError = new browser_core_1.BoundedBuffer(); | ||
var addErrorStrategy = function (providedError) { | ||
beforeInitAddError.add([providedError, clonedCommonContext()]); | ||
var commonContext = clonedCommonContext(); | ||
beforeInitApiCalls.add(function () { return addErrorStrategy(providedError, commonContext); }); | ||
}; | ||
@@ -41,19 +46,12 @@ function clonedCommonContext() { | ||
} | ||
; | ||
var configuration; | ||
var startView; | ||
(_a = startRumImpl(userConfiguration, function () { return ({ | ||
user: user, | ||
context: globalContextManager.get(), | ||
}); }), addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, addTimingStrategy = _a.addTiming, getInternalContextStrategy = _a.getInternalContext); | ||
beforeInitAddAction.drain(function (_a) { | ||
var action = _a[0], commonContext = _a[1]; | ||
return addActionStrategy(action, commonContext); | ||
}); | ||
beforeInitAddError.drain(function (_a) { | ||
var error = _a[0], commonContext = _a[1]; | ||
return addErrorStrategy(error, commonContext); | ||
}); | ||
beforeInitAddTiming.drain(function (_a) { | ||
var name = _a[0], time = _a[1]; | ||
return addTimingStrategy(name, time); | ||
}); | ||
}); }), configuration = _a.configuration, startView = _a.startView, addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, addTimingStrategy = _a.addTiming, getInternalContextStrategy = _a.getInternalContext); | ||
if (configuration.isEnabled('view-renaming')) { | ||
startViewStrategy = startView; | ||
} | ||
beforeInitApiCalls.drain(); | ||
isAlreadyInitialized = true; | ||
@@ -113,2 +111,5 @@ }), | ||
}); | ||
rumPublicApi['startView'] = browser_core_1.monitor(function (name) { | ||
startViewStrategy(name); | ||
}); | ||
return rumPublicApi; | ||
@@ -115,0 +116,0 @@ function sanitizeUser(newUser) { |
import { LifeCycle } from '../domain/lifeCycle'; | ||
declare type MutationObserverConstructor = new (callback: MutationCallback) => MutationObserver; | ||
export declare function getMutationObserverConstructor(): MutationObserverConstructor | undefined; | ||
export declare function startDOMMutationCollection(lifeCycle: LifeCycle): { | ||
stop(): void; | ||
}; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.startDOMMutationCollection = void 0; | ||
exports.startDOMMutationCollection = exports.getMutationObserverConstructor = void 0; | ||
var browser_core_1 = require("@datadog/browser-core"); | ||
@@ -9,3 +9,3 @@ var lifeCycle_1 = require("../domain/lifeCycle"); | ||
var browserWindow = window; | ||
// Angular uses Zone.js to provide a context persisting accross async tasks. Zone.js replaces the | ||
// Angular uses Zone.js to provide a context persisting across async tasks. Zone.js replaces the | ||
// global MutationObserver constructor with a patched version to support the context propagation. | ||
@@ -30,2 +30,3 @@ // There is an ongoing issue[1][2] with this setup when using a MutationObserver within a Angular | ||
} | ||
exports.getMutationObserverConstructor = getMutationObserverConstructor; | ||
function startDOMMutationCollection(lifeCycle) { | ||
@@ -32,0 +33,0 @@ var observer; |
@@ -37,3 +37,4 @@ import { Duration, ClocksState, TimeStamp } from '@datadog/browser-core'; | ||
addTiming: (name: string, time?: TimeStamp) => void; | ||
startView: (name?: string | undefined, startClocks?: ClocksState | undefined) => void; | ||
stop: () => void; | ||
}; |
@@ -58,4 +58,4 @@ "use strict"; | ||
} | ||
function trackViewChange() { | ||
return newView(lifeCycle, location, isRecording, rawRumEvent_types_1.ViewLoadingType.ROUTE_CHANGE, currentView.url); | ||
function trackViewChange(startClocks, name) { | ||
return newView(lifeCycle, location, isRecording, rawRumEvent_types_1.ViewLoadingType.ROUTE_CHANGE, currentView.url, startClocks, name); | ||
} | ||
@@ -68,2 +68,7 @@ return { | ||
}, | ||
startView: function (name, startClocks) { | ||
currentView.end(startClocks); | ||
currentView.triggerUpdate(); | ||
currentView = trackViewChange(startClocks, name); | ||
}, | ||
stop: function () { | ||
@@ -112,4 +117,5 @@ stopInitialViewTracking(); | ||
scheduleUpdate: scheduleViewUpdate, | ||
end: function () { | ||
endClocks = browser_core_1.clocksNow(); | ||
end: function (clocks) { | ||
if (clocks === void 0) { clocks = browser_core_1.clocksNow(); } | ||
endClocks = clocks; | ||
stopViewMetricsTracking(); | ||
@@ -116,0 +122,0 @@ lifeCycle.notify(lifeCycle_1.LifeCycleEventType.VIEW_ENDED, { endClocks: endClocks }); |
import { LifeCycle } from '../../lifeCycle'; | ||
export declare function startViewCollection(lifeCycle: LifeCycle, location: Location): { | ||
addTiming: (name: string, time?: import("@datadog/browser-core").TimeStamp) => void; | ||
startView: (name?: string | undefined, startClocks?: import("@datadog/browser-core").ClocksState | undefined) => void; | ||
stop: () => void; | ||
}; |
@@ -9,1 +9,2 @@ export { RumUserConfiguration, RumPublicApi, makeRumPublicApi, StartRum } from './boot/rumPublicApi'; | ||
export { RumSession } from './domain/rumSession'; | ||
export { getMutationObserverConstructor } from './browser/domMutationCollection'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LifeCycleEventType = exports.LifeCycle = exports.startRum = exports.makeRumPublicApi = void 0; | ||
exports.getMutationObserverConstructor = exports.LifeCycleEventType = exports.LifeCycle = exports.startRum = exports.makeRumPublicApi = void 0; | ||
var rumPublicApi_1 = require("./boot/rumPublicApi"); | ||
@@ -11,2 +11,4 @@ Object.defineProperty(exports, "makeRumPublicApi", { enumerable: true, get: function () { return rumPublicApi_1.makeRumPublicApi; } }); | ||
Object.defineProperty(exports, "LifeCycleEventType", { enumerable: true, get: function () { return lifeCycle_1.LifeCycleEventType; } }); | ||
var domMutationCollection_1 = require("./browser/domMutationCollection"); | ||
Object.defineProperty(exports, "getMutationObserverConstructor", { enumerable: true, get: function () { return domMutationCollection_1.getMutationObserverConstructor; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -84,2 +84,12 @@ /** | ||
}; | ||
/** | ||
* View properties | ||
*/ | ||
readonly view?: { | ||
/** | ||
* Is the action starting in the foreground (focus in browser) | ||
*/ | ||
readonly in_foreground?: boolean; | ||
[k: string]: unknown; | ||
}; | ||
[k: string]: unknown; | ||
@@ -100,2 +110,6 @@ }; | ||
/** | ||
* UUID of the error | ||
*/ | ||
readonly id?: string; | ||
/** | ||
* Error message | ||
@@ -168,2 +182,12 @@ */ | ||
}; | ||
/** | ||
* View properties | ||
*/ | ||
readonly view?: { | ||
/** | ||
* Is the error starting in the foreground (focus in browser) | ||
*/ | ||
readonly in_foreground?: boolean; | ||
[k: string]: unknown; | ||
}; | ||
[k: string]: unknown; | ||
@@ -184,2 +208,6 @@ }; | ||
/** | ||
* UUID of the long task | ||
*/ | ||
readonly id?: string; | ||
/** | ||
* Duration in ns of the long task | ||
@@ -492,2 +520,16 @@ */ | ||
}; | ||
/** | ||
* List of the periods of time the user had the view in foreground (focused in the browser) | ||
*/ | ||
readonly in_foreground_periods?: { | ||
/** | ||
* Duration in ns between start of the view and start of foreground period | ||
*/ | ||
readonly start: number; | ||
/** | ||
* Duration in ns of the view foreground period | ||
*/ | ||
readonly duration: number; | ||
[k: string]: unknown; | ||
}[]; | ||
[k: string]: unknown; | ||
@@ -625,3 +667,9 @@ }; | ||
}; | ||
/** | ||
* User provided context | ||
*/ | ||
context?: { | ||
[k: string]: unknown; | ||
}; | ||
[k: string]: unknown; | ||
} |
export var buildEnv = { | ||
buildMode: 'release', | ||
datacenter: 'us', | ||
sdkVersion: '2.10.0', | ||
sdkVersion: '2.11.1', | ||
}; | ||
//# sourceMappingURL=buildEnv.js.map |
@@ -10,2 +10,3 @@ import { Configuration } from '@datadog/browser-core'; | ||
addTiming: (name: string, time?: import("@datadog/browser-core").TimeStamp) => void; | ||
startView: (name?: string | undefined, startClocks?: import("@datadog/browser-core").ClocksState | undefined) => void; | ||
configuration: Configuration; | ||
@@ -17,8 +18,5 @@ lifeCycle: LifeCycle; | ||
}; | ||
export declare function startRumEventCollection(applicationId: string, location: Location, lifeCycle: LifeCycle, configuration: Configuration, session: RumSession, getCommonContext: () => CommonContext): { | ||
addAction: (action: import("../domain/rumEventsCollection/action/trackActions").CustomAction, savedCommonContext?: CommonContext | undefined) => void; | ||
addError: ({ error, startClocks, context: customerContext, source }: import("../domain/rumEventsCollection/error/errorCollection").ProvidedError, savedCommonContext?: CommonContext | undefined) => void; | ||
export declare function startRumEventCollection(applicationId: string, lifeCycle: LifeCycle, configuration: Configuration, session: RumSession, getCommonContext: () => CommonContext): { | ||
parentContexts: import("../domain/parentContexts").ParentContexts; | ||
addTiming: (name: string, time?: import("@datadog/browser-core").TimeStamp) => void; | ||
stop(): void; | ||
stop: () => void; | ||
}; |
@@ -26,3 +26,8 @@ import { combine, commonInit } from '@datadog/browser-core'; | ||
}); | ||
var _b = startRumEventCollection(userConfiguration.applicationId, location, lifeCycle, configuration, session, getCommonContext), parentContexts = _b.parentContexts, addError = _b.addError, addAction = _b.addAction, addTiming = _b.addTiming; | ||
var parentContexts = startRumEventCollection(userConfiguration.applicationId, lifeCycle, configuration, session, getCommonContext).parentContexts; | ||
startLongTaskCollection(lifeCycle); | ||
startResourceCollection(lifeCycle, session); | ||
var _b = startViewCollection(lifeCycle, location), addTiming = _b.addTiming, startView = _b.startView; | ||
var addError = startErrorCollection(lifeCycle, configuration).addError; | ||
var addAction = startActionCollection(lifeCycle, configuration).addAction; | ||
startRequestCollection(lifeCycle, configuration); | ||
@@ -36,2 +41,3 @@ startPerformanceCollection(lifeCycle, configuration); | ||
addTiming: addTiming, | ||
startView: startView, | ||
configuration: configuration, | ||
@@ -44,18 +50,9 @@ lifeCycle: lifeCycle, | ||
} | ||
export function startRumEventCollection(applicationId, location, lifeCycle, configuration, session, getCommonContext) { | ||
export function startRumEventCollection(applicationId, lifeCycle, configuration, session, getCommonContext) { | ||
var parentContexts = startParentContexts(lifeCycle, session); | ||
var batch = startRumBatch(configuration, lifeCycle); | ||
startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getCommonContext); | ||
startLongTaskCollection(lifeCycle); | ||
startResourceCollection(lifeCycle, session); | ||
var _a = startViewCollection(lifeCycle, location), addTiming = _a.addTiming, stopViewCollection = _a.stop; | ||
var addError = startErrorCollection(lifeCycle, configuration).addError; | ||
var addAction = startActionCollection(lifeCycle, configuration).addAction; | ||
return { | ||
addAction: addAction, | ||
addError: addError, | ||
parentContexts: parentContexts, | ||
addTiming: addTiming, | ||
stop: function () { | ||
stopViewCollection(); | ||
// prevent batch from previous tests to keep running and send unwanted requests | ||
@@ -62,0 +59,0 @@ // could be replaced by stopping all the component when they will all have a stop method |
@@ -8,13 +8,18 @@ import { BoundedBuffer, buildCookieOptions, checkCookiesAuthorized, checkIsNotLocalFile, createContextManager, deepClone, ErrorSource, isPercentage, makePublicApi, monitor, clocksNow, timeStampNow, display, } from '@datadog/browser-core'; | ||
var getInternalContextStrategy = function () { return undefined; }; | ||
var beforeInitAddTiming = new BoundedBuffer(); | ||
var beforeInitApiCalls = new BoundedBuffer(); | ||
var addTimingStrategy = function (name) { | ||
beforeInitAddTiming.add([name, timeStampNow()]); | ||
var time = timeStampNow(); | ||
beforeInitApiCalls.add(function () { return addTimingStrategy(name, time); }); | ||
}; | ||
var beforeInitAddAction = new BoundedBuffer(); | ||
var startViewStrategy = function (name) { | ||
var startClocks = clocksNow(); | ||
beforeInitApiCalls.add(function () { return startViewStrategy(name, startClocks); }); | ||
}; | ||
var addActionStrategy = function (action) { | ||
beforeInitAddAction.add([action, clonedCommonContext()]); | ||
var commonContext = clonedCommonContext(); | ||
beforeInitApiCalls.add(function () { return addActionStrategy(action, commonContext); }); | ||
}; | ||
var beforeInitAddError = new BoundedBuffer(); | ||
var addErrorStrategy = function (providedError) { | ||
beforeInitAddError.add([providedError, clonedCommonContext()]); | ||
var commonContext = clonedCommonContext(); | ||
beforeInitApiCalls.add(function () { return addErrorStrategy(providedError, commonContext); }); | ||
}; | ||
@@ -38,19 +43,12 @@ function clonedCommonContext() { | ||
} | ||
; | ||
var configuration; | ||
var startView; | ||
(_a = startRumImpl(userConfiguration, function () { return ({ | ||
user: user, | ||
context: globalContextManager.get(), | ||
}); }), addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, addTimingStrategy = _a.addTiming, getInternalContextStrategy = _a.getInternalContext); | ||
beforeInitAddAction.drain(function (_a) { | ||
var action = _a[0], commonContext = _a[1]; | ||
return addActionStrategy(action, commonContext); | ||
}); | ||
beforeInitAddError.drain(function (_a) { | ||
var error = _a[0], commonContext = _a[1]; | ||
return addErrorStrategy(error, commonContext); | ||
}); | ||
beforeInitAddTiming.drain(function (_a) { | ||
var name = _a[0], time = _a[1]; | ||
return addTimingStrategy(name, time); | ||
}); | ||
}); }), configuration = _a.configuration, startView = _a.startView, addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, addTimingStrategy = _a.addTiming, getInternalContextStrategy = _a.getInternalContext); | ||
if (configuration.isEnabled('view-renaming')) { | ||
startViewStrategy = startView; | ||
} | ||
beforeInitApiCalls.drain(); | ||
isAlreadyInitialized = true; | ||
@@ -110,2 +108,5 @@ }), | ||
}); | ||
rumPublicApi['startView'] = monitor(function (name) { | ||
startViewStrategy(name); | ||
}); | ||
return rumPublicApi; | ||
@@ -112,0 +113,0 @@ function sanitizeUser(newUser) { |
import { LifeCycle } from '../domain/lifeCycle'; | ||
declare type MutationObserverConstructor = new (callback: MutationCallback) => MutationObserver; | ||
export declare function getMutationObserverConstructor(): MutationObserverConstructor | undefined; | ||
export declare function startDOMMutationCollection(lifeCycle: LifeCycle): { | ||
stop(): void; | ||
}; | ||
export {}; |
import { monitor } from '@datadog/browser-core'; | ||
import { LifeCycleEventType } from '../domain/lifeCycle'; | ||
function getMutationObserverConstructor() { | ||
export function getMutationObserverConstructor() { | ||
var constructor; | ||
var browserWindow = window; | ||
// Angular uses Zone.js to provide a context persisting accross async tasks. Zone.js replaces the | ||
// Angular uses Zone.js to provide a context persisting across async tasks. Zone.js replaces the | ||
// global MutationObserver constructor with a patched version to support the context propagation. | ||
@@ -8,0 +8,0 @@ // There is an ongoing issue[1][2] with this setup when using a MutationObserver within a Angular |
@@ -37,3 +37,4 @@ import { Duration, ClocksState, TimeStamp } from '@datadog/browser-core'; | ||
addTiming: (name: string, time?: TimeStamp) => void; | ||
startView: (name?: string | undefined, startClocks?: ClocksState | undefined) => void; | ||
stop: () => void; | ||
}; |
@@ -55,4 +55,4 @@ import { __assign } from "tslib"; | ||
} | ||
function trackViewChange() { | ||
return newView(lifeCycle, location, isRecording, ViewLoadingType.ROUTE_CHANGE, currentView.url); | ||
function trackViewChange(startClocks, name) { | ||
return newView(lifeCycle, location, isRecording, ViewLoadingType.ROUTE_CHANGE, currentView.url, startClocks, name); | ||
} | ||
@@ -65,2 +65,7 @@ return { | ||
}, | ||
startView: function (name, startClocks) { | ||
currentView.end(startClocks); | ||
currentView.triggerUpdate(); | ||
currentView = trackViewChange(startClocks, name); | ||
}, | ||
stop: function () { | ||
@@ -108,4 +113,5 @@ stopInitialViewTracking(); | ||
scheduleUpdate: scheduleViewUpdate, | ||
end: function () { | ||
endClocks = clocksNow(); | ||
end: function (clocks) { | ||
if (clocks === void 0) { clocks = clocksNow(); } | ||
endClocks = clocks; | ||
stopViewMetricsTracking(); | ||
@@ -112,0 +118,0 @@ lifeCycle.notify(LifeCycleEventType.VIEW_ENDED, { endClocks: endClocks }); |
import { LifeCycle } from '../../lifeCycle'; | ||
export declare function startViewCollection(lifeCycle: LifeCycle, location: Location): { | ||
addTiming: (name: string, time?: import("@datadog/browser-core").TimeStamp) => void; | ||
startView: (name?: string | undefined, startClocks?: import("@datadog/browser-core").ClocksState | undefined) => void; | ||
stop: () => void; | ||
}; |
@@ -9,1 +9,2 @@ export { RumUserConfiguration, RumPublicApi, makeRumPublicApi, StartRum } from './boot/rumPublicApi'; | ||
export { RumSession } from './domain/rumSession'; | ||
export { getMutationObserverConstructor } from './browser/domMutationCollection'; |
export { makeRumPublicApi } from './boot/rumPublicApi'; | ||
export { startRum } from './boot/rum'; | ||
export { LifeCycle, LifeCycleEventType } from './domain/lifeCycle'; | ||
export { getMutationObserverConstructor } from './browser/domMutationCollection'; | ||
//# sourceMappingURL=index.js.map |
@@ -84,2 +84,12 @@ /** | ||
}; | ||
/** | ||
* View properties | ||
*/ | ||
readonly view?: { | ||
/** | ||
* Is the action starting in the foreground (focus in browser) | ||
*/ | ||
readonly in_foreground?: boolean; | ||
[k: string]: unknown; | ||
}; | ||
[k: string]: unknown; | ||
@@ -100,2 +110,6 @@ }; | ||
/** | ||
* UUID of the error | ||
*/ | ||
readonly id?: string; | ||
/** | ||
* Error message | ||
@@ -168,2 +182,12 @@ */ | ||
}; | ||
/** | ||
* View properties | ||
*/ | ||
readonly view?: { | ||
/** | ||
* Is the error starting in the foreground (focus in browser) | ||
*/ | ||
readonly in_foreground?: boolean; | ||
[k: string]: unknown; | ||
}; | ||
[k: string]: unknown; | ||
@@ -184,2 +208,6 @@ }; | ||
/** | ||
* UUID of the long task | ||
*/ | ||
readonly id?: string; | ||
/** | ||
* Duration in ns of the long task | ||
@@ -492,2 +520,16 @@ */ | ||
}; | ||
/** | ||
* List of the periods of time the user had the view in foreground (focused in the browser) | ||
*/ | ||
readonly in_foreground_periods?: { | ||
/** | ||
* Duration in ns between start of the view and start of foreground period | ||
*/ | ||
readonly start: number; | ||
/** | ||
* Duration in ns of the view foreground period | ||
*/ | ||
readonly duration: number; | ||
[k: string]: unknown; | ||
}[]; | ||
[k: string]: unknown; | ||
@@ -625,3 +667,9 @@ }; | ||
}; | ||
/** | ||
* User provided context | ||
*/ | ||
context?: { | ||
[k: string]: unknown; | ||
}; | ||
[k: string]: unknown; | ||
} |
{ | ||
"name": "@datadog/browser-rum-core", | ||
"version": "2.10.0", | ||
"version": "2.11.1", | ||
"license": "Apache-2.0", | ||
@@ -15,3 +15,3 @@ "main": "cjs/index.js", | ||
"dependencies": { | ||
"@datadog/browser-core": "2.10.0", | ||
"@datadog/browser-core": "2.11.1", | ||
"tslib": "^1.10.0" | ||
@@ -27,3 +27,3 @@ }, | ||
}, | ||
"gitHead": "b096bbce392494bdec53fbd17394ca74511c604b" | ||
"gitHead": "6e95f9755e7926c30395bd29f484848da80bb37d" | ||
} |
@@ -1,2 +0,3 @@ | ||
import { RelativeTime } from '@datadog/browser-core' | ||
import { RelativeTime, Configuration } from '@datadog/browser-core' | ||
import { RumSession } from '@datadog/browser-rum-core' | ||
import { isIE } from '../../../core/test/specHelper' | ||
@@ -8,2 +9,3 @@ import { setup, TestSetupBuilder } from '../../test/specHelper' | ||
import { SESSION_KEEP_ALIVE_INTERVAL, THROTTLE_VIEW_UPDATE_PERIOD } from '../domain/rumEventsCollection/view/trackViews' | ||
import { startViewCollection } from '../domain/rumEventsCollection/view/viewCollection' | ||
import { RumEvent } from '../rumEvent.types' | ||
@@ -20,2 +22,28 @@ import { startRumEventCollection } from './rum' | ||
function startRum( | ||
applicationId: string, | ||
lifeCycle: LifeCycle, | ||
configuration: Configuration, | ||
session: RumSession, | ||
location: Location | ||
) { | ||
const { stop: rumEventCollectionStop } = startRumEventCollection( | ||
applicationId, | ||
lifeCycle, | ||
configuration, | ||
session, | ||
() => ({ | ||
context: {}, | ||
user: {}, | ||
}) | ||
) | ||
const { stop: viewCollectionStop } = startViewCollection(lifeCycle, location) | ||
return { | ||
stop: () => { | ||
rumEventCollectionStop() | ||
viewCollectionStop() | ||
}, | ||
} | ||
} | ||
describe('rum session', () => { | ||
@@ -32,6 +60,3 @@ let setupBuilder: TestSetupBuilder | ||
serverRumEvents = collectServerEvents(lifeCycle) | ||
return startRumEventCollection(applicationId, location, lifeCycle, configuration, session, () => ({ | ||
context: {}, | ||
user: {}, | ||
})) | ||
return startRum(applicationId, lifeCycle, configuration, session, location) | ||
}) | ||
@@ -89,6 +114,3 @@ }) | ||
serverRumEvents = collectServerEvents(lifeCycle) | ||
return startRumEventCollection(applicationId, location, lifeCycle, configuration, session, () => ({ | ||
context: {}, | ||
user: {}, | ||
})) | ||
return startRum(applicationId, lifeCycle, configuration, session, location) | ||
}) | ||
@@ -153,6 +175,3 @@ }) | ||
serverRumEvents = collectServerEvents(lifeCycle) | ||
return startRumEventCollection(applicationId, location, lifeCycle, configuration, session, () => ({ | ||
context: {}, | ||
user: {}, | ||
})) | ||
return startRum(applicationId, lifeCycle, configuration, session, location) | ||
}) | ||
@@ -159,0 +178,0 @@ }) |
@@ -37,5 +37,4 @@ import { combine, commonInit, Configuration } from '@datadog/browser-core' | ||
const { parentContexts, addError, addAction, addTiming } = startRumEventCollection( | ||
const { parentContexts } = startRumEventCollection( | ||
userConfiguration.applicationId, | ||
location, | ||
lifeCycle, | ||
@@ -47,2 +46,8 @@ configuration, | ||
startLongTaskCollection(lifeCycle) | ||
startResourceCollection(lifeCycle, session) | ||
const { addTiming, startView } = startViewCollection(lifeCycle, location) | ||
const { addError } = startErrorCollection(lifeCycle, configuration) | ||
const { addAction } = startActionCollection(lifeCycle, configuration) | ||
startRequestCollection(lifeCycle, configuration) | ||
@@ -58,2 +63,3 @@ startPerformanceCollection(lifeCycle, configuration) | ||
addTiming, | ||
startView, | ||
configuration, | ||
@@ -69,3 +75,2 @@ lifeCycle, | ||
applicationId: string, | ||
location: Location, | ||
lifeCycle: LifeCycle, | ||
@@ -79,17 +84,6 @@ configuration: Configuration, | ||
startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getCommonContext) | ||
startLongTaskCollection(lifeCycle) | ||
startResourceCollection(lifeCycle, session) | ||
const { addTiming, stop: stopViewCollection } = startViewCollection(lifeCycle, location) | ||
const { addError } = startErrorCollection(lifeCycle, configuration) | ||
const { addAction } = startActionCollection(lifeCycle, configuration) | ||
return { | ||
addAction, | ||
addError, | ||
parentContexts, | ||
addTiming, | ||
stop() { | ||
stopViewCollection() | ||
stop: () => { | ||
// prevent batch from previous tests to keep running and send unwanted requests | ||
@@ -96,0 +90,0 @@ // could be replaced by stopping all the component when they will all have a stop method |
@@ -1,2 +0,2 @@ | ||
import { ErrorSource, ONE_SECOND, RelativeTime, getTimeStamp, display } from '@datadog/browser-core' | ||
import { ErrorSource, ONE_SECOND, RelativeTime, getTimeStamp, display, TimeStamp } from '@datadog/browser-core' | ||
import { setup, TestSetupBuilder } from '../../test/specHelper' | ||
@@ -10,3 +10,4 @@ import { ActionType } from '../rawRumEvent.types' | ||
addTiming: () => undefined, | ||
configuration: {} as any, | ||
startView: () => undefined, | ||
configuration: { isEnabled: () => true } as any, | ||
getInternalContext: () => undefined, | ||
@@ -450,2 +451,53 @@ lifeCycle: {} as any, | ||
}) | ||
describe('startView', () => { | ||
let startViewSpy: jasmine.Spy<ReturnType<StartRum>['startView']> | ||
let displaySpy: jasmine.Spy<() => void> | ||
let rumPublicApi: RumPublicApi | ||
let setupBuilder: TestSetupBuilder | ||
beforeEach(() => { | ||
startViewSpy = jasmine.createSpy() | ||
displaySpy = spyOn(display, 'error') | ||
rumPublicApi = makeRumPublicApi(() => ({ | ||
...noopStartRum(), | ||
startView: startViewSpy, | ||
})) | ||
setupBuilder = setup() | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should allow to start view before init', () => { | ||
const { clock } = setupBuilder.withFakeClock().build() | ||
clock.tick(10) | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
;(rumPublicApi as any).startView('foo') | ||
expect(startViewSpy).not.toHaveBeenCalled() | ||
clock.tick(20) | ||
rumPublicApi.init(DEFAULT_INIT_CONFIGURATION) | ||
expect(startViewSpy.calls.argsFor(0)[0]).toEqual('foo') | ||
expect(startViewSpy.calls.argsFor(0)[1]).toEqual({ | ||
relative: 10 as RelativeTime, | ||
timeStamp: (jasmine.any(Number) as unknown) as TimeStamp, | ||
}) | ||
}) | ||
it('should to start view', () => { | ||
rumPublicApi.init(DEFAULT_INIT_CONFIGURATION) | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
;(rumPublicApi as any).startView('foo') | ||
expect(startViewSpy.calls.argsFor(0)[0]).toEqual('foo') | ||
expect(startViewSpy.calls.argsFor(0)[1]).toBeUndefined() | ||
expect(displaySpy).not.toHaveBeenCalled() | ||
}) | ||
}) | ||
}) |
@@ -15,8 +15,6 @@ import { | ||
clocksNow, | ||
TimeStamp, | ||
timeStampNow, | ||
display, | ||
} from '@datadog/browser-core' | ||
import { CustomAction } from '../domain/rumEventsCollection/action/trackActions' | ||
import { ProvidedError, ProvidedSource } from '../domain/rumEventsCollection/error/errorCollection' | ||
import { ProvidedSource } from '../domain/rumEventsCollection/error/errorCollection' | ||
import { CommonContext, User, ActionType } from '../rawRumEvent.types' | ||
@@ -48,15 +46,18 @@ import { RumEvent } from '../rumEvent.types' | ||
const beforeInitAddTiming = new BoundedBuffer<[string, TimeStamp]>() | ||
const beforeInitApiCalls = new BoundedBuffer() | ||
let addTimingStrategy: StartRumResult['addTiming'] = (name) => { | ||
beforeInitAddTiming.add([name, timeStampNow()]) | ||
const time = timeStampNow() | ||
beforeInitApiCalls.add(() => addTimingStrategy(name, time)) | ||
} | ||
const beforeInitAddAction = new BoundedBuffer<[CustomAction, CommonContext]>() | ||
let startViewStrategy: StartRumResult['startView'] = (name) => { | ||
const startClocks = clocksNow() | ||
beforeInitApiCalls.add(() => startViewStrategy(name, startClocks)) | ||
} | ||
let addActionStrategy: StartRumResult['addAction'] = (action) => { | ||
beforeInitAddAction.add([action, clonedCommonContext()]) | ||
const commonContext = clonedCommonContext() | ||
beforeInitApiCalls.add(() => addActionStrategy(action, commonContext)) | ||
} | ||
const beforeInitAddError = new BoundedBuffer<[ProvidedError, CommonContext]>() | ||
let addErrorStrategy: StartRumResult['addError'] = (providedError) => { | ||
beforeInitAddError.add([providedError, clonedCommonContext()]) | ||
const commonContext = clonedCommonContext() | ||
beforeInitApiCalls.add(() => addErrorStrategy(providedError, commonContext)) | ||
} | ||
@@ -84,3 +85,7 @@ | ||
let configuration | ||
let startView | ||
;({ | ||
configuration, | ||
startView, | ||
addAction: addActionStrategy, | ||
@@ -94,6 +99,6 @@ addError: addErrorStrategy, | ||
}))) | ||
beforeInitAddAction.drain(([action, commonContext]) => addActionStrategy(action, commonContext)) | ||
beforeInitAddError.drain(([error, commonContext]) => addErrorStrategy(error, commonContext)) | ||
beforeInitAddTiming.drain(([name, time]) => addTimingStrategy(name, time)) | ||
if (configuration.isEnabled('view-renaming')) { | ||
startViewStrategy = startView | ||
} | ||
beforeInitApiCalls.drain() | ||
isAlreadyInitialized = true | ||
@@ -160,2 +165,5 @@ }), | ||
}) | ||
;(rumPublicApi as any)['startView'] = monitor((name?: string) => { | ||
startViewStrategy(name) | ||
}) | ||
return rumPublicApi | ||
@@ -162,0 +170,0 @@ |
@@ -13,7 +13,7 @@ import { monitor } from '@datadog/browser-core' | ||
function getMutationObserverConstructor(): MutationObserverConstructor | undefined { | ||
export function getMutationObserverConstructor(): MutationObserverConstructor | undefined { | ||
let constructor: MutationObserverConstructor | undefined | ||
const browserWindow: BrowserWindow = window | ||
// Angular uses Zone.js to provide a context persisting accross async tasks. Zone.js replaces the | ||
// Angular uses Zone.js to provide a context persisting across async tasks. Zone.js replaces the | ||
// global MutationObserver constructor with a patched version to support the context propagation. | ||
@@ -20,0 +20,0 @@ // There is an ongoing issue[1][2] with this setup when using a MutationObserver within a Angular |
@@ -1,2 +0,10 @@ | ||
import { Duration, RelativeTime, TimeStamp, timeStampNow, display } from '@datadog/browser-core' | ||
import { | ||
ClocksState, | ||
Duration, | ||
RelativeTime, | ||
TimeStamp, | ||
timeStampNow, | ||
display, | ||
relativeToClocks, | ||
} from '@datadog/browser-core' | ||
import { setup, TestSetupBuilder } from '../../../../test/specHelper' | ||
@@ -522,1 +530,64 @@ import { | ||
}) | ||
describe('rum start view', () => { | ||
let setupBuilder: TestSetupBuilder | ||
let handler: jasmine.Spy | ||
let getViewEvent: (index: number) => ViewEvent | ||
let getHandledCount: () => number | ||
let startView: (name?: string, endClocks?: ClocksState) => void | ||
beforeEach(() => { | ||
;({ getHandledCount, getViewEvent, handler } = spyOnViews()) | ||
setupBuilder = setup().beforeBuild(({ location, lifeCycle }) => { | ||
lifeCycle.subscribe(LifeCycleEventType.VIEW_UPDATED, handler) | ||
;({ startView } = trackViews(location, lifeCycle)) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should start a new view', () => { | ||
const { clock } = setupBuilder.withFakeClock().build() | ||
expect(getHandledCount()).toBe(1) | ||
const initialViewId = getViewEvent(0).id | ||
clock.tick(10) | ||
startView() | ||
expect(getHandledCount()).toBe(3) | ||
expect(getViewEvent(1).id).toBe(initialViewId) | ||
expect(getViewEvent(1).isActive).toBe(false) | ||
expect(getViewEvent(1).startClocks.relative).toBe(0 as RelativeTime) | ||
expect(getViewEvent(1).duration).toBe(10 as Duration) | ||
expect(getViewEvent(2).id).not.toBe(initialViewId) | ||
expect(getViewEvent(2).isActive).toBe(true) | ||
expect(getViewEvent(2).startClocks.relative).toBe(10 as RelativeTime) | ||
}) | ||
it('should name the view', () => { | ||
setupBuilder.build() | ||
startView() | ||
startView('foo') | ||
startView('bar') | ||
expect(getViewEvent(2).name).toBeUndefined() | ||
expect(getViewEvent(4).name).toBe('foo') | ||
expect(getViewEvent(6).name).toBe('bar') | ||
}) | ||
it('should use the provided clock to stop the current view and start the new one', () => { | ||
const { clock } = setupBuilder.withFakeClock().build() | ||
clock.tick(100) | ||
startView('foo', relativeToClocks(50 as RelativeTime)) | ||
expect(getViewEvent(1).duration).toBe(50 as Duration) | ||
expect(getViewEvent(2).startClocks.relative).toBe(50 as RelativeTime) | ||
}) | ||
}) |
@@ -119,4 +119,4 @@ import { | ||
function trackViewChange() { | ||
return newView(lifeCycle, location, isRecording, ViewLoadingType.ROUTE_CHANGE, currentView.url) | ||
function trackViewChange(startClocks?: ClocksState, name?: string) { | ||
return newView(lifeCycle, location, isRecording, ViewLoadingType.ROUTE_CHANGE, currentView.url, startClocks, name) | ||
} | ||
@@ -129,2 +129,7 @@ | ||
}, | ||
startView: (name?: string, startClocks?: ClocksState) => { | ||
currentView.end(startClocks) | ||
currentView.triggerUpdate() | ||
currentView = trackViewChange(startClocks, name) | ||
}, | ||
stop: () => { | ||
@@ -199,4 +204,4 @@ stopInitialViewTracking() | ||
scheduleUpdate: scheduleViewUpdate, | ||
end() { | ||
endClocks = clocksNow() | ||
end(clocks = clocksNow()) { | ||
endClocks = clocks | ||
stopViewMetricsTracking() | ||
@@ -203,0 +208,0 @@ lifeCycle.notify(LifeCycleEventType.VIEW_ENDED, { endClocks }) |
@@ -17,1 +17,2 @@ export { RumUserConfiguration, RumPublicApi, makeRumPublicApi, StartRum } from './boot/rumPublicApi' | ||
export { RumSession } from './domain/rumSession' | ||
export { getMutationObserverConstructor } from './browser/domMutationCollection' |
@@ -86,2 +86,12 @@ /* eslint-disable */ | ||
} | ||
/** | ||
* View properties | ||
*/ | ||
readonly view?: { | ||
/** | ||
* Is the action starting in the foreground (focus in browser) | ||
*/ | ||
readonly in_foreground?: boolean | ||
[k: string]: unknown | ||
} | ||
[k: string]: unknown | ||
@@ -102,2 +112,6 @@ } | ||
/** | ||
* UUID of the error | ||
*/ | ||
readonly id?: string | ||
/** | ||
* Error message | ||
@@ -184,2 +198,12 @@ */ | ||
} | ||
/** | ||
* View properties | ||
*/ | ||
readonly view?: { | ||
/** | ||
* Is the error starting in the foreground (focus in browser) | ||
*/ | ||
readonly in_foreground?: boolean | ||
[k: string]: unknown | ||
} | ||
[k: string]: unknown | ||
@@ -200,2 +224,6 @@ } | ||
/** | ||
* UUID of the long task | ||
*/ | ||
readonly id?: string | ||
/** | ||
* Duration in ns of the long task | ||
@@ -530,2 +558,16 @@ */ | ||
} | ||
/** | ||
* List of the periods of time the user had the view in foreground (focused in the browser) | ||
*/ | ||
readonly in_foreground_periods?: { | ||
/** | ||
* Duration in ns between start of the view and start of foreground period | ||
*/ | ||
readonly start: number | ||
/** | ||
* Duration in ns of the view foreground period | ||
*/ | ||
readonly duration: number | ||
[k: string]: unknown | ||
}[] | ||
[k: string]: unknown | ||
@@ -674,3 +716,9 @@ } | ||
} | ||
/** | ||
* User provided context | ||
*/ | ||
context?: { | ||
[k: string]: unknown | ||
} | ||
[k: string]: unknown | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
812895
16796
+ Added@datadog/browser-core@2.11.1(transitive)
- Removed@datadog/browser-core@2.10.0(transitive)
Updated@datadog/browser-core@2.11.1