Socket
Socket
Sign inDemoInstall

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 4.38.0 to 4.39.0

cjs/domain/getSessionReplayUrl.d.ts

2

cjs/boot/rumPublicApi.d.ts

@@ -17,2 +17,3 @@ import type { Context, InitConfiguration, User } from '@datadog/browser-core';

getReplayStats: (viewId: string) => ReplayStats | undefined;
getSessionReplayLink: (configuration: RumConfiguration, sessionManager: RumSessionManager, viewContexts: ViewContexts) => string | undefined;
}

@@ -60,2 +61,3 @@ interface RumPublicApiOptions {

addFeatureFlagEvaluation: (key: string, value: any) => void;
getSessionReplayLink: () => string | undefined;
} & {

@@ -62,0 +64,0 @@ onReady(callback: () => void): void;

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

var stopSessionStrategy = browser_core_1.noop;
var getSessionReplayLinkStrategy = function () { return undefined; };
var bufferApiCalls = new browser_core_1.BoundedBuffer();

@@ -77,2 +78,5 @@ var addTimingStrategy = function (name, time) {

var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, globalContextManager, userContextManager, initialViewOptions);
getSessionReplayLinkStrategy = function () {
return recorderApi.getSessionReplayLink(configuration, startRumResults.session, startRumResults.viewContexts);
};
(startViewStrategy = startRumResults.startView, addActionStrategy = startRumResults.addAction, addErrorStrategy = startRumResults.addError, addTimingStrategy = startRumResults.addTiming, addFeatureFlagEvaluationStrategy = startRumResults.addFeatureFlagEvaluation, getInternalContextStrategy = startRumResults.getInternalContext, stopSessionStrategy = startRumResults.stopSession);

@@ -156,2 +160,3 @@ bufferApiCalls.drain();

}),
getSessionReplayLink: (0, browser_core_1.monitor)(function () { return getSessionReplayLinkStrategy(); }),
});

@@ -158,0 +163,0 @@ return rumPublicApi;

2

cjs/browser/performanceCollection.js

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

// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
performance.addEventListener('resourcetimingbufferfull', function () {
(0, browser_core_1.addEventListener)(performance, 'resourcetimingbufferfull', function () {
performance.clearResourceTimings();

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

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

var displayContext_1 = require("./contexts/displayContext");
var limitModification_1 = require("./limitModification");
var VIEW_EVENTS_MODIFIABLE_FIELD_PATHS = [

@@ -49,3 +50,3 @@ // Fields with sensitive data

},
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.38.0" : undefined,
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.39.0" : undefined,
},

@@ -97,3 +98,3 @@ application: {

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

@@ -100,0 +101,0 @@ return false;

@@ -25,2 +25,3 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core';

defaultPrivacyLevel?: DefaultPrivacyLevel | undefined;
subdomain?: string;
/**

@@ -58,2 +59,3 @@ * @deprecated use sessionReplaySampleRate instead

version?: string;
subdomain?: string;
customerDataTelemetrySampleRate: number;

@@ -60,0 +62,0 @@ }

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

trackLongTasks: initConfiguration.trackLongTasks,
subdomain: initConfiguration.subdomain,
defaultPrivacyLevel: (0, browser_core_1.objectHasValue)(browser_core_1.DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)

@@ -62,0 +63,0 @@ ? initConfiguration.defaultPrivacyLevel

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

}
var featureFlagContexts = new browser_core_1.ContextHistory(exports.FEATURE_FLAG_CONTEXT_TIME_OUT_DELAY);
var featureFlagContexts = new browser_core_1.ValueHistory(exports.FEATURE_FLAG_CONTEXT_TIME_OUT_DELAY);
var bytesCountCache = 0;

@@ -27,0 +27,0 @@ var alreadyWarned = false;

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

function startUrlContexts(lifeCycle, locationChangeObservable, location) {
var urlContextHistory = new browser_core_1.ContextHistory(exports.URL_CONTEXT_TIME_OUT_DELAY);
var urlContextHistory = new browser_core_1.ValueHistory(exports.URL_CONTEXT_TIME_OUT_DELAY);
var previousViewUrl;

@@ -15,0 +15,0 @@ lifeCycle.subscribe(4 /* LifeCycleEventType.VIEW_ENDED */, function (_a) {

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

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

@@ -9,2 +9,3 @@ export declare const VIEW_CONTEXT_TIME_OUT_DELAY: number;

name?: string;
startClocks: ClocksState;
}

@@ -11,0 +12,0 @@ export interface ViewContexts {

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

function startViewContexts(lifeCycle) {
var viewContextHistory = new browser_core_1.ContextHistory(exports.VIEW_CONTEXT_TIME_OUT_DELAY);
var viewContextHistory = new browser_core_1.ValueHistory(exports.VIEW_CONTEXT_TIME_OUT_DELAY);
lifeCycle.subscribe(2 /* LifeCycleEventType.VIEW_CREATED */, function (view) {

@@ -25,2 +25,3 @@ viewContextHistory.add(buildViewContext(view), view.startClocks.relative);

name: view.name,
startClocks: view.startClocks,
};

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

import type { Duration, ClocksState, RelativeTime, TimeStamp } from '@datadog/browser-core';
import { Observable, ContextHistory } from '@datadog/browser-core';
import { Observable, ValueHistory } from '@datadog/browser-core';
import type { FrustrationType } from '../../../rawRumEvent.types';

@@ -37,3 +37,3 @@ import { ActionType } from '../../../rawRumEvent.types';

}
type ClickActionIdHistory = ContextHistory<ClickAction['id']>;
type ClickActionIdHistory = ValueHistory<ClickAction['id']>;
export declare const CLICK_ACTION_MAX_DURATION: number;

@@ -40,0 +40,0 @@ export declare const ACTION_CONTEXT_TIME_OUT_DELAY: number;

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

function trackClickActions(lifeCycle, domMutationObservable, configuration) {
var history = new browser_core_1.ContextHistory(exports.ACTION_CONTEXT_TIME_OUT_DELAY);
var history = new browser_core_1.ValueHistory(exports.ACTION_CONTEXT_TIME_OUT_DELAY);
var stopObservable = new browser_core_1.Observable();

@@ -19,0 +19,0 @@ var currentClickChain;

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

var duration = (0, browser_core_1.toServerDuration)(request.duration);
var durationOverrideInfo = computeDurationOverrideInfo(duration, correspondingTimingOverrides === null || correspondingTimingOverrides === void 0 ? void 0 : correspondingTimingOverrides.resource.duration);
var pageStateInfo = computePageStateInfo(pageStateHistory, startClocks, (_a = matchingTiming === null || matchingTiming === void 0 ? void 0 : matchingTiming.duration) !== null && _a !== void 0 ? _a : request.duration);

@@ -44,3 +43,3 @@ var resourceEvent = (0, browser_core_1.combine)({

type: "resource" /* RumEventType.RESOURCE */,
}, tracingInfo, correspondingTimingOverrides, indexingInfo, durationOverrideInfo, pageStateInfo);
}, tracingInfo, correspondingTimingOverrides, indexingInfo, pageStateInfo);
return {

@@ -116,14 +115,2 @@ startTime: startClocks.relative,

}
function computeDurationOverrideInfo(computedDuration, performanceEntryDuration) {
if (!(0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.RESOURCE_DURATIONS)) {
return;
}
return {
_dd: {
computed_duration: computedDuration,
performance_entry_duration: performanceEntryDuration,
override_duration_diff: performanceEntryDuration ? computedDuration - performanceEntryDuration : undefined,
},
};
}
// TODO next major: use directly PerformanceEntry type in domain context

@@ -130,0 +117,0 @@ function toPerformanceEntryRepresentation(entry) {

import type { RelativeTime } from '@datadog/browser-core';
export declare function trackFirstHidden(eventTarget?: EventTarget): {
export declare function trackFirstHidden(eventTarget?: Window): {
timeStamp: RelativeTime;
};
export declare function resetFirstHidden(): void;

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

*/
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, eventTarget: EventTarget, callback: (lcpTiming: RelativeTime) => void): {
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, eventTarget: Window, callback: (lcpTiming: RelativeTime) => void): {
stop: () => void;

@@ -33,0 +33,0 @@ };

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

import type { BatchFlushEvent, ContextManager, Observable, Telemetry } from '@datadog/browser-core';
import type { ContextManager, FlushEvent, Observable, Telemetry } from '@datadog/browser-core';
import type { RumConfiguration } from './configuration';

@@ -6,2 +6,2 @@ import type { FeatureFlagContexts } from './contexts/featureFlagContext';

export declare const MEASURES_PERIOD_DURATION: number;
export declare function startCustomerDataTelemetry(configuration: RumConfiguration, telemetry: Telemetry, lifeCycle: LifeCycle, globalContextManager: ContextManager, userContextManager: ContextManager, featureFlagContexts: FeatureFlagContexts, batchFlushObservable: Observable<BatchFlushEvent>): void;
export declare function startCustomerDataTelemetry(configuration: RumConfiguration, telemetry: Telemetry, lifeCycle: LifeCycle, globalContextManager: ContextManager, userContextManager: ContextManager, featureFlagContexts: FeatureFlagContexts, batchFlushObservable: Observable<FlushEvent>): void;

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

batchFlushObservable.subscribe(function (_a) {
var bufferBytesCount = _a.bufferBytesCount, bufferMessagesCount = _a.bufferMessagesCount;
var bytesCount = _a.bytesCount, messagesCount = _a.messagesCount;
// Don't measure batch that only contains telemetry events to avoid batch sending loop

@@ -37,4 +37,4 @@ // It could happen because after each batch we are adding a customer data measures telemetry event to the next one

currentPeriodMeasures.batchCount += 1;
updateMeasure(currentPeriodMeasures.batchBytesCount, bufferBytesCount);
updateMeasure(currentPeriodMeasures.batchMessagesCount, bufferMessagesCount);
updateMeasure(currentPeriodMeasures.batchBytesCount, bytesCount);
updateMeasure(currentPeriodMeasures.batchMessagesCount, messagesCount);
mergeMeasure(currentPeriodMeasures.globalContextBytes, currentBatchMeasures.globalContextBytes);

@@ -41,0 +41,0 @@ mergeMeasure(currentPeriodMeasures.userContextBytes, currentBatchMeasures.userContextBytes);

@@ -9,3 +9,3 @@ export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi';

export { ViewContexts, ViewContext } from './domain/contexts/viewContexts';
export { RumSessionManager, RumSessionPlan } from './domain/rumSessionManager';
export { RumSessionManager, RumSessionPlan, RumSession } from './domain/rumSessionManager';
export { getMutationObserverConstructor } from './browser/domMutationObservable';

@@ -17,1 +17,2 @@ export { initViewportObservable, getViewportDimension } from './browser/viewportObservable';

export * from './browser/htmlDomUtils';
export { getSessionReplayUrl } from './domain/getSessionReplayUrl';

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.STABLE_ATTRIBUTES = exports.DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE = exports.getViewportDimension = exports.initViewportObservable = exports.getMutationObserverConstructor = exports.LifeCycle = exports.startRum = exports.makeRumPublicApi = void 0;
exports.getSessionReplayUrl = exports.STABLE_ATTRIBUTES = exports.DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE = exports.getViewportDimension = exports.initViewportObservable = exports.getMutationObserverConstructor = exports.LifeCycle = exports.startRum = exports.makeRumPublicApi = void 0;
var rumPublicApi_1 = require("./boot/rumPublicApi");

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

__exportStar(require("./browser/htmlDomUtils"), exports);
var getSessionReplayUrl_1 = require("./domain/getSessionReplayUrl");
Object.defineProperty(exports, "getSessionReplayUrl", { enumerable: true, get: function () { return getSessionReplayUrl_1.getSessionReplayUrl; } });
//# sourceMappingURL=index.js.map

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

import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent, BatchFlushEvent } from '@datadog/browser-core';
import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent, FlushEvent } from '@datadog/browser-core';
import type { RumConfiguration } from '../domain/configuration';

@@ -6,5 +6,5 @@ import type { LifeCycle } from '../domain/lifeCycle';

export interface RumBatch {
flushObservable: Observable<BatchFlushEvent>;
flushObservable: Observable<FlushEvent>;
add: (message: Context, replicated?: boolean) => void;
upsert: (message: Context, key: string) => void;
}

@@ -20,10 +20,20 @@ "use strict";

function makeRumBatch(configuration, reportError, pageExitObservable) {
var primaryBatch = createRumBatch(configuration.rumEndpointBuilder);
var _a = createRumBatch(configuration.rumEndpointBuilder), primaryBatch = _a.batch, primaryFlushController = _a.flushController;
var replicaBatch;
var replica = configuration.replica;
if (replica !== undefined) {
replicaBatch = createRumBatch(replica.rumEndpointBuilder);
replicaBatch = createRumBatch(replica.rumEndpointBuilder).batch;
}
function createRumBatch(endpointBuilder) {
return new browser_core_1.Batch((0, browser_core_1.createHttpRequest)(endpointBuilder, configuration.batchBytesLimit, reportError), configuration.batchMessagesLimit, configuration.batchBytesLimit, configuration.messageBytesLimit, configuration.flushTimeout, pageExitObservable);
var flushController = (0, browser_core_1.createFlushController)({
messagesLimit: configuration.batchMessagesLimit,
bytesLimit: configuration.batchBytesLimit,
durationLimit: configuration.flushTimeout,
pageExitObservable: pageExitObservable,
});
var batch = new browser_core_1.Batch((0, browser_core_1.createHttpRequest)(endpointBuilder, configuration.batchBytesLimit, reportError), flushController, configuration.messageBytesLimit);
return {
batch: batch,
flushController: flushController,
};
}

@@ -34,3 +44,3 @@ function withReplicaApplicationId(message) {

return {
flushObservable: primaryBatch.flushObservable,
flushObservable: primaryFlushController.flushObservable,
add: function (message, replicated) {

@@ -37,0 +47,0 @@ if (replicated === void 0) { replicated = true; }

@@ -17,2 +17,3 @@ import type { Context, InitConfiguration, User } from '@datadog/browser-core';

getReplayStats: (viewId: string) => ReplayStats | undefined;
getSessionReplayLink: (configuration: RumConfiguration, sessionManager: RumSessionManager, viewContexts: ViewContexts) => string | undefined;
}

@@ -60,2 +61,3 @@ interface RumPublicApiOptions {

addFeatureFlagEvaluation: (key: string, value: any) => void;
getSessionReplayLink: () => string | undefined;
} & {

@@ -62,0 +64,0 @@ onReady(callback: () => void): void;

@@ -12,2 +12,3 @@ import { ExperimentalFeature, noop, isExperimentalFeatureEnabled, willSyntheticsInjectRum, assign, BoundedBuffer, buildCookieOptions, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, areCookiesAuthorized, checkUser, sanitizeUser, sanitize, } from '@datadog/browser-core';

var stopSessionStrategy = noop;
var getSessionReplayLinkStrategy = function () { return undefined; };
var bufferApiCalls = new BoundedBuffer();

@@ -74,2 +75,5 @@ var addTimingStrategy = function (name, time) {

var startRumResults = startRumImpl(initConfiguration, configuration, recorderApi, globalContextManager, userContextManager, initialViewOptions);
getSessionReplayLinkStrategy = function () {
return recorderApi.getSessionReplayLink(configuration, startRumResults.session, startRumResults.viewContexts);
};
(startViewStrategy = startRumResults.startView, addActionStrategy = startRumResults.addAction, addErrorStrategy = startRumResults.addError, addTimingStrategy = startRumResults.addTiming, addFeatureFlagEvaluationStrategy = startRumResults.addFeatureFlagEvaluation, getInternalContextStrategy = startRumResults.getInternalContext, stopSessionStrategy = startRumResults.stopSession);

@@ -153,2 +157,3 @@ bufferApiCalls.drain();

}),
getSessionReplayLink: monitor(function () { return getSessionReplayLinkStrategy(); }),
});

@@ -155,0 +160,0 @@ return rumPublicApi;

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

import { dateNow, assign, addEventListeners, getRelativeTime, isNumber, monitor, setTimeout, relativeNow, runOnReadyState, } from '@datadog/browser-core';
import { dateNow, assign, addEventListeners, getRelativeTime, isNumber, monitor, setTimeout, relativeNow, runOnReadyState, addEventListener, } from '@datadog/browser-core';
import { FAKE_INITIAL_DOCUMENT, isAllowedRequestUrl } from '../domain/rumEventsCollection/resource/resourceUtils';

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

// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
performance.addEventListener('resourcetimingbufferfull', function () {
addEventListener(performance, 'resourcetimingbufferfull', function () {
performance.clearResourceTimings();

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

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

import { combine, isEmptyObject, limitModification, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, } from '@datadog/browser-core';
import { combine, isEmptyObject, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, } from '@datadog/browser-core';
import { getSyntheticsContext } from './contexts/syntheticsContext';
import { getCiTestContext } from './contexts/ciTestContext';
import { getDisplayContext } from './contexts/displayContext';
import { limitModification } from './limitModification';
var VIEW_EVENTS_MODIFIABLE_FIELD_PATHS = [

@@ -45,3 +46,3 @@ // Fields with sensitive data

},
browser_sdk_version: canUseEventBridge() ? "4.38.0" : undefined,
browser_sdk_version: canUseEventBridge() ? "4.39.0" : undefined,
},

@@ -48,0 +49,0 @@ application: {

@@ -25,2 +25,3 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core';

defaultPrivacyLevel?: DefaultPrivacyLevel | undefined;
subdomain?: string;
/**

@@ -58,2 +59,3 @@ * @deprecated use sessionReplaySampleRate instead

version?: string;
subdomain?: string;
customerDataTelemetrySampleRate: number;

@@ -60,0 +62,0 @@ }

@@ -57,2 +57,3 @@ import { arrayFrom, getOrigin, isMatchOption, serializeConfiguration, assign, DefaultPrivacyLevel, display, isPercentage, objectHasValue, validateAndBuildConfiguration, } from '@datadog/browser-core';

trackLongTasks: initConfiguration.trackLongTasks,
subdomain: initConfiguration.subdomain,
defaultPrivacyLevel: objectHasValue(DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)

@@ -59,0 +60,0 @@ ? initConfiguration.defaultPrivacyLevel

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

import { warnIfCustomerDataLimitReached, throttle, jsonStringify, computeBytesCount, noop, isExperimentalFeatureEnabled, SESSION_TIME_OUT_DELAY, ContextHistory, ExperimentalFeature, } from '@datadog/browser-core';
import { warnIfCustomerDataLimitReached, throttle, jsonStringify, computeBytesCount, noop, isExperimentalFeatureEnabled, SESSION_TIME_OUT_DELAY, ValueHistory, ExperimentalFeature, } from '@datadog/browser-core';
export var FEATURE_FLAG_CONTEXT_TIME_OUT_DELAY = SESSION_TIME_OUT_DELAY;

@@ -21,3 +21,3 @@ export var BYTES_COMPUTATION_THROTTLING_DELAY = 200;

}
var featureFlagContexts = new ContextHistory(FEATURE_FLAG_CONTEXT_TIME_OUT_DELAY);
var featureFlagContexts = new ValueHistory(FEATURE_FLAG_CONTEXT_TIME_OUT_DELAY);
var bytesCountCache = 0;

@@ -24,0 +24,0 @@ var alreadyWarned = false;

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

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

@@ -9,3 +9,3 @@ * We want to attach to an event:

export function startUrlContexts(lifeCycle, locationChangeObservable, location) {
var urlContextHistory = new ContextHistory(URL_CONTEXT_TIME_OUT_DELAY);
var urlContextHistory = new ValueHistory(URL_CONTEXT_TIME_OUT_DELAY);
var previousViewUrl;

@@ -12,0 +12,0 @@ lifeCycle.subscribe(4 /* LifeCycleEventType.VIEW_ENDED */, function (_a) {

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

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

@@ -9,2 +9,3 @@ export declare const VIEW_CONTEXT_TIME_OUT_DELAY: number;

name?: string;
startClocks: ClocksState;
}

@@ -11,0 +12,0 @@ export interface ViewContexts {

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

import { SESSION_TIME_OUT_DELAY, ContextHistory } from '@datadog/browser-core';
import { SESSION_TIME_OUT_DELAY, ValueHistory } from '@datadog/browser-core';
export var VIEW_CONTEXT_TIME_OUT_DELAY = SESSION_TIME_OUT_DELAY;
export function startViewContexts(lifeCycle) {
var viewContextHistory = new ContextHistory(VIEW_CONTEXT_TIME_OUT_DELAY);
var viewContextHistory = new ValueHistory(VIEW_CONTEXT_TIME_OUT_DELAY);
lifeCycle.subscribe(2 /* LifeCycleEventType.VIEW_CREATED */, function (view) {

@@ -21,2 +21,3 @@ viewContextHistory.add(buildViewContext(view), view.startClocks.relative);

name: view.name,
startClocks: view.startClocks,
};

@@ -23,0 +24,0 @@ }

import type { Duration, ClocksState, RelativeTime, TimeStamp } from '@datadog/browser-core';
import { Observable, ContextHistory } from '@datadog/browser-core';
import { Observable, ValueHistory } from '@datadog/browser-core';
import type { FrustrationType } from '../../../rawRumEvent.types';

@@ -37,3 +37,3 @@ import { ActionType } from '../../../rawRumEvent.types';

}
type ClickActionIdHistory = ContextHistory<ClickAction['id']>;
type ClickActionIdHistory = ValueHistory<ClickAction['id']>;
export declare const CLICK_ACTION_MAX_DURATION: number;

@@ -40,0 +40,0 @@ export declare const ACTION_CONTEXT_TIME_OUT_DELAY: number;

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

import { includes, timeStampNow, isExperimentalFeatureEnabled, Observable, assign, getRelativeTime, ONE_MINUTE, ContextHistory, generateUUID, clocksNow, ONE_SECOND, elapsed, ExperimentalFeature, } from '@datadog/browser-core';
import { includes, timeStampNow, isExperimentalFeatureEnabled, Observable, assign, getRelativeTime, ONE_MINUTE, ValueHistory, generateUUID, clocksNow, ONE_SECOND, elapsed, ExperimentalFeature, } from '@datadog/browser-core';
import { trackEventCounts } from '../../trackEventCounts';

@@ -13,3 +13,3 @@ import { PAGE_ACTIVITY_VALIDATION_DELAY, waitPageActivityEnd } from '../../waitPageActivityEnd';

export function trackClickActions(lifeCycle, domMutationObservable, configuration) {
var history = new ContextHistory(ACTION_CONTEXT_TIME_OUT_DELAY);
var history = new ValueHistory(ACTION_CONTEXT_TIME_OUT_DELAY);
var stopObservable = new Observable();

@@ -16,0 +16,0 @@ var currentClickChain;

@@ -26,3 +26,2 @@ import { combine, generateUUID, toServerDuration, relativeToClocks, assign, isNumber, isExperimentalFeatureEnabled, ExperimentalFeature, } from '@datadog/browser-core';

var duration = toServerDuration(request.duration);
var durationOverrideInfo = computeDurationOverrideInfo(duration, correspondingTimingOverrides === null || correspondingTimingOverrides === void 0 ? void 0 : correspondingTimingOverrides.resource.duration);
var pageStateInfo = computePageStateInfo(pageStateHistory, startClocks, (_a = matchingTiming === null || matchingTiming === void 0 ? void 0 : matchingTiming.duration) !== null && _a !== void 0 ? _a : request.duration);

@@ -40,3 +39,3 @@ var resourceEvent = combine({

type: "resource" /* RumEventType.RESOURCE */,
}, tracingInfo, correspondingTimingOverrides, indexingInfo, durationOverrideInfo, pageStateInfo);
}, tracingInfo, correspondingTimingOverrides, indexingInfo, pageStateInfo);
return {

@@ -112,14 +111,2 @@ startTime: startClocks.relative,

}
function computeDurationOverrideInfo(computedDuration, performanceEntryDuration) {
if (!isExperimentalFeatureEnabled(ExperimentalFeature.RESOURCE_DURATIONS)) {
return;
}
return {
_dd: {
computed_duration: computedDuration,
performance_entry_duration: performanceEntryDuration,
override_duration_diff: performanceEntryDuration ? computedDuration - performanceEntryDuration : undefined,
},
};
}
// TODO next major: use directly PerformanceEntry type in domain context

@@ -126,0 +113,0 @@ function toPerformanceEntryRepresentation(entry) {

import type { RelativeTime } from '@datadog/browser-core';
export declare function trackFirstHidden(eventTarget?: EventTarget): {
export declare function trackFirstHidden(eventTarget?: Window): {
timeStamp: RelativeTime;
};
export declare function resetFirstHidden(): void;

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

*/
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, eventTarget: EventTarget, callback: (lcpTiming: RelativeTime) => void): {
export declare function trackLargestContentfulPaintTiming(lifeCycle: LifeCycle, eventTarget: Window, callback: (lcpTiming: RelativeTime) => void): {
stop: () => void;

@@ -33,0 +33,0 @@ };

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

import type { BatchFlushEvent, ContextManager, Observable, Telemetry } from '@datadog/browser-core';
import type { ContextManager, FlushEvent, Observable, Telemetry } from '@datadog/browser-core';
import type { RumConfiguration } from './configuration';

@@ -6,2 +6,2 @@ import type { FeatureFlagContexts } from './contexts/featureFlagContext';

export declare const MEASURES_PERIOD_DURATION: number;
export declare function startCustomerDataTelemetry(configuration: RumConfiguration, telemetry: Telemetry, lifeCycle: LifeCycle, globalContextManager: ContextManager, userContextManager: ContextManager, featureFlagContexts: FeatureFlagContexts, batchFlushObservable: Observable<BatchFlushEvent>): void;
export declare function startCustomerDataTelemetry(configuration: RumConfiguration, telemetry: Telemetry, lifeCycle: LifeCycle, globalContextManager: ContextManager, userContextManager: ContextManager, featureFlagContexts: FeatureFlagContexts, batchFlushObservable: Observable<FlushEvent>): void;

@@ -26,3 +26,3 @@ import { isEmptyObject, includes, performDraw, ONE_SECOND, addTelemetryDebug, setInterval } from '@datadog/browser-core';

batchFlushObservable.subscribe(function (_a) {
var bufferBytesCount = _a.bufferBytesCount, bufferMessagesCount = _a.bufferMessagesCount;
var bytesCount = _a.bytesCount, messagesCount = _a.messagesCount;
// Don't measure batch that only contains telemetry events to avoid batch sending loop

@@ -34,4 +34,4 @@ // It could happen because after each batch we are adding a customer data measures telemetry event to the next one

currentPeriodMeasures.batchCount += 1;
updateMeasure(currentPeriodMeasures.batchBytesCount, bufferBytesCount);
updateMeasure(currentPeriodMeasures.batchMessagesCount, bufferMessagesCount);
updateMeasure(currentPeriodMeasures.batchBytesCount, bytesCount);
updateMeasure(currentPeriodMeasures.batchMessagesCount, messagesCount);
mergeMeasure(currentPeriodMeasures.globalContextBytes, currentBatchMeasures.globalContextBytes);

@@ -38,0 +38,0 @@ mergeMeasure(currentPeriodMeasures.userContextBytes, currentBatchMeasures.userContextBytes);

@@ -9,3 +9,3 @@ export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi';

export { ViewContexts, ViewContext } from './domain/contexts/viewContexts';
export { RumSessionManager, RumSessionPlan } from './domain/rumSessionManager';
export { RumSessionManager, RumSessionPlan, RumSession } from './domain/rumSessionManager';
export { getMutationObserverConstructor } from './browser/domMutationObservable';

@@ -17,1 +17,2 @@ export { initViewportObservable, getViewportDimension } from './browser/viewportObservable';

export * from './browser/htmlDomUtils';
export { getSessionReplayUrl } from './domain/getSessionReplayUrl';

@@ -9,2 +9,3 @@ export { makeRumPublicApi } from './boot/rumPublicApi';

export * from './browser/htmlDomUtils';
export { getSessionReplayUrl } from './domain/getSessionReplayUrl';
//# sourceMappingURL=index.js.map

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

import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent, BatchFlushEvent } from '@datadog/browser-core';
import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent, FlushEvent } from '@datadog/browser-core';
import type { RumConfiguration } from '../domain/configuration';

@@ -6,5 +6,5 @@ import type { LifeCycle } from '../domain/lifeCycle';

export interface RumBatch {
flushObservable: Observable<BatchFlushEvent>;
flushObservable: Observable<FlushEvent>;
add: (message: Context, replicated?: boolean) => void;
upsert: (message: Context, key: string) => void;
}

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

import { Batch, combine, createHttpRequest, isTelemetryReplicationAllowed } from '@datadog/browser-core';
import { createFlushController, Batch, combine, createHttpRequest, isTelemetryReplicationAllowed, } from '@datadog/browser-core';
export function startRumBatch(configuration, lifeCycle, telemetryEventObservable, reportError, pageExitObservable) {

@@ -16,10 +16,20 @@ var batch = makeRumBatch(configuration, reportError, pageExitObservable);

function makeRumBatch(configuration, reportError, pageExitObservable) {
var primaryBatch = createRumBatch(configuration.rumEndpointBuilder);
var _a = createRumBatch(configuration.rumEndpointBuilder), primaryBatch = _a.batch, primaryFlushController = _a.flushController;
var replicaBatch;
var replica = configuration.replica;
if (replica !== undefined) {
replicaBatch = createRumBatch(replica.rumEndpointBuilder);
replicaBatch = createRumBatch(replica.rumEndpointBuilder).batch;
}
function createRumBatch(endpointBuilder) {
return new Batch(createHttpRequest(endpointBuilder, configuration.batchBytesLimit, reportError), configuration.batchMessagesLimit, configuration.batchBytesLimit, configuration.messageBytesLimit, configuration.flushTimeout, pageExitObservable);
var flushController = createFlushController({
messagesLimit: configuration.batchMessagesLimit,
bytesLimit: configuration.batchBytesLimit,
durationLimit: configuration.flushTimeout,
pageExitObservable: pageExitObservable,
});
var batch = new Batch(createHttpRequest(endpointBuilder, configuration.batchBytesLimit, reportError), flushController, configuration.messageBytesLimit);
return {
batch: batch,
flushController: flushController,
};
}

@@ -30,3 +40,3 @@ function withReplicaApplicationId(message) {

return {
flushObservable: primaryBatch.flushObservable,
flushObservable: primaryFlushController.flushObservable,
add: function (message, replicated) {

@@ -33,0 +43,0 @@ if (replicated === void 0) { replicated = true; }

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

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

"dependencies": {
"@datadog/browser-core": "4.38.0"
"@datadog/browser-core": "4.39.0"
},

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

},
"gitHead": "61ff7fdf8c51ea1bb789cb3d865ad094bfcdcf71"
"gitHead": "128da89b469c77d6cfdabca15eb3d7ac09c3d5ae"
}

@@ -54,2 +54,7 @@ import type { Context, InitConfiguration, TimeStamp, RelativeTime, User } from '@datadog/browser-core'

getReplayStats: (viewId: string) => ReplayStats | undefined
getSessionReplayLink: (
configuration: RumConfiguration,
sessionManager: RumSessionManager,
viewContexts: ViewContexts
) => string | undefined
}

@@ -73,2 +78,3 @@ interface RumPublicApiOptions {

let stopSessionStrategy: () => void = noop
let getSessionReplayLinkStrategy: () => string | undefined = () => undefined

@@ -157,3 +163,4 @@ let bufferApiCalls = new BoundedBuffer()

)
getSessionReplayLinkStrategy = () =>
recorderApi.getSessionReplayLink(configuration, startRumResults.session, startRumResults.viewContexts)
;({

@@ -279,2 +286,3 @@ startView: startViewStrategy,

}),
getSessionReplayLink: monitor(() => getSessionReplayLinkStrategy()),
})

@@ -281,0 +289,0 @@

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

runOnReadyState,
addEventListener,
} from '@datadog/browser-core'

@@ -145,3 +146,3 @@

// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
performance.addEventListener('resourcetimingbufferfull', () => {
addEventListener(performance, 'resourcetimingbufferfull', () => {
performance.clearResourceTimings()

@@ -148,0 +149,0 @@ })

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

import type { RelativeTime } from '@datadog/browser-core'
import type { ClocksState, RelativeTime } from '@datadog/browser-core'
import { ErrorSource, ONE_MINUTE, display } from '@datadog/browser-core'

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

name: 'view name',
startClocks: {} as ClocksState,
})

@@ -488,3 +489,3 @@ reportErrorSpy = jasmine.createSpy('reportError')

const { lifeCycle } = setupBuilder.build()
findView = () => ({ service: 'new service', version: 'new version', id: '1234' })
findView = () => ({ service: 'new service', version: 'new version', id: '1234', startClocks: {} as ClocksState })
notifyRawRumEvent(lifeCycle, {

@@ -491,0 +492,0 @@ rawRumEvent: createRawRumEvent(RumEventType.ACTION),

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

isEmptyObject,
limitModification,
timeStampNow,

@@ -34,2 +33,3 @@ currentDrift,

import type { CommonContext } from './contexts/commonContext'
import { limitModification } from './limitModification'

@@ -36,0 +36,0 @@ // replaced at build time

@@ -43,2 +43,3 @@ import type { Configuration, InitConfiguration, MatchOption, RawTelemetryConfiguration } from '@datadog/browser-core'

defaultPrivacyLevel?: DefaultPrivacyLevel | undefined
subdomain?: string
/**

@@ -84,2 +85,3 @@ * @deprecated use sessionReplaySampleRate instead

version?: string
subdomain?: string
customerDataTelemetrySampleRate: number

@@ -155,2 +157,3 @@ }

trackLongTasks: initConfiguration.trackLongTasks,
subdomain: initConfiguration.subdomain,
defaultPrivacyLevel: objectHasValue(DefaultPrivacyLevel, initConfiguration.defaultPrivacyLevel)

@@ -157,0 +160,0 @@ ? initConfiguration.defaultPrivacyLevel

@@ -8,4 +8,4 @@ import type { RelativeTime } from '@datadog/browser-core'

relativeToClocks,
CUSTOMER_DATA_BYTES_LIMIT,
} from '@datadog/browser-core'
import { CUSTOMER_DATA_BYTES_LIMIT } from '../../../../core/src/tools/heavyCustomerDataWarning'
import type { TestSetupBuilder } from '../../../test'

@@ -25,5 +25,6 @@ import { setup } from '../../../test'

let displaySpy: jasmine.Spy<typeof display.warn>
let fakeBytesCount = 1
let fakeBytesCount: number
beforeEach(() => {
fakeBytesCount = 1
displaySpy = spyOn(display, 'warn')

@@ -30,0 +31,0 @@ setupBuilder = setup().beforeBuild(({ lifeCycle }) => {

@@ -11,3 +11,3 @@ import type { RelativeTime, ContextValue, Context } from '@datadog/browser-core'

SESSION_TIME_OUT_DELAY,
ContextHistory,
ValueHistory,
ExperimentalFeature,

@@ -49,3 +49,3 @@ } from '@datadog/browser-core'

const featureFlagContexts = new ContextHistory<FeatureFlagContext>(FEATURE_FLAG_CONTEXT_TIME_OUT_DELAY)
const featureFlagContexts = new ValueHistory<FeatureFlagContext>(FEATURE_FLAG_CONTEXT_TIME_OUT_DELAY)
let bytesCountCache = 0

@@ -52,0 +52,0 @@ let alreadyWarned = false

import type { RelativeTime, Observable } from '@datadog/browser-core'
import { SESSION_TIME_OUT_DELAY, relativeNow, ContextHistory } from '@datadog/browser-core'
import { SESSION_TIME_OUT_DELAY, relativeNow, ValueHistory } from '@datadog/browser-core'
import type { LocationChange } from '../../browser/locationChangeObservable'

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

) {
const urlContextHistory = new ContextHistory<UrlContext>(URL_CONTEXT_TIME_OUT_DELAY)
const urlContextHistory = new ValueHistory<UrlContext>(URL_CONTEXT_TIME_OUT_DELAY)

@@ -33,0 +33,0 @@ let previousViewUrl: string | undefined

import type { RelativeTime } from '@datadog/browser-core'
import { relativeToClocks, CLEAR_OLD_CONTEXTS_INTERVAL } from '@datadog/browser-core'
import { relativeToClocks, CLEAR_OLD_VALUES_INTERVAL } from '@datadog/browser-core'
import type { TestSetupBuilder } from '../../../test'

@@ -168,3 +168,3 @@ import { setup } from '../../../test'

clock.tick(VIEW_CONTEXT_TIME_OUT_DELAY + CLEAR_OLD_CONTEXTS_INTERVAL)
clock.tick(VIEW_CONTEXT_TIME_OUT_DELAY + CLEAR_OLD_VALUES_INTERVAL)
expect(viewContexts.findView(targetTime)).toBeUndefined()

@@ -171,0 +171,0 @@ })

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

import type { RelativeTime } from '@datadog/browser-core'
import { SESSION_TIME_OUT_DELAY, ContextHistory } from '@datadog/browser-core'
import type { RelativeTime, ClocksState } from '@datadog/browser-core'
import { SESSION_TIME_OUT_DELAY, ValueHistory } from '@datadog/browser-core'
import type { LifeCycle } from '../lifeCycle'

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

name?: string
startClocks: ClocksState
}

@@ -23,3 +24,3 @@

export function startViewContexts(lifeCycle: LifeCycle): ViewContexts {
const viewContextHistory = new ContextHistory<ViewContext>(VIEW_CONTEXT_TIME_OUT_DELAY)
const viewContextHistory = new ValueHistory<ViewContext>(VIEW_CONTEXT_TIME_OUT_DELAY)

@@ -44,2 +45,3 @@ lifeCycle.subscribe(LifeCycleEventType.VIEW_CREATED, (view) => {

name: view.name,
startClocks: view.startClocks,
}

@@ -46,0 +48,0 @@ }

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

ONE_MINUTE,
ContextHistory,
ValueHistory,
generateUUID,

@@ -62,3 +62,3 @@ clocksNow,

type ClickActionIdHistory = ContextHistory<ClickAction['id']>
type ClickActionIdHistory = ValueHistory<ClickAction['id']>

@@ -74,3 +74,3 @@ // Maximum duration for click actions

) {
const history: ClickActionIdHistory = new ContextHistory(ACTION_CONTEXT_TIME_OUT_DELAY)
const history: ClickActionIdHistory = new ValueHistory(ACTION_CONTEXT_TIME_OUT_DELAY)
const stopObservable = new Observable<void>()

@@ -77,0 +77,0 @@ let currentClickChain: ClickChain | undefined

import type { Duration, RelativeTime, ServerDuration, TimeStamp } from '@datadog/browser-core'
import {
relativeToClocks,
resetExperimentalFeatures,

@@ -158,30 +157,2 @@ addExperimentalFeatures,

it('should collect computed duration and performance entry duration when resource_durations ff is enabled', () => {
addExperimentalFeatures([ExperimentalFeature.RESOURCE_DURATIONS])
const match = createResourceEntry({ startTime: 200 as RelativeTime, duration: 300 as Duration })
spyOn(performance, 'getEntriesByName').and.returnValues([match] as unknown as PerformanceResourceTiming[])
const { lifeCycle, rawRumEvents } = setupBuilder.build()
lifeCycle.notify(
LifeCycleEventType.REQUEST_COMPLETED,
createCompletedRequest({
duration: 500 as Duration,
method: 'GET',
startClocks: relativeToClocks(100 as RelativeTime),
status: 200,
type: RequestType.FETCH,
url: 'https://resource.com/valid',
input: 'https://resource.com/valid',
})
)
const rawRumResourceEvent = rawRumEvents[0].rawRumEvent as RawRumResourceEvent
expect(rawRumResourceEvent._dd).toEqual(
jasmine.objectContaining({
computed_duration: 500000000,
performance_entry_duration: 300000000,
})
)
})
it('should create resource from completed fetch request', () => {

@@ -188,0 +159,0 @@ if (isIE()) {

@@ -13,3 +13,3 @@ import {

} from '@datadog/browser-core'
import type { ClocksState, ServerDuration, Duration } from '@datadog/browser-core'
import type { ClocksState, Duration } from '@datadog/browser-core'
import type { RumConfiguration } from '../../configuration'

@@ -79,3 +79,2 @@ import type { RumPerformanceEntry, RumPerformanceResourceTiming } from '../../../browser/performanceCollection'

const duration = toServerDuration(request.duration)
const durationOverrideInfo = computeDurationOverrideInfo(duration, correspondingTimingOverrides?.resource.duration)
const pageStateInfo = computePageStateInfo(

@@ -103,3 +102,2 @@ pageStateHistory,

indexingInfo,
durationOverrideInfo,
pageStateInfo

@@ -199,19 +197,2 @@ )

function computeDurationOverrideInfo(
computedDuration: ServerDuration,
performanceEntryDuration: ServerDuration | undefined
) {
if (!isExperimentalFeatureEnabled(ExperimentalFeature.RESOURCE_DURATIONS)) {
return
}
return {
_dd: {
computed_duration: computedDuration,
performance_entry_duration: performanceEntryDuration,
override_duration_diff: performanceEntryDuration ? computedDuration - performanceEntryDuration : undefined,
},
}
}
// TODO next major: use directly PerformanceEntry type in domain context

@@ -218,0 +199,0 @@ function toPerformanceEntryRepresentation(entry: RumPerformanceEntry): PerformanceEntryRepresentation {

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

setPageVisibility('hidden')
const eventTarget = document.createElement('div')
const eventTarget = createWindowEventTarget()
const firstHidden = trackFirstHidden(eventTarget)

@@ -37,3 +37,3 @@

it('should return the timestamp of the first pagehide event', () => {
const eventTarget = document.createElement('div')
const eventTarget = createWindowEventTarget()
const firstHidden = trackFirstHidden(eventTarget)

@@ -47,3 +47,3 @@

it('should return the timestamp of the first visibilitychange event if the page is hidden', () => {
const eventTarget = document.createElement('div')
const eventTarget = createWindowEventTarget()
const firstHidden = trackFirstHidden(eventTarget)

@@ -58,3 +58,3 @@

it('should ignore visibilitychange event if the page is visible', () => {
const eventTarget = document.createElement('div')
const eventTarget = createWindowEventTarget()
const firstHidden = trackFirstHidden(eventTarget)

@@ -68,3 +68,3 @@

it('should ignore subsequent events', () => {
const eventTarget = document.createElement('div')
const eventTarget = createWindowEventTarget()
const firstHidden = trackFirstHidden(eventTarget)

@@ -82,2 +82,6 @@

})
function createWindowEventTarget() {
return document.createElement('div') as unknown as Window
}
})

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

export function trackFirstHidden(eventTarget: EventTarget = window) {
export function trackFirstHidden(eventTarget: Window = window) {
if (!trackFirstHiddenSingleton) {

@@ -10,0 +10,0 @@ if (document.visibilityState === 'hidden') {

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

let lcpCallback: jasmine.Spy<(value: RelativeTime) => void>
let eventTarget: Element
let eventTarget: Window
beforeEach(() => {
lcpCallback = jasmine.createSpy()
eventTarget = document.createElement('div')
eventTarget = document.createElement('div') as unknown as Window
setupBuilder = setup().beforeBuild(({ lifeCycle }) =>

@@ -171,0 +171,0 @@ trackLargestContentfulPaintTiming(lifeCycle, eventTarget, lcpCallback)

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

lifeCycle: LifeCycle,
eventTarget: EventTarget,
eventTarget: Window,
callback: (lcpTiming: RelativeTime) => void

@@ -122,0 +122,0 @@ ) {

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

import type { BatchFlushEvent, Context, ContextManager, TelemetryEvent } from '@datadog/browser-core'
import type { FlushEvent, Context, ContextManager, TelemetryEvent } from '@datadog/browser-core'
import { resetExperimentalFeatures, TelemetryService, startTelemetry, Observable } from '@datadog/browser-core'

@@ -13,3 +13,3 @@ import type { TestSetupBuilder } from '../../test'

let setupBuilder: TestSetupBuilder
let batchFlushObservable: Observable<BatchFlushEvent>
let batchFlushObservable: Observable<FlushEvent>
let telemetryEvents: TelemetryEvent[]

@@ -39,3 +39,7 @@ let fakeContext: Context

}
batchFlushObservable.notify({ bufferBytesCount: batchBytesCount, bufferMessagesCount: eventNumber })
batchFlushObservable.notify({
reason: 'duration_limit',
bytesCount: batchBytesCount,
messagesCount: eventNumber,
})
}

@@ -130,3 +134,3 @@

batchFlushObservable.notify({ bufferBytesCount: 1, bufferMessagesCount: 1 })
batchFlushObservable.notify({ reason: 'duration_limit', bytesCount: 1, messagesCount: 1 })

@@ -142,3 +146,3 @@ clock.tick(MEASURES_PERIOD_DURATION)

lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, viewEvent)
batchFlushObservable.notify({ bufferBytesCount: 1, bufferMessagesCount: 1 })
batchFlushObservable.notify({ reason: 'duration_limit', bytesCount: 1, messagesCount: 1 })
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, viewEvent)

@@ -145,0 +149,0 @@ clock.tick(MEASURES_PERIOD_DURATION)

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

import type { BatchFlushEvent, Context, ContextManager, Observable, Telemetry } from '@datadog/browser-core'
import type { Context, ContextManager, FlushEvent, Observable, Telemetry } from '@datadog/browser-core'
import { isEmptyObject, includes, performDraw, ONE_SECOND, addTelemetryDebug, setInterval } from '@datadog/browser-core'

@@ -44,3 +44,3 @@ import { RumEventType } from '../rawRumEvent.types'

featureFlagContexts: FeatureFlagContexts,
batchFlushObservable: Observable<BatchFlushEvent>
batchFlushObservable: Observable<FlushEvent>
) {

@@ -80,3 +80,3 @@ const customerDataTelemetryEnabled = telemetry.enabled && performDraw(configuration.customerDataTelemetrySampleRate)

batchFlushObservable.subscribe(({ bufferBytesCount, bufferMessagesCount }) => {
batchFlushObservable.subscribe(({ bytesCount, messagesCount }) => {
// Don't measure batch that only contains telemetry events to avoid batch sending loop

@@ -88,4 +88,4 @@ // It could happen because after each batch we are adding a customer data measures telemetry event to the next one

currentPeriodMeasures.batchCount += 1
updateMeasure(currentPeriodMeasures.batchBytesCount, bufferBytesCount)
updateMeasure(currentPeriodMeasures.batchMessagesCount, bufferMessagesCount)
updateMeasure(currentPeriodMeasures.batchBytesCount, bytesCount)
updateMeasure(currentPeriodMeasures.batchMessagesCount, messagesCount)
mergeMeasure(currentPeriodMeasures.globalContextBytes, currentBatchMeasures.globalContextBytes)

@@ -92,0 +92,0 @@ mergeMeasure(currentPeriodMeasures.userContextBytes, currentBatchMeasures.userContextBytes)

@@ -26,3 +26,3 @@ export { RumPublicApi, makeRumPublicApi, RecorderApi, StartRum } from './boot/rumPublicApi'

export { ViewContexts, ViewContext } from './domain/contexts/viewContexts'
export { RumSessionManager, RumSessionPlan } from './domain/rumSessionManager'
export { RumSessionManager, RumSessionPlan, RumSession } from './domain/rumSessionManager'
export { getMutationObserverConstructor } from './browser/domMutationObservable'

@@ -34,1 +34,2 @@ export { initViewportObservable, getViewportDimension } from './browser/viewportObservable'

export * from './browser/htmlDomUtils'
export { getSessionReplayUrl } from './domain/getSessionReplayUrl'

@@ -8,5 +8,11 @@ import type {

PageExitEvent,
BatchFlushEvent,
FlushEvent,
} from '@datadog/browser-core'
import { Batch, combine, createHttpRequest, isTelemetryReplicationAllowed } from '@datadog/browser-core'
import {
createFlushController,
Batch,
combine,
createHttpRequest,
isTelemetryReplicationAllowed,
} from '@datadog/browser-core'
import type { RumConfiguration } from '../domain/configuration'

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

export interface RumBatch {
flushObservable: Observable<BatchFlushEvent>
flushObservable: Observable<FlushEvent>
add: (message: Context, replicated?: boolean) => void

@@ -52,18 +58,29 @@ upsert: (message: Context, key: string) => void

): RumBatch {
const primaryBatch = createRumBatch(configuration.rumEndpointBuilder)
const { batch: primaryBatch, flushController: primaryFlushController } = createRumBatch(
configuration.rumEndpointBuilder
)
let replicaBatch: Batch | undefined
const replica = configuration.replica
if (replica !== undefined) {
replicaBatch = createRumBatch(replica.rumEndpointBuilder)
replicaBatch = createRumBatch(replica.rumEndpointBuilder).batch
}
function createRumBatch(endpointBuilder: EndpointBuilder) {
return new Batch(
const flushController = createFlushController({
messagesLimit: configuration.batchMessagesLimit,
bytesLimit: configuration.batchBytesLimit,
durationLimit: configuration.flushTimeout,
pageExitObservable,
})
const batch = new Batch(
createHttpRequest(endpointBuilder, configuration.batchBytesLimit, reportError),
configuration.batchMessagesLimit,
configuration.batchBytesLimit,
configuration.messageBytesLimit,
configuration.flushTimeout,
pageExitObservable
flushController,
configuration.messageBytesLimit
)
return {
batch,
flushController,
}
}

@@ -76,3 +93,3 @@

return {
flushObservable: primaryBatch.flushObservable,
flushObservable: primaryFlushController.flushObservable,
add: (message: Context, replicated = true) => {

@@ -79,0 +96,0 @@ primaryBatch.add(message)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc