Socket
Socket
Sign inDemoInstall

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 5.20.0 to 5.21.0

4

cjs/boot/preStartRum.d.ts
import type { TrackingConsentState, DeflateWorker } from '@datadog/browser-core';
import { type RumConfiguration, type RumInitConfiguration } from '../domain/configuration';
import { type RumConfiguration } from '../domain/configuration';
import type { CommonContext } from '../domain/contexts/commonContext';

@@ -7,2 +7,2 @@ import type { ViewOptions } from '../domain/view/trackViews';

import type { StartRumResult } from './startRum';
export declare function createPreStartStrategy({ ignoreInitIfSyntheticsWillInjectRum, startDeflateWorker }: RumPublicApiOptions, getCommonContext: () => CommonContext, trackingConsentState: TrackingConsentState, doStartRum: (initConfiguration: RumInitConfiguration, configuration: RumConfiguration, deflateWorker: DeflateWorker | undefined, initialViewOptions?: ViewOptions) => StartRumResult): Strategy;
export declare function createPreStartStrategy({ ignoreInitIfSyntheticsWillInjectRum, startDeflateWorker }: RumPublicApiOptions, getCommonContext: () => CommonContext, trackingConsentState: TrackingConsentState, doStartRum: (configuration: RumConfiguration, deflateWorker: DeflateWorker | undefined, initialViewOptions?: ViewOptions) => StartRumResult): Strategy;

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

var configuration_1 = require("../domain/configuration");
var configuration_2 = require("../domain/configuration");
function createPreStartStrategy(_a, getCommonContext, trackingConsentState, doStartRum) {

@@ -34,3 +35,3 @@ var ignoreInitIfSyntheticsWillInjectRum = _a.ignoreInitIfSyntheticsWillInjectRum, startDeflateWorker = _a.startDeflateWorker;

}
var startRumResult = doStartRum(cachedInitConfiguration, cachedConfiguration, deflateWorker, initialViewOptions);
var startRumResult = doStartRum(cachedConfiguration, deflateWorker, initialViewOptions);
bufferApiCalls.drain(startRumResult);

@@ -44,2 +45,4 @@ }

}
// Set the experimental feature flags as early as possible, so we can use them in most places
(0, browser_core_1.initFeatureFlags)(initConfiguration.enableExperimentalFeatures);
var eventBridgeAvailable = (0, browser_core_1.canUseEventBridge)();

@@ -51,2 +54,3 @@ if (eventBridgeAvailable) {

cachedInitConfiguration = initConfiguration;
(0, browser_core_1.addTelemetryConfiguration)((0, configuration_2.serializeRumConfiguration)(initConfiguration));
if (cachedConfiguration) {

@@ -53,0 +57,0 @@ (0, browser_core_1.displayAlreadyInitializedError)('DD_RUM', initConfiguration);

@@ -10,2 +10,5 @@ import type { Context, User, DeflateWorker, DeflateEncoderStreamId, DeflateEncoder, TrackingConsent, PublicApi } from '@datadog/browser-core';

import type { StartRum, StartRumResult } from './startRum';
export interface StartRecordingOptions {
force: boolean;
}
export interface RumPublicApi extends PublicApi {

@@ -180,3 +183,3 @@ /**

*/
startSessionReplayRecording: () => void;
startSessionReplayRecording: (options?: StartRecordingOptions) => void;
/**

@@ -190,3 +193,3 @@ * Stop Session Replay recording.

export interface RecorderApi {
start: () => void;
start: (options?: StartRecordingOptions) => void;
stop: () => void;

@@ -193,0 +196,0 @@ onRumStart: (lifeCycle: LifeCycle, configuration: RumConfiguration, sessionManager: RumSessionManager, viewContexts: ViewContexts, deflateWorker: DeflateWorker | undefined) => void;

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

}
var strategy = (0, preStartRum_1.createPreStartStrategy)(options, getCommonContext, trackingConsentState, function (initConfiguration, configuration, deflateWorker, initialViewOptions) {
var strategy = (0, preStartRum_1.createPreStartStrategy)(options, getCommonContext, trackingConsentState, function (configuration, deflateWorker, initialViewOptions) {
if ((0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.CUSTOM_VITALS)) {

@@ -45,3 +45,3 @@ /**

}
if (initConfiguration.storeContextsAcrossPages) {
if (configuration.storeContextsAcrossPages) {
(0, browser_core_1.storeContextManager)(configuration, globalContextManager, RUM_STORAGE_KEY, 2 /* CustomerDataType.GlobalContext */);

@@ -51,7 +51,7 @@ (0, browser_core_1.storeContextManager)(configuration, userContextManager, RUM_STORAGE_KEY, 1 /* CustomerDataType.User */);

customerDataTrackerManager.setCompressionStatus(deflateWorker ? 1 /* CustomerDataCompressionStatus.Enabled */ : 2 /* CustomerDataCompressionStatus.Disabled */);
var startRumResult = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && options.createDeflateEncoder
var startRumResult = startRumImpl(configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && options.createDeflateEncoder
? function (streamId) { return options.createDeflateEncoder(configuration, deflateWorker, streamId); }
: browser_core_1.createIdentityEncoder, trackingConsentState);
recorderApi.onRumStart(startRumResult.lifeCycle, configuration, startRumResult.session, startRumResult.viewContexts, deflateWorker);
strategy = createPostStartStrategy(initConfiguration, startRumResult);
strategy = createPostStartStrategy(strategy, startRumResult);
return startRumResult;

@@ -137,5 +137,5 @@ });

