@datadog/browser-rum-core
Advanced tools
Comparing version 4.50.1 to 5.0.0
@@ -24,13 +24,5 @@ import type { Context, InitConfiguration, User } from '@datadog/browser-core'; | ||
init: (initConfiguration: RumInitConfiguration) => void; | ||
/** @deprecated: use setGlobalContextProperty instead */ | ||
addRumGlobalContext: (key: any, value: any) => void; | ||
setGlobalContextProperty: (key: any, value: any) => void; | ||
/** @deprecated: use removeGlobalContextProperty instead */ | ||
removeRumGlobalContext: (key: any) => void; | ||
removeGlobalContextProperty: (key: any) => void; | ||
/** @deprecated: use getGlobalContext instead */ | ||
getRumGlobalContext: () => Context; | ||
getGlobalContext: () => Context; | ||
/** @deprecated: use setGlobalContext instead */ | ||
setRumGlobalContext: (context: any) => void; | ||
setGlobalContext: (context: any) => void; | ||
@@ -47,4 +39,2 @@ clearGlobalContext: () => void; | ||
removeUserProperty: (key: any) => void; | ||
/** @deprecated: renamed to clearUser */ | ||
removeUser: () => void; | ||
clearUser: () => void; | ||
@@ -51,0 +41,0 @@ startView: { |
@@ -34,2 +34,8 @@ "use strict"; | ||
}; | ||
var recorderStartStrategy = function () { | ||
bufferApiCalls.add(function () { return recorderStartStrategy(); }); | ||
}; | ||
var recorderStopStrategy = function () { | ||
bufferApiCalls.add(function () { return recorderStopStrategy(); }); | ||
}; | ||
var addFeatureFlagEvaluationStrategy = function (key, value) { | ||
@@ -96,5 +102,7 @@ bufferApiCalls.add(function () { return addFeatureFlagEvaluationStrategy(key, value); }); | ||
}; | ||
recorderStartStrategy = recorderApi.start; | ||
recorderStopStrategy = recorderApi.stop; | ||
(startViewStrategy = startRumResults.startView, addActionStrategy = startRumResults.addAction, addErrorStrategy = startRumResults.addError, addTimingStrategy = startRumResults.addTiming, addFeatureFlagEvaluationStrategy = startRumResults.addFeatureFlagEvaluation, getInternalContextStrategy = startRumResults.getInternalContext, stopSessionStrategy = startRumResults.stopSession); | ||
recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts); | ||
bufferApiCalls.drain(); | ||
recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts); | ||
} | ||
@@ -107,13 +115,5 @@ var startView = (0, browser_core_1.monitor)(function (options) { | ||
init: (0, browser_core_1.monitor)(initRum), | ||
/** @deprecated: use setGlobalContextProperty instead */ | ||
addRumGlobalContext: (0, browser_core_1.monitor)(function (key, value) { return globalContextManager.add(key, value); }), | ||
setGlobalContextProperty: (0, browser_core_1.monitor)(function (key, value) { return globalContextManager.setContextProperty(key, value); }), | ||
/** @deprecated: use removeGlobalContextProperty instead */ | ||
removeRumGlobalContext: (0, browser_core_1.monitor)(function (key) { return globalContextManager.remove(key); }), | ||
removeGlobalContextProperty: (0, browser_core_1.monitor)(function (key) { return globalContextManager.removeContextProperty(key); }), | ||
/** @deprecated: use getGlobalContext instead */ | ||
getRumGlobalContext: (0, browser_core_1.monitor)(function () { return globalContextManager.get(); }), | ||
getGlobalContext: (0, browser_core_1.monitor)(function () { return globalContextManager.getContext(); }), | ||
/** @deprecated: use setGlobalContext instead */ | ||
setRumGlobalContext: (0, browser_core_1.monitor)(function (context) { return globalContextManager.set(context); }), | ||
setGlobalContext: (0, browser_core_1.monitor)(function (context) { return globalContextManager.setContext(context); }), | ||
@@ -157,4 +157,2 @@ clearGlobalContext: (0, browser_core_1.monitor)(function () { return globalContextManager.clearContext(); }), | ||
removeUserProperty: (0, browser_core_1.monitor)(function (key) { return userContextManager.removeContextProperty(key); }), | ||
/** @deprecated: renamed to clearUser */ | ||
removeUser: (0, browser_core_1.monitor)(function () { return userContextManager.clearContext(); }), | ||
clearUser: (0, browser_core_1.monitor)(function () { return userContextManager.clearContext(); }), | ||
@@ -165,4 +163,4 @@ startView: startView, | ||
}), | ||
startSessionReplayRecording: (0, browser_core_1.monitor)(recorderApi.start), | ||
stopSessionReplayRecording: (0, browser_core_1.monitor)(recorderApi.stop), | ||
startSessionReplayRecording: (0, browser_core_1.monitor)(function () { return recorderStartStrategy(); }), | ||
stopSessionReplayRecording: (0, browser_core_1.monitor)(function () { return recorderStopStrategy(); }), | ||
/** | ||
@@ -169,0 +167,0 @@ * This feature is currently in beta. For more information see the full [feature flag tracking guide](https://docs.datadoghq.com/real_user_monitoring/feature_flag_tracking/). |
@@ -74,3 +74,3 @@ "use strict"; | ||
(0, browser_core_1.addTelemetryConfiguration)((0, configuration_1.serializeRumConfiguration)(initConfiguration)); | ||
(0, longTaskCollection_1.startLongTaskCollection)(lifeCycle, session); | ||
(0, longTaskCollection_1.startLongTaskCollection)(lifeCycle, configuration, session); | ||
(0, resourceCollection_1.startResourceCollection)(lifeCycle, configuration, session, pageStateHistory); | ||
@@ -77,0 +77,0 @@ var _b = (0, viewCollection_1.startViewCollection)(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, initialViewOptions), addTiming = _b.addTiming, startView = _b.startView, stopViewCollection = _b.stop; |
@@ -36,3 +36,3 @@ "use strict"; | ||
}).stop; | ||
var removeListener = (0, browser_core_1.addEventListener)(configuration, window, "popstate" /* DOM_EVENT.POP_STATE */, onHistoryChange).stop; | ||
var removeListener = (0, browser_core_1.addEventListener)(configuration, window, browser_core_1.DOM_EVENT.POP_STATE, onHistoryChange).stop; | ||
return { | ||
@@ -47,4 +47,4 @@ stop: function () { | ||
function trackHash(configuration, onHashChange) { | ||
return (0, browser_core_1.addEventListener)(configuration, window, "hashchange" /* DOM_EVENT.HASH_CHANGE */, onHashChange); | ||
return (0, browser_core_1.addEventListener)(configuration, window, browser_core_1.DOM_EVENT.HASH_CHANGE, onHashChange); | ||
} | ||
//# sourceMappingURL=locationChangeObservable.js.map |
import type { Duration, RelativeTime } from '@datadog/browser-core'; | ||
import type { RumConfiguration } from '../domain/configuration'; | ||
import type { LifeCycle } from '../domain/lifeCycle'; | ||
import type { PerformanceEntryRepresentation } from '../domainContext.types'; | ||
type RumPerformanceObserverConstructor = new (callback: PerformanceObserverCallback) => RumPerformanceObserver; | ||
@@ -46,9 +45,10 @@ export interface BrowserWindow extends Window { | ||
traceId?: string; | ||
toJSON(): PerformanceEntryRepresentation; | ||
toJSON(): Omit<PerformanceEntry, 'toJSON'>; | ||
} | ||
export interface RumPerformanceLongTaskTiming { | ||
name: string; | ||
entryType: RumPerformanceEntryType.LONG_TASK; | ||
startTime: RelativeTime; | ||
duration: Duration; | ||
toJSON(): PerformanceEntryRepresentation; | ||
toJSON(): Omit<PerformanceEntry, 'toJSON'>; | ||
} | ||
@@ -55,0 +55,0 @@ export interface RumPerformancePaintTiming { |
@@ -142,3 +142,3 @@ "use strict"; | ||
var timingSent = false; | ||
var removeEventListeners = (0, browser_core_1.addEventListeners)(configuration, window, ["click" /* DOM_EVENT.CLICK */, "mousedown" /* DOM_EVENT.MOUSE_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */, "touchstart" /* DOM_EVENT.TOUCH_START */, "pointerdown" /* DOM_EVENT.POINTER_DOWN */], function (evt) { | ||
var removeEventListeners = (0, browser_core_1.addEventListeners)(configuration, window, [browser_core_1.DOM_EVENT.CLICK, browser_core_1.DOM_EVENT.MOUSE_DOWN, browser_core_1.DOM_EVENT.KEY_DOWN, browser_core_1.DOM_EVENT.TOUCH_START, browser_core_1.DOM_EVENT.POINTER_DOWN], function (evt) { | ||
// Only count cancelable events, which should trigger behavior important to the user. | ||
@@ -159,3 +159,3 @@ if (!evt.cancelable) { | ||
}; | ||
if (evt.type === "pointerdown" /* DOM_EVENT.POINTER_DOWN */) { | ||
if (evt.type === browser_core_1.DOM_EVENT.POINTER_DOWN) { | ||
sendTimingIfPointerIsNotCancelled(configuration, timing); | ||
@@ -174,4 +174,4 @@ } | ||
function sendTimingIfPointerIsNotCancelled(configuration, timing) { | ||
(0, browser_core_1.addEventListeners)(configuration, window, ["pointerup" /* DOM_EVENT.POINTER_UP */, "pointercancel" /* DOM_EVENT.POINTER_CANCEL */], function (event) { | ||
if (event.type === "pointerup" /* DOM_EVENT.POINTER_UP */) { | ||
(0, browser_core_1.addEventListeners)(configuration, window, [browser_core_1.DOM_EVENT.POINTER_UP, browser_core_1.DOM_EVENT.POINTER_CANCEL], function (event) { | ||
if (event.type === browser_core_1.DOM_EVENT.POINTER_UP) { | ||
sendTiming(timing); | ||
@@ -178,0 +178,0 @@ } |
@@ -18,3 +18,3 @@ "use strict"; | ||
}, 200).throttled; | ||
return (0, browser_core_1.addEventListener)(configuration, window, "resize" /* DOM_EVENT.RESIZE */, updateDimension, { capture: true, passive: true }) | ||
return (0, browser_core_1.addEventListener)(configuration, window, browser_core_1.DOM_EVENT.RESIZE, updateDimension, { capture: true, passive: true }) | ||
.stop; | ||
@@ -21,0 +21,0 @@ }); |
@@ -68,3 +68,3 @@ "use strict"; | ||
startTime: action.startClocks.relative, | ||
domainContext: isAutoAction(action) ? { event: action.event, events: action.events } : {}, | ||
domainContext: isAutoAction(action) ? { events: action.events } : {}, | ||
}; | ||
@@ -71,0 +71,0 @@ } |
@@ -14,3 +14,3 @@ "use strict"; | ||
var listeners = [ | ||
(0, browser_core_1.addEventListener)(configuration, window, "pointerdown" /* DOM_EVENT.POINTER_DOWN */, function (event) { | ||
(0, browser_core_1.addEventListener)(configuration, window, browser_core_1.DOM_EVENT.POINTER_DOWN, function (event) { | ||
if (isValidPointerEvent(event)) { | ||
@@ -25,3 +25,3 @@ selectionEmptyAtPointerDown = isSelectionEmpty(); | ||
}, { capture: true }), | ||
(0, browser_core_1.addEventListener)(configuration, window, "selectionchange" /* DOM_EVENT.SELECTION_CHANGE */, function () { | ||
(0, browser_core_1.addEventListener)(configuration, window, browser_core_1.DOM_EVENT.SELECTION_CHANGE, function () { | ||
if (!selectionEmptyAtPointerDown || !isSelectionEmpty()) { | ||
@@ -31,3 +31,3 @@ userActivity.selection = true; | ||
}, { capture: true }), | ||
(0, browser_core_1.addEventListener)(configuration, window, "pointerup" /* DOM_EVENT.POINTER_UP */, function (event) { | ||
(0, browser_core_1.addEventListener)(configuration, window, browser_core_1.DOM_EVENT.POINTER_UP, function (event) { | ||
if (isValidPointerEvent(event) && clickContext) { | ||
@@ -40,3 +40,3 @@ // Use a scoped variable to make sure the value is not changed by other clicks | ||
}, { capture: true }), | ||
(0, browser_core_1.addEventListener)(configuration, window, "input" /* DOM_EVENT.INPUT */, function () { | ||
(0, browser_core_1.addEventListener)(configuration, window, browser_core_1.DOM_EVENT.INPUT, function () { | ||
userActivity.input = true; | ||
@@ -43,0 +43,0 @@ }, { capture: true }), |
@@ -25,3 +25,3 @@ "use strict"; | ||
onPointerDown: function (pointerDownEvent) { | ||
return processPointerDown(configuration, lifeCycle, domMutationObservable, history, pointerDownEvent); | ||
return processPointerDown(configuration, lifeCycle, domMutationObservable, pointerDownEvent); | ||
}, | ||
@@ -34,5 +34,3 @@ onPointerUp: function (_a, startEvent, getUserActivity) { | ||
var actionContexts = { | ||
findActionId: function (startTime) { | ||
return configuration.trackFrustrations ? history.findAll(startTime) : history.find(startTime); | ||
}, | ||
findActionId: function (startTime) { return history.findAll(startTime); }, | ||
}; | ||
@@ -62,14 +60,4 @@ return { | ||
exports.trackClickActions = trackClickActions; | ||
function processPointerDown(configuration, lifeCycle, domMutationObservable, history, pointerDownEvent) { | ||
if (!configuration.trackFrustrations && history.find()) { | ||
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any new | ||
// action if another one is already occurring. | ||
return; | ||
} | ||
function processPointerDown(configuration, lifeCycle, domMutationObservable, pointerDownEvent) { | ||
var clickActionBase = computeClickActionBase(pointerDownEvent, configuration.actionNameAttribute); | ||
if (!configuration.trackFrustrations && !clickActionBase.name) { | ||
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any action | ||
// with a blank name | ||
return; | ||
} | ||
var hadActivityOnPointerDown = false; | ||
@@ -86,5 +74,3 @@ (0, waitPageActivityEnd_1.waitPageActivityEnd)(lifeCycle, domMutationObservable, configuration, function (pageActivityEndEvent) { | ||
var click = newClick(lifeCycle, history, getUserActivity, clickActionBase, startEvent); | ||
if (configuration.trackFrustrations) { | ||
appendClickToClickChain(click); | ||
} | ||
appendClickToClickChain(click); | ||
var stopWaitPageActivityEnd = (0, waitPageActivityEnd_1.waitPageActivityEnd)(lifeCycle, domMutationObservable, configuration, function (pageActivityEndEvent) { | ||
@@ -108,14 +94,2 @@ if (pageActivityEndEvent.hadActivity && pageActivityEndEvent.end < click.startClocks.timeStamp) { | ||
} | ||
// Validate or discard the click only if we don't track frustrations. It'll be done when | ||
// the click chain is finalized. | ||
if (!configuration.trackFrustrations) { | ||
if (!pageActivityEndEvent.hadActivity) { | ||
// If we are not tracking frustrations, we should discard the click to keep backward | ||
// compatibility. | ||
click.discard(); | ||
} | ||
else { | ||
click.validate(); | ||
} | ||
} | ||
} | ||
@@ -122,0 +96,0 @@ }, exports.CLICK_ACTION_MAX_DURATION).stop; |
@@ -53,5 +53,2 @@ "use strict"; | ||
drift: (0, browser_core_1.currentDrift)(), | ||
session: { | ||
plan: session.plan, | ||
}, | ||
configuration: { | ||
@@ -61,3 +58,3 @@ session_sample_rate: (0, browser_core_1.round)(configuration.sessionSampleRate, 3), | ||
}, | ||
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.50.1" : undefined, | ||
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "5.0.0" : undefined, | ||
}, | ||
@@ -92,2 +89,6 @@ application: { | ||
} | ||
if (serverRumEvent.type === 'view') { | ||
; | ||
serverRumEvent.session.sampled_for_replay = session.sessionReplayAllowed; | ||
} | ||
if (!(0, browser_core_1.isEmptyObject)(commonContext.user)) { | ||
@@ -94,0 +95,0 @@ ; |
@@ -5,35 +5,16 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core'; | ||
import type { RumEvent } from '../rumEvent.types'; | ||
import type { TracingOption } from './tracing/tracer.types'; | ||
import type { PropagatorType, TracingOption } from './tracing/tracer.types'; | ||
export declare const DEFAULT_PROPAGATOR_TYPES: PropagatorType[]; | ||
export interface RumInitConfiguration extends InitConfiguration { | ||
applicationId: string; | ||
beforeSend?: ((event: RumEvent, context: RumEventDomainContext) => void | boolean) | undefined; | ||
/** | ||
* @deprecated use sessionReplaySampleRate instead | ||
*/ | ||
premiumSampleRate?: number | undefined; | ||
beforeSend?: ((event: RumEvent, context: RumEventDomainContext) => boolean) | undefined; | ||
excludedActivityUrls?: MatchOption[] | undefined; | ||
workerUrl?: string; | ||
/** | ||
* @deprecated use allowedTracingUrls instead | ||
*/ | ||
allowedTracingOrigins?: MatchOption[] | undefined; | ||
allowedTracingUrls?: Array<MatchOption | TracingOption> | undefined; | ||
/** | ||
* @deprecated use traceSampleRate instead | ||
*/ | ||
tracingSampleRate?: number | undefined; | ||
traceSampleRate?: number | undefined; | ||
defaultPrivacyLevel?: DefaultPrivacyLevel | undefined; | ||
subdomain?: string; | ||
/** | ||
* @deprecated use sessionReplaySampleRate instead | ||
*/ | ||
replaySampleRate?: number | undefined; | ||
sessionReplaySampleRate?: number | undefined; | ||
/** | ||
* @deprecated use trackUserInteractions instead | ||
*/ | ||
trackInteractions?: boolean | undefined; | ||
startSessionReplayRecordingManually?: boolean | undefined; | ||
trackUserInteractions?: boolean | undefined; | ||
trackFrustrations?: boolean | undefined; | ||
actionNameAttribute?: string | undefined; | ||
@@ -53,9 +34,8 @@ trackViewsManually?: boolean | undefined; | ||
defaultPrivacyLevel: DefaultPrivacyLevel; | ||
oldPlansBehavior: boolean; | ||
sessionReplaySampleRate: number; | ||
startSessionReplayRecordingManually: boolean; | ||
trackUserInteractions: boolean; | ||
trackFrustrations: boolean; | ||
trackViewsManually: boolean; | ||
trackResources: boolean | undefined; | ||
trackLongTasks: boolean | undefined; | ||
trackResources: boolean; | ||
trackLongTasks: boolean; | ||
version?: string; | ||
@@ -62,0 +42,0 @@ subdomain?: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.serializeRumConfiguration = exports.validateAndBuildRumConfiguration = void 0; | ||
exports.serializeRumConfiguration = exports.validateAndBuildRumConfiguration = exports.DEFAULT_PROPAGATOR_TYPES = void 0; | ||
var browser_core_1 = require("@datadog/browser-core"); | ||
var tracer_1 = require("./tracing/tracer"); | ||
exports.DEFAULT_PROPAGATOR_TYPES = ['tracecontext', 'datadog']; | ||
function validateAndBuildRumConfiguration(initConfiguration) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b; | ||
if (!initConfiguration.applicationId) { | ||
@@ -17,14 +18,3 @@ browser_core_1.display.error('Application ID is not configured, no RUM data will be collected.'); | ||
} | ||
// TODO remove fallback in next major | ||
var premiumSampleRate = (_a = initConfiguration.premiumSampleRate) !== null && _a !== void 0 ? _a : initConfiguration.replaySampleRate; | ||
if (premiumSampleRate !== undefined && initConfiguration.sessionReplaySampleRate !== undefined) { | ||
browser_core_1.display.warn('Ignoring Premium Sample Rate because Session Replay Sample Rate is set'); | ||
premiumSampleRate = undefined; | ||
} | ||
if (premiumSampleRate !== undefined && !(0, browser_core_1.isPercentage)(premiumSampleRate)) { | ||
browser_core_1.display.error('Premium Sample Rate should be a number between 0 and 100'); | ||
return; | ||
} | ||
var traceSampleRate = (_b = initConfiguration.traceSampleRate) !== null && _b !== void 0 ? _b : initConfiguration.tracingSampleRate; | ||
if (traceSampleRate !== undefined && !(0, browser_core_1.isPercentage)(traceSampleRate)) { | ||
if (initConfiguration.traceSampleRate !== undefined && !(0, browser_core_1.isPercentage)(initConfiguration.traceSampleRate)) { | ||
browser_core_1.display.error('Trace Sample Rate should be a number between 0 and 100'); | ||
@@ -45,4 +35,2 @@ return; | ||
} | ||
var trackUserInteractions = !!((_c = initConfiguration.trackUserInteractions) !== null && _c !== void 0 ? _c : initConfiguration.trackInteractions); | ||
var trackFrustrations = !!initConfiguration.trackFrustrations; | ||
return (0, browser_core_1.assign)({ | ||
@@ -52,17 +40,16 @@ applicationId: initConfiguration.applicationId, | ||
actionNameAttribute: initConfiguration.actionNameAttribute, | ||
sessionReplaySampleRate: (_e = (_d = initConfiguration.sessionReplaySampleRate) !== null && _d !== void 0 ? _d : premiumSampleRate) !== null && _e !== void 0 ? _e : 100, | ||
oldPlansBehavior: initConfiguration.sessionReplaySampleRate === undefined, | ||
traceSampleRate: traceSampleRate, | ||
sessionReplaySampleRate: (_a = initConfiguration.sessionReplaySampleRate) !== null && _a !== void 0 ? _a : 0, | ||
startSessionReplayRecordingManually: !!initConfiguration.startSessionReplayRecordingManually, | ||
traceSampleRate: initConfiguration.traceSampleRate, | ||
allowedTracingUrls: allowedTracingUrls, | ||
excludedActivityUrls: (_f = initConfiguration.excludedActivityUrls) !== null && _f !== void 0 ? _f : [], | ||
excludedActivityUrls: (_b = initConfiguration.excludedActivityUrls) !== null && _b !== void 0 ? _b : [], | ||
workerUrl: initConfiguration.workerUrl, | ||
trackUserInteractions: trackUserInteractions || trackFrustrations, | ||
trackFrustrations: trackFrustrations, | ||
trackUserInteractions: !!initConfiguration.trackUserInteractions, | ||
trackViewsManually: !!initConfiguration.trackViewsManually, | ||
trackResources: initConfiguration.trackResources, | ||
trackLongTasks: initConfiguration.trackLongTasks, | ||
trackResources: !!initConfiguration.trackResources, | ||
trackLongTasks: !!initConfiguration.trackLongTasks, | ||
subdomain: initConfiguration.subdomain, | ||
defaultPrivacyLevel: (0, browser_core_1.objectHasValue)(browser_core_1.DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel) | ||
? initConfiguration.defaultPrivacyLevel | ||
: browser_core_1.DefaultPrivacyLevel.MASK_USER_INPUT, | ||
: browser_core_1.DefaultPrivacyLevel.MASK, | ||
customerDataTelemetrySampleRate: 1, | ||
@@ -73,10 +60,5 @@ }, baseConfiguration); | ||
/** | ||
* Handles allowedTracingUrls and processes legacy allowedTracingOrigins | ||
* Validates allowedTracingUrls and converts match options to tracing options | ||
*/ | ||
function validateAndBuildTracingOptions(initConfiguration) { | ||
// Advise about parameters precedence. | ||
if (initConfiguration.allowedTracingUrls !== undefined && initConfiguration.allowedTracingOrigins !== undefined) { | ||
browser_core_1.display.warn('Both allowedTracingUrls and allowedTracingOrigins (deprecated) have been defined. The parameter allowedTracingUrls will override allowedTracingOrigins.'); | ||
} | ||
// Handle allowedTracingUrls first | ||
if (initConfiguration.allowedTracingUrls !== undefined) { | ||
@@ -95,3 +77,3 @@ if (!Array.isArray(initConfiguration.allowedTracingUrls)) { | ||
if ((0, browser_core_1.isMatchOption)(option)) { | ||
tracingOptions_1.push({ match: option, propagatorTypes: ['datadog'] }); | ||
tracingOptions_1.push({ match: option, propagatorTypes: exports.DEFAULT_PROPAGATOR_TYPES }); | ||
} | ||
@@ -107,48 +89,7 @@ else if ((0, tracer_1.isTracingOption)(option)) { | ||
} | ||
// Handle conversion of allowedTracingOrigins to allowedTracingUrls | ||
if (initConfiguration.allowedTracingOrigins !== undefined) { | ||
if (!Array.isArray(initConfiguration.allowedTracingOrigins)) { | ||
browser_core_1.display.error('Allowed Tracing Origins should be an array'); | ||
return; | ||
} | ||
if (initConfiguration.allowedTracingOrigins.length !== 0 && initConfiguration.service === undefined) { | ||
browser_core_1.display.error('Service needs to be configured when tracing is enabled'); | ||
return; | ||
} | ||
var tracingOptions_2 = []; | ||
initConfiguration.allowedTracingOrigins.forEach(function (legacyMatchOption) { | ||
var tracingOption = convertLegacyMatchOptionToTracingOption(legacyMatchOption); | ||
if (tracingOption) { | ||
tracingOptions_2.push(tracingOption); | ||
} | ||
}); | ||
return tracingOptions_2; | ||
} | ||
return []; | ||
} | ||
/** | ||
* Converts parameters from the deprecated allowedTracingOrigins | ||
* to allowedTracingUrls. Handles the change from origin to full URLs. | ||
* Combines the selected tracing propagators from the different options in allowedTracingUrls | ||
*/ | ||
function convertLegacyMatchOptionToTracingOption(item) { | ||
var match; | ||
if (typeof item === 'string') { | ||
match = item; | ||
} | ||
else if (item instanceof RegExp) { | ||
match = function (url) { return item.test((0, browser_core_1.getOrigin)(url)); }; | ||
} | ||
else if (typeof item === 'function') { | ||
match = function (url) { return item((0, browser_core_1.getOrigin)(url)); }; | ||
} | ||
if (match === undefined) { | ||
browser_core_1.display.warn('Allowed Tracing Origins parameters should be a string, RegExp or function. Ignoring parameter', item); | ||
return undefined; | ||
} | ||
return { match: match, propagatorTypes: ['datadog'] }; | ||
} | ||
/** | ||
* Combines the selected tracing propagators from the different options in allowedTracingUrls, | ||
* and assumes 'datadog' has been selected when using allowedTracingOrigins | ||
*/ | ||
function getSelectedTracingPropagators(configuration) { | ||
@@ -159,3 +100,3 @@ var usedTracingPropagators = new Set(); | ||
if ((0, browser_core_1.isMatchOption)(option)) { | ||
usedTracingPropagators.add('datadog'); | ||
exports.DEFAULT_PROPAGATOR_TYPES.forEach(function (propagatorType) { return usedTracingPropagators.add(propagatorType); }); | ||
} | ||
@@ -168,17 +109,11 @@ else if ((0, browser_core_1.getType)(option) === 'object' && Array.isArray(option.propagatorTypes)) { | ||
} | ||
if (Array.isArray(configuration.allowedTracingOrigins) && configuration.allowedTracingOrigins.length > 0) { | ||
usedTracingPropagators.add('datadog'); | ||
} | ||
return (0, browser_core_1.arrayFrom)(usedTracingPropagators); | ||
} | ||
function serializeRumConfiguration(configuration) { | ||
var _a, _b; | ||
var baseSerializedConfiguration = (0, browser_core_1.serializeConfiguration)(configuration); | ||
return (0, browser_core_1.assign)({ | ||
premium_sample_rate: configuration.premiumSampleRate, | ||
replay_sample_rate: configuration.replaySampleRate, | ||
session_replay_sample_rate: configuration.sessionReplaySampleRate, | ||
trace_sample_rate: (_a = configuration.traceSampleRate) !== null && _a !== void 0 ? _a : configuration.tracingSampleRate, | ||
start_session_replay_recording_manually: configuration.startSessionReplayRecordingManually, | ||
trace_sample_rate: configuration.traceSampleRate, | ||
action_name_attribute: configuration.actionNameAttribute, | ||
use_allowed_tracing_origins: Array.isArray(configuration.allowedTracingOrigins) && configuration.allowedTracingOrigins.length > 0, | ||
use_allowed_tracing_urls: Array.isArray(configuration.allowedTracingUrls) && configuration.allowedTracingUrls.length > 0, | ||
@@ -189,5 +124,6 @@ selected_tracing_propagators: getSelectedTracingPropagators(configuration), | ||
use_worker_url: !!configuration.workerUrl, | ||
track_frustrations: configuration.trackFrustrations, | ||
track_views_manually: configuration.trackViewsManually, | ||
track_user_interactions: (_b = configuration.trackUserInteractions) !== null && _b !== void 0 ? _b : configuration.trackInteractions, | ||
track_user_interactions: configuration.trackUserInteractions, | ||
track_resources: configuration.trackResources, | ||
track_long_task: configuration.trackLongTasks, | ||
}, baseSerializedConfiguration); | ||
@@ -194,0 +130,0 @@ } |
@@ -16,15 +16,11 @@ "use strict"; | ||
var stopEventListeners = (0, browser_core_1.addEventListeners)(configuration, window, [ | ||
"pageshow" /* DOM_EVENT.PAGE_SHOW */, | ||
"focus" /* DOM_EVENT.FOCUS */, | ||
"blur" /* DOM_EVENT.BLUR */, | ||
"visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, | ||
"resume" /* DOM_EVENT.RESUME */, | ||
"freeze" /* DOM_EVENT.FREEZE */, | ||
"pagehide" /* DOM_EVENT.PAGE_HIDE */, | ||
browser_core_1.DOM_EVENT.PAGE_SHOW, | ||
browser_core_1.DOM_EVENT.FOCUS, | ||
browser_core_1.DOM_EVENT.BLUR, | ||
browser_core_1.DOM_EVENT.VISIBILITY_CHANGE, | ||
browser_core_1.DOM_EVENT.RESUME, | ||
browser_core_1.DOM_EVENT.FREEZE, | ||
browser_core_1.DOM_EVENT.PAGE_HIDE, | ||
], function (event) { | ||
// Only get events fired by the browser to avoid false currentPageState changes done with custom events | ||
// cf: developer extension auto flush: https://github.com/DataDog/browser-sdk/blob/2f72bf05a672794c9e33965351964382a94c72ba/developer-extension/src/panel/flushEvents.ts#L11-L12 | ||
if (event.isTrusted) { | ||
addPageState(computePageState(event), event.timeStamp); | ||
} | ||
addPageState(computePageState(event), event.timeStamp); | ||
}, { capture: true }).stop; | ||
@@ -74,6 +70,6 @@ function addPageState(nextPageState, startTime) { | ||
function computePageState(event) { | ||
if (event.type === "freeze" /* DOM_EVENT.FREEZE */) { | ||
if (event.type === browser_core_1.DOM_EVENT.FREEZE) { | ||
return "frozen" /* PageState.FROZEN */; | ||
} | ||
else if (event.type === "pagehide" /* DOM_EVENT.PAGE_HIDE */) { | ||
else if (event.type === browser_core_1.DOM_EVENT.PAGE_HIDE) { | ||
return event.persisted ? "frozen" /* PageState.FROZEN */ : "terminated" /* PageState.TERMINATED */; | ||
@@ -80,0 +76,0 @@ } |
@@ -46,2 +46,10 @@ "use strict"; | ||
} | ||
if (!element.parentElement) { | ||
(0, browser_core_1.addTelemetryDebug)('selector from element without parent', { | ||
debug: { | ||
selector: combineSelector((0, browser_core_1.cssEscape)(element.tagName), targetElementSelector), | ||
isConnected: element.isConnected, | ||
}, | ||
}); | ||
} | ||
var uniqueSelectorAmongChildren = findSelector(element, UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS, isSelectorUniqueAmongSiblings, actionNameAttribute, targetElementSelector); | ||
@@ -48,0 +56,0 @@ targetElementSelector = |
import type { LifeCycle } from '../lifeCycle'; | ||
import type { RumSessionManager } from '../rumSessionManager'; | ||
export declare function startLongTaskCollection(lifeCycle: LifeCycle, sessionManager: RumSessionManager): void; | ||
import type { RumConfiguration } from '../configuration'; | ||
export declare function startLongTaskCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, sessionManager: RumSessionManager): void; |
@@ -6,3 +6,3 @@ "use strict"; | ||
var performanceCollection_1 = require("../../browser/performanceCollection"); | ||
function startLongTaskCollection(lifeCycle, sessionManager) { | ||
function startLongTaskCollection(lifeCycle, configuration, sessionManager) { | ||
lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) { | ||
@@ -15,3 +15,3 @@ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { | ||
var session = sessionManager.findTrackedSession(entry.startTime); | ||
if (!session || !session.longTaskAllowed) { | ||
if (!session || !configuration.trackLongTasks) { | ||
break; | ||
@@ -34,3 +34,3 @@ } | ||
startTime: startClocks.relative, | ||
domainContext: { performanceEntry: entry.toJSON() }, | ||
domainContext: { performanceEntry: entry }, | ||
}); | ||
@@ -37,0 +37,0 @@ } |
@@ -29,3 +29,3 @@ "use strict"; | ||
var tracingInfo = computeRequestTracingInfo(request, configuration); | ||
var indexingInfo = computeIndexingInfo(sessionManager, startClocks); | ||
var indexingInfo = computeIndexingInfo(configuration, sessionManager, startClocks); | ||
var duration = computeRequestDuration(pageStateHistory, startClocks, request.duration); | ||
@@ -49,3 +49,3 @@ var pageStateInfo = computePageStateInfo(pageStateHistory, startClocks, (_a = matchingTiming === null || matchingTiming === void 0 ? void 0 : matchingTiming.duration) !== null && _a !== void 0 ? _a : request.duration); | ||
domainContext: { | ||
performanceEntry: matchingTiming && toPerformanceEntryRepresentation(matchingTiming), | ||
performanceEntry: matchingTiming, | ||
xhr: request.xhr, | ||
@@ -64,3 +64,3 @@ response: request.response, | ||
var tracingInfo = computeEntryTracingInfo(entry, configuration); | ||
var indexingInfo = computeIndexingInfo(sessionManager, startClocks); | ||
var indexingInfo = computeIndexingInfo(configuration, sessionManager, startClocks); | ||
var pageStateInfo = computePageStateInfo(pageStateHistory, startClocks, entry.duration); | ||
@@ -80,3 +80,3 @@ var resourceEvent = (0, browser_core_1.combine)({ | ||
domainContext: { | ||
performanceEntry: toPerformanceEntryRepresentation(entry), | ||
performanceEntry: entry, | ||
}, | ||
@@ -118,6 +118,2 @@ }; | ||
} | ||
// TODO next major: use directly PerformanceEntry type in domain context | ||
function toPerformanceEntryRepresentation(entry) { | ||
return entry; | ||
} | ||
/** | ||
@@ -129,7 +125,7 @@ * @returns number between 0 and 1 which represents trace sample rate | ||
} | ||
function computeIndexingInfo(sessionManager, resourceStart) { | ||
function computeIndexingInfo(configuration, sessionManager, resourceStart) { | ||
var session = sessionManager.findTrackedSession(resourceStart.relative); | ||
return { | ||
_dd: { | ||
discarded: !session || !session.resourceAllowed, | ||
discarded: !session || !configuration.trackResources, | ||
}, | ||
@@ -151,6 +147,2 @@ }; | ||
var _a; | ||
// TODO remove FF in next major | ||
if (!(0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.NO_RESOURCE_DURATION_FROZEN_STATE)) { | ||
return (0, browser_core_1.toServerDuration)(duration); | ||
} | ||
var requestCrossedFrozenState = (_a = pageStateHistory | ||
@@ -157,0 +149,0 @@ .findAll(startClocks.relative, duration)) === null || _a === void 0 ? void 0 : _a.some(function (pageState) { return pageState.state === "frozen" /* PageState.FROZEN */; }); |
@@ -13,11 +13,4 @@ import type { RelativeTime } from '@datadog/browser-core'; | ||
id: string; | ||
plan: RumSessionPlan; | ||
sessionReplayAllowed: boolean; | ||
longTaskAllowed: boolean; | ||
resourceAllowed: boolean; | ||
}; | ||
export declare const enum RumSessionPlan { | ||
WITHOUT_SESSION_REPLAY = 1, | ||
WITH_SESSION_REPLAY = 2 | ||
} | ||
export declare const enum RumTrackingType { | ||
@@ -24,0 +17,0 @@ NOT_TRACKED = "0", |
@@ -22,15 +22,5 @@ "use strict"; | ||
} | ||
var plan = session.trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */ | ||
? 2 /* RumSessionPlan.WITH_SESSION_REPLAY */ | ||
: 1 /* RumSessionPlan.WITHOUT_SESSION_REPLAY */; | ||
return { | ||
id: session.id, | ||
plan: plan, | ||
sessionReplayAllowed: plan === 2 /* RumSessionPlan.WITH_SESSION_REPLAY */, | ||
longTaskAllowed: configuration.trackLongTasks !== undefined | ||
? configuration.trackLongTasks | ||
: configuration.oldPlansBehavior && plan === 2 /* RumSessionPlan.WITH_SESSION_REPLAY */, | ||
resourceAllowed: configuration.trackResources !== undefined | ||
? configuration.trackResources | ||
: configuration.oldPlansBehavior && plan === 2 /* RumSessionPlan.WITH_SESSION_REPLAY */, | ||
sessionReplayAllowed: session.trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */, | ||
}; | ||
@@ -49,6 +39,3 @@ }, | ||
id: '00000000-aaaa-0000-aaaa-000000000000', | ||
plan: 1 /* RumSessionPlan.WITHOUT_SESSION_REPLAY */, | ||
sessionReplayAllowed: false, | ||
longTaskAllowed: true, | ||
resourceAllowed: true, | ||
}; | ||
@@ -55,0 +42,0 @@ return { |
@@ -20,4 +20,4 @@ "use strict"; | ||
batchHasRumEvent = true; | ||
updateMeasure(currentBatchMeasures.globalContextBytes, !(0, browser_core_1.isEmptyObject)(globalContextManager.get()) ? globalContextManager.getBytesCount() : 0); | ||
updateMeasure(currentBatchMeasures.userContextBytes, !(0, browser_core_1.isEmptyObject)(userContextManager.get()) ? userContextManager.getBytesCount() : 0); | ||
updateMeasure(currentBatchMeasures.globalContextBytes, !(0, browser_core_1.isEmptyObject)(globalContextManager.getContext()) ? globalContextManager.getBytesCount() : 0); | ||
updateMeasure(currentBatchMeasures.userContextBytes, !(0, browser_core_1.isEmptyObject)(userContextManager.getContext()) ? userContextManager.getBytesCount() : 0); | ||
var featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(); | ||
@@ -24,0 +24,0 @@ var hasFeatureFlagContext = (0, browser_core_1.includes)(["view" /* RumEventType.VIEW */, "error" /* RumEventType.ERROR */], event.type) && |
@@ -5,3 +5,2 @@ "use strict"; | ||
var browser_core_1 = require("@datadog/browser-core"); | ||
var foregroundContexts_1 = require("../contexts/foregroundContexts"); | ||
var trackViews_1 = require("./trackViews"); | ||
@@ -19,3 +18,2 @@ function startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, initialViewOptions) { | ||
var featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(view.startClocks.relative); | ||
var pageStatesEnabled = (0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.PAGE_STATES); | ||
var pageStates = pageStateHistory.findAll(view.startClocks.relative, view.duration); | ||
@@ -26,3 +24,3 @@ var viewEvent = { | ||
replay_stats: replayStats, | ||
page_states: pageStatesEnabled ? pageStates : undefined, | ||
page_states: pageStates, | ||
}, | ||
@@ -67,3 +65,2 @@ date: view.startClocks.timeStamp, | ||
time_spent: (0, browser_core_1.toServerDuration)(view.duration), | ||
in_foreground_periods: !pageStatesEnabled && pageStates ? (0, foregroundContexts_1.mapToForegroundPeriods)(pageStates, view.duration) : undefined, // Todo: Remove in the next major release | ||
}, | ||
@@ -70,0 +67,0 @@ feature_flags: featureFlagContext && !(0, browser_core_1.isEmptyObject)(featureFlagContext) ? featureFlagContext : undefined, |
@@ -14,4 +14,4 @@ "use strict"; | ||
timeStamp = Infinity; | ||
(stopListeners = (0, browser_core_1.addEventListeners)(configuration, eventTarget, ["pagehide" /* DOM_EVENT.PAGE_HIDE */, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */], function (event) { | ||
if (event.type === "pagehide" /* DOM_EVENT.PAGE_HIDE */ || document.visibilityState === 'hidden') { | ||
(stopListeners = (0, browser_core_1.addEventListeners)(configuration, eventTarget, [browser_core_1.DOM_EVENT.PAGE_HIDE, browser_core_1.DOM_EVENT.VISIBILITY_CHANGE], function (event) { | ||
if (event.type === browser_core_1.DOM_EVENT.PAGE_HIDE || document.visibilityState === 'hidden') { | ||
timeStamp = event.timeStamp; | ||
@@ -18,0 +18,0 @@ stopListeners(); |
@@ -21,3 +21,3 @@ "use strict"; | ||
var firstInteractionTimestamp = Infinity; | ||
var stopEventListener = (0, browser_core_1.addEventListeners)(configuration, eventTarget, ["pointerdown" /* DOM_EVENT.POINTER_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */], function (event) { | ||
var stopEventListener = (0, browser_core_1.addEventListeners)(configuration, eventTarget, [browser_core_1.DOM_EVENT.POINTER_DOWN, browser_core_1.DOM_EVENT.KEY_DOWN], function (event) { | ||
firstInteractionTimestamp = event.timeStamp; | ||
@@ -24,0 +24,0 @@ }, { capture: true, once: true }).stop; |
@@ -67,3 +67,3 @@ "use strict"; | ||
resizeObserver_1.observe(observerTarget_1); | ||
var eventListener_1 = (0, browser_core_1.addEventListener)(configuration, window, "scroll" /* DOM_EVENT.SCROLL */, throttledNotify_1.throttled, { | ||
var eventListener_1 = (0, browser_core_1.addEventListener)(configuration, window, browser_core_1.DOM_EVENT.SCROLL, throttledNotify_1.throttled, { | ||
passive: true, | ||
@@ -70,0 +70,0 @@ }); |
@@ -10,6 +10,2 @@ /** | ||
export interface RumActionEventDomainContext { | ||
/** | ||
* @deprecated use events array instead | ||
*/ | ||
event?: Event; | ||
events?: Event[]; | ||
@@ -22,10 +18,10 @@ } | ||
error?: Error; | ||
performanceEntry?: PerformanceEntryRepresentation; | ||
performanceEntry?: PerformanceEntry; | ||
} | ||
export interface RumXhrResourceEventDomainContext { | ||
xhr: XMLHttpRequest; | ||
performanceEntry?: PerformanceEntryRepresentation; | ||
performanceEntry?: PerformanceEntry; | ||
} | ||
export interface RumOtherResourceEventDomainContext { | ||
performanceEntry: PerformanceEntryRepresentation; | ||
performanceEntry: PerformanceEntry; | ||
} | ||
@@ -36,9 +32,3 @@ export interface RumErrorEventDomainContext { | ||
export interface RumLongTaskEventDomainContext { | ||
performanceEntry: PerformanceEntryRepresentation; | ||
performanceEntry: PerformanceEntry; | ||
} | ||
/** | ||
* Symbolizes the type of the value returned by performanceEntry.toJSON(). Can also be built | ||
* manually to represent other kind of performance entries (ex: initial_document) or polyfilled | ||
* based on `performance.timing`. | ||
*/ | ||
export type PerformanceEntryRepresentation = Omit<PerformanceEntry, 'toJSON'>; |
@@ -9,3 +9,3 @@ export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi'; | ||
export { ViewContexts, ViewContext } from './domain/contexts/viewContexts'; | ||
export { RumSessionManager, RumSessionPlan, RumSession } from './domain/rumSessionManager'; | ||
export { RumSessionManager, RumSession } from './domain/rumSessionManager'; | ||
export { getMutationObserverConstructor } from './browser/domMutationObservable'; | ||
@@ -12,0 +12,0 @@ export { initViewportObservable, getViewportDimension } from './browser/viewportObservable'; |
import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel } from '@datadog/browser-core'; | ||
import type { PageState } from './domain/contexts/pageStateHistory'; | ||
import type { RumSessionPlan } from './domain/rumSessionManager'; | ||
export declare const enum RumEventType { | ||
@@ -93,3 +92,2 @@ ACTION = "action", | ||
frustration: Count; | ||
in_foreground_periods?: InForegroundPeriod[]; | ||
}; | ||
@@ -119,6 +117,2 @@ session: { | ||
} | ||
export interface InForegroundPeriod { | ||
start: ServerDuration; | ||
duration: ServerDuration; | ||
} | ||
export type PageStateServerEntry = { | ||
@@ -237,5 +231,2 @@ state: PageState; | ||
drift: number; | ||
session: { | ||
plan: RumSessionPlan; | ||
}; | ||
configuration: { | ||
@@ -242,0 +233,0 @@ session_sample_rate: number; |
@@ -24,13 +24,5 @@ import type { Context, InitConfiguration, User } from '@datadog/browser-core'; | ||
init: (initConfiguration: RumInitConfiguration) => void; | ||
/** @deprecated: use setGlobalContextProperty instead */ | ||
addRumGlobalContext: (key: any, value: any) => void; | ||
setGlobalContextProperty: (key: any, value: any) => void; | ||
/** @deprecated: use removeGlobalContextProperty instead */ | ||
removeRumGlobalContext: (key: any) => void; | ||
removeGlobalContextProperty: (key: any) => void; | ||
/** @deprecated: use getGlobalContext instead */ | ||
getRumGlobalContext: () => Context; | ||
getGlobalContext: () => Context; | ||
/** @deprecated: use setGlobalContext instead */ | ||
setRumGlobalContext: (context: any) => void; | ||
setGlobalContext: (context: any) => void; | ||
@@ -47,4 +39,2 @@ clearGlobalContext: () => void; | ||
removeUserProperty: (key: any) => void; | ||
/** @deprecated: renamed to clearUser */ | ||
removeUser: () => void; | ||
clearUser: () => void; | ||
@@ -51,0 +41,0 @@ startView: { |
@@ -31,2 +31,8 @@ import { noop, willSyntheticsInjectRum, assign, BoundedBuffer, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, checkUser, sanitizeUser, sanitize, createStoredContextManager, combine, } from '@datadog/browser-core'; | ||
}; | ||
var recorderStartStrategy = function () { | ||
bufferApiCalls.add(function () { return recorderStartStrategy(); }); | ||
}; | ||
var recorderStopStrategy = function () { | ||
bufferApiCalls.add(function () { return recorderStopStrategy(); }); | ||
}; | ||
var addFeatureFlagEvaluationStrategy = function (key, value) { | ||
@@ -93,5 +99,7 @@ bufferApiCalls.add(function () { return addFeatureFlagEvaluationStrategy(key, value); }); | ||
}; | ||
recorderStartStrategy = recorderApi.start; | ||
recorderStopStrategy = recorderApi.stop; | ||
(startViewStrategy = startRumResults.startView, addActionStrategy = startRumResults.addAction, addErrorStrategy = startRumResults.addError, addTimingStrategy = startRumResults.addTiming, addFeatureFlagEvaluationStrategy = startRumResults.addFeatureFlagEvaluation, getInternalContextStrategy = startRumResults.getInternalContext, stopSessionStrategy = startRumResults.stopSession); | ||
recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts); | ||
bufferApiCalls.drain(); | ||
recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts); | ||
} | ||
@@ -104,13 +112,5 @@ var startView = monitor(function (options) { | ||
init: monitor(initRum), | ||
/** @deprecated: use setGlobalContextProperty instead */ | ||
addRumGlobalContext: monitor(function (key, value) { return globalContextManager.add(key, value); }), | ||
setGlobalContextProperty: monitor(function (key, value) { return globalContextManager.setContextProperty(key, value); }), | ||
/** @deprecated: use removeGlobalContextProperty instead */ | ||
removeRumGlobalContext: monitor(function (key) { return globalContextManager.remove(key); }), | ||
removeGlobalContextProperty: monitor(function (key) { return globalContextManager.removeContextProperty(key); }), | ||
/** @deprecated: use getGlobalContext instead */ | ||
getRumGlobalContext: monitor(function () { return globalContextManager.get(); }), | ||
getGlobalContext: monitor(function () { return globalContextManager.getContext(); }), | ||
/** @deprecated: use setGlobalContext instead */ | ||
setRumGlobalContext: monitor(function (context) { return globalContextManager.set(context); }), | ||
setGlobalContext: monitor(function (context) { return globalContextManager.setContext(context); }), | ||
@@ -154,4 +154,2 @@ clearGlobalContext: monitor(function () { return globalContextManager.clearContext(); }), | ||
removeUserProperty: monitor(function (key) { return userContextManager.removeContextProperty(key); }), | ||
/** @deprecated: renamed to clearUser */ | ||
removeUser: monitor(function () { return userContextManager.clearContext(); }), | ||
clearUser: monitor(function () { return userContextManager.clearContext(); }), | ||
@@ -162,4 +160,4 @@ startView: startView, | ||
}), | ||
startSessionReplayRecording: monitor(recorderApi.start), | ||
stopSessionReplayRecording: monitor(recorderApi.stop), | ||
startSessionReplayRecording: monitor(function () { return recorderStartStrategy(); }), | ||
stopSessionReplayRecording: monitor(function () { return recorderStopStrategy(); }), | ||
/** | ||
@@ -166,0 +164,0 @@ * This feature is currently in beta. For more information see the full [feature flag tracking guide](https://docs.datadoghq.com/real_user_monitoring/feature_flag_tracking/). |
@@ -71,3 +71,3 @@ import { sendToExtension, createPageExitObservable, addTelemetryConfiguration, startTelemetry, canUseEventBridge, getEventBridge, addTelemetryDebug, } from '@datadog/browser-core'; | ||
addTelemetryConfiguration(serializeRumConfiguration(initConfiguration)); | ||
startLongTaskCollection(lifeCycle, session); | ||
startLongTaskCollection(lifeCycle, configuration, session); | ||
startResourceCollection(lifeCycle, configuration, session, pageStateHistory); | ||
@@ -74,0 +74,0 @@ var _b = startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, initialViewOptions), addTiming = _b.addTiming, startView = _b.startView, stopViewCollection = _b.stop; |
@@ -1,2 +0,2 @@ | ||
import { addEventListener, instrumentMethodAndCallOriginal, Observable, shallowClone, } from '@datadog/browser-core'; | ||
import { addEventListener, DOM_EVENT, instrumentMethodAndCallOriginal, Observable, shallowClone, } from '@datadog/browser-core'; | ||
export function createLocationChangeObservable(configuration, location) { | ||
@@ -32,3 +32,3 @@ var currentLocation = shallowClone(location); | ||
}).stop; | ||
var removeListener = addEventListener(configuration, window, "popstate" /* DOM_EVENT.POP_STATE */, onHistoryChange).stop; | ||
var removeListener = addEventListener(configuration, window, DOM_EVENT.POP_STATE, onHistoryChange).stop; | ||
return { | ||
@@ -43,4 +43,4 @@ stop: function () { | ||
function trackHash(configuration, onHashChange) { | ||
return addEventListener(configuration, window, "hashchange" /* DOM_EVENT.HASH_CHANGE */, onHashChange); | ||
return addEventListener(configuration, window, DOM_EVENT.HASH_CHANGE, onHashChange); | ||
} | ||
//# sourceMappingURL=locationChangeObservable.js.map |
import type { Duration, RelativeTime } from '@datadog/browser-core'; | ||
import type { RumConfiguration } from '../domain/configuration'; | ||
import type { LifeCycle } from '../domain/lifeCycle'; | ||
import type { PerformanceEntryRepresentation } from '../domainContext.types'; | ||
type RumPerformanceObserverConstructor = new (callback: PerformanceObserverCallback) => RumPerformanceObserver; | ||
@@ -46,9 +45,10 @@ export interface BrowserWindow extends Window { | ||
traceId?: string; | ||
toJSON(): PerformanceEntryRepresentation; | ||
toJSON(): Omit<PerformanceEntry, 'toJSON'>; | ||
} | ||
export interface RumPerformanceLongTaskTiming { | ||
name: string; | ||
entryType: RumPerformanceEntryType.LONG_TASK; | ||
startTime: RelativeTime; | ||
duration: Duration; | ||
toJSON(): PerformanceEntryRepresentation; | ||
toJSON(): Omit<PerformanceEntry, 'toJSON'>; | ||
} | ||
@@ -55,0 +55,0 @@ export interface RumPerformancePaintTiming { |
@@ -1,2 +0,2 @@ | ||
import { dateNow, assign, addEventListeners, getRelativeTime, isNumber, monitor, setTimeout, relativeNow, runOnReadyState, addEventListener, objectHasValue, } from '@datadog/browser-core'; | ||
import { dateNow, assign, addEventListeners, DOM_EVENT, getRelativeTime, isNumber, monitor, setTimeout, relativeNow, runOnReadyState, addEventListener, objectHasValue, } from '@datadog/browser-core'; | ||
import { FAKE_INITIAL_DOCUMENT, isAllowedRequestUrl } from '../domain/resource/resourceUtils'; | ||
@@ -136,3 +136,3 @@ import { getDocumentTraceId } from '../domain/tracing/getDocumentTraceId'; | ||
var timingSent = false; | ||
var removeEventListeners = addEventListeners(configuration, window, ["click" /* DOM_EVENT.CLICK */, "mousedown" /* DOM_EVENT.MOUSE_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */, "touchstart" /* DOM_EVENT.TOUCH_START */, "pointerdown" /* DOM_EVENT.POINTER_DOWN */], function (evt) { | ||
var removeEventListeners = addEventListeners(configuration, window, [DOM_EVENT.CLICK, DOM_EVENT.MOUSE_DOWN, DOM_EVENT.KEY_DOWN, DOM_EVENT.TOUCH_START, DOM_EVENT.POINTER_DOWN], function (evt) { | ||
// Only count cancelable events, which should trigger behavior important to the user. | ||
@@ -153,3 +153,3 @@ if (!evt.cancelable) { | ||
}; | ||
if (evt.type === "pointerdown" /* DOM_EVENT.POINTER_DOWN */) { | ||
if (evt.type === DOM_EVENT.POINTER_DOWN) { | ||
sendTimingIfPointerIsNotCancelled(configuration, timing); | ||
@@ -168,4 +168,4 @@ } | ||
function sendTimingIfPointerIsNotCancelled(configuration, timing) { | ||
addEventListeners(configuration, window, ["pointerup" /* DOM_EVENT.POINTER_UP */, "pointercancel" /* DOM_EVENT.POINTER_CANCEL */], function (event) { | ||
if (event.type === "pointerup" /* DOM_EVENT.POINTER_UP */) { | ||
addEventListeners(configuration, window, [DOM_EVENT.POINTER_UP, DOM_EVENT.POINTER_CANCEL], function (event) { | ||
if (event.type === DOM_EVENT.POINTER_UP) { | ||
sendTiming(timing); | ||
@@ -172,0 +172,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Observable, throttle, addEventListener } from '@datadog/browser-core'; | ||
import { Observable, throttle, addEventListener, DOM_EVENT } from '@datadog/browser-core'; | ||
var viewportObservable; | ||
@@ -14,3 +14,3 @@ export function initViewportObservable(configuration) { | ||
}, 200).throttled; | ||
return addEventListener(configuration, window, "resize" /* DOM_EVENT.RESIZE */, updateDimension, { capture: true, passive: true }) | ||
return addEventListener(configuration, window, DOM_EVENT.RESIZE, updateDimension, { capture: true, passive: true }) | ||
.stop; | ||
@@ -17,0 +17,0 @@ }); |
@@ -64,3 +64,3 @@ import { noop, assign, combine, toServerDuration, generateUUID } from '@datadog/browser-core'; | ||
startTime: action.startClocks.relative, | ||
domainContext: isAutoAction(action) ? { event: action.event, events: action.events } : {}, | ||
domainContext: isAutoAction(action) ? { events: action.events } : {}, | ||
}; | ||
@@ -67,0 +67,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { addEventListener } from '@datadog/browser-core'; | ||
import { addEventListener, DOM_EVENT } from '@datadog/browser-core'; | ||
export function listenActionEvents(configuration, _a) { | ||
@@ -11,3 +11,3 @@ var onPointerDown = _a.onPointerDown, onPointerUp = _a.onPointerUp; | ||
var listeners = [ | ||
addEventListener(configuration, window, "pointerdown" /* DOM_EVENT.POINTER_DOWN */, function (event) { | ||
addEventListener(configuration, window, DOM_EVENT.POINTER_DOWN, function (event) { | ||
if (isValidPointerEvent(event)) { | ||
@@ -22,3 +22,3 @@ selectionEmptyAtPointerDown = isSelectionEmpty(); | ||
}, { capture: true }), | ||
addEventListener(configuration, window, "selectionchange" /* DOM_EVENT.SELECTION_CHANGE */, function () { | ||
addEventListener(configuration, window, DOM_EVENT.SELECTION_CHANGE, function () { | ||
if (!selectionEmptyAtPointerDown || !isSelectionEmpty()) { | ||
@@ -28,3 +28,3 @@ userActivity.selection = true; | ||
}, { capture: true }), | ||
addEventListener(configuration, window, "pointerup" /* DOM_EVENT.POINTER_UP */, function (event) { | ||
addEventListener(configuration, window, DOM_EVENT.POINTER_UP, function (event) { | ||
if (isValidPointerEvent(event) && clickContext) { | ||
@@ -37,3 +37,3 @@ // Use a scoped variable to make sure the value is not changed by other clicks | ||
}, { capture: true }), | ||
addEventListener(configuration, window, "input" /* DOM_EVENT.INPUT */, function () { | ||
addEventListener(configuration, window, DOM_EVENT.INPUT, function () { | ||
userActivity.input = true; | ||
@@ -40,0 +40,0 @@ }, { capture: true }), |
@@ -22,3 +22,3 @@ import { includes, timeStampNow, Observable, assign, getRelativeTime, ONE_MINUTE, ValueHistory, generateUUID, clocksNow, ONE_SECOND, elapsed, } from '@datadog/browser-core'; | ||
onPointerDown: function (pointerDownEvent) { | ||
return processPointerDown(configuration, lifeCycle, domMutationObservable, history, pointerDownEvent); | ||
return processPointerDown(configuration, lifeCycle, domMutationObservable, pointerDownEvent); | ||
}, | ||
@@ -31,5 +31,3 @@ onPointerUp: function (_a, startEvent, getUserActivity) { | ||
var actionContexts = { | ||
findActionId: function (startTime) { | ||
return configuration.trackFrustrations ? history.findAll(startTime) : history.find(startTime); | ||
}, | ||
findActionId: function (startTime) { return history.findAll(startTime); }, | ||
}; | ||
@@ -58,14 +56,4 @@ return { | ||
} | ||
function processPointerDown(configuration, lifeCycle, domMutationObservable, history, pointerDownEvent) { | ||
if (!configuration.trackFrustrations && history.find()) { | ||
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any new | ||
// action if another one is already occurring. | ||
return; | ||
} | ||
function processPointerDown(configuration, lifeCycle, domMutationObservable, pointerDownEvent) { | ||
var clickActionBase = computeClickActionBase(pointerDownEvent, configuration.actionNameAttribute); | ||
if (!configuration.trackFrustrations && !clickActionBase.name) { | ||
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any action | ||
// with a blank name | ||
return; | ||
} | ||
var hadActivityOnPointerDown = false; | ||
@@ -82,5 +70,3 @@ waitPageActivityEnd(lifeCycle, domMutationObservable, configuration, function (pageActivityEndEvent) { | ||
var click = newClick(lifeCycle, history, getUserActivity, clickActionBase, startEvent); | ||
if (configuration.trackFrustrations) { | ||
appendClickToClickChain(click); | ||
} | ||
appendClickToClickChain(click); | ||
var stopWaitPageActivityEnd = waitPageActivityEnd(lifeCycle, domMutationObservable, configuration, function (pageActivityEndEvent) { | ||
@@ -104,14 +90,2 @@ if (pageActivityEndEvent.hadActivity && pageActivityEndEvent.end < click.startClocks.timeStamp) { | ||
} | ||
// Validate or discard the click only if we don't track frustrations. It'll be done when | ||
// the click chain is finalized. | ||
if (!configuration.trackFrustrations) { | ||
if (!pageActivityEndEvent.hadActivity) { | ||
// If we are not tracking frustrations, we should discard the click to keep backward | ||
// compatibility. | ||
click.discard(); | ||
} | ||
else { | ||
click.validate(); | ||
} | ||
} | ||
} | ||
@@ -118,0 +92,0 @@ }, CLICK_ACTION_MAX_DURATION).stop; |
@@ -50,5 +50,2 @@ import { combine, isEmptyObject, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, assign, round, } from '@datadog/browser-core'; | ||
drift: currentDrift(), | ||
session: { | ||
plan: session.plan, | ||
}, | ||
configuration: { | ||
@@ -58,3 +55,3 @@ session_sample_rate: round(configuration.sessionSampleRate, 3), | ||
}, | ||
browser_sdk_version: canUseEventBridge() ? "4.50.1" : undefined, | ||
browser_sdk_version: canUseEventBridge() ? "5.0.0" : undefined, | ||
}, | ||
@@ -89,2 +86,6 @@ application: { | ||
} | ||
if (serverRumEvent.type === 'view') { | ||
; | ||
serverRumEvent.session.sampled_for_replay = session.sessionReplayAllowed; | ||
} | ||
if (!isEmptyObject(commonContext.user)) { | ||
@@ -91,0 +92,0 @@ ; |
@@ -5,35 +5,16 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core'; | ||
import type { RumEvent } from '../rumEvent.types'; | ||
import type { TracingOption } from './tracing/tracer.types'; | ||
import type { PropagatorType, TracingOption } from './tracing/tracer.types'; | ||
export declare const DEFAULT_PROPAGATOR_TYPES: PropagatorType[]; | ||
export interface RumInitConfiguration extends InitConfiguration { | ||
applicationId: string; | ||
beforeSend?: ((event: RumEvent, context: RumEventDomainContext) => void | boolean) | undefined; | ||
/** | ||
* @deprecated use sessionReplaySampleRate instead | ||
*/ | ||
premiumSampleRate?: number | undefined; | ||
beforeSend?: ((event: RumEvent, context: RumEventDomainContext) => boolean) | undefined; | ||
excludedActivityUrls?: MatchOption[] | undefined; | ||
workerUrl?: string; | ||
/** | ||
* @deprecated use allowedTracingUrls instead | ||
*/ | ||
allowedTracingOrigins?: MatchOption[] | undefined; | ||
allowedTracingUrls?: Array<MatchOption | TracingOption> | undefined; | ||
/** | ||
* @deprecated use traceSampleRate instead | ||
*/ | ||
tracingSampleRate?: number | undefined; | ||
traceSampleRate?: number | undefined; | ||
defaultPrivacyLevel?: DefaultPrivacyLevel | undefined; | ||
subdomain?: string; | ||
/** | ||
* @deprecated use sessionReplaySampleRate instead | ||
*/ | ||
replaySampleRate?: number | undefined; | ||
sessionReplaySampleRate?: number | undefined; | ||
/** | ||
* @deprecated use trackUserInteractions instead | ||
*/ | ||
trackInteractions?: boolean | undefined; | ||
startSessionReplayRecordingManually?: boolean | undefined; | ||
trackUserInteractions?: boolean | undefined; | ||
trackFrustrations?: boolean | undefined; | ||
actionNameAttribute?: string | undefined; | ||
@@ -53,9 +34,8 @@ trackViewsManually?: boolean | undefined; | ||
defaultPrivacyLevel: DefaultPrivacyLevel; | ||
oldPlansBehavior: boolean; | ||
sessionReplaySampleRate: number; | ||
startSessionReplayRecordingManually: boolean; | ||
trackUserInteractions: boolean; | ||
trackFrustrations: boolean; | ||
trackViewsManually: boolean; | ||
trackResources: boolean | undefined; | ||
trackLongTasks: boolean | undefined; | ||
trackResources: boolean; | ||
trackLongTasks: boolean; | ||
version?: string; | ||
@@ -62,0 +42,0 @@ subdomain?: string; |
@@ -1,5 +0,6 @@ | ||
import { getType, arrayFrom, getOrigin, isMatchOption, serializeConfiguration, assign, DefaultPrivacyLevel, display, isPercentage, objectHasValue, validateAndBuildConfiguration, } from '@datadog/browser-core'; | ||
import { getType, arrayFrom, isMatchOption, serializeConfiguration, assign, DefaultPrivacyLevel, display, isPercentage, objectHasValue, validateAndBuildConfiguration, } from '@datadog/browser-core'; | ||
import { isTracingOption } from './tracing/tracer'; | ||
export var DEFAULT_PROPAGATOR_TYPES = ['tracecontext', 'datadog']; | ||
export function validateAndBuildRumConfiguration(initConfiguration) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b; | ||
if (!initConfiguration.applicationId) { | ||
@@ -14,14 +15,3 @@ display.error('Application ID is not configured, no RUM data will be collected.'); | ||
} | ||
// TODO remove fallback in next major | ||
var premiumSampleRate = (_a = initConfiguration.premiumSampleRate) !== null && _a !== void 0 ? _a : initConfiguration.replaySampleRate; | ||
if (premiumSampleRate !== undefined && initConfiguration.sessionReplaySampleRate !== undefined) { | ||
display.warn('Ignoring Premium Sample Rate because Session Replay Sample Rate is set'); | ||
premiumSampleRate = undefined; | ||
} | ||
if (premiumSampleRate !== undefined && !isPercentage(premiumSampleRate)) { | ||
display.error('Premium Sample Rate should be a number between 0 and 100'); | ||
return; | ||
} | ||
var traceSampleRate = (_b = initConfiguration.traceSampleRate) !== null && _b !== void 0 ? _b : initConfiguration.tracingSampleRate; | ||
if (traceSampleRate !== undefined && !isPercentage(traceSampleRate)) { | ||
if (initConfiguration.traceSampleRate !== undefined && !isPercentage(initConfiguration.traceSampleRate)) { | ||
display.error('Trace Sample Rate should be a number between 0 and 100'); | ||
@@ -42,4 +32,2 @@ return; | ||
} | ||
var trackUserInteractions = !!((_c = initConfiguration.trackUserInteractions) !== null && _c !== void 0 ? _c : initConfiguration.trackInteractions); | ||
var trackFrustrations = !!initConfiguration.trackFrustrations; | ||
return assign({ | ||
@@ -49,17 +37,16 @@ applicationId: initConfiguration.applicationId, | ||
actionNameAttribute: initConfiguration.actionNameAttribute, | ||
sessionReplaySampleRate: (_e = (_d = initConfiguration.sessionReplaySampleRate) !== null && _d !== void 0 ? _d : premiumSampleRate) !== null && _e !== void 0 ? _e : 100, | ||
oldPlansBehavior: initConfiguration.sessionReplaySampleRate === undefined, | ||
traceSampleRate: traceSampleRate, | ||
sessionReplaySampleRate: (_a = initConfiguration.sessionReplaySampleRate) !== null && _a !== void 0 ? _a : 0, | ||
startSessionReplayRecordingManually: !!initConfiguration.startSessionReplayRecordingManually, | ||
traceSampleRate: initConfiguration.traceSampleRate, | ||
allowedTracingUrls: allowedTracingUrls, | ||
excludedActivityUrls: (_f = initConfiguration.excludedActivityUrls) !== null && _f !== void 0 ? _f : [], | ||
excludedActivityUrls: (_b = initConfiguration.excludedActivityUrls) !== null && _b !== void 0 ? _b : [], | ||
workerUrl: initConfiguration.workerUrl, | ||
trackUserInteractions: trackUserInteractions || trackFrustrations, | ||
trackFrustrations: trackFrustrations, | ||
trackUserInteractions: !!initConfiguration.trackUserInteractions, | ||
trackViewsManually: !!initConfiguration.trackViewsManually, | ||
trackResources: initConfiguration.trackResources, | ||
trackLongTasks: initConfiguration.trackLongTasks, | ||
trackResources: !!initConfiguration.trackResources, | ||
trackLongTasks: !!initConfiguration.trackLongTasks, | ||
subdomain: initConfiguration.subdomain, | ||
defaultPrivacyLevel: objectHasValue(DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel) | ||
? initConfiguration.defaultPrivacyLevel | ||
: DefaultPrivacyLevel.MASK_USER_INPUT, | ||
: DefaultPrivacyLevel.MASK, | ||
customerDataTelemetrySampleRate: 1, | ||
@@ -69,10 +56,5 @@ }, baseConfiguration); | ||
/** | ||
* Handles allowedTracingUrls and processes legacy allowedTracingOrigins | ||
* Validates allowedTracingUrls and converts match options to tracing options | ||
*/ | ||
function validateAndBuildTracingOptions(initConfiguration) { | ||
// Advise about parameters precedence. | ||
if (initConfiguration.allowedTracingUrls !== undefined && initConfiguration.allowedTracingOrigins !== undefined) { | ||
display.warn('Both allowedTracingUrls and allowedTracingOrigins (deprecated) have been defined. The parameter allowedTracingUrls will override allowedTracingOrigins.'); | ||
} | ||
// Handle allowedTracingUrls first | ||
if (initConfiguration.allowedTracingUrls !== undefined) { | ||
@@ -91,3 +73,3 @@ if (!Array.isArray(initConfiguration.allowedTracingUrls)) { | ||
if (isMatchOption(option)) { | ||
tracingOptions_1.push({ match: option, propagatorTypes: ['datadog'] }); | ||
tracingOptions_1.push({ match: option, propagatorTypes: DEFAULT_PROPAGATOR_TYPES }); | ||
} | ||
@@ -103,48 +85,7 @@ else if (isTracingOption(option)) { | ||
} | ||
// Handle conversion of allowedTracingOrigins to allowedTracingUrls | ||
if (initConfiguration.allowedTracingOrigins !== undefined) { | ||
if (!Array.isArray(initConfiguration.allowedTracingOrigins)) { | ||
display.error('Allowed Tracing Origins should be an array'); | ||
return; | ||
} | ||
if (initConfiguration.allowedTracingOrigins.length !== 0 && initConfiguration.service === undefined) { | ||
display.error('Service needs to be configured when tracing is enabled'); | ||
return; | ||
} | ||
var tracingOptions_2 = []; | ||
initConfiguration.allowedTracingOrigins.forEach(function (legacyMatchOption) { | ||
var tracingOption = convertLegacyMatchOptionToTracingOption(legacyMatchOption); | ||
if (tracingOption) { | ||
tracingOptions_2.push(tracingOption); | ||
} | ||
}); | ||
return tracingOptions_2; | ||
} | ||
return []; | ||
} | ||
/** | ||
* Converts parameters from the deprecated allowedTracingOrigins | ||
* to allowedTracingUrls. Handles the change from origin to full URLs. | ||
* Combines the selected tracing propagators from the different options in allowedTracingUrls | ||
*/ | ||
function convertLegacyMatchOptionToTracingOption(item) { | ||
var match; | ||
if (typeof item === 'string') { | ||
match = item; | ||
} | ||
else if (item instanceof RegExp) { | ||
match = function (url) { return item.test(getOrigin(url)); }; | ||
} | ||
else if (typeof item === 'function') { | ||
match = function (url) { return item(getOrigin(url)); }; | ||
} | ||
if (match === undefined) { | ||
display.warn('Allowed Tracing Origins parameters should be a string, RegExp or function. Ignoring parameter', item); | ||
return undefined; | ||
} | ||
return { match: match, propagatorTypes: ['datadog'] }; | ||
} | ||
/** | ||
* Combines the selected tracing propagators from the different options in allowedTracingUrls, | ||
* and assumes 'datadog' has been selected when using allowedTracingOrigins | ||
*/ | ||
function getSelectedTracingPropagators(configuration) { | ||
@@ -155,3 +96,3 @@ var usedTracingPropagators = new Set(); | ||
if (isMatchOption(option)) { | ||
usedTracingPropagators.add('datadog'); | ||
DEFAULT_PROPAGATOR_TYPES.forEach(function (propagatorType) { return usedTracingPropagators.add(propagatorType); }); | ||
} | ||
@@ -164,17 +105,11 @@ else if (getType(option) === 'object' && Array.isArray(option.propagatorTypes)) { | ||
} | ||
if (Array.isArray(configuration.allowedTracingOrigins) && configuration.allowedTracingOrigins.length > 0) { | ||
usedTracingPropagators.add('datadog'); | ||
} | ||
return arrayFrom(usedTracingPropagators); | ||
} | ||
export function serializeRumConfiguration(configuration) { | ||
var _a, _b; | ||
var baseSerializedConfiguration = serializeConfiguration(configuration); | ||
return assign({ | ||
premium_sample_rate: configuration.premiumSampleRate, | ||
replay_sample_rate: configuration.replaySampleRate, | ||
session_replay_sample_rate: configuration.sessionReplaySampleRate, | ||
trace_sample_rate: (_a = configuration.traceSampleRate) !== null && _a !== void 0 ? _a : configuration.tracingSampleRate, | ||
start_session_replay_recording_manually: configuration.startSessionReplayRecordingManually, | ||
trace_sample_rate: configuration.traceSampleRate, | ||
action_name_attribute: configuration.actionNameAttribute, | ||
use_allowed_tracing_origins: Array.isArray(configuration.allowedTracingOrigins) && configuration.allowedTracingOrigins.length > 0, | ||
use_allowed_tracing_urls: Array.isArray(configuration.allowedTracingUrls) && configuration.allowedTracingUrls.length > 0, | ||
@@ -185,7 +120,8 @@ selected_tracing_propagators: getSelectedTracingPropagators(configuration), | ||
use_worker_url: !!configuration.workerUrl, | ||
track_frustrations: configuration.trackFrustrations, | ||
track_views_manually: configuration.trackViewsManually, | ||
track_user_interactions: (_b = configuration.trackUserInteractions) !== null && _b !== void 0 ? _b : configuration.trackInteractions, | ||
track_user_interactions: configuration.trackUserInteractions, | ||
track_resources: configuration.trackResources, | ||
track_long_task: configuration.trackLongTasks, | ||
}, baseSerializedConfiguration); | ||
} | ||
//# sourceMappingURL=configuration.js.map |
@@ -1,2 +0,2 @@ | ||
import { elapsed, ValueHistory, SESSION_TIME_OUT_DELAY, toServerDuration, addEventListeners, relativeNow, } from '@datadog/browser-core'; | ||
import { elapsed, ValueHistory, SESSION_TIME_OUT_DELAY, toServerDuration, addEventListeners, relativeNow, DOM_EVENT, } from '@datadog/browser-core'; | ||
// Arbitrary value to cap number of element for memory consumption in the browser | ||
@@ -13,15 +13,11 @@ export var MAX_PAGE_STATE_ENTRIES = 4000; | ||
var stopEventListeners = addEventListeners(configuration, window, [ | ||
"pageshow" /* DOM_EVENT.PAGE_SHOW */, | ||
"focus" /* DOM_EVENT.FOCUS */, | ||
"blur" /* DOM_EVENT.BLUR */, | ||
"visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, | ||
"resume" /* DOM_EVENT.RESUME */, | ||
"freeze" /* DOM_EVENT.FREEZE */, | ||
"pagehide" /* DOM_EVENT.PAGE_HIDE */, | ||
DOM_EVENT.PAGE_SHOW, | ||
DOM_EVENT.FOCUS, | ||
DOM_EVENT.BLUR, | ||
DOM_EVENT.VISIBILITY_CHANGE, | ||
DOM_EVENT.RESUME, | ||
DOM_EVENT.FREEZE, | ||
DOM_EVENT.PAGE_HIDE, | ||
], function (event) { | ||
// Only get events fired by the browser to avoid false currentPageState changes done with custom events | ||
// cf: developer extension auto flush: https://github.com/DataDog/browser-sdk/blob/2f72bf05a672794c9e33965351964382a94c72ba/developer-extension/src/panel/flushEvents.ts#L11-L12 | ||
if (event.isTrusted) { | ||
addPageState(computePageState(event), event.timeStamp); | ||
} | ||
addPageState(computePageState(event), event.timeStamp); | ||
}, { capture: true }).stop; | ||
@@ -70,6 +66,6 @@ function addPageState(nextPageState, startTime) { | ||
function computePageState(event) { | ||
if (event.type === "freeze" /* DOM_EVENT.FREEZE */) { | ||
if (event.type === DOM_EVENT.FREEZE) { | ||
return "frozen" /* PageState.FROZEN */; | ||
} | ||
else if (event.type === "pagehide" /* DOM_EVENT.PAGE_HIDE */) { | ||
else if (event.type === DOM_EVENT.PAGE_HIDE) { | ||
return event.persisted ? "frozen" /* PageState.FROZEN */ : "terminated" /* PageState.TERMINATED */; | ||
@@ -76,0 +72,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { cssEscape } from '@datadog/browser-core'; | ||
import { cssEscape, addTelemetryDebug } from '@datadog/browser-core'; | ||
import { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './action/getActionNameFromElement'; | ||
@@ -43,2 +43,10 @@ /** | ||
} | ||
if (!element.parentElement) { | ||
addTelemetryDebug('selector from element without parent', { | ||
debug: { | ||
selector: combineSelector(cssEscape(element.tagName), targetElementSelector), | ||
isConnected: element.isConnected, | ||
}, | ||
}); | ||
} | ||
var uniqueSelectorAmongChildren = findSelector(element, UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS, isSelectorUniqueAmongSiblings, actionNameAttribute, targetElementSelector); | ||
@@ -45,0 +53,0 @@ targetElementSelector = |
import type { LifeCycle } from '../lifeCycle'; | ||
import type { RumSessionManager } from '../rumSessionManager'; | ||
export declare function startLongTaskCollection(lifeCycle: LifeCycle, sessionManager: RumSessionManager): void; | ||
import type { RumConfiguration } from '../configuration'; | ||
export declare function startLongTaskCollection(lifeCycle: LifeCycle, configuration: RumConfiguration, sessionManager: RumSessionManager): void; |
import { toServerDuration, relativeToClocks, generateUUID } from '@datadog/browser-core'; | ||
import { RumPerformanceEntryType } from '../../browser/performanceCollection'; | ||
export function startLongTaskCollection(lifeCycle, sessionManager) { | ||
export function startLongTaskCollection(lifeCycle, configuration, sessionManager) { | ||
lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) { | ||
@@ -11,3 +11,3 @@ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { | ||
var session = sessionManager.findTrackedSession(entry.startTime); | ||
if (!session || !session.longTaskAllowed) { | ||
if (!session || !configuration.trackLongTasks) { | ||
break; | ||
@@ -30,3 +30,3 @@ } | ||
startTime: startClocks.relative, | ||
domainContext: { performanceEntry: entry.toJSON() }, | ||
domainContext: { performanceEntry: entry }, | ||
}); | ||
@@ -33,0 +33,0 @@ } |
@@ -25,3 +25,3 @@ import { combine, generateUUID, toServerDuration, relativeToClocks, assign, isNumber, isExperimentalFeatureEnabled, ExperimentalFeature, } from '@datadog/browser-core'; | ||
var tracingInfo = computeRequestTracingInfo(request, configuration); | ||
var indexingInfo = computeIndexingInfo(sessionManager, startClocks); | ||
var indexingInfo = computeIndexingInfo(configuration, sessionManager, startClocks); | ||
var duration = computeRequestDuration(pageStateHistory, startClocks, request.duration); | ||
@@ -45,3 +45,3 @@ var pageStateInfo = computePageStateInfo(pageStateHistory, startClocks, (_a = matchingTiming === null || matchingTiming === void 0 ? void 0 : matchingTiming.duration) !== null && _a !== void 0 ? _a : request.duration); | ||
domainContext: { | ||
performanceEntry: matchingTiming && toPerformanceEntryRepresentation(matchingTiming), | ||
performanceEntry: matchingTiming, | ||
xhr: request.xhr, | ||
@@ -60,3 +60,3 @@ response: request.response, | ||
var tracingInfo = computeEntryTracingInfo(entry, configuration); | ||
var indexingInfo = computeIndexingInfo(sessionManager, startClocks); | ||
var indexingInfo = computeIndexingInfo(configuration, sessionManager, startClocks); | ||
var pageStateInfo = computePageStateInfo(pageStateHistory, startClocks, entry.duration); | ||
@@ -76,3 +76,3 @@ var resourceEvent = combine({ | ||
domainContext: { | ||
performanceEntry: toPerformanceEntryRepresentation(entry), | ||
performanceEntry: entry, | ||
}, | ||
@@ -114,6 +114,2 @@ }; | ||
} | ||
// TODO next major: use directly PerformanceEntry type in domain context | ||
function toPerformanceEntryRepresentation(entry) { | ||
return entry; | ||
} | ||
/** | ||
@@ -125,7 +121,7 @@ * @returns number between 0 and 1 which represents trace sample rate | ||
} | ||
function computeIndexingInfo(sessionManager, resourceStart) { | ||
function computeIndexingInfo(configuration, sessionManager, resourceStart) { | ||
var session = sessionManager.findTrackedSession(resourceStart.relative); | ||
return { | ||
_dd: { | ||
discarded: !session || !session.resourceAllowed, | ||
discarded: !session || !configuration.trackResources, | ||
}, | ||
@@ -147,6 +143,2 @@ }; | ||
var _a; | ||
// TODO remove FF in next major | ||
if (!isExperimentalFeatureEnabled(ExperimentalFeature.NO_RESOURCE_DURATION_FROZEN_STATE)) { | ||
return toServerDuration(duration); | ||
} | ||
var requestCrossedFrozenState = (_a = pageStateHistory | ||
@@ -153,0 +145,0 @@ .findAll(startClocks.relative, duration)) === null || _a === void 0 ? void 0 : _a.some(function (pageState) { return pageState.state === "frozen" /* PageState.FROZEN */; }); |
@@ -13,11 +13,4 @@ import type { RelativeTime } from '@datadog/browser-core'; | ||
id: string; | ||
plan: RumSessionPlan; | ||
sessionReplayAllowed: boolean; | ||
longTaskAllowed: boolean; | ||
resourceAllowed: boolean; | ||
}; | ||
export declare const enum RumSessionPlan { | ||
WITHOUT_SESSION_REPLAY = 1, | ||
WITH_SESSION_REPLAY = 2 | ||
} | ||
export declare const enum RumTrackingType { | ||
@@ -24,0 +17,0 @@ NOT_TRACKED = "0", |
@@ -19,15 +19,5 @@ import { Observable, noop, performDraw, startSessionManager } from '@datadog/browser-core'; | ||
} | ||
var plan = session.trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */ | ||
? 2 /* RumSessionPlan.WITH_SESSION_REPLAY */ | ||
: 1 /* RumSessionPlan.WITHOUT_SESSION_REPLAY */; | ||
return { | ||
id: session.id, | ||
plan: plan, | ||
sessionReplayAllowed: plan === 2 /* RumSessionPlan.WITH_SESSION_REPLAY */, | ||
longTaskAllowed: configuration.trackLongTasks !== undefined | ||
? configuration.trackLongTasks | ||
: configuration.oldPlansBehavior && plan === 2 /* RumSessionPlan.WITH_SESSION_REPLAY */, | ||
resourceAllowed: configuration.trackResources !== undefined | ||
? configuration.trackResources | ||
: configuration.oldPlansBehavior && plan === 2 /* RumSessionPlan.WITH_SESSION_REPLAY */, | ||
sessionReplayAllowed: session.trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */, | ||
}; | ||
@@ -45,6 +35,3 @@ }, | ||
id: '00000000-aaaa-0000-aaaa-000000000000', | ||
plan: 1 /* RumSessionPlan.WITHOUT_SESSION_REPLAY */, | ||
sessionReplayAllowed: false, | ||
longTaskAllowed: true, | ||
resourceAllowed: true, | ||
}; | ||
@@ -51,0 +38,0 @@ return { |
@@ -17,4 +17,4 @@ import { isEmptyObject, includes, performDraw, ONE_SECOND, addTelemetryDebug, setInterval } from '@datadog/browser-core'; | ||
batchHasRumEvent = true; | ||
updateMeasure(currentBatchMeasures.globalContextBytes, !isEmptyObject(globalContextManager.get()) ? globalContextManager.getBytesCount() : 0); | ||
updateMeasure(currentBatchMeasures.userContextBytes, !isEmptyObject(userContextManager.get()) ? userContextManager.getBytesCount() : 0); | ||
updateMeasure(currentBatchMeasures.globalContextBytes, !isEmptyObject(globalContextManager.getContext()) ? globalContextManager.getBytesCount() : 0); | ||
updateMeasure(currentBatchMeasures.userContextBytes, !isEmptyObject(userContextManager.getContext()) ? userContextManager.getBytesCount() : 0); | ||
var featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(); | ||
@@ -21,0 +21,0 @@ var hasFeatureFlagContext = includes(["view" /* RumEventType.VIEW */, "error" /* RumEventType.ERROR */], event.type) && |
@@ -1,3 +0,2 @@ | ||
import { isExperimentalFeatureEnabled, ExperimentalFeature, isEmptyObject, mapValues, toServerDuration, isNumber, } from '@datadog/browser-core'; | ||
import { mapToForegroundPeriods } from '../contexts/foregroundContexts'; | ||
import { isEmptyObject, mapValues, toServerDuration, isNumber } from '@datadog/browser-core'; | ||
import { trackViews } from './trackViews'; | ||
@@ -14,3 +13,2 @@ export function startViewCollection(lifeCycle, configuration, location, domMutationObservable, locationChangeObservable, featureFlagContexts, pageStateHistory, recorderApi, initialViewOptions) { | ||
var featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(view.startClocks.relative); | ||
var pageStatesEnabled = isExperimentalFeatureEnabled(ExperimentalFeature.PAGE_STATES); | ||
var pageStates = pageStateHistory.findAll(view.startClocks.relative, view.duration); | ||
@@ -21,3 +19,3 @@ var viewEvent = { | ||
replay_stats: replayStats, | ||
page_states: pageStatesEnabled ? pageStates : undefined, | ||
page_states: pageStates, | ||
}, | ||
@@ -62,3 +60,2 @@ date: view.startClocks.timeStamp, | ||
time_spent: toServerDuration(view.duration), | ||
in_foreground_periods: !pageStatesEnabled && pageStates ? mapToForegroundPeriods(pageStates, view.duration) : undefined, // Todo: Remove in the next major release | ||
}, | ||
@@ -65,0 +62,0 @@ feature_flags: featureFlagContext && !isEmptyObject(featureFlagContext) ? featureFlagContext : undefined, |
@@ -1,2 +0,2 @@ | ||
import { addEventListeners } from '@datadog/browser-core'; | ||
import { addEventListeners, DOM_EVENT } from '@datadog/browser-core'; | ||
export function trackFirstHidden(configuration, eventTarget) { | ||
@@ -11,4 +11,4 @@ if (eventTarget === void 0) { eventTarget = window; } | ||
timeStamp = Infinity; | ||
(stopListeners = addEventListeners(configuration, eventTarget, ["pagehide" /* DOM_EVENT.PAGE_HIDE */, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */], function (event) { | ||
if (event.type === "pagehide" /* DOM_EVENT.PAGE_HIDE */ || document.visibilityState === 'hidden') { | ||
(stopListeners = addEventListeners(configuration, eventTarget, [DOM_EVENT.PAGE_HIDE, DOM_EVENT.VISIBILITY_CHANGE], function (event) { | ||
if (event.type === DOM_EVENT.PAGE_HIDE || document.visibilityState === 'hidden') { | ||
timeStamp = event.timeStamp; | ||
@@ -15,0 +15,0 @@ stopListeners(); |
@@ -1,2 +0,2 @@ | ||
import { ExperimentalFeature, ONE_MINUTE, addEventListeners, findLast, isExperimentalFeatureEnabled, } from '@datadog/browser-core'; | ||
import { DOM_EVENT, ExperimentalFeature, ONE_MINUTE, addEventListeners, findLast, isExperimentalFeatureEnabled, } from '@datadog/browser-core'; | ||
import { RumPerformanceEntryType } from '../../../browser/performanceCollection'; | ||
@@ -18,3 +18,3 @@ import { getSelectorFromElement } from '../../getSelectorFromElement'; | ||
var firstInteractionTimestamp = Infinity; | ||
var stopEventListener = addEventListeners(configuration, eventTarget, ["pointerdown" /* DOM_EVENT.POINTER_DOWN */, "keydown" /* DOM_EVENT.KEY_DOWN */], function (event) { | ||
var stopEventListener = addEventListeners(configuration, eventTarget, [DOM_EVENT.POINTER_DOWN, DOM_EVENT.KEY_DOWN], function (event) { | ||
firstInteractionTimestamp = event.timeStamp; | ||
@@ -21,0 +21,0 @@ }, { capture: true, once: true }).stop; |
@@ -1,2 +0,2 @@ | ||
import { Observable, ONE_SECOND, elapsed, relativeNow, throttle, addEventListener, monitor, } from '@datadog/browser-core'; | ||
import { Observable, ONE_SECOND, elapsed, relativeNow, throttle, addEventListener, DOM_EVENT, monitor, } from '@datadog/browser-core'; | ||
import { getScrollY } from '../../../browser/scroll'; | ||
@@ -62,3 +62,3 @@ import { getViewportDimension } from '../../../browser/viewportObservable'; | ||
resizeObserver_1.observe(observerTarget_1); | ||
var eventListener_1 = addEventListener(configuration, window, "scroll" /* DOM_EVENT.SCROLL */, throttledNotify_1.throttled, { | ||
var eventListener_1 = addEventListener(configuration, window, DOM_EVENT.SCROLL, throttledNotify_1.throttled, { | ||
passive: true, | ||
@@ -65,0 +65,0 @@ }); |
@@ -10,6 +10,2 @@ /** | ||
export interface RumActionEventDomainContext { | ||
/** | ||
* @deprecated use events array instead | ||
*/ | ||
event?: Event; | ||
events?: Event[]; | ||
@@ -22,10 +18,10 @@ } | ||
error?: Error; | ||
performanceEntry?: PerformanceEntryRepresentation; | ||
performanceEntry?: PerformanceEntry; | ||
} | ||
export interface RumXhrResourceEventDomainContext { | ||
xhr: XMLHttpRequest; | ||
performanceEntry?: PerformanceEntryRepresentation; | ||
performanceEntry?: PerformanceEntry; | ||
} | ||
export interface RumOtherResourceEventDomainContext { | ||
performanceEntry: PerformanceEntryRepresentation; | ||
performanceEntry: PerformanceEntry; | ||
} | ||
@@ -36,9 +32,3 @@ export interface RumErrorEventDomainContext { | ||
export interface RumLongTaskEventDomainContext { | ||
performanceEntry: PerformanceEntryRepresentation; | ||
performanceEntry: PerformanceEntry; | ||
} | ||
/** | ||
* Symbolizes the type of the value returned by performanceEntry.toJSON(). Can also be built | ||
* manually to represent other kind of performance entries (ex: initial_document) or polyfilled | ||
* based on `performance.timing`. | ||
*/ | ||
export type PerformanceEntryRepresentation = Omit<PerformanceEntry, 'toJSON'>; |
@@ -9,3 +9,3 @@ export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi'; | ||
export { ViewContexts, ViewContext } from './domain/contexts/viewContexts'; | ||
export { RumSessionManager, RumSessionPlan, RumSession } from './domain/rumSessionManager'; | ||
export { RumSessionManager, RumSession } from './domain/rumSessionManager'; | ||
export { getMutationObserverConstructor } from './browser/domMutationObservable'; | ||
@@ -12,0 +12,0 @@ export { initViewportObservable, getViewportDimension } from './browser/viewportObservable'; |
import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel } from '@datadog/browser-core'; | ||
import type { PageState } from './domain/contexts/pageStateHistory'; | ||
import type { RumSessionPlan } from './domain/rumSessionManager'; | ||
export declare const enum RumEventType { | ||
@@ -93,3 +92,2 @@ ACTION = "action", | ||
frustration: Count; | ||
in_foreground_periods?: InForegroundPeriod[]; | ||
}; | ||
@@ -119,6 +117,2 @@ session: { | ||
} | ||
export interface InForegroundPeriod { | ||
start: ServerDuration; | ||
duration: ServerDuration; | ||
} | ||
export type PageStateServerEntry = { | ||
@@ -237,5 +231,2 @@ state: PageState; | ||
drift: number; | ||
session: { | ||
plan: RumSessionPlan; | ||
}; | ||
configuration: { | ||
@@ -242,0 +233,0 @@ session_sample_rate: number; |
{ | ||
"name": "@datadog/browser-rum-core", | ||
"version": "4.50.1", | ||
"version": "5.0.0", | ||
"license": "Apache-2.0", | ||
@@ -15,3 +15,3 @@ "main": "cjs/index.js", | ||
"dependencies": { | ||
"@datadog/browser-core": "4.50.1" | ||
"@datadog/browser-core": "5.0.0" | ||
}, | ||
@@ -32,3 +32,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "2f7a2b0b88ec8e9b5ffef9bdb7f8ace9b97ccafc" | ||
"gitHead": "31b6e0946955b78ce0f8f090efb3d7dd11ff8f3f" | ||
} |
@@ -99,2 +99,10 @@ import type { Context, InitConfiguration, TimeStamp, RelativeTime, User } from '@datadog/browser-core' | ||
let recorderStartStrategy: typeof recorderApi.start = () => { | ||
bufferApiCalls.add(() => recorderStartStrategy()) | ||
} | ||
let recorderStopStrategy: typeof recorderApi.stop = () => { | ||
bufferApiCalls.add(() => recorderStopStrategy()) | ||
} | ||
let addFeatureFlagEvaluationStrategy: StartRumResult['addFeatureFlagEvaluation'] = (key: string, value: any) => { | ||
@@ -182,2 +190,4 @@ bufferApiCalls.add(() => addFeatureFlagEvaluationStrategy(key, value)) | ||
recorderApi.getSessionReplayLink(configuration, startRumResults.session, startRumResults.viewContexts) | ||
recorderStartStrategy = recorderApi.start | ||
recorderStopStrategy = recorderApi.stop | ||
;({ | ||
@@ -192,3 +202,2 @@ startView: startViewStrategy, | ||
} = startRumResults) | ||
bufferApiCalls.drain() | ||
@@ -201,2 +210,3 @@ recorderApi.onRumStart( | ||
) | ||
bufferApiCalls.drain() | ||
} | ||
@@ -215,16 +225,8 @@ | ||
/** @deprecated: use setGlobalContextProperty instead */ | ||
addRumGlobalContext: monitor((key, value) => globalContextManager.add(key, value)), | ||
setGlobalContextProperty: monitor((key, value) => globalContextManager.setContextProperty(key, value)), | ||
/** @deprecated: use removeGlobalContextProperty instead */ | ||
removeRumGlobalContext: monitor((key) => globalContextManager.remove(key)), | ||
removeGlobalContextProperty: monitor((key) => globalContextManager.removeContextProperty(key)), | ||
/** @deprecated: use getGlobalContext instead */ | ||
getRumGlobalContext: monitor(() => globalContextManager.get()), | ||
getGlobalContext: monitor(() => globalContextManager.getContext()), | ||
/** @deprecated: use setGlobalContext instead */ | ||
setRumGlobalContext: monitor((context) => globalContextManager.set(context)), | ||
setGlobalContext: monitor((context) => globalContextManager.setContext(context)), | ||
@@ -277,4 +279,2 @@ | ||
/** @deprecated: renamed to clearUser */ | ||
removeUser: monitor(() => userContextManager.clearContext()), | ||
clearUser: monitor(() => userContextManager.clearContext()), | ||
@@ -288,4 +288,4 @@ | ||
startSessionReplayRecording: monitor(recorderApi.start), | ||
stopSessionReplayRecording: monitor(recorderApi.stop), | ||
startSessionReplayRecording: monitor(() => recorderStartStrategy()), | ||
stopSessionReplayRecording: monitor(() => recorderStopStrategy()), | ||
@@ -292,0 +292,0 @@ /** |
@@ -131,3 +131,3 @@ import type { Observable, TelemetryEvent, RawError, ContextManager } from '@datadog/browser-core' | ||
startLongTaskCollection(lifeCycle, session) | ||
startLongTaskCollection(lifeCycle, configuration, session) | ||
startResourceCollection(lifeCycle, configuration, session, pageStateHistory) | ||
@@ -134,0 +134,0 @@ |
@@ -23,3 +23,2 @@ import type { Duration, RelativeTime, TimeStamp } from '@datadog/browser-core' | ||
import { getDocumentTraceId } from '../domain/tracing/getDocumentTraceId' | ||
import type { PerformanceEntryRepresentation } from '../domainContext.types' | ||
@@ -70,10 +69,11 @@ type RumPerformanceObserverConstructor = new (callback: PerformanceObserverCallback) => RumPerformanceObserver | ||
traceId?: string | ||
toJSON(): PerformanceEntryRepresentation | ||
toJSON(): Omit<PerformanceEntry, 'toJSON'> | ||
} | ||
export interface RumPerformanceLongTaskTiming { | ||
name: string | ||
entryType: RumPerformanceEntryType.LONG_TASK | ||
startTime: RelativeTime | ||
duration: Duration | ||
toJSON(): PerformanceEntryRepresentation | ||
toJSON(): Omit<PerformanceEntry, 'toJSON'> | ||
} | ||
@@ -246,3 +246,3 @@ | ||
const navigationEntry = performance.getEntriesByType(RumPerformanceEntryType.NAVIGATION)[0] | ||
timing = assign(navigationEntry.toJSON(), forcedAttributes) | ||
timing = assign(navigationEntry.toJSON() as RumPerformanceResourceTiming, forcedAttributes) | ||
} else { | ||
@@ -249,0 +249,0 @@ const relativePerformanceTiming = computeRelativePerformanceTiming() |
@@ -107,3 +107,3 @@ import type { ClocksState, Context, Observable } from '@datadog/browser-core' | ||
startTime: action.startClocks.relative, | ||
domainContext: isAutoAction(action) ? { event: action.event, events: action.events } : {}, | ||
domainContext: isAutoAction(action) ? { events: action.events } : {}, | ||
} | ||
@@ -110,0 +110,0 @@ } |
@@ -85,3 +85,3 @@ import type { Duration, ClocksState, RelativeTime, TimeStamp } from '@datadog/browser-core' | ||
onPointerDown: (pointerDownEvent) => | ||
processPointerDown(configuration, lifeCycle, domMutationObservable, history, pointerDownEvent), | ||
processPointerDown(configuration, lifeCycle, domMutationObservable, pointerDownEvent), | ||
onPointerUp: ({ clickActionBase, hadActivityOnPointerDown }, startEvent, getUserActivity) => | ||
@@ -103,4 +103,3 @@ startClickAction( | ||
const actionContexts: ActionContexts = { | ||
findActionId: (startTime?: RelativeTime) => | ||
configuration.trackFrustrations ? history.findAll(startTime) : history.find(startTime), | ||
findActionId: (startTime?: RelativeTime) => history.findAll(startTime), | ||
} | ||
@@ -137,17 +136,5 @@ | ||
domMutationObservable: Observable<void>, | ||
history: ClickActionIdHistory, | ||
pointerDownEvent: MouseEventOnElement | ||
) { | ||
if (!configuration.trackFrustrations && history.find()) { | ||
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any new | ||
// action if another one is already occurring. | ||
return | ||
} | ||
const clickActionBase = computeClickActionBase(pointerDownEvent, configuration.actionNameAttribute) | ||
if (!configuration.trackFrustrations && !clickActionBase.name) { | ||
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any action | ||
// with a blank name | ||
return | ||
} | ||
@@ -184,7 +171,4 @@ let hadActivityOnPointerDown = false | ||
const click = newClick(lifeCycle, history, getUserActivity, clickActionBase, startEvent) | ||
appendClickToClickChain(click) | ||
if (configuration.trackFrustrations) { | ||
appendClickToClickChain(click) | ||
} | ||
const { stop: stopWaitPageActivityEnd } = waitPageActivityEnd( | ||
@@ -210,14 +194,2 @@ lifeCycle, | ||
} | ||
// Validate or discard the click only if we don't track frustrations. It'll be done when | ||
// the click chain is finalized. | ||
if (!configuration.trackFrustrations) { | ||
if (!pageActivityEndEvent.hadActivity) { | ||
// If we are not tracking frustrations, we should discard the click to keep backward | ||
// compatibility. | ||
click.discard() | ||
} else { | ||
click.validate() | ||
} | ||
} | ||
} | ||
@@ -224,0 +196,0 @@ }, |
@@ -129,5 +129,2 @@ import type { Context, RawError, EventRateLimiter, User } from '@datadog/browser-core' | ||
drift: currentDrift(), | ||
session: { | ||
plan: session.plan, | ||
}, | ||
configuration: { | ||
@@ -168,2 +165,5 @@ session_sample_rate: round(configuration.sessionSampleRate, 3), | ||
} | ||
if (serverRumEvent.type === 'view') { | ||
;(serverRumEvent.session as Mutable<RumEvent['session']>).sampled_for_replay = session.sessionReplayAllowed | ||
} | ||
@@ -170,0 +170,0 @@ if (!isEmptyObject(commonContext.user)) { |
@@ -5,3 +5,2 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core' | ||
arrayFrom, | ||
getOrigin, | ||
isMatchOption, | ||
@@ -21,10 +20,8 @@ serializeConfiguration, | ||
export const DEFAULT_PROPAGATOR_TYPES: PropagatorType[] = ['tracecontext', 'datadog'] | ||
export interface RumInitConfiguration extends InitConfiguration { | ||
// global options | ||
applicationId: string | ||
beforeSend?: ((event: RumEvent, context: RumEventDomainContext) => void | boolean) | undefined | ||
/** | ||
* @deprecated use sessionReplaySampleRate instead | ||
*/ | ||
premiumSampleRate?: number | undefined | ||
beforeSend?: ((event: RumEvent, context: RumEventDomainContext) => boolean) | undefined | ||
excludedActivityUrls?: MatchOption[] | undefined | ||
@@ -34,11 +31,3 @@ workerUrl?: string | ||
// tracing options | ||
/** | ||
* @deprecated use allowedTracingUrls instead | ||
*/ | ||
allowedTracingOrigins?: MatchOption[] | undefined | ||
allowedTracingUrls?: Array<MatchOption | TracingOption> | undefined | ||
/** | ||
* @deprecated use traceSampleRate instead | ||
*/ | ||
tracingSampleRate?: number | undefined | ||
traceSampleRate?: number | undefined | ||
@@ -49,15 +38,7 @@ | ||
subdomain?: string | ||
/** | ||
* @deprecated use sessionReplaySampleRate instead | ||
*/ | ||
replaySampleRate?: number | undefined | ||
sessionReplaySampleRate?: number | undefined | ||
startSessionReplayRecordingManually?: boolean | undefined | ||
// action options | ||
/** | ||
* @deprecated use trackUserInteractions instead | ||
*/ | ||
trackInteractions?: boolean | undefined | ||
trackUserInteractions?: boolean | undefined | ||
trackFrustrations?: boolean | undefined | ||
actionNameAttribute?: string | undefined | ||
@@ -83,9 +64,8 @@ | ||
defaultPrivacyLevel: DefaultPrivacyLevel | ||
oldPlansBehavior: boolean | ||
sessionReplaySampleRate: number | ||
startSessionReplayRecordingManually: boolean | ||
trackUserInteractions: boolean | ||
trackFrustrations: boolean | ||
trackViewsManually: boolean | ||
trackResources: boolean | undefined | ||
trackLongTasks: boolean | undefined | ||
trackResources: boolean | ||
trackLongTasks: boolean | ||
version?: string | ||
@@ -112,16 +92,3 @@ subdomain?: string | ||
// TODO remove fallback in next major | ||
let premiumSampleRate = initConfiguration.premiumSampleRate ?? initConfiguration.replaySampleRate | ||
if (premiumSampleRate !== undefined && initConfiguration.sessionReplaySampleRate !== undefined) { | ||
display.warn('Ignoring Premium Sample Rate because Session Replay Sample Rate is set') | ||
premiumSampleRate = undefined | ||
} | ||
if (premiumSampleRate !== undefined && !isPercentage(premiumSampleRate)) { | ||
display.error('Premium Sample Rate should be a number between 0 and 100') | ||
return | ||
} | ||
const traceSampleRate = initConfiguration.traceSampleRate ?? initConfiguration.tracingSampleRate | ||
if (traceSampleRate !== undefined && !isPercentage(traceSampleRate)) { | ||
if (initConfiguration.traceSampleRate !== undefined && !isPercentage(initConfiguration.traceSampleRate)) { | ||
display.error('Trace Sample Rate should be a number between 0 and 100') | ||
@@ -146,5 +113,2 @@ return | ||
const trackUserInteractions = !!(initConfiguration.trackUserInteractions ?? initConfiguration.trackInteractions) | ||
const trackFrustrations = !!initConfiguration.trackFrustrations | ||
return assign( | ||
@@ -155,17 +119,16 @@ { | ||
actionNameAttribute: initConfiguration.actionNameAttribute, | ||
sessionReplaySampleRate: initConfiguration.sessionReplaySampleRate ?? premiumSampleRate ?? 100, | ||
oldPlansBehavior: initConfiguration.sessionReplaySampleRate === undefined, | ||
traceSampleRate, | ||
sessionReplaySampleRate: initConfiguration.sessionReplaySampleRate ?? 0, | ||
startSessionReplayRecordingManually: !!initConfiguration.startSessionReplayRecordingManually, | ||
traceSampleRate: initConfiguration.traceSampleRate, | ||
allowedTracingUrls, | ||
excludedActivityUrls: initConfiguration.excludedActivityUrls ?? [], | ||
workerUrl: initConfiguration.workerUrl, | ||
trackUserInteractions: trackUserInteractions || trackFrustrations, | ||
trackFrustrations, | ||
trackUserInteractions: !!initConfiguration.trackUserInteractions, | ||
trackViewsManually: !!initConfiguration.trackViewsManually, | ||
trackResources: initConfiguration.trackResources, | ||
trackLongTasks: initConfiguration.trackLongTasks, | ||
trackResources: !!initConfiguration.trackResources, | ||
trackLongTasks: !!initConfiguration.trackLongTasks, | ||
subdomain: initConfiguration.subdomain, | ||
defaultPrivacyLevel: objectHasValue(DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel) | ||
? initConfiguration.defaultPrivacyLevel | ||
: DefaultPrivacyLevel.MASK_USER_INPUT, | ||
: DefaultPrivacyLevel.MASK, | ||
customerDataTelemetrySampleRate: 1, | ||
@@ -178,12 +141,5 @@ }, | ||
/** | ||
* Handles allowedTracingUrls and processes legacy allowedTracingOrigins | ||
* Validates allowedTracingUrls and converts match options to tracing options | ||
*/ | ||
function validateAndBuildTracingOptions(initConfiguration: RumInitConfiguration): TracingOption[] | undefined { | ||
// Advise about parameters precedence. | ||
if (initConfiguration.allowedTracingUrls !== undefined && initConfiguration.allowedTracingOrigins !== undefined) { | ||
display.warn( | ||
'Both allowedTracingUrls and allowedTracingOrigins (deprecated) have been defined. The parameter allowedTracingUrls will override allowedTracingOrigins.' | ||
) | ||
} | ||
// Handle allowedTracingUrls first | ||
if (initConfiguration.allowedTracingUrls !== undefined) { | ||
@@ -202,3 +158,3 @@ if (!Array.isArray(initConfiguration.allowedTracingUrls)) { | ||
if (isMatchOption(option)) { | ||
tracingOptions.push({ match: option, propagatorTypes: ['datadog'] }) | ||
tracingOptions.push({ match: option, propagatorTypes: DEFAULT_PROPAGATOR_TYPES }) | ||
} else if (isTracingOption(option)) { | ||
@@ -217,23 +173,2 @@ tracingOptions.push(option) | ||
// Handle conversion of allowedTracingOrigins to allowedTracingUrls | ||
if (initConfiguration.allowedTracingOrigins !== undefined) { | ||
if (!Array.isArray(initConfiguration.allowedTracingOrigins)) { | ||
display.error('Allowed Tracing Origins should be an array') | ||
return | ||
} | ||
if (initConfiguration.allowedTracingOrigins.length !== 0 && initConfiguration.service === undefined) { | ||
display.error('Service needs to be configured when tracing is enabled') | ||
return | ||
} | ||
const tracingOptions: TracingOption[] = [] | ||
initConfiguration.allowedTracingOrigins.forEach((legacyMatchOption) => { | ||
const tracingOption = convertLegacyMatchOptionToTracingOption(legacyMatchOption) | ||
if (tracingOption) { | ||
tracingOptions.push(tracingOption) | ||
} | ||
}) | ||
return tracingOptions | ||
} | ||
return [] | ||
@@ -243,27 +178,4 @@ } | ||
/** | ||
* Converts parameters from the deprecated allowedTracingOrigins | ||
* to allowedTracingUrls. Handles the change from origin to full URLs. | ||
* Combines the selected tracing propagators from the different options in allowedTracingUrls | ||
*/ | ||
function convertLegacyMatchOptionToTracingOption(item: MatchOption): TracingOption | undefined { | ||
let match: MatchOption | undefined | ||
if (typeof item === 'string') { | ||
match = item | ||
} else if (item instanceof RegExp) { | ||
match = (url) => item.test(getOrigin(url)) | ||
} else if (typeof item === 'function') { | ||
match = (url) => item(getOrigin(url)) | ||
} | ||
if (match === undefined) { | ||
display.warn('Allowed Tracing Origins parameters should be a string, RegExp or function. Ignoring parameter', item) | ||
return undefined | ||
} | ||
return { match, propagatorTypes: ['datadog'] } | ||
} | ||
/** | ||
* Combines the selected tracing propagators from the different options in allowedTracingUrls, | ||
* and assumes 'datadog' has been selected when using allowedTracingOrigins | ||
*/ | ||
function getSelectedTracingPropagators(configuration: RumInitConfiguration): PropagatorType[] { | ||
@@ -275,3 +187,3 @@ const usedTracingPropagators = new Set<PropagatorType>() | ||
if (isMatchOption(option)) { | ||
usedTracingPropagators.add('datadog') | ||
DEFAULT_PROPAGATOR_TYPES.forEach((propagatorType) => usedTracingPropagators.add(propagatorType)) | ||
} else if (getType(option) === 'object' && Array.isArray(option.propagatorTypes)) { | ||
@@ -284,6 +196,2 @@ // Ensure we have an array, as we cannot rely on types yet (configuration is provided by users) | ||
if (Array.isArray(configuration.allowedTracingOrigins) && configuration.allowedTracingOrigins.length > 0) { | ||
usedTracingPropagators.add('datadog') | ||
} | ||
return arrayFrom(usedTracingPropagators) | ||
@@ -297,9 +205,6 @@ } | ||
{ | ||
premium_sample_rate: configuration.premiumSampleRate, | ||
replay_sample_rate: configuration.replaySampleRate, | ||
session_replay_sample_rate: configuration.sessionReplaySampleRate, | ||
trace_sample_rate: configuration.traceSampleRate ?? configuration.tracingSampleRate, | ||
start_session_replay_recording_manually: configuration.startSessionReplayRecordingManually, | ||
trace_sample_rate: configuration.traceSampleRate, | ||
action_name_attribute: configuration.actionNameAttribute, | ||
use_allowed_tracing_origins: | ||
Array.isArray(configuration.allowedTracingOrigins) && configuration.allowedTracingOrigins.length > 0, | ||
use_allowed_tracing_urls: | ||
@@ -312,5 +217,6 @@ Array.isArray(configuration.allowedTracingUrls) && configuration.allowedTracingUrls.length > 0, | ||
use_worker_url: !!configuration.workerUrl, | ||
track_frustrations: configuration.trackFrustrations, | ||
track_views_manually: configuration.trackViewsManually, | ||
track_user_interactions: configuration.trackUserInteractions ?? configuration.trackInteractions, | ||
track_user_interactions: configuration.trackUserInteractions, | ||
track_resources: configuration.trackResources, | ||
track_long_task: configuration.trackLongTasks, | ||
}, | ||
@@ -317,0 +223,0 @@ baseSerializedConfiguration |
@@ -60,7 +60,3 @@ import type { Duration, RelativeTime } from '@datadog/browser-core' | ||
(event) => { | ||
// Only get events fired by the browser to avoid false currentPageState changes done with custom events | ||
// cf: developer extension auto flush: https://github.com/DataDog/browser-sdk/blob/2f72bf05a672794c9e33965351964382a94c72ba/developer-extension/src/panel/flushEvents.ts#L11-L12 | ||
if (event.isTrusted) { | ||
addPageState(computePageState(event), event.timeStamp as RelativeTime) | ||
} | ||
addPageState(computePageState(event), event.timeStamp as RelativeTime) | ||
}, | ||
@@ -67,0 +63,0 @@ { capture: true } |
@@ -1,2 +0,2 @@ | ||
import { cssEscape } from '@datadog/browser-core' | ||
import { cssEscape, addTelemetryDebug } from '@datadog/browser-core' | ||
import { DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE } from './action/getActionNameFromElement' | ||
@@ -57,2 +57,11 @@ | ||
if (!element.parentElement) { | ||
addTelemetryDebug('selector from element without parent', { | ||
debug: { | ||
selector: combineSelector(cssEscape(element.tagName), targetElementSelector), | ||
isConnected: element.isConnected, | ||
}, | ||
}) | ||
} | ||
const uniqueSelectorAmongChildren = findSelector( | ||
@@ -59,0 +68,0 @@ element, |
@@ -8,4 +8,9 @@ import { toServerDuration, relativeToClocks, generateUUID } from '@datadog/browser-core' | ||
import { RumPerformanceEntryType } from '../../browser/performanceCollection' | ||
import type { RumConfiguration } from '../configuration' | ||
export function startLongTaskCollection(lifeCycle: LifeCycle, sessionManager: RumSessionManager) { | ||
export function startLongTaskCollection( | ||
lifeCycle: LifeCycle, | ||
configuration: RumConfiguration, | ||
sessionManager: RumSessionManager | ||
) { | ||
lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, (entries) => { | ||
@@ -17,3 +22,3 @@ for (const entry of entries) { | ||
const session = sessionManager.findTrackedSession(entry.startTime) | ||
if (!session || !session.longTaskAllowed) { | ||
if (!session || !configuration.trackLongTasks) { | ||
break | ||
@@ -36,3 +41,3 @@ } | ||
startTime: startClocks.relative, | ||
domainContext: { performanceEntry: entry.toJSON() }, | ||
domainContext: { performanceEntry: entry }, | ||
}) | ||
@@ -39,0 +44,0 @@ } |
@@ -15,9 +15,5 @@ import { | ||
import type { RumConfiguration } from '../configuration' | ||
import type { RumPerformanceEntry, RumPerformanceResourceTiming } from '../../browser/performanceCollection' | ||
import type { RumPerformanceResourceTiming } from '../../browser/performanceCollection' | ||
import { RumPerformanceEntryType } from '../../browser/performanceCollection' | ||
import type { | ||
PerformanceEntryRepresentation, | ||
RumXhrResourceEventDomainContext, | ||
RumFetchResourceEventDomainContext, | ||
} from '../../domainContext.types' | ||
import type { RumXhrResourceEventDomainContext, RumFetchResourceEventDomainContext } from '../../domainContext.types' | ||
import type { RawRumResourceEvent } from '../../rawRumEvent.types' | ||
@@ -78,3 +74,3 @@ import { RumEventType } from '../../rawRumEvent.types' | ||
const tracingInfo = computeRequestTracingInfo(request, configuration) | ||
const indexingInfo = computeIndexingInfo(sessionManager, startClocks) | ||
const indexingInfo = computeIndexingInfo(configuration, sessionManager, startClocks) | ||
@@ -111,3 +107,3 @@ const duration = computeRequestDuration(pageStateHistory, startClocks, request.duration) | ||
domainContext: { | ||
performanceEntry: matchingTiming && toPerformanceEntryRepresentation(matchingTiming), | ||
performanceEntry: matchingTiming, | ||
xhr: request.xhr, | ||
@@ -133,3 +129,3 @@ response: request.response, | ||
const tracingInfo = computeEntryTracingInfo(entry, configuration) | ||
const indexingInfo = computeIndexingInfo(sessionManager, startClocks) | ||
const indexingInfo = computeIndexingInfo(configuration, sessionManager, startClocks) | ||
const pageStateInfo = computePageStateInfo(pageStateHistory, startClocks, entry.duration) | ||
@@ -156,3 +152,3 @@ | ||
domainContext: { | ||
performanceEntry: toPerformanceEntryRepresentation(entry), | ||
performanceEntry: entry, | ||
}, | ||
@@ -201,7 +197,2 @@ } | ||
// TODO next major: use directly PerformanceEntry type in domain context | ||
function toPerformanceEntryRepresentation(entry: RumPerformanceEntry): PerformanceEntryRepresentation { | ||
return entry as PerformanceEntryRepresentation | ||
} | ||
/** | ||
@@ -214,7 +205,11 @@ * @returns number between 0 and 1 which represents trace sample rate | ||
function computeIndexingInfo(sessionManager: RumSessionManager, resourceStart: ClocksState) { | ||
function computeIndexingInfo( | ||
configuration: RumConfiguration, | ||
sessionManager: RumSessionManager, | ||
resourceStart: ClocksState | ||
) { | ||
const session = sessionManager.findTrackedSession(resourceStart.relative) | ||
return { | ||
_dd: { | ||
discarded: !session || !session.resourceAllowed, | ||
discarded: !session || !configuration.trackResources, | ||
}, | ||
@@ -238,7 +233,2 @@ } | ||
function computeRequestDuration(pageStateHistory: PageStateHistory, startClocks: ClocksState, duration: Duration) { | ||
// TODO remove FF in next major | ||
if (!isExperimentalFeatureEnabled(ExperimentalFeature.NO_RESOURCE_DURATION_FROZEN_STATE)) { | ||
return toServerDuration(duration) | ||
} | ||
const requestCrossedFrozenState = pageStateHistory | ||
@@ -245,0 +235,0 @@ .findAll(startClocks.relative, duration) |
@@ -17,18 +17,7 @@ import type { RelativeTime } from '@datadog/browser-core' | ||
id: string | ||
plan: RumSessionPlan | ||
sessionReplayAllowed: boolean | ||
longTaskAllowed: boolean | ||
resourceAllowed: boolean | ||
} | ||
export const enum RumSessionPlan { | ||
WITHOUT_SESSION_REPLAY = 1, | ||
WITH_SESSION_REPLAY = 2, | ||
} | ||
export const enum RumTrackingType { | ||
NOT_TRACKED = '0', | ||
// Note: the "tracking type" value (stored in the session cookie) does not match the "session | ||
// plan" value (sent in RUM events). This is expected, and was done to keep retrocompatibility | ||
// with active sessions when upgrading the SDK. | ||
TRACKED_WITH_SESSION_REPLAY = '1', | ||
@@ -57,18 +46,5 @@ TRACKED_WITHOUT_SESSION_REPLAY = '2', | ||
} | ||
const plan = | ||
session.trackingType === RumTrackingType.TRACKED_WITH_SESSION_REPLAY | ||
? RumSessionPlan.WITH_SESSION_REPLAY | ||
: RumSessionPlan.WITHOUT_SESSION_REPLAY | ||
return { | ||
id: session.id, | ||
plan, | ||
sessionReplayAllowed: plan === RumSessionPlan.WITH_SESSION_REPLAY, | ||
longTaskAllowed: | ||
configuration.trackLongTasks !== undefined | ||
? configuration.trackLongTasks | ||
: configuration.oldPlansBehavior && plan === RumSessionPlan.WITH_SESSION_REPLAY, | ||
resourceAllowed: | ||
configuration.trackResources !== undefined | ||
? configuration.trackResources | ||
: configuration.oldPlansBehavior && plan === RumSessionPlan.WITH_SESSION_REPLAY, | ||
sessionReplayAllowed: session.trackingType === RumTrackingType.TRACKED_WITH_SESSION_REPLAY, | ||
} | ||
@@ -87,6 +63,3 @@ }, | ||
id: '00000000-aaaa-0000-aaaa-000000000000', | ||
plan: RumSessionPlan.WITHOUT_SESSION_REPLAY, // plan value should not be taken into account for mobile | ||
sessionReplayAllowed: false, | ||
longTaskAllowed: true, | ||
resourceAllowed: true, | ||
} | ||
@@ -93,0 +66,0 @@ return { |
@@ -60,3 +60,3 @@ import type { Context, ContextManager, FlushEvent, Observable, Telemetry } from '@datadog/browser-core' | ||
currentBatchMeasures.globalContextBytes, | ||
!isEmptyObject(globalContextManager.get()) ? globalContextManager.getBytesCount() : 0 | ||
!isEmptyObject(globalContextManager.getContext()) ? globalContextManager.getBytesCount() : 0 | ||
) | ||
@@ -66,3 +66,3 @@ | ||
currentBatchMeasures.userContextBytes, | ||
!isEmptyObject(userContextManager.get()) ? userContextManager.getBytesCount() : 0 | ||
!isEmptyObject(userContextManager.getContext()) ? userContextManager.getBytesCount() : 0 | ||
) | ||
@@ -69,0 +69,0 @@ |
import type { Duration, ServerDuration, Observable } from '@datadog/browser-core' | ||
import { | ||
isExperimentalFeatureEnabled, | ||
ExperimentalFeature, | ||
isEmptyObject, | ||
mapValues, | ||
toServerDuration, | ||
isNumber, | ||
} from '@datadog/browser-core' | ||
import { isEmptyObject, mapValues, toServerDuration, isNumber } from '@datadog/browser-core' | ||
import type { RecorderApi } from '../../boot/rumPublicApi' | ||
@@ -15,3 +8,2 @@ import type { RawRumViewEvent } from '../../rawRumEvent.types' | ||
import { LifeCycleEventType } from '../lifeCycle' | ||
import { mapToForegroundPeriods } from '../contexts/foregroundContexts' | ||
import type { LocationChange } from '../../browser/locationChangeObservable' | ||
@@ -61,3 +53,2 @@ import type { RumConfiguration } from '../configuration' | ||
const featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(view.startClocks.relative) | ||
const pageStatesEnabled = isExperimentalFeatureEnabled(ExperimentalFeature.PAGE_STATES) | ||
const pageStates = pageStateHistory.findAll(view.startClocks.relative, view.duration) | ||
@@ -68,3 +59,3 @@ const viewEvent: RawRumViewEvent = { | ||
replay_stats: replayStats, | ||
page_states: pageStatesEnabled ? pageStates : undefined, | ||
page_states: pageStates, | ||
}, | ||
@@ -109,4 +100,2 @@ date: view.startClocks.timeStamp, | ||
time_spent: toServerDuration(view.duration), | ||
in_foreground_periods: | ||
!pageStatesEnabled && pageStates ? mapToForegroundPeriods(pageStates, view.duration) : undefined, // Todo: Remove in the next major release | ||
}, | ||
@@ -113,0 +102,0 @@ feature_flags: featureFlagContext && !isEmptyObject(featureFlagContext) ? featureFlagContext : undefined, |
@@ -24,6 +24,2 @@ /** | ||
export interface RumActionEventDomainContext { | ||
/** | ||
* @deprecated use events array instead | ||
*/ | ||
event?: Event | ||
events?: Event[] | ||
@@ -37,3 +33,3 @@ } | ||
error?: Error | ||
performanceEntry?: PerformanceEntryRepresentation | ||
performanceEntry?: PerformanceEntry | ||
} | ||
@@ -43,7 +39,7 @@ | ||
xhr: XMLHttpRequest | ||
performanceEntry?: PerformanceEntryRepresentation | ||
performanceEntry?: PerformanceEntry | ||
} | ||
export interface RumOtherResourceEventDomainContext { | ||
performanceEntry: PerformanceEntryRepresentation | ||
performanceEntry: PerformanceEntry | ||
} | ||
@@ -56,10 +52,3 @@ | ||
export interface RumLongTaskEventDomainContext { | ||
performanceEntry: PerformanceEntryRepresentation | ||
performanceEntry: PerformanceEntry | ||
} | ||
/** | ||
* Symbolizes the type of the value returned by performanceEntry.toJSON(). Can also be built | ||
* manually to represent other kind of performance entries (ex: initial_document) or polyfilled | ||
* based on `performance.timing`. | ||
*/ | ||
export type PerformanceEntryRepresentation = Omit<PerformanceEntry, 'toJSON'> |
@@ -26,3 +26,3 @@ export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi' | ||
export { ViewContexts, ViewContext } from './domain/contexts/viewContexts' | ||
export { RumSessionManager, RumSessionPlan, RumSession } from './domain/rumSessionManager' | ||
export { RumSessionManager, RumSession } from './domain/rumSessionManager' | ||
export { getMutationObserverConstructor } from './browser/domMutationObservable' | ||
@@ -29,0 +29,0 @@ export { initViewportObservable, getViewportDimension } from './browser/viewportObservable' |
@@ -13,3 +13,2 @@ import type { | ||
import type { PageState } from './domain/contexts/pageStateHistory' | ||
import type { RumSessionPlan } from './domain/rumSessionManager' | ||
@@ -110,3 +109,2 @@ export const enum RumEventType { | ||
frustration: Count | ||
in_foreground_periods?: InForegroundPeriod[] | ||
} | ||
@@ -138,7 +136,2 @@ session: { | ||
export interface InForegroundPeriod { | ||
start: ServerDuration | ||
duration: ServerDuration | ||
} | ||
export type PageStateServerEntry = { state: PageState; start: ServerDuration } | ||
@@ -269,5 +262,2 @@ | ||
drift: number | ||
session: { | ||
plan: RumSessionPlan | ||
} | ||
configuration: { | ||
@@ -274,0 +264,0 @@ session_sample_rate: number |
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
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
1174049
458
21504
+ Added@datadog/browser-core@5.0.0(transitive)
- Removed@datadog/browser-core@4.50.1(transitive)
Updated@datadog/browser-core@5.0.0