@datadog/browser-rum-core
Advanced tools
Comparing version 4.47.0 to 4.48.0
@@ -5,2 +5,14 @@ import type { Duration, RelativeTime } from '@datadog/browser-core'; | ||
import type { PerformanceEntryRepresentation } from '../domainContext.types'; | ||
type RumPerformanceObserverConstructor = new (callback: PerformanceObserverCallback) => RumPerformanceObserver; | ||
export interface BrowserWindow extends Window { | ||
PerformanceObserver: RumPerformanceObserverConstructor; | ||
performance: Performance & { | ||
interactionCount?: number; | ||
}; | ||
} | ||
export interface RumPerformanceObserver extends PerformanceObserver { | ||
observe(options?: PerformanceObserverInit & { | ||
durationThreshold: number; | ||
}): void; | ||
} | ||
export interface RumPerformanceResourceTiming { | ||
@@ -55,4 +67,12 @@ entryType: 'resource'; | ||
processingStart: RelativeTime; | ||
duration: Duration; | ||
target?: Node; | ||
interactionId?: number; | ||
} | ||
export interface RumPerformanceEventTiming { | ||
entryType: 'event'; | ||
startTime: RelativeTime; | ||
duration: Duration; | ||
interactionId?: number; | ||
} | ||
export interface RumLayoutShiftTiming { | ||
@@ -67,3 +87,3 @@ entryType: 'layout-shift'; | ||
} | ||
export type RumPerformanceEntry = RumPerformanceResourceTiming | RumPerformanceLongTaskTiming | RumPerformancePaintTiming | RumPerformanceNavigationTiming | RumLargestContentfulPaintTiming | RumFirstInputTiming | RumLayoutShiftTiming; | ||
export type RumPerformanceEntry = RumPerformanceResourceTiming | RumPerformanceLongTaskTiming | RumPerformancePaintTiming | RumPerformanceNavigationTiming | RumLargestContentfulPaintTiming | RumFirstInputTiming | RumPerformanceEventTiming | RumLayoutShiftTiming; | ||
export declare function supportPerformanceTimingEvent(entryType: string): boolean; | ||
@@ -75,1 +95,2 @@ export declare function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration): void; | ||
}; | ||
export {}; |
@@ -31,3 +31,3 @@ "use strict"; | ||
var mainEntries = ['resource', 'navigation', 'longtask', 'paint']; | ||
var experimentalEntries = ['largest-contentful-paint', 'first-input', 'layout-shift']; | ||
var experimentalEntries = ['largest-contentful-paint', 'first-input', 'layout-shift', 'event']; | ||
try { | ||
@@ -38,4 +38,10 @@ // Experimental entries are not retrieved by performance.getEntries() | ||
experimentalEntries.forEach(function (type) { | ||
var observer = new PerformanceObserver(handlePerformanceEntryList_1); | ||
observer.observe({ type: type, buffered: true }); | ||
var observer = new window.PerformanceObserver(handlePerformanceEntryList_1); | ||
observer.observe({ | ||
type: type, | ||
buffered: true, | ||
// durationThreshold only impact PerformanceEventTiming entries used for INP computation which requires a threshold at 40 (default is 104ms) | ||
// cf: https://github.com/GoogleChrome/web-vitals/blob/3806160ffbc93c3c4abf210a167b81228172b31c/src/onINP.ts#L209 | ||
durationThreshold: 40, | ||
}); | ||
}); | ||
@@ -124,2 +130,3 @@ } | ||
startTime: evt.timeStamp, | ||
duration: 0, // arbitrary value to avoid nullable duration and simplify INP logic | ||
}; | ||
@@ -182,3 +189,4 @@ if (evt.type === "pointerdown" /* DOM_EVENT.POINTER_DOWN */) { | ||
entry.entryType === 'first-input' || | ||
entry.entryType === 'layout-shift'; | ||
entry.entryType === 'layout-shift' || | ||
entry.entryType === 'event'; | ||
}); | ||
@@ -185,0 +193,0 @@ var rumAllowedPerformanceEntries = rumPerformanceEntries.filter(function (entry) { return !isIncompleteNavigation(entry) && !isForbiddenResource(configuration, entry); }); |
@@ -60,3 +60,3 @@ "use strict"; | ||
}, | ||
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.47.0" : undefined, | ||
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.48.0" : undefined, | ||
}, | ||
@@ -63,0 +63,0 @@ application: { |
@@ -8,5 +8,5 @@ import type { Duration, ClocksState, TimeStamp, Observable, RelativeTime } from '@datadog/browser-core'; | ||
import type { RumConfiguration } from '../../configuration'; | ||
import type { Timings } from './trackInitialViewTimings'; | ||
import type { ScrollMetrics } from './trackViewMetrics'; | ||
import type { WebVitalTelemetryDebug } from './startWebVitalTelemetryDebug'; | ||
import type { InitialViewMetrics } from './viewMetrics/trackInitialViewMetrics'; | ||
import type { CommonViewMetrics } from './viewMetrics/trackCommonViewMetrics'; | ||
export interface ViewEvent { | ||
@@ -18,3 +18,4 @@ id: string; | ||
location: Readonly<Location>; | ||
timings: Timings; | ||
commonViewMetrics: CommonViewMetrics; | ||
initialViewMetrics: InitialViewMetrics; | ||
customTimings: ViewCustomTimings; | ||
@@ -27,6 +28,3 @@ eventCounts: EventCounts; | ||
sessionIsActive: boolean; | ||
loadingTime?: Duration; | ||
loadingType: ViewLoadingType; | ||
cumulativeLayoutShift?: number; | ||
scrollMetrics?: ScrollMetrics; | ||
} | ||
@@ -33,0 +31,0 @@ export interface ViewCreatedEvent { |
@@ -5,5 +5,5 @@ "use strict"; | ||
var browser_core_1 = require("@datadog/browser-core"); | ||
var trackInitialViewTimings_1 = require("./trackInitialViewTimings"); | ||
var trackViewMetrics_1 = require("./trackViewMetrics"); | ||
var trackViewEventCounts_1 = require("./trackViewEventCounts"); | ||
var trackInitialViewMetrics_1 = require("./viewMetrics/trackInitialViewMetrics"); | ||
var trackCommonViewMetrics_1 = require("./viewMetrics/trackCommonViewMetrics"); | ||
exports.THROTTLE_VIEW_UPDATE_PERIOD = 3000; | ||
@@ -93,6 +93,6 @@ exports.SESSION_KEEP_ALIVE_INTERVAL = 5 * browser_core_1.ONE_MINUTE; | ||
}), scheduleViewUpdate = _a.throttled, cancelScheduleViewUpdate = _a.cancel; | ||
var _b = (0, trackViewMetrics_1.trackViewMetrics)(lifeCycle, domMutationObservable, configuration, scheduleViewUpdate, loadingType, startClocks, webVitalTelemetryDebug), setLoadEvent = _b.setLoadEvent, stopViewMetricsTracking = _b.stop, viewMetrics = _b.viewMetrics, getScrollMetrics = _b.getScrollMetrics; | ||
var _b = (0, trackCommonViewMetrics_1.trackCommonViewMetrics)(lifeCycle, domMutationObservable, configuration, scheduleViewUpdate, loadingType, startClocks, webVitalTelemetryDebug), setLoadEvent = _b.setLoadEvent, stopCommonViewMetricsTracking = _b.stop, getCommonViewMetrics = _b.getCommonViewMetrics; | ||
var _c = loadingType === "initial_load" /* ViewLoadingType.INITIAL_LOAD */ | ||
? (0, trackInitialViewTimings_1.trackInitialViewTimings)(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) | ||
: { scheduleStop: browser_core_1.noop, timings: {} }, scheduleStopInitialViewTimingsTracking = _c.scheduleStop, timings = _c.timings; | ||
? (0, trackInitialViewMetrics_1.trackInitialViewMetrics)(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) | ||
: { scheduleStop: browser_core_1.noop, initialViewMetrics: {} }, scheduleStopInitialViewMetricsTracking = _c.scheduleStop, initialViewMetrics = _c.initialViewMetrics; | ||
var _d = (0, trackViewEventCounts_1.trackViewEventCounts)(lifeCycle, id, scheduleViewUpdate), scheduleStopEventCountsTracking = _d.scheduleStop, eventCounts = _d.eventCounts; | ||
@@ -107,3 +107,3 @@ // Session keep alive | ||
var currentEnd = endClocks === undefined ? (0, browser_core_1.timeStampNow)() : endClocks.timeStamp; | ||
lifeCycle.notify(3 /* LifeCycleEventType.VIEW_UPDATED */, (0, browser_core_1.assign)({ | ||
lifeCycle.notify(3 /* LifeCycleEventType.VIEW_UPDATED */, { | ||
customTimings: customTimings, | ||
@@ -118,3 +118,4 @@ documentVersion: documentVersion, | ||
startClocks: startClocks, | ||
timings: timings, | ||
commonViewMetrics: getCommonViewMetrics(), | ||
initialViewMetrics: initialViewMetrics, | ||
duration: (0, browser_core_1.elapsed)(startClocks.timeStamp, currentEnd), | ||
@@ -124,4 +125,3 @@ isActive: endClocks === undefined, | ||
eventCounts: eventCounts, | ||
scrollMetrics: getScrollMetrics(), | ||
}, viewMetrics)); | ||
}); | ||
} | ||
@@ -143,4 +143,4 @@ return { | ||
(0, browser_core_1.clearInterval)(keepAliveIntervalId); | ||
stopViewMetricsTracking(); | ||
scheduleStopInitialViewTimingsTracking(); | ||
stopCommonViewMetricsTracking(); | ||
scheduleStopInitialViewMetricsTracking(); | ||
scheduleStopEventCountsTracking(); | ||
@@ -147,0 +147,0 @@ triggerViewUpdate(); |
@@ -35,18 +35,19 @@ "use strict"; | ||
}, | ||
cumulative_layout_shift: view.cumulativeLayoutShift, | ||
first_byte: (0, browser_core_1.toServerDuration)(view.timings.firstByte), | ||
dom_complete: (0, browser_core_1.toServerDuration)(view.timings.domComplete), | ||
dom_content_loaded: (0, browser_core_1.toServerDuration)(view.timings.domContentLoaded), | ||
dom_interactive: (0, browser_core_1.toServerDuration)(view.timings.domInteractive), | ||
cumulative_layout_shift: view.commonViewMetrics.cumulativeLayoutShift, | ||
first_byte: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.firstByte), | ||
dom_complete: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.domComplete), | ||
dom_content_loaded: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.domContentLoaded), | ||
dom_interactive: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.domInteractive), | ||
error: { | ||
count: view.eventCounts.errorCount, | ||
}, | ||
first_contentful_paint: (0, browser_core_1.toServerDuration)(view.timings.firstContentfulPaint), | ||
first_input_delay: (0, browser_core_1.toServerDuration)(view.timings.firstInputDelay), | ||
first_input_time: (0, browser_core_1.toServerDuration)(view.timings.firstInputTime), | ||
first_contentful_paint: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.firstContentfulPaint), | ||
first_input_delay: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.firstInputDelay), | ||
first_input_time: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.firstInputTime), | ||
interaction_to_next_paint: (0, browser_core_1.toServerDuration)(view.commonViewMetrics.interactionToNextPaint), | ||
is_active: view.isActive, | ||
name: view.name, | ||
largest_contentful_paint: (0, browser_core_1.toServerDuration)(view.timings.largestContentfulPaint), | ||
load_event: (0, browser_core_1.toServerDuration)(view.timings.loadEvent), | ||
loading_time: discardNegativeDuration((0, browser_core_1.toServerDuration)(view.loadingTime)), | ||
largest_contentful_paint: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.largestContentfulPaint), | ||
load_event: (0, browser_core_1.toServerDuration)(view.initialViewMetrics.loadEvent), | ||
loading_time: discardNegativeDuration((0, browser_core_1.toServerDuration)(view.commonViewMetrics.loadingTime)), | ||
loading_type: view.loadingType, | ||
@@ -63,9 +64,9 @@ long_task: { | ||
feature_flags: featureFlagContext && !(0, browser_core_1.isEmptyObject)(featureFlagContext) ? featureFlagContext : undefined, | ||
display: view.scrollMetrics | ||
display: view.commonViewMetrics.scroll | ||
? { | ||
scroll: { | ||
max_depth: view.scrollMetrics.maxDepth, | ||
max_depth_scroll_height: view.scrollMetrics.maxDepthScrollHeight, | ||
max_depth_scroll_top: view.scrollMetrics.maxDepthScrollTop, | ||
max_depth_time: (0, browser_core_1.toServerDuration)(view.scrollMetrics.maxDepthTime), | ||
max_depth: view.commonViewMetrics.scroll.maxDepth, | ||
max_depth_scroll_height: view.commonViewMetrics.scroll.maxDepthScrollHeight, | ||
max_depth_scroll_top: view.commonViewMetrics.scroll.maxDepthScrollTop, | ||
max_depth_time: (0, browser_core_1.toServerDuration)(view.commonViewMetrics.scroll.maxDepthTime), | ||
}, | ||
@@ -72,0 +73,0 @@ } |
@@ -70,2 +70,3 @@ import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel } from '@datadog/browser-core'; | ||
first_input_time?: ServerDuration; | ||
interaction_to_next_paint?: ServerDuration; | ||
cumulative_layout_shift?: number; | ||
@@ -72,0 +73,0 @@ custom_timings?: { |
@@ -527,2 +527,6 @@ /** | ||
/** | ||
* Longest duration in ns between an interaction and the next paint | ||
*/ | ||
readonly interaction_to_next_paint?: number; | ||
/** | ||
* Total layout shift score that occurred on the view | ||
@@ -529,0 +533,0 @@ */ |
@@ -1,9 +0,8 @@ | ||
import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent, FlushEvent } from '@datadog/browser-core'; | ||
import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent } from '@datadog/browser-core'; | ||
import type { RumConfiguration } from '../domain/configuration'; | ||
import type { LifeCycle } from '../domain/lifeCycle'; | ||
export declare function startRumBatch(configuration: RumConfiguration, lifeCycle: LifeCycle, telemetryEventObservable: Observable<TelemetryEvent & Context>, reportError: (error: RawError) => void, pageExitObservable: Observable<PageExitEvent>, sessionExpireObservable: Observable<void>): RumBatch; | ||
export interface RumBatch { | ||
flushObservable: Observable<FlushEvent>; | ||
add: (message: Context, replicated?: boolean) => void; | ||
export declare function startRumBatch(configuration: RumConfiguration, lifeCycle: LifeCycle, telemetryEventObservable: Observable<TelemetryEvent & Context>, reportError: (error: RawError) => void, pageExitObservable: Observable<PageExitEvent>, sessionExpireObservable: Observable<void>): { | ||
flushObservable: Observable<import("@datadog/browser-core").FlushEvent>; | ||
add(message: Context, replicated?: boolean | undefined): void; | ||
upsert: (message: Context, key: string) => void; | ||
} | ||
}; |
@@ -6,3 +6,9 @@ "use strict"; | ||
function startRumBatch(configuration, lifeCycle, telemetryEventObservable, reportError, pageExitObservable, sessionExpireObservable) { | ||
var batch = makeRumBatch(configuration, reportError, pageExitObservable, sessionExpireObservable); | ||
var replica = configuration.replica; | ||
var batch = (0, browser_core_1.startBatchWithReplica)(configuration, { | ||
endpoint: configuration.rumEndpointBuilder, | ||
}, replica && { | ||
endpoint: replica.rumEndpointBuilder, | ||
transformMessage: function (message) { return (0, browser_core_1.combine)(message, { application: { id: replica.applicationId } }); }, | ||
}, reportError, pageExitObservable, sessionExpireObservable); | ||
lifeCycle.subscribe(11 /* LifeCycleEventType.RUM_EVENT_COLLECTED */, function (serverRumEvent) { | ||
@@ -20,43 +26,2 @@ if (serverRumEvent.type === "view" /* RumEventType.VIEW */) { | ||
exports.startRumBatch = startRumBatch; | ||
function makeRumBatch(configuration, reportError, pageExitObservable, sessionExpireObservable) { | ||
var _a = createRumBatch(configuration.rumEndpointBuilder), primaryBatch = _a.batch, primaryFlushController = _a.flushController; | ||
var replicaBatch; | ||
var replica = configuration.replica; | ||
if (replica !== undefined) { | ||
replicaBatch = createRumBatch(replica.rumEndpointBuilder).batch; | ||
} | ||
function createRumBatch(endpointBuilder) { | ||
var flushController = (0, browser_core_1.createFlushController)({ | ||
messagesLimit: configuration.batchMessagesLimit, | ||
bytesLimit: configuration.batchBytesLimit, | ||
durationLimit: configuration.flushTimeout, | ||
pageExitObservable: pageExitObservable, | ||
sessionExpireObservable: sessionExpireObservable, | ||
}); | ||
var batch = new browser_core_1.Batch((0, browser_core_1.createHttpRequest)(configuration, endpointBuilder, configuration.batchBytesLimit, reportError), flushController, configuration.messageBytesLimit); | ||
return { | ||
batch: batch, | ||
flushController: flushController, | ||
}; | ||
} | ||
function withReplicaApplicationId(message) { | ||
return (0, browser_core_1.combine)(message, { application: { id: replica.applicationId } }); | ||
} | ||
return { | ||
flushObservable: primaryFlushController.flushObservable, | ||
add: function (message, replicated) { | ||
if (replicated === void 0) { replicated = true; } | ||
primaryBatch.add(message); | ||
if (replicaBatch && replicated) { | ||
replicaBatch.add(withReplicaApplicationId(message)); | ||
} | ||
}, | ||
upsert: function (message, key) { | ||
primaryBatch.upsert(message, key); | ||
if (replicaBatch) { | ||
replicaBatch.upsert(withReplicaApplicationId(message), key); | ||
} | ||
}, | ||
}; | ||
} | ||
//# sourceMappingURL=startRumBatch.js.map |
@@ -5,2 +5,14 @@ import type { Duration, RelativeTime } from '@datadog/browser-core'; | ||
import type { PerformanceEntryRepresentation } from '../domainContext.types'; | ||
type RumPerformanceObserverConstructor = new (callback: PerformanceObserverCallback) => RumPerformanceObserver; | ||
export interface BrowserWindow extends Window { | ||
PerformanceObserver: RumPerformanceObserverConstructor; | ||
performance: Performance & { | ||
interactionCount?: number; | ||
}; | ||
} | ||
export interface RumPerformanceObserver extends PerformanceObserver { | ||
observe(options?: PerformanceObserverInit & { | ||
durationThreshold: number; | ||
}): void; | ||
} | ||
export interface RumPerformanceResourceTiming { | ||
@@ -55,4 +67,12 @@ entryType: 'resource'; | ||
processingStart: RelativeTime; | ||
duration: Duration; | ||
target?: Node; | ||
interactionId?: number; | ||
} | ||
export interface RumPerformanceEventTiming { | ||
entryType: 'event'; | ||
startTime: RelativeTime; | ||
duration: Duration; | ||
interactionId?: number; | ||
} | ||
export interface RumLayoutShiftTiming { | ||
@@ -67,3 +87,3 @@ entryType: 'layout-shift'; | ||
} | ||
export type RumPerformanceEntry = RumPerformanceResourceTiming | RumPerformanceLongTaskTiming | RumPerformancePaintTiming | RumPerformanceNavigationTiming | RumLargestContentfulPaintTiming | RumFirstInputTiming | RumLayoutShiftTiming; | ||
export type RumPerformanceEntry = RumPerformanceResourceTiming | RumPerformanceLongTaskTiming | RumPerformancePaintTiming | RumPerformanceNavigationTiming | RumLargestContentfulPaintTiming | RumFirstInputTiming | RumPerformanceEventTiming | RumLayoutShiftTiming; | ||
export declare function supportPerformanceTimingEvent(entryType: string): boolean; | ||
@@ -75,1 +95,2 @@ export declare function startPerformanceCollection(lifeCycle: LifeCycle, configuration: RumConfiguration): void; | ||
}; | ||
export {}; |
@@ -27,3 +27,3 @@ import { dateNow, assign, addEventListeners, getRelativeTime, isNumber, monitor, setTimeout, relativeNow, runOnReadyState, addEventListener, } from '@datadog/browser-core'; | ||
var mainEntries = ['resource', 'navigation', 'longtask', 'paint']; | ||
var experimentalEntries = ['largest-contentful-paint', 'first-input', 'layout-shift']; | ||
var experimentalEntries = ['largest-contentful-paint', 'first-input', 'layout-shift', 'event']; | ||
try { | ||
@@ -34,4 +34,10 @@ // Experimental entries are not retrieved by performance.getEntries() | ||
experimentalEntries.forEach(function (type) { | ||
var observer = new PerformanceObserver(handlePerformanceEntryList_1); | ||
observer.observe({ type: type, buffered: true }); | ||
var observer = new window.PerformanceObserver(handlePerformanceEntryList_1); | ||
observer.observe({ | ||
type: type, | ||
buffered: true, | ||
// durationThreshold only impact PerformanceEventTiming entries used for INP computation which requires a threshold at 40 (default is 104ms) | ||
// cf: https://github.com/GoogleChrome/web-vitals/blob/3806160ffbc93c3c4abf210a167b81228172b31c/src/onINP.ts#L209 | ||
durationThreshold: 40, | ||
}); | ||
}); | ||
@@ -118,2 +124,3 @@ } | ||
startTime: evt.timeStamp, | ||
duration: 0, // arbitrary value to avoid nullable duration and simplify INP logic | ||
}; | ||
@@ -176,3 +183,4 @@ if (evt.type === "pointerdown" /* DOM_EVENT.POINTER_DOWN */) { | ||
entry.entryType === 'first-input' || | ||
entry.entryType === 'layout-shift'; | ||
entry.entryType === 'layout-shift' || | ||
entry.entryType === 'event'; | ||
}); | ||
@@ -179,0 +187,0 @@ var rumAllowedPerformanceEntries = rumPerformanceEntries.filter(function (entry) { return !isIncompleteNavigation(entry) && !isForbiddenResource(configuration, entry); }); |
@@ -57,3 +57,3 @@ import { combine, isEmptyObject, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, assign, round, } from '@datadog/browser-core'; | ||
}, | ||
browser_sdk_version: canUseEventBridge() ? "4.47.0" : undefined, | ||
browser_sdk_version: canUseEventBridge() ? "4.48.0" : undefined, | ||
}, | ||
@@ -60,0 +60,0 @@ application: { |
@@ -8,5 +8,5 @@ import type { Duration, ClocksState, TimeStamp, Observable, RelativeTime } from '@datadog/browser-core'; | ||
import type { RumConfiguration } from '../../configuration'; | ||
import type { Timings } from './trackInitialViewTimings'; | ||
import type { ScrollMetrics } from './trackViewMetrics'; | ||
import type { WebVitalTelemetryDebug } from './startWebVitalTelemetryDebug'; | ||
import type { InitialViewMetrics } from './viewMetrics/trackInitialViewMetrics'; | ||
import type { CommonViewMetrics } from './viewMetrics/trackCommonViewMetrics'; | ||
export interface ViewEvent { | ||
@@ -18,3 +18,4 @@ id: string; | ||
location: Readonly<Location>; | ||
timings: Timings; | ||
commonViewMetrics: CommonViewMetrics; | ||
initialViewMetrics: InitialViewMetrics; | ||
customTimings: ViewCustomTimings; | ||
@@ -27,6 +28,3 @@ eventCounts: EventCounts; | ||
sessionIsActive: boolean; | ||
loadingTime?: Duration; | ||
loadingType: ViewLoadingType; | ||
cumulativeLayoutShift?: number; | ||
scrollMetrics?: ScrollMetrics; | ||
} | ||
@@ -33,0 +31,0 @@ export interface ViewCreatedEvent { |
@@ -1,5 +0,5 @@ | ||
import { noop, PageExitReason, shallowClone, assign, elapsed, generateUUID, ONE_MINUTE, throttle, clocksNow, clocksOrigin, timeStampNow, display, looksLikeRelativeTime, setInterval, clearInterval, } from '@datadog/browser-core'; | ||
import { trackInitialViewTimings } from './trackInitialViewTimings'; | ||
import { trackViewMetrics } from './trackViewMetrics'; | ||
import { noop, PageExitReason, shallowClone, elapsed, generateUUID, ONE_MINUTE, throttle, clocksNow, clocksOrigin, timeStampNow, display, looksLikeRelativeTime, setInterval, clearInterval, } from '@datadog/browser-core'; | ||
import { trackViewEventCounts } from './trackViewEventCounts'; | ||
import { trackInitialViewMetrics } from './viewMetrics/trackInitialViewMetrics'; | ||
import { trackCommonViewMetrics } from './viewMetrics/trackCommonViewMetrics'; | ||
export var THROTTLE_VIEW_UPDATE_PERIOD = 3000; | ||
@@ -88,6 +88,6 @@ export var SESSION_KEEP_ALIVE_INTERVAL = 5 * ONE_MINUTE; | ||
}), scheduleViewUpdate = _a.throttled, cancelScheduleViewUpdate = _a.cancel; | ||
var _b = trackViewMetrics(lifeCycle, domMutationObservable, configuration, scheduleViewUpdate, loadingType, startClocks, webVitalTelemetryDebug), setLoadEvent = _b.setLoadEvent, stopViewMetricsTracking = _b.stop, viewMetrics = _b.viewMetrics, getScrollMetrics = _b.getScrollMetrics; | ||
var _b = trackCommonViewMetrics(lifeCycle, domMutationObservable, configuration, scheduleViewUpdate, loadingType, startClocks, webVitalTelemetryDebug), setLoadEvent = _b.setLoadEvent, stopCommonViewMetricsTracking = _b.stop, getCommonViewMetrics = _b.getCommonViewMetrics; | ||
var _c = loadingType === "initial_load" /* ViewLoadingType.INITIAL_LOAD */ | ||
? trackInitialViewTimings(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) | ||
: { scheduleStop: noop, timings: {} }, scheduleStopInitialViewTimingsTracking = _c.scheduleStop, timings = _c.timings; | ||
? trackInitialViewMetrics(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) | ||
: { scheduleStop: noop, initialViewMetrics: {} }, scheduleStopInitialViewMetricsTracking = _c.scheduleStop, initialViewMetrics = _c.initialViewMetrics; | ||
var _d = trackViewEventCounts(lifeCycle, id, scheduleViewUpdate), scheduleStopEventCountsTracking = _d.scheduleStop, eventCounts = _d.eventCounts; | ||
@@ -102,3 +102,3 @@ // Session keep alive | ||
var currentEnd = endClocks === undefined ? timeStampNow() : endClocks.timeStamp; | ||
lifeCycle.notify(3 /* LifeCycleEventType.VIEW_UPDATED */, assign({ | ||
lifeCycle.notify(3 /* LifeCycleEventType.VIEW_UPDATED */, { | ||
customTimings: customTimings, | ||
@@ -113,3 +113,4 @@ documentVersion: documentVersion, | ||
startClocks: startClocks, | ||
timings: timings, | ||
commonViewMetrics: getCommonViewMetrics(), | ||
initialViewMetrics: initialViewMetrics, | ||
duration: elapsed(startClocks.timeStamp, currentEnd), | ||
@@ -119,4 +120,3 @@ isActive: endClocks === undefined, | ||
eventCounts: eventCounts, | ||
scrollMetrics: getScrollMetrics(), | ||
}, viewMetrics)); | ||
}); | ||
} | ||
@@ -138,4 +138,4 @@ return { | ||
clearInterval(keepAliveIntervalId); | ||
stopViewMetricsTracking(); | ||
scheduleStopInitialViewTimingsTracking(); | ||
stopCommonViewMetricsTracking(); | ||
scheduleStopInitialViewMetricsTracking(); | ||
scheduleStopEventCountsTracking(); | ||
@@ -142,0 +142,0 @@ triggerViewUpdate(); |
@@ -31,18 +31,19 @@ import { isExperimentalFeatureEnabled, ExperimentalFeature, isEmptyObject, mapValues, toServerDuration, isNumber, } from '@datadog/browser-core'; | ||
}, | ||
cumulative_layout_shift: view.cumulativeLayoutShift, | ||
first_byte: toServerDuration(view.timings.firstByte), | ||
dom_complete: toServerDuration(view.timings.domComplete), | ||
dom_content_loaded: toServerDuration(view.timings.domContentLoaded), | ||
dom_interactive: toServerDuration(view.timings.domInteractive), | ||
cumulative_layout_shift: view.commonViewMetrics.cumulativeLayoutShift, | ||
first_byte: toServerDuration(view.initialViewMetrics.firstByte), | ||
dom_complete: toServerDuration(view.initialViewMetrics.domComplete), | ||
dom_content_loaded: toServerDuration(view.initialViewMetrics.domContentLoaded), | ||
dom_interactive: toServerDuration(view.initialViewMetrics.domInteractive), | ||
error: { | ||
count: view.eventCounts.errorCount, | ||
}, | ||
first_contentful_paint: toServerDuration(view.timings.firstContentfulPaint), | ||
first_input_delay: toServerDuration(view.timings.firstInputDelay), | ||
first_input_time: toServerDuration(view.timings.firstInputTime), | ||
first_contentful_paint: toServerDuration(view.initialViewMetrics.firstContentfulPaint), | ||
first_input_delay: toServerDuration(view.initialViewMetrics.firstInputDelay), | ||
first_input_time: toServerDuration(view.initialViewMetrics.firstInputTime), | ||
interaction_to_next_paint: toServerDuration(view.commonViewMetrics.interactionToNextPaint), | ||
is_active: view.isActive, | ||
name: view.name, | ||
largest_contentful_paint: toServerDuration(view.timings.largestContentfulPaint), | ||
load_event: toServerDuration(view.timings.loadEvent), | ||
loading_time: discardNegativeDuration(toServerDuration(view.loadingTime)), | ||
largest_contentful_paint: toServerDuration(view.initialViewMetrics.largestContentfulPaint), | ||
load_event: toServerDuration(view.initialViewMetrics.loadEvent), | ||
loading_time: discardNegativeDuration(toServerDuration(view.commonViewMetrics.loadingTime)), | ||
loading_type: view.loadingType, | ||
@@ -59,9 +60,9 @@ long_task: { | ||
feature_flags: featureFlagContext && !isEmptyObject(featureFlagContext) ? featureFlagContext : undefined, | ||
display: view.scrollMetrics | ||
display: view.commonViewMetrics.scroll | ||
? { | ||
scroll: { | ||
max_depth: view.scrollMetrics.maxDepth, | ||
max_depth_scroll_height: view.scrollMetrics.maxDepthScrollHeight, | ||
max_depth_scroll_top: view.scrollMetrics.maxDepthScrollTop, | ||
max_depth_time: toServerDuration(view.scrollMetrics.maxDepthTime), | ||
max_depth: view.commonViewMetrics.scroll.maxDepth, | ||
max_depth_scroll_height: view.commonViewMetrics.scroll.maxDepthScrollHeight, | ||
max_depth_scroll_top: view.commonViewMetrics.scroll.maxDepthScrollTop, | ||
max_depth_time: toServerDuration(view.commonViewMetrics.scroll.maxDepthTime), | ||
}, | ||
@@ -68,0 +69,0 @@ } |
@@ -70,2 +70,3 @@ import type { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp, RawErrorCause, DefaultPrivacyLevel } from '@datadog/browser-core'; | ||
first_input_time?: ServerDuration; | ||
interaction_to_next_paint?: ServerDuration; | ||
cumulative_layout_shift?: number; | ||
@@ -72,0 +73,0 @@ custom_timings?: { |
@@ -527,2 +527,6 @@ /** | ||
/** | ||
* Longest duration in ns between an interaction and the next paint | ||
*/ | ||
readonly interaction_to_next_paint?: number; | ||
/** | ||
* Total layout shift score that occurred on the view | ||
@@ -529,0 +533,0 @@ */ |
@@ -1,9 +0,8 @@ | ||
import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent, FlushEvent } from '@datadog/browser-core'; | ||
import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent } from '@datadog/browser-core'; | ||
import type { RumConfiguration } from '../domain/configuration'; | ||
import type { LifeCycle } from '../domain/lifeCycle'; | ||
export declare function startRumBatch(configuration: RumConfiguration, lifeCycle: LifeCycle, telemetryEventObservable: Observable<TelemetryEvent & Context>, reportError: (error: RawError) => void, pageExitObservable: Observable<PageExitEvent>, sessionExpireObservable: Observable<void>): RumBatch; | ||
export interface RumBatch { | ||
flushObservable: Observable<FlushEvent>; | ||
add: (message: Context, replicated?: boolean) => void; | ||
export declare function startRumBatch(configuration: RumConfiguration, lifeCycle: LifeCycle, telemetryEventObservable: Observable<TelemetryEvent & Context>, reportError: (error: RawError) => void, pageExitObservable: Observable<PageExitEvent>, sessionExpireObservable: Observable<void>): { | ||
flushObservable: Observable<import("@datadog/browser-core").FlushEvent>; | ||
add(message: Context, replicated?: boolean | undefined): void; | ||
upsert: (message: Context, key: string) => void; | ||
} | ||
}; |
@@ -1,4 +0,10 @@ | ||
import { createFlushController, Batch, combine, createHttpRequest, isTelemetryReplicationAllowed, } from '@datadog/browser-core'; | ||
import { combine, isTelemetryReplicationAllowed, startBatchWithReplica } from '@datadog/browser-core'; | ||
export function startRumBatch(configuration, lifeCycle, telemetryEventObservable, reportError, pageExitObservable, sessionExpireObservable) { | ||
var batch = makeRumBatch(configuration, reportError, pageExitObservable, sessionExpireObservable); | ||
var replica = configuration.replica; | ||
var batch = startBatchWithReplica(configuration, { | ||
endpoint: configuration.rumEndpointBuilder, | ||
}, replica && { | ||
endpoint: replica.rumEndpointBuilder, | ||
transformMessage: function (message) { return combine(message, { application: { id: replica.applicationId } }); }, | ||
}, reportError, pageExitObservable, sessionExpireObservable); | ||
lifeCycle.subscribe(11 /* LifeCycleEventType.RUM_EVENT_COLLECTED */, function (serverRumEvent) { | ||
@@ -15,43 +21,2 @@ if (serverRumEvent.type === "view" /* RumEventType.VIEW */) { | ||
} | ||
function makeRumBatch(configuration, reportError, pageExitObservable, sessionExpireObservable) { | ||
var _a = createRumBatch(configuration.rumEndpointBuilder), primaryBatch = _a.batch, primaryFlushController = _a.flushController; | ||
var replicaBatch; | ||
var replica = configuration.replica; | ||
if (replica !== undefined) { | ||
replicaBatch = createRumBatch(replica.rumEndpointBuilder).batch; | ||
} | ||
function createRumBatch(endpointBuilder) { | ||
var flushController = createFlushController({ | ||
messagesLimit: configuration.batchMessagesLimit, | ||
bytesLimit: configuration.batchBytesLimit, | ||
durationLimit: configuration.flushTimeout, | ||
pageExitObservable: pageExitObservable, | ||
sessionExpireObservable: sessionExpireObservable, | ||
}); | ||
var batch = new Batch(createHttpRequest(configuration, endpointBuilder, configuration.batchBytesLimit, reportError), flushController, configuration.messageBytesLimit); | ||
return { | ||
batch: batch, | ||
flushController: flushController, | ||
}; | ||
} | ||
function withReplicaApplicationId(message) { | ||
return combine(message, { application: { id: replica.applicationId } }); | ||
} | ||
return { | ||
flushObservable: primaryFlushController.flushObservable, | ||
add: function (message, replicated) { | ||
if (replicated === void 0) { replicated = true; } | ||
primaryBatch.add(message); | ||
if (replicaBatch && replicated) { | ||
replicaBatch.add(withReplicaApplicationId(message)); | ||
} | ||
}, | ||
upsert: function (message, key) { | ||
primaryBatch.upsert(message, key); | ||
if (replicaBatch) { | ||
replicaBatch.upsert(withReplicaApplicationId(message), key); | ||
} | ||
}, | ||
}; | ||
} | ||
//# sourceMappingURL=startRumBatch.js.map |
{ | ||
"name": "@datadog/browser-rum-core", | ||
"version": "4.47.0", | ||
"version": "4.48.0", | ||
"license": "Apache-2.0", | ||
@@ -15,3 +15,3 @@ "main": "cjs/index.js", | ||
"dependencies": { | ||
"@datadog/browser-core": "4.47.0" | ||
"@datadog/browser-core": "4.48.0" | ||
}, | ||
@@ -32,3 +32,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "8aa80956202b4b2eb82b15ffd0f815c58679873d" | ||
"gitHead": "fb747ba67e23abd3f21112c51d9fbac4c9c6fed4" | ||
} |
@@ -24,2 +24,13 @@ import type { Duration, RelativeTime, TimeStamp } from '@datadog/browser-core' | ||
type RumPerformanceObserverConstructor = new (callback: PerformanceObserverCallback) => RumPerformanceObserver | ||
export interface BrowserWindow extends Window { | ||
PerformanceObserver: RumPerformanceObserverConstructor | ||
performance: Performance & { interactionCount?: number } | ||
} | ||
export interface RumPerformanceObserver extends PerformanceObserver { | ||
observe(options?: PerformanceObserverInit & { durationThreshold: number }): void | ||
} | ||
export interface RumPerformanceResourceTiming { | ||
@@ -79,5 +90,14 @@ entryType: 'resource' | ||
processingStart: RelativeTime | ||
duration: Duration | ||
target?: Node | ||
interactionId?: number | ||
} | ||
export interface RumPerformanceEventTiming { | ||
entryType: 'event' | ||
startTime: RelativeTime | ||
duration: Duration | ||
interactionId?: number | ||
} | ||
export interface RumLayoutShiftTiming { | ||
@@ -100,2 +120,3 @@ entryType: 'layout-shift' | ||
| RumFirstInputTiming | ||
| RumPerformanceEventTiming | ||
| RumLayoutShiftTiming | ||
@@ -132,3 +153,3 @@ | ||
const mainEntries = ['resource', 'navigation', 'longtask', 'paint'] | ||
const experimentalEntries = ['largest-contentful-paint', 'first-input', 'layout-shift'] | ||
const experimentalEntries = ['largest-contentful-paint', 'first-input', 'layout-shift', 'event'] | ||
@@ -140,4 +161,10 @@ try { | ||
experimentalEntries.forEach((type) => { | ||
const observer = new PerformanceObserver(handlePerformanceEntryList) | ||
observer.observe({ type, buffered: true }) | ||
const observer = new (window as BrowserWindow).PerformanceObserver(handlePerformanceEntryList) | ||
observer.observe({ | ||
type, | ||
buffered: true, | ||
// durationThreshold only impact PerformanceEventTiming entries used for INP computation which requires a threshold at 40 (default is 104ms) | ||
// cf: https://github.com/GoogleChrome/web-vitals/blob/3806160ffbc93c3c4abf210a167b81228172b31c/src/onINP.ts#L209 | ||
durationThreshold: 40, | ||
}) | ||
}) | ||
@@ -247,2 +274,3 @@ } catch (e) { | ||
startTime: evt.timeStamp as RelativeTime, | ||
duration: 0 as Duration, // arbitrary value to avoid nullable duration and simplify INP logic | ||
} | ||
@@ -326,3 +354,4 @@ | ||
entry.entryType === 'first-input' || | ||
entry.entryType === 'layout-shift' | ||
entry.entryType === 'layout-shift' || | ||
entry.entryType === 'event' | ||
) as RumPerformanceEntry[] | ||
@@ -329,0 +358,0 @@ |
@@ -6,3 +6,2 @@ import type { Duration, ClocksState, TimeStamp, Observable, Subscription, RelativeTime } from '@datadog/browser-core' | ||
shallowClone, | ||
assign, | ||
elapsed, | ||
@@ -29,8 +28,8 @@ generateUUID, | ||
import type { RumConfiguration } from '../../configuration' | ||
import type { Timings } from './trackInitialViewTimings' | ||
import { trackInitialViewTimings } from './trackInitialViewTimings' | ||
import type { ScrollMetrics } from './trackViewMetrics' | ||
import { trackViewMetrics } from './trackViewMetrics' | ||
import { trackViewEventCounts } from './trackViewEventCounts' | ||
import type { WebVitalTelemetryDebug } from './startWebVitalTelemetryDebug' | ||
import { trackInitialViewMetrics } from './viewMetrics/trackInitialViewMetrics' | ||
import type { InitialViewMetrics } from './viewMetrics/trackInitialViewMetrics' | ||
import { trackCommonViewMetrics } from './viewMetrics/trackCommonViewMetrics' | ||
import type { CommonViewMetrics } from './viewMetrics/trackCommonViewMetrics' | ||
@@ -43,3 +42,4 @@ export interface ViewEvent { | ||
location: Readonly<Location> | ||
timings: Timings | ||
commonViewMetrics: CommonViewMetrics | ||
initialViewMetrics: InitialViewMetrics | ||
customTimings: ViewCustomTimings | ||
@@ -52,6 +52,3 @@ eventCounts: EventCounts | ||
sessionIsActive: boolean | ||
loadingTime?: Duration | ||
loadingType: ViewLoadingType | ||
cumulativeLayoutShift?: number | ||
scrollMetrics?: ScrollMetrics | ||
} | ||
@@ -204,6 +201,5 @@ | ||
setLoadEvent, | ||
stop: stopViewMetricsTracking, | ||
viewMetrics, | ||
getScrollMetrics, | ||
} = trackViewMetrics( | ||
stop: stopCommonViewMetricsTracking, | ||
getCommonViewMetrics, | ||
} = trackCommonViewMetrics( | ||
lifeCycle, | ||
@@ -218,6 +214,6 @@ domMutationObservable, | ||
const { scheduleStop: scheduleStopInitialViewTimingsTracking, timings } = | ||
const { scheduleStop: scheduleStopInitialViewMetricsTracking, initialViewMetrics } = | ||
loadingType === ViewLoadingType.INITIAL_LOAD | ||
? trackInitialViewTimings(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) | ||
: { scheduleStop: noop, timings: {} as Timings } | ||
? trackInitialViewMetrics(lifeCycle, configuration, webVitalTelemetryDebug, setLoadEvent, scheduleViewUpdate) | ||
: { scheduleStop: noop, initialViewMetrics: {} as InitialViewMetrics } | ||
@@ -241,25 +237,19 @@ const { scheduleStop: scheduleStopEventCountsTracking, eventCounts } = trackViewEventCounts( | ||
lifeCycle.notify( | ||
LifeCycleEventType.VIEW_UPDATED, | ||
assign( | ||
{ | ||
customTimings, | ||
documentVersion, | ||
id, | ||
name, | ||
service, | ||
version, | ||
loadingType, | ||
location, | ||
startClocks, | ||
timings, | ||
duration: elapsed(startClocks.timeStamp, currentEnd), | ||
isActive: endClocks === undefined, | ||
sessionIsActive, | ||
eventCounts, | ||
scrollMetrics: getScrollMetrics(), | ||
}, | ||
viewMetrics | ||
) | ||
) | ||
lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, { | ||
customTimings, | ||
documentVersion, | ||
id, | ||
name, | ||
service, | ||
version, | ||
loadingType, | ||
location, | ||
startClocks, | ||
commonViewMetrics: getCommonViewMetrics(), | ||
initialViewMetrics, | ||
duration: elapsed(startClocks.timeStamp, currentEnd), | ||
isActive: endClocks === undefined, | ||
sessionIsActive, | ||
eventCounts, | ||
}) | ||
} | ||
@@ -281,4 +271,4 @@ | ||
clearInterval(keepAliveIntervalId) | ||
stopViewMetricsTracking() | ||
scheduleStopInitialViewTimingsTracking() | ||
stopCommonViewMetricsTracking() | ||
scheduleStopInitialViewMetricsTracking() | ||
scheduleStopEventCountsTracking() | ||
@@ -285,0 +275,0 @@ triggerViewUpdate() |
@@ -82,18 +82,19 @@ import type { Duration, ServerDuration, Observable } from '@datadog/browser-core' | ||
}, | ||
cumulative_layout_shift: view.cumulativeLayoutShift, | ||
first_byte: toServerDuration(view.timings.firstByte), | ||
dom_complete: toServerDuration(view.timings.domComplete), | ||
dom_content_loaded: toServerDuration(view.timings.domContentLoaded), | ||
dom_interactive: toServerDuration(view.timings.domInteractive), | ||
cumulative_layout_shift: view.commonViewMetrics.cumulativeLayoutShift, | ||
first_byte: toServerDuration(view.initialViewMetrics.firstByte), | ||
dom_complete: toServerDuration(view.initialViewMetrics.domComplete), | ||
dom_content_loaded: toServerDuration(view.initialViewMetrics.domContentLoaded), | ||
dom_interactive: toServerDuration(view.initialViewMetrics.domInteractive), | ||
error: { | ||
count: view.eventCounts.errorCount, | ||
}, | ||
first_contentful_paint: toServerDuration(view.timings.firstContentfulPaint), | ||
first_input_delay: toServerDuration(view.timings.firstInputDelay), | ||
first_input_time: toServerDuration(view.timings.firstInputTime), | ||
first_contentful_paint: toServerDuration(view.initialViewMetrics.firstContentfulPaint), | ||
first_input_delay: toServerDuration(view.initialViewMetrics.firstInputDelay), | ||
first_input_time: toServerDuration(view.initialViewMetrics.firstInputTime), | ||
interaction_to_next_paint: toServerDuration(view.commonViewMetrics.interactionToNextPaint), | ||
is_active: view.isActive, | ||
name: view.name, | ||
largest_contentful_paint: toServerDuration(view.timings.largestContentfulPaint), | ||
load_event: toServerDuration(view.timings.loadEvent), | ||
loading_time: discardNegativeDuration(toServerDuration(view.loadingTime)), | ||
largest_contentful_paint: toServerDuration(view.initialViewMetrics.largestContentfulPaint), | ||
load_event: toServerDuration(view.initialViewMetrics.loadEvent), | ||
loading_time: discardNegativeDuration(toServerDuration(view.commonViewMetrics.loadingTime)), | ||
loading_type: view.loadingType, | ||
@@ -111,9 +112,9 @@ long_task: { | ||
feature_flags: featureFlagContext && !isEmptyObject(featureFlagContext) ? featureFlagContext : undefined, | ||
display: view.scrollMetrics | ||
display: view.commonViewMetrics.scroll | ||
? { | ||
scroll: { | ||
max_depth: view.scrollMetrics.maxDepth, | ||
max_depth_scroll_height: view.scrollMetrics.maxDepthScrollHeight, | ||
max_depth_scroll_top: view.scrollMetrics.maxDepthScrollTop, | ||
max_depth_time: toServerDuration(view.scrollMetrics.maxDepthTime), | ||
max_depth: view.commonViewMetrics.scroll.maxDepth, | ||
max_depth_scroll_height: view.commonViewMetrics.scroll.maxDepthScrollHeight, | ||
max_depth_scroll_top: view.commonViewMetrics.scroll.maxDepthScrollTop, | ||
max_depth_time: toServerDuration(view.commonViewMetrics.scroll.maxDepthTime), | ||
}, | ||
@@ -120,0 +121,0 @@ } |
@@ -86,2 +86,3 @@ import type { | ||
first_input_time?: ServerDuration | ||
interaction_to_next_paint?: ServerDuration | ||
cumulative_layout_shift?: number | ||
@@ -88,0 +89,0 @@ custom_timings?: { |
@@ -579,2 +579,6 @@ /* eslint-disable */ | ||
/** | ||
* Longest duration in ns between an interaction and the next paint | ||
*/ | ||
readonly interaction_to_next_paint?: number | ||
/** | ||
* Total layout shift score that occurred on the view | ||
@@ -581,0 +585,0 @@ */ |
@@ -1,17 +0,3 @@ | ||
import type { | ||
Context, | ||
EndpointBuilder, | ||
TelemetryEvent, | ||
Observable, | ||
RawError, | ||
PageExitEvent, | ||
FlushEvent, | ||
} from '@datadog/browser-core' | ||
import { | ||
createFlushController, | ||
Batch, | ||
combine, | ||
createHttpRequest, | ||
isTelemetryReplicationAllowed, | ||
} from '@datadog/browser-core' | ||
import type { Context, TelemetryEvent, Observable, RawError, PageExitEvent } from '@datadog/browser-core' | ||
import { combine, isTelemetryReplicationAllowed, startBatchWithReplica } from '@datadog/browser-core' | ||
import type { RumConfiguration } from '../domain/configuration' | ||
@@ -31,4 +17,18 @@ import type { LifeCycle } from '../domain/lifeCycle' | ||
) { | ||
const batch = makeRumBatch(configuration, reportError, pageExitObservable, sessionExpireObservable) | ||
const replica = configuration.replica | ||
const batch = startBatchWithReplica( | ||
configuration, | ||
{ | ||
endpoint: configuration.rumEndpointBuilder, | ||
}, | ||
replica && { | ||
endpoint: replica.rumEndpointBuilder, | ||
transformMessage: (message) => combine(message, { application: { id: replica.applicationId } }), | ||
}, | ||
reportError, | ||
pageExitObservable, | ||
sessionExpireObservable | ||
) | ||
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, (serverRumEvent: RumEvent & Context) => { | ||
@@ -46,64 +46,1 @@ if (serverRumEvent.type === RumEventType.VIEW) { | ||
} | ||
export interface RumBatch { | ||
flushObservable: Observable<FlushEvent> | ||
add: (message: Context, replicated?: boolean) => void | ||
upsert: (message: Context, key: string) => void | ||
} | ||
function makeRumBatch( | ||
configuration: RumConfiguration, | ||
reportError: (error: RawError) => void, | ||
pageExitObservable: Observable<PageExitEvent>, | ||
sessionExpireObservable: Observable<void> | ||
): RumBatch { | ||
const { batch: primaryBatch, flushController: primaryFlushController } = createRumBatch( | ||
configuration.rumEndpointBuilder | ||
) | ||
let replicaBatch: Batch | undefined | ||
const replica = configuration.replica | ||
if (replica !== undefined) { | ||
replicaBatch = createRumBatch(replica.rumEndpointBuilder).batch | ||
} | ||
function createRumBatch(endpointBuilder: EndpointBuilder) { | ||
const flushController = createFlushController({ | ||
messagesLimit: configuration.batchMessagesLimit, | ||
bytesLimit: configuration.batchBytesLimit, | ||
durationLimit: configuration.flushTimeout, | ||
pageExitObservable, | ||
sessionExpireObservable, | ||
}) | ||
const batch = new Batch( | ||
createHttpRequest(configuration, endpointBuilder, configuration.batchBytesLimit, reportError), | ||
flushController, | ||
configuration.messageBytesLimit | ||
) | ||
return { | ||
batch, | ||
flushController, | ||
} | ||
} | ||
function withReplicaApplicationId(message: Context) { | ||
return combine(message, { application: { id: replica!.applicationId } }) | ||
} | ||
return { | ||
flushObservable: primaryFlushController.flushObservable, | ||
add: (message: Context, replicated = true) => { | ||
primaryBatch.add(message) | ||
if (replicaBatch && replicated) { | ||
replicaBatch.add(withReplicaApplicationId(message)) | ||
} | ||
}, | ||
upsert: (message: Context, key: string) => { | ||
primaryBatch.upsert(message, key) | ||
if (replicaBatch) { | ||
replicaBatch.upsert(withReplicaApplicationId(message), key) | ||
} | ||
}, | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1185381
472
21578
+ Added@datadog/browser-core@4.48.0(transitive)
- Removed@datadog/browser-core@4.47.0(transitive)
Updated@datadog/browser-core@4.48.0