getSessionReplayLink: (0, browser_core_1.monitor)(function () { return recorderApi.getSessionReplayLink(); }),
startSessionReplayRecording: (0, browser_core_1.monitor)(function () {
recorderApi.start();
(0, browser_core_1.addTelemetryUsage)({ feature: 'start-session-replay-recording' });
startSessionReplayRecording: (0, browser_core_1.monitor)(function (options) {
recorderApi.start(options);
(0, browser_core_1.addTelemetryUsage)({ feature: 'start-session-replay-recording', force: options === null || options === void 0 ? void 0 : options.force });
}),

@@ -147,3 +147,3 @@ stopSessionReplayRecording: (0, browser_core_1.monitor)(function () { return recorderApi.stop(); }),

exports.makeRumPublicApi = makeRumPublicApi;
function createPostStartStrategy(initConfiguration, startRumResult) {
function createPostStartStrategy(preStartStrategy, startRumResult) {
return (0, browser_core_1.assign)({

@@ -153,5 +153,5 @@ init: function (initConfiguration) {

},
initConfiguration: initConfiguration,
initConfiguration: preStartStrategy.initConfiguration,
}, startRumResult);
}
//# sourceMappingURL=rumPublicApi.js.map

@@ -5,3 +5,3 @@ import type { Observable, RawError, DeflateEncoderStreamId, Encoder, CustomerDataTrackerManager, TrackingConsentState } from '@datadog/browser-core';

import type { LocationChange } from '../browser/locationChangeObservable';
import type { RumConfiguration, RumInitConfiguration } from '../domain/configuration';
import type { RumConfiguration } from '../domain/configuration';
import type { ViewOptions } from '../domain/view/trackViews';

@@ -12,3 +12,3 @@ import type { CommonContext } from '../domain/contexts/commonContext';

export type StartRumResult = ReturnType<StartRum>;
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, getCommonContext: () => CommonContext, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder, trackingConsentState: TrackingConsentState): {
export declare function startRum(configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, getCommonContext: () => CommonContext, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder, trackingConsentState: TrackingConsentState): {
addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;

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

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

var locationChangeObservable_1 = require("../browser/locationChangeObservable");
var configuration_1 = require("../domain/configuration");
var featureFlagContext_1 = require("../domain/contexts/featureFlagContext");

@@ -30,3 +29,3 @@ var startCustomerDataTelemetry_1 = require("../domain/startCustomerDataTelemetry");

var ciVisibilityContext_1 = require("../domain/contexts/ciVisibilityContext");
function startRum(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, createEncoder,
function startRum(configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, createEncoder,
// `startRum` and its subcomponents assume tracking consent is granted initially and starts

@@ -83,3 +82,2 @@ // collecting logs unconditionally. As such, `startRum` should be called with a

(0, browser_core_1.drainPreStartTelemetry)();
(0, browser_core_1.addTelemetryConfiguration)((0, configuration_1.serializeRumConfiguration)(initConfiguration));
(0, longTaskCollection_1.startLongTaskCollection)(lifeCycle, configuration);

@@ -86,0 +84,0 @@ (0, resourceCollection_1.startResourceCollection)(lifeCycle, configuration, pageStateHistory);

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

import type { ViewContexts } from './contexts/viewContexts';
import type { RumSessionManager } from './rumSessionManager';
import { type RumSessionManager } from './rumSessionManager';
import type { UrlContexts } from './contexts/urlContexts';

@@ -8,0 +8,0 @@ import type { RumConfiguration } from './configuration';

@@ -18,2 +18,9 @@ "use strict";

var _a, _b;
// TODO: lift this declaration to module level once feature flag is removed
var ROOT_MODIFIABLE_FIELD_PATHS = (0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.MICRO_FRONTEND)
? {
service: 'string',
version: 'string',
}
: {};
modifiableFieldPathsByEvent = (_a = {},

@@ -26,11 +33,13 @@ _a["view" /* RumEventType.VIEW */] = VIEW_MODIFIABLE_FIELD_PATHS,

'error.fingerprint': 'string',
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS, ROOT_MODIFIABLE_FIELD_PATHS),
_a["resource" /* RumEventType.RESOURCE */] = (0, browser_core_1.assign)({
'resource.url': 'string',
}, (0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.WRITABLE_RESOURCE_GRAPHQL) && {
'resource.graphql': 'object',
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),
}, (0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.WRITABLE_RESOURCE_GRAPHQL)
? {
'resource.graphql': 'object',
}
: {}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS, ROOT_MODIFIABLE_FIELD_PATHS),
_a["action" /* RumEventType.ACTION */] = (0, browser_core_1.assign)({
'action.target.name': 'string',
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS, ROOT_MODIFIABLE_FIELD_PATHS),
_a["long_task" /* RumEventType.LONG_TASK */] = (0, browser_core_1.assign)({}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),

@@ -61,3 +70,3 @@ _a["vital" /* RumEventType.VITAL */] = (0, browser_core_1.assign)({}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),

},
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "5.20.0" : undefined,
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "5.21.0" : undefined,
},

@@ -99,3 +108,4 @@ application: {

;
serverRumEvent.session.sampled_for_replay = session.sessionReplayAllowed;
serverRumEvent.session.sampled_for_replay =
session.sessionReplay === 1 /* SessionReplayState.SAMPLED */;
}

@@ -102,0 +112,0 @@ if (!(0, browser_core_1.isEmptyObject)(commonContext.user)) {

@@ -8,18 +8,89 @@ import type { Configuration, InitConfiguration, MatchOption } from '@datadog/browser-core';

export interface RumInitConfiguration extends InitConfiguration {
/**
* The RUM application ID.
*/
applicationId: string;
/**
* Access to every event collected by the RUM SDK before they are sent to Datadog.
* It allows:
* - Enrich your RUM events with additional context attributes
* - Modify your RUM events to modify their content, or redact sensitive sequences (see the list of editable properties)
* - Discard selected RUM events
*
* See [Enrich And Control Browser RUM Data With beforeSend](https://docs.datadoghq.com/real_user_monitoring/guide/enrich-and-control-rum-data) for further information.
*/
beforeSend?: ((event: RumEvent, context: RumEventDomainContext) => boolean) | undefined;
/**
* A list of request origins ignored when computing the page activity.
* See [How page activity is calculated](https://docs.datadoghq.com/real_user_monitoring/browser/monitoring_page_performance/#how-page-activity-is-calculated) for further information.
*/
excludedActivityUrls?: MatchOption[] | undefined;
/**
* URL pointing to the Datadog Browser SDK Worker JavaScript file. The URL can be relative or absolute, but is required to have the same origin as the web application.
* See [Content Security Policy guidelines](https://docs.datadoghq.com/integrations/content_security_policy_logs/?tab=firefox#use-csp-with-real-user-monitoring-and-session-replay) for further information.
*/
workerUrl?: string;
/**
* Compress requests sent to the Datadog intake to reduce bandwidth usage when sending large amounts of data. The compression is done in a Worker thread.
* See [Content Security Policy guidelines](https://docs.datadoghq.com/integrations/content_security_policy_logs/?tab=firefox#use-csp-with-real-user-monitoring-and-session-replay) for further information.
*/
compressIntakeRequests?: boolean | undefined;
/**
* A list of request URLs used to inject tracing headers.
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*/
allowedTracingUrls?: Array<MatchOption | TracingOption> | undefined;
/**
* The percentage of requests to trace: 100 for all, 0 for none.
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*/
traceSampleRate?: number | undefined;
/**
* If you set a `traceSampleRate`, to ensure backend services' sampling decisions are still applied, configure the `traceContextInjection` initialization parameter to sampled.
* @default all
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*/
traceContextInjection?: TraceContextInjection | undefined;
/**
* Allow to protect end user privacy and prevent sensitive organizational information from being collected.
* @default mask
* See [Replay Privacy Options](https://docs.datadoghq.com/real_user_monitoring/session_replay/browser/privacy_options) for further information.
*/
defaultPrivacyLevel?: DefaultPrivacyLevel | undefined;
/**
* If you are accessing Datadog through a custom subdomain, you can set `subdomain` to include your custom domain in the `getSessionReplayLink()` returned URL .
* See [Connect Session Replay To Your Third-Party Tools](https://docs.datadoghq.com/real_user_monitoring/guide/connect-session-replay-to-your-third-party-tools) for further information.
*/
subdomain?: string;
/**
* The percentage of tracked sessions with [Browser RUM & Session Replay pricing](https://www.datadoghq.com/pricing/?product=real-user-monitoring--session-replay#real-user-monitoring--session-replay) features: 100 for all, 0 for none.
* See [Configure Your Setup For Browser RUM and Browser RUM & Session Replay Sampling](https://docs.datadoghq.com/real_user_monitoring/guide/sampling-browser-plans) for further information.
*/
sessionReplaySampleRate?: number | undefined;
/**
* If the session is sampled for Session Replay, only start the recording when `startSessionReplayRecording()` is called, instead of at the beginning of the session.
* See [Session Replay Usage](https://docs.datadoghq.com/real_user_monitoring/session_replay/browser/#usage) for further information.
*/
startSessionReplayRecordingManually?: boolean | undefined;
/**
* Enables automatic collection of users actions.
* See [Tracking User Actions](https://docs.datadoghq.com/real_user_monitoring/browser/tracking_user_actions) for further information.
*/
trackUserInteractions?: boolean | undefined;
/**
* Specify your own attribute to use to name actions.
* See [Declare a name for click actions](https://docs.datadoghq.com/real_user_monitoring/browser/tracking_user_actions/#declare-a-name-for-click-actions) for further information.
*/
actionNameAttribute?: string | undefined;
/**
* Allows you to control RUM views creation. See [Override default RUM view names](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#override-default-rum-view-names) for further information.
*/
trackViewsManually?: boolean | undefined;
/**
* Enables collection of resource events.
*/
trackResources?: boolean | undefined;
/**
* Enables collection of long task events.
*/
trackLongTasks?: boolean | undefined;

@@ -26,0 +97,0 @@ }

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

expireObservable: Observable<void>;
setForcedReplay: () => void;
}
export type RumSession = {
id: string;
sessionReplayAllowed: boolean;
sessionReplay: SessionReplayState;
};

@@ -21,2 +22,7 @@ export declare const enum RumTrackingType {

}
export declare const enum SessionReplayState {
OFF = 0,
SAMPLED = 1,
FORCED = 2
}
export declare function startRumSessionManager(configuration: RumConfiguration, lifeCycle: LifeCycle, trackingConsentState: TrackingConsentState): RumSessionManager;

@@ -23,0 +29,0 @@ /**

@@ -14,2 +14,11 @@ "use strict";

});
sessionManager.sessionStateUpdateObservable.subscribe(function (_a) {
var previousState = _a.previousState, newState = _a.newState;
if (!previousState.forcedReplay && newState.forcedReplay) {
var sessionEntity = sessionManager.findSession();
if (sessionEntity) {
sessionEntity.isReplayForced = true;
}
}
});
return {

@@ -23,3 +32,7 @@ findTrackedSession: function (startTime) {

id: session.id,
sessionReplayAllowed: session.trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */,
sessionReplay: session.trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */
? 1 /* SessionReplayState.SAMPLED */
: session.isReplayForced
? 2 /* SessionReplayState.FORCED */
: 0 /* SessionReplayState.OFF */,
};

@@ -29,2 +42,3 @@ },

expireObservable: sessionManager.expireObservable,
setForcedReplay: function () { return sessionManager.updateSessionState({ forcedReplay: '1' }); },
};

@@ -39,3 +53,3 @@ }

id: '00000000-aaaa-0000-aaaa-000000000000',
sessionReplayAllowed: (0, browser_core_1.bridgeSupports)("records" /* BridgeCapability.RECORDS */),
sessionReplay: (0, browser_core_1.bridgeSupports)("records" /* BridgeCapability.RECORDS */) ? 1 /* SessionReplayState.SAMPLED */ : 0 /* SessionReplayState.OFF */,
};

@@ -46,2 +60,3 @@ return {

expireObservable: new browser_core_1.Observable(),
setForcedReplay: browser_core_1.noop,
};

@@ -48,0 +63,0 @@ }

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

function processViewUpdate(view, configuration, featureFlagContexts, recorderApi, pageStateHistory) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
var replayStats = recorderApi.getReplayStats(view.id);

@@ -39,7 +39,8 @@ var featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(view.startClocks.relative);

cumulative_layout_shift: (_a = view.commonViewMetrics.cumulativeLayoutShift) === null || _a === void 0 ? void 0 : _a.value,
cumulative_layout_shift_target_selector: (_b = view.commonViewMetrics.cumulativeLayoutShift) === null || _b === void 0 ? void 0 : _b.targetSelector,
first_byte: (0, browser_core_1.toServerDuration)((_c = view.initialViewMetrics.navigationTimings) === null || _c === void 0 ? void 0 : _c.firstByte),
dom_complete: (0, browser_core_1.toServerDuration)((_d = view.initialViewMetrics.navigationTimings) === null || _d === void 0 ? void 0 : _d.domComplete),
dom_content_loaded: (0, browser_core_1.toServerDuration)((_e = view.initialViewMetrics.navigationTimings) === null || _e === void 0 ? void 0 : _e.domContentLoaded),
dom_interactive: (0, browser_core_1.toServerDuration)((_f = view.initialViewMetrics.navigationTimings) === null || _f === void 0 ? void 0 : _f.domInteractive),
cumulative_layout_shift_time: (0, browser_core_1.toServerDuration)((_b = view.commonViewMetrics.cumulativeLayoutShift) === null || _b === void 0 ? void 0 : _b.time),
cumulative_layout_shift_target_selector: (_c = view.commonViewMetrics.cumulativeLayoutShift) === null || _c === void 0 ? void 0 : _c.targetSelector,
first_byte: (0, browser_core_1.toServerDuration)((_d = view.initialViewMetrics.navigationTimings) === null || _d === void 0 ? void 0 : _d.firstByte),
dom_complete: (0, browser_core_1.toServerDuration)((_e = view.initialViewMetrics.navigationTimings) === null || _e === void 0 ? void 0 : _e.domComplete),
dom_content_loaded: (0, browser_core_1.toServerDuration)((_f = view.initialViewMetrics.navigationTimings) === null || _f === void 0 ? void 0 : _f.domContentLoaded),
dom_interactive: (0, browser_core_1.toServerDuration)((_g = view.initialViewMetrics.navigationTimings) === null || _g === void 0 ? void 0 : _g.domInteractive),
error: {

@@ -49,12 +50,13 @@ count: view.eventCounts.errorCount,

first_contentful_paint: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.firstContentfulPaint),
first_input_delay: (0, browser_core_1.toServerDuration)((_g = view.initialViewMetrics.firstInput) === null || _g === void 0 ? void 0 : _g.delay),
first_input_time: (0, browser_core_1.toServerDuration)((_h = view.initialViewMetrics.firstInput) === null || _h === void 0 ? void 0 : _h.time),
first_input_target_selector: (_j = view.initialViewMetrics.firstInput) === null || _j === void 0 ? void 0 : _j.targetSelector,
interaction_to_next_paint: (0, browser_core_1.toServerDuration)((_k = view.commonViewMetrics.interactionToNextPaint) === null || _k === void 0 ? void 0 : _k.value),
interaction_to_next_paint_target_selector: (_l = view.commonViewMetrics.interactionToNextPaint) === null || _l === void 0 ? void 0 : _l.targetSelector,
first_input_delay: (0, browser_core_1.toServerDuration)((_h = view.initialViewMetrics.firstInput) === null || _h === void 0 ? void 0 : _h.delay),
first_input_time: (0, browser_core_1.toServerDuration)((_j = view.initialViewMetrics.firstInput) === null || _j === void 0 ? void 0 : _j.time),
first_input_target_selector: (_k = view.initialViewMetrics.firstInput) === null || _k === void 0 ? void 0 : _k.targetSelector,
interaction_to_next_paint: (0, browser_core_1.toServerDuration)((_l = view.commonViewMetrics.interactionToNextPaint) === null || _l === void 0 ? void 0 : _l.value),
interaction_to_next_paint_time: (0, browser_core_1.toServerDuration)((_m = view.commonViewMetrics.interactionToNextPaint) === null || _m === void 0 ? void 0 : _m.time),
interaction_to_next_paint_target_selector: (_o = view.commonViewMetrics.interactionToNextPaint) === null || _o === void 0 ? void 0 : _o.targetSelector,
is_active: view.isActive,
name: view.name,
largest_contentful_paint: (0, browser_core_1.toServerDuration)((_m = view.initialViewMetrics.largestContentfulPaint) === null || _m === void 0 ? void 0 : _m.value),
largest_contentful_paint_target_selector: (_o = view.initialViewMetrics.largestContentfulPaint) === null || _o === void 0 ? void 0 : _o.targetSelector,
load_event: (0, browser_core_1.toServerDuration)((_p = view.initialViewMetrics.navigationTimings) === null || _p === void 0 ? void 0 : _p.loadEvent),
largest_contentful_paint: (0, browser_core_1.toServerDuration)((_p = view.initialViewMetrics.largestContentfulPaint) === null || _p === void 0 ? void 0 : _p.value),
largest_contentful_paint_target_selector: (_q = view.initialViewMetrics.largestContentfulPaint) === null || _q === void 0 ? void 0 : _q.targetSelector,
load_event: (0, browser_core_1.toServerDuration)((_r = view.initialViewMetrics.navigationTimings) === null || _r === void 0 ? void 0 : _r.loadEvent),
loading_time: (0, discardNegativeDuration_1.discardNegativeDuration)((0, browser_core_1.toServerDuration)(view.commonViewMetrics.loadingTime)),

@@ -61,0 +63,0 @@ loading_type: view.loadingType,

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

}).stop;
var stopCLSTracking = (0, trackCumulativeLayoutShift_1.trackCumulativeLayoutShift)(configuration, lifeCycle, function (cumulativeLayoutShift) {
var stopCLSTracking = (0, trackCumulativeLayoutShift_1.trackCumulativeLayoutShift)(configuration, lifeCycle, viewStart.relative, function (cumulativeLayoutShift) {
commonViewMetrics.cumulativeLayoutShift = cumulativeLayoutShift;

@@ -20,0 +20,0 @@ scheduleViewUpdate();

import { noop } from '@datadog/browser-core';
import type { Duration, RelativeTime } from '@datadog/browser-core';
import type { LifeCycle } from '../../lifeCycle';

@@ -7,2 +8,3 @@ import type { RumConfiguration } from '../../configuration';

targetSelector?: string;
time?: Duration;
}

@@ -26,3 +28,3 @@ /**

*/
export declare function trackCumulativeLayoutShift(configuration: RumConfiguration, lifeCycle: LifeCycle, callback: (cumulativeLayoutShift: CumulativeLayoutShift) => void): {
export declare function trackCumulativeLayoutShift(configuration: RumConfiguration, lifeCycle: LifeCycle, viewStart: RelativeTime, callback: (cumulativeLayoutShift: CumulativeLayoutShift) => void): {
stop: typeof noop;

@@ -29,0 +31,0 @@ };

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

*/
function trackCumulativeLayoutShift(configuration, lifeCycle, callback) {
function trackCumulativeLayoutShift(configuration, lifeCycle, viewStart, callback) {
if (!isLayoutShiftSupported()) {

@@ -35,2 +35,3 @@ return {

var maxClsTarget;
var maxClsStartTime;
// if no layout shift happen the value should be reported as 0

@@ -49,2 +50,3 @@ callback({

maxClsTarget = target ? new WeakRef(target) : undefined;
maxClsStartTime = (0, browser_core_1.elapsed)(viewStart, entry.startTime);
}

@@ -57,2 +59,3 @@ if (cumulatedValue > maxClsValue) {

targetSelector: target && (0, getSelectorFromElement_1.getSelectorFromElement)(target, configuration.actionNameAttribute),
time: maxClsStartTime,
});

@@ -59,0 +62,0 @@ }

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

targetSelector?: string;
time?: Duration;
}

@@ -11,0 +12,0 @@ /**

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

var interactionToNextPaintTargetSelector;
var interactionToNextPaintStartTime;
var stop = lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {

@@ -48,2 +49,3 @@ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {

interactionToNextPaint = newInteraction.duration;
interactionToNextPaintStartTime = (0, browser_core_1.elapsed)(viewStart, newInteraction.startTime);
if (newInteraction.target && (0, htmlDomUtils_1.isElementNode)(newInteraction.target)) {

@@ -65,2 +67,3 @@ interactionToNextPaintTargetSelector = (0, getSelectorFromElement_1.getSelectorFromElement)(newInteraction.target, configuration.actionNameAttribute);

targetSelector: interactionToNextPaintTargetSelector,
time: interactionToNextPaintStartTime,
};

@@ -67,0 +70,0 @@ }

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

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

@@ -21,1 +21,2 @@ export { RumEvent, RumActionEvent, CommonProperties, RumErrorEvent, RumViewEvent, RumResourceEvent, RumLongTaskEvent, RumVitalEvent, } from './rumEvent.types';

export { isLongDataUrl, sanitizeDataUrl, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH } from './domain/resource/resourceUtils';
export { SessionReplayState } from './domain/rumSessionManager';

@@ -77,4 +77,6 @@ import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel, Connectivity, Csp } from '@datadog/browser-core';

interaction_to_next_paint?: ServerDuration;
interaction_to_next_paint_time?: ServerDuration;
interaction_to_next_paint_target_selector?: string;
cumulative_layout_shift?: number;
cumulative_layout_shift_time?: ServerDuration;
cumulative_layout_shift_target_selector?: string;

@@ -81,0 +83,0 @@ custom_timings?: {

@@ -695,2 +695,6 @@ /**

/**
* Duration in ns between start of the view and start of the INP
*/
readonly interaction_to_next_paint_time?: number;
/**
* CSS selector path of the interacted element corresponding to INP

@@ -704,2 +708,6 @@ */

/**
* Duration in ns between start of the view and start of the largest layout shift contributing to CLS
*/
readonly cumulative_layout_shift_time?: number;
/**
* CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS

@@ -1047,7 +1055,7 @@ */

*/
readonly service?: string;
service?: string;
/**
* The version for this application
*/
readonly version?: string;
version?: string;
/**

@@ -1054,0 +1062,0 @@ * The build version for this application

import type { TrackingConsentState, DeflateWorker } from '@datadog/browser-core';
import { type RumConfiguration, type RumInitConfiguration } from '../domain/configuration';
import { type RumConfiguration } from '../domain/configuration';
import type { CommonContext } from '../domain/contexts/commonContext';

@@ -7,2 +7,2 @@ import type { ViewOptions } from '../domain/view/trackViews';

import type { StartRumResult } from './startRum';
export declare function createPreStartStrategy({ ignoreInitIfSyntheticsWillInjectRum, startDeflateWorker }: RumPublicApiOptions, getCommonContext: () => CommonContext, trackingConsentState: TrackingConsentState, doStartRum: (initConfiguration: RumInitConfiguration, configuration: RumConfiguration, deflateWorker: DeflateWorker | undefined, initialViewOptions?: ViewOptions) => StartRumResult): Strategy;
export declare function createPreStartStrategy({ ignoreInitIfSyntheticsWillInjectRum, startDeflateWorker }: RumPublicApiOptions, getCommonContext: () => CommonContext, trackingConsentState: TrackingConsentState, doStartRum: (configuration: RumConfiguration, deflateWorker: DeflateWorker | undefined, initialViewOptions?: ViewOptions) => StartRumResult): Strategy;

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

import { BoundedBuffer, display, canUseEventBridge, displayAlreadyInitializedError, willSyntheticsInjectRum, noop, timeStampNow, clocksNow, assign, getEventBridge, } from '@datadog/browser-core';
import { BoundedBuffer, display, canUseEventBridge, displayAlreadyInitializedError, willSyntheticsInjectRum, noop, timeStampNow, clocksNow, assign, getEventBridge, addTelemetryConfiguration, initFeatureFlags, } from '@datadog/browser-core';
import { validateAndBuildRumConfiguration, } from '../domain/configuration';
import { serializeRumConfiguration } from '../domain/configuration';
export function createPreStartStrategy(_a, getCommonContext, trackingConsentState, doStartRum) {

@@ -30,3 +31,3 @@ var ignoreInitIfSyntheticsWillInjectRum = _a.ignoreInitIfSyntheticsWillInjectRum, startDeflateWorker = _a.startDeflateWorker;

}
var startRumResult = doStartRum(cachedInitConfiguration, cachedConfiguration, deflateWorker, initialViewOptions);
var startRumResult = doStartRum(cachedConfiguration, deflateWorker, initialViewOptions);
bufferApiCalls.drain(startRumResult);

@@ -40,2 +41,4 @@ }

}
// Set the experimental feature flags as early as possible, so we can use them in most places
initFeatureFlags(initConfiguration.enableExperimentalFeatures);
var eventBridgeAvailable = canUseEventBridge();

@@ -47,2 +50,3 @@ if (eventBridgeAvailable) {

cachedInitConfiguration = initConfiguration;
addTelemetryConfiguration(serializeRumConfiguration(initConfiguration));
if (cachedConfiguration) {

@@ -49,0 +53,0 @@ displayAlreadyInitializedError('DD_RUM', initConfiguration);

@@ -10,2 +10,5 @@ import type { Context, User, DeflateWorker, DeflateEncoderStreamId, DeflateEncoder, TrackingConsent, PublicApi } from '@datadog/browser-core';

import type { StartRum, StartRumResult } from './startRum';
export interface StartRecordingOptions {
force: boolean;
}
export interface RumPublicApi extends PublicApi {

@@ -180,3 +183,3 @@ /**

*/
startSessionReplayRecording: () => void;
startSessionReplayRecording: (options?: StartRecordingOptions) => void;
/**

@@ -190,3 +193,3 @@ * Stop Session Replay recording.

export interface RecorderApi {
start: () => void;
start: (options?: StartRecordingOptions) => void;
stop: () => void;

@@ -193,0 +196,0 @@ onRumStart: (lifeCycle: LifeCycle, configuration: RumConfiguration, sessionManager: RumSessionManager, viewContexts: ViewContexts, deflateWorker: DeflateWorker | undefined) => void;

@@ -14,3 +14,3 @@ import { addTelemetryUsage, timeStampToClocks, isExperimentalFeatureEnabled, ExperimentalFeature, assign, createContextManager, deepClone, makePublicApi, monitor, clocksNow, callMonitored, createHandlingStack, checkUser, sanitizeUser, sanitize, createIdentityEncoder, createCustomerDataTrackerManager, storeContextManager, displayAlreadyInitializedError, createTrackingConsentState, } from '@datadog/browser-core';

}
var strategy = createPreStartStrategy(options, getCommonContext, trackingConsentState, function (initConfiguration, configuration, deflateWorker, initialViewOptions) {
var strategy = createPreStartStrategy(options, getCommonContext, trackingConsentState, function (configuration, deflateWorker, initialViewOptions) {
if (isExperimentalFeatureEnabled(ExperimentalFeature.CUSTOM_VITALS)) {

@@ -42,3 +42,3 @@ /**

}
if (initConfiguration.storeContextsAcrossPages) {
if (configuration.storeContextsAcrossPages) {
storeContextManager(configuration, globalContextManager, RUM_STORAGE_KEY, 2 /* CustomerDataType.GlobalContext */);

@@ -48,7 +48,7 @@ storeContextManager(configuration, userContextManager, RUM_STORAGE_KEY, 1 /* CustomerDataType.User */);

customerDataTrackerManager.setCompressionStatus(deflateWorker ? 1 /* CustomerDataCompressionStatus.Enabled */ : 2 /* CustomerDataCompressionStatus.Disabled */);
var startRumResult = startRumImpl(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && options.createDeflateEncoder
var startRumResult = startRumImpl(configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, deflateWorker && options.createDeflateEncoder
? function (streamId) { return options.createDeflateEncoder(configuration, deflateWorker, streamId); }
: createIdentityEncoder, trackingConsentState);
recorderApi.onRumStart(startRumResult.lifeCycle, configuration, startRumResult.session, startRumResult.viewContexts, deflateWorker);
strategy = createPostStartStrategy(initConfiguration, startRumResult);
strategy = createPostStartStrategy(strategy, startRumResult);
return startRumResult;

@@ -134,5 +134,5 @@ });

getSessionReplayLink: monitor(function () { return recorderApi.getSessionReplayLink(); }),
startSessionReplayRecording: monitor(function () {
recorderApi.start();
addTelemetryUsage({ feature: 'start-session-replay-recording' });
startSessionReplayRecording: monitor(function (options) {
recorderApi.start(options);
addTelemetryUsage({ feature: 'start-session-replay-recording', force: options === null || options === void 0 ? void 0 : options.force });
}),

@@ -143,3 +143,3 @@ stopSessionReplayRecording: monitor(function () { return recorderApi.stop(); }),

}
function createPostStartStrategy(initConfiguration, startRumResult) {
function createPostStartStrategy(preStartStrategy, startRumResult) {
return assign({

@@ -149,5 +149,5 @@ init: function (initConfiguration) {

},
initConfiguration: initConfiguration,
initConfiguration: preStartStrategy.initConfiguration,
}, startRumResult);
}
//# sourceMappingURL=rumPublicApi.js.map

@@ -5,3 +5,3 @@ import type { Observable, RawError, DeflateEncoderStreamId, Encoder, CustomerDataTrackerManager, TrackingConsentState } from '@datadog/browser-core';

import type { LocationChange } from '../browser/locationChangeObservable';
import type { RumConfiguration, RumInitConfiguration } from '../domain/configuration';
import type { RumConfiguration } from '../domain/configuration';
import type { ViewOptions } from '../domain/view/trackViews';

@@ -12,3 +12,3 @@ import type { CommonContext } from '../domain/contexts/commonContext';

export type StartRumResult = ReturnType<StartRum>;
export declare function startRum(initConfiguration: RumInitConfiguration, configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, getCommonContext: () => CommonContext, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder, trackingConsentState: TrackingConsentState): {
export declare function startRum(configuration: RumConfiguration, recorderApi: RecorderApi, customerDataTrackerManager: CustomerDataTrackerManager, getCommonContext: () => CommonContext, initialViewOptions: ViewOptions | undefined, createEncoder: (streamId: DeflateEncoderStreamId) => Encoder, trackingConsentState: TrackingConsentState): {
addAction: (action: import("../domain/action/actionCollection").CustomAction, savedCommonContext?: CommonContext | undefined) => void;

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

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

import { sendToExtension, createPageExitObservable, addTelemetryConfiguration, startTelemetry, canUseEventBridge, getEventBridge, addTelemetryDebug, drainPreStartTelemetry, } from '@datadog/browser-core';
import { sendToExtension, createPageExitObservable, startTelemetry, canUseEventBridge, getEventBridge, addTelemetryDebug, drainPreStartTelemetry, } from '@datadog/browser-core';
import { createDOMMutationObservable } from '../browser/domMutationObservable';

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

import { createLocationChangeObservable } from '../browser/locationChangeObservable';
import { serializeRumConfiguration } from '../domain/configuration';
import { startFeatureFlagContexts } from '../domain/contexts/featureFlagContext';

@@ -27,3 +26,3 @@ import { startCustomerDataTelemetry } from '../domain/startCustomerDataTelemetry';

import { startCiVisibilityContext } from '../domain/contexts/ciVisibilityContext';
export function startRum(initConfiguration, configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, createEncoder,
export function startRum(configuration, recorderApi, customerDataTrackerManager, getCommonContext, initialViewOptions, createEncoder,
// `startRum` and its subcomponents assume tracking consent is granted initially and starts

@@ -80,3 +79,2 @@ // collecting logs unconditionally. As such, `startRum` should be called with a

drainPreStartTelemetry();
addTelemetryConfiguration(serializeRumConfiguration(initConfiguration));
startLongTaskCollection(lifeCycle, configuration);

@@ -83,0 +81,0 @@ startResourceCollection(lifeCycle, configuration, pageStateHistory);

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

import type { ViewContexts } from './contexts/viewContexts';
import type { RumSessionManager } from './rumSessionManager';
import { type RumSessionManager } from './rumSessionManager';
import type { UrlContexts } from './contexts/urlContexts';

@@ -8,0 +8,0 @@ import type { RumConfiguration } from './configuration';

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

var _a, _b;
// TODO: lift this declaration to module level once feature flag is removed
var ROOT_MODIFIABLE_FIELD_PATHS = isExperimentalFeatureEnabled(ExperimentalFeature.MICRO_FRONTEND)
? {
service: 'string',
version: 'string',
}
: {};
modifiableFieldPathsByEvent = (_a = {},

@@ -23,11 +30,13 @@ _a["view" /* RumEventType.VIEW */] = VIEW_MODIFIABLE_FIELD_PATHS,

'error.fingerprint': 'string',
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS, ROOT_MODIFIABLE_FIELD_PATHS),
_a["resource" /* RumEventType.RESOURCE */] = assign({
'resource.url': 'string',
}, isExperimentalFeatureEnabled(ExperimentalFeature.WRITABLE_RESOURCE_GRAPHQL) && {
'resource.graphql': 'object',
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),
}, isExperimentalFeatureEnabled(ExperimentalFeature.WRITABLE_RESOURCE_GRAPHQL)
? {
'resource.graphql': 'object',
}
: {}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS, ROOT_MODIFIABLE_FIELD_PATHS),
_a["action" /* RumEventType.ACTION */] = assign({
'action.target.name': 'string',
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),
}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS, ROOT_MODIFIABLE_FIELD_PATHS),
_a["long_task" /* RumEventType.LONG_TASK */] = assign({}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),

@@ -58,3 +67,3 @@ _a["vital" /* RumEventType.VITAL */] = assign({}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),

},
browser_sdk_version: canUseEventBridge() ? "5.20.0" : undefined,
browser_sdk_version: canUseEventBridge() ? "5.21.0" : undefined,
},

@@ -96,3 +105,4 @@ application: {

;
serverRumEvent.session.sampled_for_replay = session.sessionReplayAllowed;
serverRumEvent.session.sampled_for_replay =
session.sessionReplay === 1 /* SessionReplayState.SAMPLED */;
}

@@ -99,0 +109,0 @@ if (!isEmptyObject(commonContext.user)) {

@@ -8,18 +8,89 @@ import type { Configuration, InitConfiguration, MatchOption } from '@datadog/browser-core';

export interface RumInitConfiguration extends InitConfiguration {
/**
* The RUM application ID.
*/
applicationId: string;
/**
* Access to every event collected by the RUM SDK before they are sent to Datadog.
* It allows:
* - Enrich your RUM events with additional context attributes
* - Modify your RUM events to modify their content, or redact sensitive sequences (see the list of editable properties)
* - Discard selected RUM events
*
* See [Enrich And Control Browser RUM Data With beforeSend](https://docs.datadoghq.com/real_user_monitoring/guide/enrich-and-control-rum-data) for further information.
*/
beforeSend?: ((event: RumEvent, context: RumEventDomainContext) => boolean) | undefined;
/**
* A list of request origins ignored when computing the page activity.
* See [How page activity is calculated](https://docs.datadoghq.com/real_user_monitoring/browser/monitoring_page_performance/#how-page-activity-is-calculated) for further information.
*/
excludedActivityUrls?: MatchOption[] | undefined;
/**
* URL pointing to the Datadog Browser SDK Worker JavaScript file. The URL can be relative or absolute, but is required to have the same origin as the web application.
* See [Content Security Policy guidelines](https://docs.datadoghq.com/integrations/content_security_policy_logs/?tab=firefox#use-csp-with-real-user-monitoring-and-session-replay) for further information.
*/
workerUrl?: string;
/**
* Compress requests sent to the Datadog intake to reduce bandwidth usage when sending large amounts of data. The compression is done in a Worker thread.
* See [Content Security Policy guidelines](https://docs.datadoghq.com/integrations/content_security_policy_logs/?tab=firefox#use-csp-with-real-user-monitoring-and-session-replay) for further information.
*/
compressIntakeRequests?: boolean | undefined;
/**
* A list of request URLs used to inject tracing headers.
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*/
allowedTracingUrls?: Array<MatchOption | TracingOption> | undefined;
/**
* The percentage of requests to trace: 100 for all, 0 for none.
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*/
traceSampleRate?: number | undefined;
/**
* If you set a `traceSampleRate`, to ensure backend services' sampling decisions are still applied, configure the `traceContextInjection` initialization parameter to sampled.
* @default all
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*/
traceContextInjection?: TraceContextInjection | undefined;
/**
* Allow to protect end user privacy and prevent sensitive organizational information from being collected.
* @default mask
* See [Replay Privacy Options](https://docs.datadoghq.com/real_user_monitoring/session_replay/browser/privacy_options) for further information.
*/
defaultPrivacyLevel?: DefaultPrivacyLevel | undefined;
/**
* If you are accessing Datadog through a custom subdomain, you can set `subdomain` to include your custom domain in the `getSessionReplayLink()` returned URL .
* See [Connect Session Replay To Your Third-Party Tools](https://docs.datadoghq.com/real_user_monitoring/guide/connect-session-replay-to-your-third-party-tools) for further information.
*/
subdomain?: string;
/**
* The percentage of tracked sessions with [Browser RUM & Session Replay pricing](https://www.datadoghq.com/pricing/?product=real-user-monitoring--session-replay#real-user-monitoring--session-replay) features: 100 for all, 0 for none.
* See [Configure Your Setup For Browser RUM and Browser RUM & Session Replay Sampling](https://docs.datadoghq.com/real_user_monitoring/guide/sampling-browser-plans) for further information.
*/
sessionReplaySampleRate?: number | undefined;
/**
* If the session is sampled for Session Replay, only start the recording when `startSessionReplayRecording()` is called, instead of at the beginning of the session.
* See [Session Replay Usage](https://docs.datadoghq.com/real_user_monitoring/session_replay/browser/#usage) for further information.
*/
startSessionReplayRecordingManually?: boolean | undefined;
/**
* Enables automatic collection of users actions.
* See [Tracking User Actions](https://docs.datadoghq.com/real_user_monitoring/browser/tracking_user_actions) for further information.
*/
trackUserInteractions?: boolean | undefined;
/**
* Specify your own attribute to use to name actions.
* See [Declare a name for click actions](https://docs.datadoghq.com/real_user_monitoring/browser/tracking_user_actions/#declare-a-name-for-click-actions) for further information.
*/
actionNameAttribute?: string | undefined;
/**
* Allows you to control RUM views creation. See [Override default RUM view names](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#override-default-rum-view-names) for further information.
*/
trackViewsManually?: boolean | undefined;
/**
* Enables collection of resource events.
*/
trackResources?: boolean | undefined;
/**
* Enables collection of long task events.
*/
trackLongTasks?: boolean | undefined;

@@ -26,0 +97,0 @@ }

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

expireObservable: Observable<void>;
setForcedReplay: () => void;
}
export type RumSession = {
id: string;
sessionReplayAllowed: boolean;
sessionReplay: SessionReplayState;
};

@@ -21,2 +22,7 @@ export declare const enum RumTrackingType {

}
export declare const enum SessionReplayState {
OFF = 0,
SAMPLED = 1,
FORCED = 2
}
export declare function startRumSessionManager(configuration: RumConfiguration, lifeCycle: LifeCycle, trackingConsentState: TrackingConsentState): RumSessionManager;

@@ -23,0 +29,0 @@ /**

@@ -11,2 +11,11 @@ import { Observable, bridgeSupports, noop, performDraw, startSessionManager, } from '@datadog/browser-core';

});
sessionManager.sessionStateUpdateObservable.subscribe(function (_a) {
var previousState = _a.previousState, newState = _a.newState;
if (!previousState.forcedReplay && newState.forcedReplay) {
var sessionEntity = sessionManager.findSession();
if (sessionEntity) {
sessionEntity.isReplayForced = true;
}
}
});
return {

@@ -20,3 +29,7 @@ findTrackedSession: function (startTime) {

id: session.id,
sessionReplayAllowed: session.trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */,
sessionReplay: session.trackingType === "1" /* RumTrackingType.TRACKED_WITH_SESSION_REPLAY */
? 1 /* SessionReplayState.SAMPLED */
: session.isReplayForced
? 2 /* SessionReplayState.FORCED */
: 0 /* SessionReplayState.OFF */,
};

@@ -26,2 +39,3 @@ },

expireObservable: sessionManager.expireObservable,
setForcedReplay: function () { return sessionManager.updateSessionState({ forcedReplay: '1' }); },
};

@@ -35,3 +49,3 @@ }

id: '00000000-aaaa-0000-aaaa-000000000000',
sessionReplayAllowed: bridgeSupports("records" /* BridgeCapability.RECORDS */),
sessionReplay: bridgeSupports("records" /* BridgeCapability.RECORDS */) ? 1 /* SessionReplayState.SAMPLED */ : 0 /* SessionReplayState.OFF */,
};

@@ -42,2 +56,3 @@ return {

expireObservable: new Observable(),
setForcedReplay: noop,
};

@@ -44,0 +59,0 @@ }

@@ -11,3 +11,3 @@ import { isEmptyObject, mapValues, toServerDuration } from '@datadog/browser-core';

function processViewUpdate(view, configuration, featureFlagContexts, recorderApi, pageStateHistory) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
var replayStats = recorderApi.getReplayStats(view.id);

@@ -35,7 +35,8 @@ var featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(view.startClocks.relative);

cumulative_layout_shift: (_a = view.commonViewMetrics.cumulativeLayoutShift) === null || _a === void 0 ? void 0 : _a.value,
cumulative_layout_shift_target_selector: (_b = view.commonViewMetrics.cumulativeLayoutShift) === null || _b === void 0 ? void 0 : _b.targetSelector,
first_byte: toServerDuration((_c = view.initialViewMetrics.navigationTimings) === null || _c === void 0 ? void 0 : _c.firstByte),
dom_complete: toServerDuration((_d = view.initialViewMetrics.navigationTimings) === null || _d === void 0 ? void 0 : _d.domComplete),
dom_content_loaded: toServerDuration((_e = view.initialViewMetrics.navigationTimings) === null || _e === void 0 ? void 0 : _e.domContentLoaded),
dom_interactive: toServerDuration((_f = view.initialViewMetrics.navigationTimings) === null || _f === void 0 ? void 0 : _f.domInteractive),
cumulative_layout_shift_time: toServerDuration((_b = view.commonViewMetrics.cumulativeLayoutShift) === null || _b === void 0 ? void 0 : _b.time),
cumulative_layout_shift_target_selector: (_c = view.commonViewMetrics.cumulativeLayoutShift) === null || _c === void 0 ? void 0 : _c.targetSelector,
first_byte: toServerDuration((_d = view.initialViewMetrics.navigationTimings) === null || _d === void 0 ? void 0 : _d.firstByte),
dom_complete: toServerDuration((_e = view.initialViewMetrics.navigationTimings) === null || _e === void 0 ? void 0 : _e.domComplete),
dom_content_loaded: toServerDuration((_f = view.initialViewMetrics.navigationTimings) === null || _f === void 0 ? void 0 : _f.domContentLoaded),
dom_interactive: toServerDuration((_g = view.initialViewMetrics.navigationTimings) === null || _g === void 0 ? void 0 : _g.domInteractive),
error: {

@@ -45,12 +46,13 @@ count: view.eventCounts.errorCount,

first_contentful_paint: toServerDuration(view.initialViewMetrics.firstContentfulPaint),
first_input_delay: toServerDuration((_g = view.initialViewMetrics.firstInput) === null || _g === void 0 ? void 0 : _g.delay),
first_input_time: toServerDuration((_h = view.initialViewMetrics.firstInput) === null || _h === void 0 ? void 0 : _h.time),
first_input_target_selector: (_j = view.initialViewMetrics.firstInput) === null || _j === void 0 ? void 0 : _j.targetSelector,
interaction_to_next_paint: toServerDuration((_k = view.commonViewMetrics.interactionToNextPaint) === null || _k === void 0 ? void 0 : _k.value),
interaction_to_next_paint_target_selector: (_l = view.commonViewMetrics.interactionToNextPaint) === null || _l === void 0 ? void 0 : _l.targetSelector,
first_input_delay: toServerDuration((_h = view.initialViewMetrics.firstInput) === null || _h === void 0 ? void 0 : _h.delay),
first_input_time: toServerDuration((_j = view.initialViewMetrics.firstInput) === null || _j === void 0 ? void 0 : _j.time),
first_input_target_selector: (_k = view.initialViewMetrics.firstInput) === null || _k === void 0 ? void 0 : _k.targetSelector,
interaction_to_next_paint: toServerDuration((_l = view.commonViewMetrics.interactionToNextPaint) === null || _l === void 0 ? void 0 : _l.value),
interaction_to_next_paint_time: toServerDuration((_m = view.commonViewMetrics.interactionToNextPaint) === null || _m === void 0 ? void 0 : _m.time),
interaction_to_next_paint_target_selector: (_o = view.commonViewMetrics.interactionToNextPaint) === null || _o === void 0 ? void 0 : _o.targetSelector,
is_active: view.isActive,
name: view.name,
largest_contentful_paint: toServerDuration((_m = view.initialViewMetrics.largestContentfulPaint) === null || _m === void 0 ? void 0 : _m.value),
largest_contentful_paint_target_selector: (_o = view.initialViewMetrics.largestContentfulPaint) === null || _o === void 0 ? void 0 : _o.targetSelector,
load_event: toServerDuration((_p = view.initialViewMetrics.navigationTimings) === null || _p === void 0 ? void 0 : _p.loadEvent),
largest_contentful_paint: toServerDuration((_p = view.initialViewMetrics.largestContentfulPaint) === null || _p === void 0 ? void 0 : _p.value),
largest_contentful_paint_target_selector: (_q = view.initialViewMetrics.largestContentfulPaint) === null || _q === void 0 ? void 0 : _q.targetSelector,
load_event: toServerDuration((_r = view.initialViewMetrics.navigationTimings) === null || _r === void 0 ? void 0 : _r.loadEvent),
loading_time: discardNegativeDuration(toServerDuration(view.commonViewMetrics.loadingTime)),

@@ -57,0 +59,0 @@ loading_type: view.loadingType,

@@ -14,3 +14,3 @@ import { trackCumulativeLayoutShift } from './trackCumulativeLayoutShift';

}).stop;
var stopCLSTracking = trackCumulativeLayoutShift(configuration, lifeCycle, function (cumulativeLayoutShift) {
var stopCLSTracking = trackCumulativeLayoutShift(configuration, lifeCycle, viewStart.relative, function (cumulativeLayoutShift) {
commonViewMetrics.cumulativeLayoutShift = cumulativeLayoutShift;

@@ -17,0 +17,0 @@ scheduleViewUpdate();

import { noop } from '@datadog/browser-core';
import type { Duration, RelativeTime } from '@datadog/browser-core';
import type { LifeCycle } from '../../lifeCycle';

@@ -7,2 +8,3 @@ import type { RumConfiguration } from '../../configuration';

targetSelector?: string;
time?: Duration;
}

@@ -26,3 +28,3 @@ /**

*/
export declare function trackCumulativeLayoutShift(configuration: RumConfiguration, lifeCycle: LifeCycle, callback: (cumulativeLayoutShift: CumulativeLayoutShift) => void): {
export declare function trackCumulativeLayoutShift(configuration: RumConfiguration, lifeCycle: LifeCycle, viewStart: RelativeTime, callback: (cumulativeLayoutShift: CumulativeLayoutShift) => void): {
stop: typeof noop;

@@ -29,0 +31,0 @@ };

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

import { round, find, ONE_SECOND, noop } from '@datadog/browser-core';
import { round, find, ONE_SECOND, noop, elapsed } from '@datadog/browser-core';
import { isElementNode } from '../../../browser/htmlDomUtils';

@@ -22,3 +22,3 @@ import { supportPerformanceTimingEvent, RumPerformanceEntryType } from '../../../browser/performanceCollection';

*/
export function trackCumulativeLayoutShift(configuration, lifeCycle, callback) {
export function trackCumulativeLayoutShift(configuration, lifeCycle, viewStart, callback) {
if (!isLayoutShiftSupported()) {

@@ -32,2 +32,3 @@ return {

var maxClsTarget;
var maxClsStartTime;
// if no layout shift happen the value should be reported as 0

@@ -46,2 +47,3 @@ callback({

maxClsTarget = target ? new WeakRef(target) : undefined;
maxClsStartTime = elapsed(viewStart, entry.startTime);
}

@@ -54,2 +56,3 @@ if (cumulatedValue > maxClsValue) {

targetSelector: target && getSelectorFromElement(target, configuration.actionNameAttribute),
time: maxClsStartTime,
});

@@ -56,0 +59,0 @@ }

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

targetSelector?: string;
time?: Duration;
}

@@ -11,0 +12,0 @@ /**

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

import { noop, ONE_MINUTE } from '@datadog/browser-core';
import { elapsed, noop, ONE_MINUTE } from '@datadog/browser-core';
import { RumPerformanceEntryType, supportPerformanceTimingEvent } from '../../../browser/performanceCollection';

@@ -29,2 +29,3 @@ import { getSelectorFromElement } from '../../getSelectorFromElement';

var interactionToNextPaintTargetSelector;
var interactionToNextPaintStartTime;
var stop = lifeCycle.subscribe(0 /* LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {

@@ -45,2 +46,3 @@ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {

interactionToNextPaint = newInteraction.duration;
interactionToNextPaintStartTime = elapsed(viewStart, newInteraction.startTime);
if (newInteraction.target && isElementNode(newInteraction.target)) {

@@ -62,2 +64,3 @@ interactionToNextPaintTargetSelector = getSelectorFromElement(newInteraction.target, configuration.actionNameAttribute);

targetSelector: interactionToNextPaintTargetSelector,
time: interactionToNextPaintStartTime,
};

@@ -64,0 +67,0 @@ }

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

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

@@ -21,1 +21,2 @@ export { RumEvent, RumActionEvent, CommonProperties, RumErrorEvent, RumViewEvent, RumResourceEvent, RumLongTaskEvent, RumVitalEvent, } from './rumEvent.types';

export { isLongDataUrl, sanitizeDataUrl, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH } from './domain/resource/resourceUtils';
export { SessionReplayState } from './domain/rumSessionManager';

@@ -77,4 +77,6 @@ import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel, Connectivity, Csp } from '@datadog/browser-core';

interaction_to_next_paint?: ServerDuration;
interaction_to_next_paint_time?: ServerDuration;
interaction_to_next_paint_target_selector?: string;
cumulative_layout_shift?: number;
cumulative_layout_shift_time?: ServerDuration;
cumulative_layout_shift_target_selector?: string;

@@ -81,0 +83,0 @@ custom_timings?: {

@@ -695,2 +695,6 @@ /**

/**
* Duration in ns between start of the view and start of the INP
*/
readonly interaction_to_next_paint_time?: number;
/**
* CSS selector path of the interacted element corresponding to INP

@@ -704,2 +708,6 @@ */

/**
* Duration in ns between start of the view and start of the largest layout shift contributing to CLS
*/
readonly cumulative_layout_shift_time?: number;
/**
* CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS

@@ -1047,7 +1055,7 @@ */

*/
readonly service?: string;
service?: string;
/**
* The version for this application
*/
readonly version?: string;
version?: string;
/**

@@ -1054,0 +1062,0 @@ * The build version for this application

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

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

"dependencies": {
"@datadog/browser-core": "5.20.0"
"@datadog/browser-core": "5.21.0"
},

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

},
"gitHead": "1dafdcfbf43a0f0ed8a0cbd5f13d16ba68378074"
"gitHead": "717e92a496147b5e5f4e0e23e56984944a9c0493"
}

@@ -12,2 +12,4 @@ import {

getEventBridge,
addTelemetryConfiguration,
initFeatureFlags,
} from '@datadog/browser-core'

@@ -22,2 +24,3 @@ import type { TrackingConsentState, DeflateWorker } from '@datadog/browser-core'

import type { ViewOptions } from '../domain/view/trackViews'
import { serializeRumConfiguration } from '../domain/configuration'
import type { RumPublicApiOptions, Strategy } from './rumPublicApi'

@@ -31,3 +34,2 @@ import type { StartRumResult } from './startRum'

doStartRum: (
initConfiguration: RumInitConfiguration,
configuration: RumConfiguration,

@@ -72,3 +74,3 @@ deflateWorker: DeflateWorker | undefined,

const startRumResult = doStartRum(cachedInitConfiguration, cachedConfiguration, deflateWorker, initialViewOptions)
const startRumResult = doStartRum(cachedConfiguration, deflateWorker, initialViewOptions)

@@ -85,2 +87,5 @@ bufferApiCalls.drain(startRumResult)

// Set the experimental feature flags as early as possible, so we can use them in most places
initFeatureFlags(initConfiguration.enableExperimentalFeatures)
const eventBridgeAvailable = canUseEventBridge()

@@ -93,2 +98,3 @@ if (eventBridgeAvailable) {

cachedInitConfiguration = initConfiguration
addTelemetryConfiguration(serializeRumConfiguration(initConfiguration))

@@ -95,0 +101,0 @@ if (cachedConfiguration) {

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

export interface StartRecordingOptions {
force: boolean
}
export interface RumPublicApi extends PublicApi {

@@ -238,3 +241,3 @@ /**

*/
startSessionReplayRecording: () => void
startSessionReplayRecording: (options?: StartRecordingOptions) => void

@@ -250,3 +253,3 @@ /**

export interface RecorderApi {
start: () => void
start: (options?: StartRecordingOptions) => void
stop: () => void

@@ -316,3 +319,3 @@ onRumStart: (

(initConfiguration, configuration, deflateWorker, initialViewOptions) => {
(configuration, deflateWorker, initialViewOptions) => {
if (isExperimentalFeatureEnabled(ExperimentalFeature.CUSTOM_VITALS)) {

@@ -357,3 +360,3 @@ /**

if (initConfiguration.storeContextsAcrossPages) {
if (configuration.storeContextsAcrossPages) {
storeContextManager(configuration, globalContextManager, RUM_STORAGE_KEY, CustomerDataType.GlobalContext)

@@ -368,3 +371,2 @@ storeContextManager(configuration, userContextManager, RUM_STORAGE_KEY, CustomerDataType.User)

const startRumResult = startRumImpl(
initConfiguration,
configuration,

@@ -389,3 +391,3 @@ recorderApi,

strategy = createPostStartStrategy(initConfiguration, startRumResult)
strategy = createPostStartStrategy(strategy, startRumResult)

@@ -497,6 +499,5 @@ return startRumResult

getSessionReplayLink: monitor(() => recorderApi.getSessionReplayLink()),
startSessionReplayRecording: monitor(() => {
recorderApi.start()
addTelemetryUsage({ feature: 'start-session-replay-recording' })
startSessionReplayRecording: monitor((options?: StartRecordingOptions) => {
recorderApi.start(options)
addTelemetryUsage({ feature: 'start-session-replay-recording', force: options?.force })
}),

@@ -510,3 +511,3 @@

function createPostStartStrategy(initConfiguration: RumInitConfiguration, startRumResult: StartRumResult): Strategy {
function createPostStartStrategy(preStartStrategy: Strategy, startRumResult: StartRumResult): Strategy {
return assign(

@@ -517,3 +518,3 @@ {

},
initConfiguration,
initConfiguration: preStartStrategy.initConfiguration,
},

@@ -520,0 +521,0 @@ startRumResult

@@ -14,3 +14,2 @@ import type {

TelemetryService,
addTelemetryConfiguration,
startTelemetry,

@@ -42,4 +41,3 @@ canUseEventBridge,

import { createLocationChangeObservable } from '../browser/locationChangeObservable'
import type { RumConfiguration, RumInitConfiguration } from '../domain/configuration'
import { serializeRumConfiguration } from '../domain/configuration'
import type { RumConfiguration } from '../domain/configuration'
import type { ViewOptions } from '../domain/view/trackViews'

@@ -59,3 +57,2 @@ import { startFeatureFlagContexts } from '../domain/contexts/featureFlagContext'

export function startRum(
initConfiguration: RumInitConfiguration,
configuration: RumConfiguration,

@@ -151,3 +148,2 @@ recorderApi: RecorderApi,

drainPreStartTelemetry()
addTelemetryConfiguration(serializeRumConfiguration(initConfiguration))

@@ -154,0 +150,0 @@ startLongTaskCollection(lifeCycle, configuration)

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

import type { ViewContexts } from './contexts/viewContexts'
import type { RumSessionManager } from './rumSessionManager'
import { SessionReplayState, type RumSessionManager } from './rumSessionManager'
import type { UrlContexts } from './contexts/urlContexts'

@@ -76,2 +76,12 @@ import type { RumConfiguration } from './configuration'

) {
// TODO: lift this declaration to module level once feature flag is removed
const ROOT_MODIFIABLE_FIELD_PATHS: ModifiableFieldPaths = isExperimentalFeatureEnabled(
ExperimentalFeature.MICRO_FRONTEND
)
? {
service: 'string',
version: 'string',
}
: {}
modifiableFieldPathsByEvent = {

@@ -87,3 +97,4 @@ [RumEventType.VIEW]: VIEW_MODIFIABLE_FIELD_PATHS,

USER_CUSTOMIZABLE_FIELD_PATHS,
VIEW_MODIFIABLE_FIELD_PATHS
VIEW_MODIFIABLE_FIELD_PATHS,
ROOT_MODIFIABLE_FIELD_PATHS
),

@@ -94,7 +105,10 @@ [RumEventType.RESOURCE]: assign(

},
isExperimentalFeatureEnabled(ExperimentalFeature.WRITABLE_RESOURCE_GRAPHQL) && {
'resource.graphql': 'object',
},
isExperimentalFeatureEnabled(ExperimentalFeature.WRITABLE_RESOURCE_GRAPHQL)
? {
'resource.graphql': 'object',
}
: {},
USER_CUSTOMIZABLE_FIELD_PATHS,
VIEW_MODIFIABLE_FIELD_PATHS
VIEW_MODIFIABLE_FIELD_PATHS,
ROOT_MODIFIABLE_FIELD_PATHS
),

@@ -106,3 +120,4 @@ [RumEventType.ACTION]: assign(

USER_CUSTOMIZABLE_FIELD_PATHS,
VIEW_MODIFIABLE_FIELD_PATHS
VIEW_MODIFIABLE_FIELD_PATHS,
ROOT_MODIFIABLE_FIELD_PATHS
),

@@ -186,3 +201,4 @@ [RumEventType.LONG_TASK]: assign({}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS),

if (serverRumEvent.type === 'view') {
;(serverRumEvent.session as Mutable<RumEvent['session']>).sampled_for_replay = session.sessionReplayAllowed
;(serverRumEvent.session as Mutable<RumEvent['session']>).sampled_for_replay =
session.sessionReplay === SessionReplayState.SAMPLED
}

@@ -189,0 +205,0 @@

@@ -24,27 +24,98 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core'

// global options
/**
* The RUM application ID.
*/
applicationId: string
/**
* Access to every event collected by the RUM SDK before they are sent to Datadog.
* It allows:
* - Enrich your RUM events with additional context attributes
* - Modify your RUM events to modify their content, or redact sensitive sequences (see the list of editable properties)
* - Discard selected RUM events
*
* See [Enrich And Control Browser RUM Data With beforeSend](https://docs.datadoghq.com/real_user_monitoring/guide/enrich-and-control-rum-data) for further information.
*/
beforeSend?: ((event: RumEvent, context: RumEventDomainContext) => boolean) | undefined
/**
* A list of request origins ignored when computing the page activity.
* See [How page activity is calculated](https://docs.datadoghq.com/real_user_monitoring/browser/monitoring_page_performance/#how-page-activity-is-calculated) for further information.
*/
excludedActivityUrls?: MatchOption[] | undefined
/**
* URL pointing to the Datadog Browser SDK Worker JavaScript file. The URL can be relative or absolute, but is required to have the same origin as the web application.
* See [Content Security Policy guidelines](https://docs.datadoghq.com/integrations/content_security_policy_logs/?tab=firefox#use-csp-with-real-user-monitoring-and-session-replay) for further information.
*/
workerUrl?: string
/**
* Compress requests sent to the Datadog intake to reduce bandwidth usage when sending large amounts of data. The compression is done in a Worker thread.
* See [Content Security Policy guidelines](https://docs.datadoghq.com/integrations/content_security_policy_logs/?tab=firefox#use-csp-with-real-user-monitoring-and-session-replay) for further information.
*/
compressIntakeRequests?: boolean | undefined
// tracing options
/**
* A list of request URLs used to inject tracing headers.
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*/
allowedTracingUrls?: Array<MatchOption | TracingOption> | undefined
/**
* The percentage of requests to trace: 100 for all, 0 for none.
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*/
traceSampleRate?: number | undefined
/**
* If you set a `traceSampleRate`, to ensure backend services' sampling decisions are still applied, configure the `traceContextInjection` initialization parameter to sampled.
* @default all
* See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/?tab=browserrum) for further information.
*/
traceContextInjection?: TraceContextInjection | undefined
// replay options
/**
* Allow to protect end user privacy and prevent sensitive organizational information from being collected.
* @default mask
* See [Replay Privacy Options](https://docs.datadoghq.com/real_user_monitoring/session_replay/browser/privacy_options) for further information.
*/
defaultPrivacyLevel?: DefaultPrivacyLevel | undefined
/**
* If you are accessing Datadog through a custom subdomain, you can set `subdomain` to include your custom domain in the `getSessionReplayLink()` returned URL .
* See [Connect Session Replay To Your Third-Party Tools](https://docs.datadoghq.com/real_user_monitoring/guide/connect-session-replay-to-your-third-party-tools) for further information.
*/
subdomain?: string
/**
* The percentage of tracked sessions with [Browser RUM & Session Replay pricing](https://www.datadoghq.com/pricing/?product=real-user-monitoring--session-replay#real-user-monitoring--session-replay) features: 100 for all, 0 for none.
* See [Configure Your Setup For Browser RUM and Browser RUM & Session Replay Sampling](https://docs.datadoghq.com/real_user_monitoring/guide/sampling-browser-plans) for further information.
*/
sessionReplaySampleRate?: number | undefined
/**
* If the session is sampled for Session Replay, only start the recording when `startSessionReplayRecording()` is called, instead of at the beginning of the session.
* See [Session Replay Usage](https://docs.datadoghq.com/real_user_monitoring/session_replay/browser/#usage) for further information.
*/
startSessionReplayRecordingManually?: boolean | undefined
// action options
/**
* Enables automatic collection of users actions.
* See [Tracking User Actions](https://docs.datadoghq.com/real_user_monitoring/browser/tracking_user_actions) for further information.
*/
trackUserInteractions?: boolean | undefined
/**
* Specify your own attribute to use to name actions.
* See [Declare a name for click actions](https://docs.datadoghq.com/real_user_monitoring/browser/tracking_user_actions/#declare-a-name-for-click-actions) for further information.
*/
actionNameAttribute?: string | undefined
// view options
/**
* Allows you to control RUM views creation. See [Override default RUM view names](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#override-default-rum-view-names) for further information.
*/
trackViewsManually?: boolean | undefined
/**
* Enables collection of resource events.
*/
trackResources?: boolean | undefined
/**
* Enables collection of long task events.
*/
trackLongTasks?: boolean | undefined

@@ -51,0 +122,0 @@ }

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

expireObservable: Observable<void>
setForcedReplay: () => void
}

@@ -25,3 +26,3 @@

id: string
sessionReplayAllowed: boolean
sessionReplay: SessionReplayState
}

@@ -35,2 +36,8 @@

export const enum SessionReplayState {
OFF,
SAMPLED,
FORCED,
}
export function startRumSessionManager(

@@ -56,2 +63,11 @@ configuration: RumConfiguration,

sessionManager.sessionStateUpdateObservable.subscribe(({ previousState, newState }) => {
if (!previousState.forcedReplay && newState.forcedReplay) {
const sessionEntity = sessionManager.findSession()
if (sessionEntity) {
sessionEntity.isReplayForced = true
}
}
})
return {

@@ -65,3 +81,8 @@ findTrackedSession: (startTime) => {

id: session.id,
sessionReplayAllowed: session.trackingType === RumTrackingType.TRACKED_WITH_SESSION_REPLAY,
sessionReplay:
session.trackingType === RumTrackingType.TRACKED_WITH_SESSION_REPLAY
? SessionReplayState.SAMPLED
: session.isReplayForced
? SessionReplayState.FORCED
: SessionReplayState.OFF,
}

@@ -71,2 +92,3 @@ },

expireObservable: sessionManager.expireObservable,
setForcedReplay: () => sessionManager.updateSessionState({ forcedReplay: '1' }),
}

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

id: '00000000-aaaa-0000-aaaa-000000000000',
sessionReplayAllowed: bridgeSupports(BridgeCapability.RECORDS),
sessionReplay: bridgeSupports(BridgeCapability.RECORDS) ? SessionReplayState.SAMPLED : SessionReplayState.OFF,
}

@@ -88,2 +110,3 @@ return {

expireObservable: new Observable(),
setForcedReplay: noop,
}

@@ -90,0 +113,0 @@ }

@@ -73,2 +73,3 @@ import type { Duration, ServerDuration, Observable } from '@datadog/browser-core'

cumulative_layout_shift: view.commonViewMetrics.cumulativeLayoutShift?.value,
cumulative_layout_shift_time: toServerDuration(view.commonViewMetrics.cumulativeLayoutShift?.time),
cumulative_layout_shift_target_selector: view.commonViewMetrics.cumulativeLayoutShift?.targetSelector,

@@ -87,2 +88,3 @@ first_byte: toServerDuration(view.initialViewMetrics.navigationTimings?.firstByte),

interaction_to_next_paint: toServerDuration(view.commonViewMetrics.interactionToNextPaint?.value),
interaction_to_next_paint_time: toServerDuration(view.commonViewMetrics.interactionToNextPaint?.time),
interaction_to_next_paint_target_selector: view.commonViewMetrics.interactionToNextPaint?.targetSelector,

@@ -89,0 +91,0 @@ is_active: view.isActive,

@@ -46,6 +46,11 @@ import type { ClocksState, Duration, Observable } from '@datadog/browser-core'

const { stop: stopCLSTracking } = trackCumulativeLayoutShift(configuration, lifeCycle, (cumulativeLayoutShift) => {
commonViewMetrics.cumulativeLayoutShift = cumulativeLayoutShift
scheduleViewUpdate()
})
const { stop: stopCLSTracking } = trackCumulativeLayoutShift(
configuration,
lifeCycle,
viewStart.relative,
(cumulativeLayoutShift) => {
commonViewMetrics.cumulativeLayoutShift = cumulativeLayoutShift
scheduleViewUpdate()
}
)

@@ -52,0 +57,0 @@ const {

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

import { round, find, ONE_SECOND, noop } from '@datadog/browser-core'
import type { RelativeTime, WeakRef, WeakRefConstructor } from '@datadog/browser-core'
import { round, find, ONE_SECOND, noop, elapsed } from '@datadog/browser-core'
import type { Duration, RelativeTime, WeakRef, WeakRefConstructor } from '@datadog/browser-core'
import { isElementNode } from '../../../browser/htmlDomUtils'

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

targetSelector?: string
time?: Duration
}

@@ -39,2 +40,3 @@

lifeCycle: LifeCycle,
viewStart: RelativeTime,
callback: (cumulativeLayoutShift: CumulativeLayoutShift) => void

@@ -51,2 +53,3 @@ ) {

let maxClsTarget: WeakRef<HTMLElement> | undefined
let maxClsStartTime: Duration | undefined

@@ -67,2 +70,3 @@ // if no layout shift happen the value should be reported as 0

maxClsTarget = target ? new WeakRef(target) : undefined
maxClsStartTime = elapsed(viewStart, entry.startTime)
}

@@ -77,2 +81,3 @@

targetSelector: target && getSelectorFromElement(target, configuration.actionNameAttribute),
time: maxClsStartTime,
})

@@ -79,0 +84,0 @@ }

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

import { noop, ONE_MINUTE } from '@datadog/browser-core'
import { elapsed, noop, ONE_MINUTE } from '@datadog/browser-core'
import type { Duration, RelativeTime } from '@datadog/browser-core'

@@ -21,2 +21,3 @@ import { RumPerformanceEntryType, supportPerformanceTimingEvent } from '../../../browser/performanceCollection'

targetSelector?: string
time?: Duration
}

@@ -50,2 +51,3 @@ /**

let interactionToNextPaintTargetSelector: string | undefined
let interactionToNextPaintStartTime: Duration | undefined

@@ -69,2 +71,3 @@ const { unsubscribe: stop } = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, (entries) => {

interactionToNextPaint = newInteraction.duration
interactionToNextPaintStartTime = elapsed(viewStart, newInteraction.startTime)

@@ -90,2 +93,3 @@ if (newInteraction.target && isElementNode(newInteraction.target)) {

targetSelector: interactionToNextPaintTargetSelector,
time: interactionToNextPaintStartTime,
}

@@ -92,0 +96,0 @@ } else if (getViewInteractionCount()) {

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

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

@@ -39,1 +39,2 @@ export {

export { isLongDataUrl, sanitizeDataUrl, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH } from './domain/resource/resourceUtils'
export { SessionReplayState } from './domain/rumSessionManager'

@@ -95,4 +95,6 @@ import type {

interaction_to_next_paint?: ServerDuration
interaction_to_next_paint_time?: ServerDuration
interaction_to_next_paint_target_selector?: string
cumulative_layout_shift?: number
cumulative_layout_shift_time?: ServerDuration
cumulative_layout_shift_target_selector?: string

@@ -99,0 +101,0 @@ custom_timings?: {

@@ -767,2 +767,6 @@ /* eslint-disable */

/**
* Duration in ns between start of the view and start of the INP
*/
readonly interaction_to_next_paint_time?: number
/**
* CSS selector path of the interacted element corresponding to INP

@@ -776,2 +780,6 @@ */

/**
* Duration in ns between start of the view and start of the largest layout shift contributing to CLS
*/
readonly cumulative_layout_shift_time?: number
/**
* CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS

@@ -1121,7 +1129,7 @@ */

*/
readonly service?: string
service?: string
/**
* The version for this application
*/
readonly version?: string
version?: string
/**

@@ -1128,0 +1136,0 @@ * The build version for this application

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc