Socket
Socket
Sign inDemoInstall

@datadog/browser-rum

Package Overview
Dependencies
Maintainers
1
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-rum - npm Package Compare versions

Comparing version 4.36.0 to 4.37.0

2

cjs/boot/recorderApi.d.ts
import type { RecorderApi } from '@datadog/browser-rum-core';
import { startDeflateWorker } from '../domain/segmentCollection';
import type { startRecording } from './startRecording';
export declare type StartRecording = typeof startRecording;
export type StartRecording = typeof startRecording;
export declare function makeRecorderApi(startRecordingImpl: StartRecording, startDeflateWorkerImpl?: typeof startDeflateWorker): RecorderApi;

@@ -19,9 +19,9 @@ "use strict";

var state = {
status: 0 /* Stopped */,
status: 0 /* RecorderStatus.Stopped */,
};
var startStrategy = function () {
state = { status: 1 /* IntentToStart */ };
state = { status: 1 /* RecorderStatus.IntentToStart */ };
};
var stopStrategy = function () {
state = { status: 0 /* Stopped */ };
state = { status: 0 /* RecorderStatus.Stopped */ };
};

@@ -33,10 +33,10 @@ return {

onRumStart: function (lifeCycle, configuration, sessionManager, viewContexts) {
lifeCycle.subscribe(7 /* SESSION_EXPIRED */, function () {
if (state.status === 2 /* Starting */ || state.status === 3 /* Started */) {
lifeCycle.subscribe(7 /* LifeCycleEventType.SESSION_EXPIRED */, function () {
if (state.status === 2 /* RecorderStatus.Starting */ || state.status === 3 /* RecorderStatus.Started */) {
stopStrategy();
state = { status: 1 /* IntentToStart */ };
state = { status: 1 /* RecorderStatus.IntentToStart */ };
}
});
lifeCycle.subscribe(8 /* SESSION_RENEWED */, function () {
if (state.status === 1 /* IntentToStart */) {
lifeCycle.subscribe(8 /* LifeCycleEventType.SESSION_RENEWED */, function () {
if (state.status === 1 /* RecorderStatus.IntentToStart */) {
startStrategy();

@@ -48,15 +48,15 @@ }

if (!session || !session.sessionReplayAllowed) {
state = { status: 1 /* IntentToStart */ };
state = { status: 1 /* RecorderStatus.IntentToStart */ };
return;
}
if (state.status === 2 /* Starting */ || state.status === 3 /* Started */) {
if (state.status === 2 /* RecorderStatus.Starting */ || state.status === 3 /* RecorderStatus.Started */) {
return;
}
state = { status: 2 /* Starting */ };
state = { status: 2 /* RecorderStatus.Starting */ };
(0, browser_core_1.runOnReadyState)('interactive', function () {
if (state.status !== 2 /* Starting */) {
if (state.status !== 2 /* RecorderStatus.Starting */) {
return;
}
startDeflateWorkerImpl(function (worker) {
if (state.status !== 2 /* Starting */) {
if (state.status !== 2 /* RecorderStatus.Starting */) {
return;

@@ -66,3 +66,3 @@ }

state = {
status: 0 /* Stopped */,
status: 0 /* RecorderStatus.Stopped */,
};

@@ -73,3 +73,3 @@ return;

state = {
status: 3 /* Started */,
status: 3 /* RecorderStatus.Started */,
stopRecording: stopRecording,

@@ -81,17 +81,17 @@ };

stopStrategy = function () {
if (state.status === 0 /* Stopped */) {
if (state.status === 0 /* RecorderStatus.Stopped */) {
return;
}
if (state.status === 3 /* Started */) {
if (state.status === 3 /* RecorderStatus.Started */) {
state.stopRecording();
}
state = {
status: 0 /* Stopped */,
status: 0 /* RecorderStatus.Stopped */,
};
};
if (state.status === 1 /* IntentToStart */) {
if (state.status === 1 /* RecorderStatus.IntentToStart */) {
startStrategy();
}
},
isRecording: function () { return state.status === 3 /* Started */; },
isRecording: function () { return state.status === 3 /* RecorderStatus.Started */; },
};

@@ -98,0 +98,0 @@ }

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

var reportError = function (error) {
lifeCycle.notify(12 /* RAW_ERROR_COLLECTED */, { error: error });
lifeCycle.notify(12 /* LifeCycleEventType.RAW_ERROR_COLLECTED */, { error: error });
};

@@ -20,3 +20,3 @@ var replayRequest = httpRequest || (0, browser_core_1.createHttpRequest)(configuration.sessionReplayEndpointBuilder, segmentCollection_1.SEGMENT_BYTES_LIMIT, reportError);

}), stopRecording = _b.stop, takeSubsequentFullSnapshot = _b.takeSubsequentFullSnapshot, flushMutations = _b.flushMutations;
var unsubscribeViewEnded = lifeCycle.subscribe(4 /* VIEW_ENDED */, function () {
var unsubscribeViewEnded = lifeCycle.subscribe(4 /* LifeCycleEventType.VIEW_ENDED */, function () {
flushMutations();

@@ -28,3 +28,3 @@ addRecord({

}).unsubscribe;
var unsubscribeViewCreated = lifeCycle.subscribe(2 /* VIEW_CREATED */, function (view) {
var unsubscribeViewCreated = lifeCycle.subscribe(2 /* LifeCycleEventType.VIEW_CREATED */, function (view) {
takeSubsequentFullSnapshot(view.startClocks.timeStamp);

@@ -31,0 +31,0 @@ }).unsubscribe;

@@ -8,3 +8,3 @@ export declare const NodePrivacyLevel: {

};
export declare type NodePrivacyLevel = (typeof NodePrivacyLevel)[keyof typeof NodePrivacyLevel];
export type NodePrivacyLevel = (typeof NodePrivacyLevel)[keyof typeof NodePrivacyLevel];
export declare const PRIVACY_ATTR_NAME = "data-dd-privacy";

@@ -11,0 +11,0 @@ export declare const PRIVACY_ATTR_VALUE_ALLOW = "allow";

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

export declare type ElementsScrollPositions = ReturnType<typeof createElementsScrollPositions>;
export declare type ScrollPositions = {
export type ElementsScrollPositions = ReturnType<typeof createElementsScrollPositions>;
export type ScrollPositions = {
scrollLeft: number;

@@ -4,0 +4,0 @@ scrollTop: number;

import type { FocusRecord } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type FocusCallback = (data: FocusRecord['data']) => void;
export type FocusCallback = (data: FocusRecord['data']) => void;
export declare function initFocusObserver(focusCb: FocusCallback): ListenerHandler;

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

function initFocusObserver(focusCb) {
return (0, browser_core_1.addEventListeners)(window, ["focus" /* FOCUS */, "blur" /* BLUR */], function () {
return (0, browser_core_1.addEventListeners)(window, ["focus" /* DOM_EVENT.FOCUS */, "blur" /* DOM_EVENT.BLUR */], function () {
focusCb({ has_focus: document.hasFocus() });

@@ -9,0 +9,0 @@ }).stop;

import type { LifeCycle } from '@datadog/browser-rum-core';
import type { FrustrationRecord } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type FrustrationCallback = (record: FrustrationRecord) => void;
export type FrustrationCallback = (record: FrustrationRecord) => void;
export declare function initFrustrationObserver(lifeCycle: LifeCycle, frustrationCb: FrustrationCallback): ListenerHandler;

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

function initFrustrationObserver(lifeCycle, frustrationCb) {
return lifeCycle.subscribe(10 /* RAW_RUM_EVENT_COLLECTED */, function (data) {
return lifeCycle.subscribe(10 /* LifeCycleEventType.RAW_RUM_EVENT_COLLECTED */, function (data) {
var _a, _b, _c;
if (data.rawRumEvent.type === "action" /* ACTION */ &&
data.rawRumEvent.action.type === "click" /* CLICK */ &&
if (data.rawRumEvent.type === "action" /* RumEventType.ACTION */ &&
data.rawRumEvent.action.type === "click" /* ActionType.CLICK */ &&
((_b = (_a = data.rawRumEvent.action.frustration) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.length) &&

@@ -13,0 +13,0 @@ 'events' in data.domainContext &&

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

import type { ListenerHandler } from './utils';
declare type InputObserverOptions = {
type InputObserverOptions = {
domEvents?: Array<DOM_EVENT.INPUT | DOM_EVENT.CHANGE>;
target?: Node;
};
export declare type InputCallback = (v: InputState & {
export type InputCallback = (v: InputState & {
id: number;

@@ -12,0 +12,0 @@ }) => void;

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

function initInputObserver(cb, defaultPrivacyLevel, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.domEvents, domEvents = _c === void 0 ? ["input" /* INPUT */, "change" /* CHANGE */] : _c, _d = _b.target, target = _d === void 0 ? document : _d;
var _b = _a === void 0 ? {} : _a, _c = _b.domEvents, domEvents = _c === void 0 ? ["input" /* DOM_EVENT.INPUT */, "change" /* DOM_EVENT.CHANGE */] : _c, _d = _b.target, target = _d === void 0 ? document : _d;
var lastInputStateMap = new WeakMap();

@@ -13,0 +13,0 @@ function onElementChange(target) {

import type { DefaultPrivacyLevel } from '@datadog/browser-core';
import type { MediaInteraction } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type MediaInteractionCallback = (p: MediaInteraction) => void;
export type MediaInteractionCallback = (p: MediaInteraction) => void;
export declare function initMediaInteractionObserver(mediaInteractionCb: MediaInteractionCallback, defaultPrivacyLevel: DefaultPrivacyLevel): ListenerHandler;

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

id: (0, serialization_1.getSerializedNodeId)(target),
type: event.type === "play" /* PLAY */ ? types_1.MediaInteractionType.Play : types_1.MediaInteractionType.Pause,
type: event.type === "play" /* DOM_EVENT.PLAY */ ? types_1.MediaInteractionType.Play : types_1.MediaInteractionType.Pause,
});
};
return (0, browser_core_1.addEventListeners)(document, ["play" /* PLAY */, "pause" /* PAUSE */], handler, { capture: true, passive: true }).stop;
return (0, browser_core_1.addEventListeners)(document, ["play" /* DOM_EVENT.PLAY */, "pause" /* DOM_EVENT.PAUSE */], handler, { capture: true, passive: true }).stop;
}
exports.initMediaInteractionObserver = initMediaInteractionObserver;
//# sourceMappingURL=mediaInteractionObserver.js.map
import type { DefaultPrivacyLevel } from '@datadog/browser-core';
import type { BrowserIncrementalSnapshotRecord } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type MouseInteractionCallBack = (record: BrowserIncrementalSnapshotRecord) => void;
export type MouseInteractionCallBack = (record: BrowserIncrementalSnapshotRecord) => void;
export declare function initMouseInteractionObserver(cb: MouseInteractionCallBack, defaultPrivacyLevel: DefaultPrivacyLevel): ListenerHandler;

@@ -22,11 +22,11 @@ "use strict";

// `PointerInteraction/Up` records that we could reference from `Frustration` records.
_a["pointerup" /* POINTER_UP */] = types_1.MouseInteractionType.MouseUp,
_a["mousedown" /* MOUSE_DOWN */] = types_1.MouseInteractionType.MouseDown,
_a["click" /* CLICK */] = types_1.MouseInteractionType.Click,
_a["contextmenu" /* CONTEXT_MENU */] = types_1.MouseInteractionType.ContextMenu,
_a["dblclick" /* DBL_CLICK */] = types_1.MouseInteractionType.DblClick,
_a["focus" /* FOCUS */] = types_1.MouseInteractionType.Focus,
_a["blur" /* BLUR */] = types_1.MouseInteractionType.Blur,
_a["touchstart" /* TOUCH_START */] = types_1.MouseInteractionType.TouchStart,
_a["touchend" /* TOUCH_END */] = types_1.MouseInteractionType.TouchEnd,
_a["pointerup" /* DOM_EVENT.POINTER_UP */] = types_1.MouseInteractionType.MouseUp,
_a["mousedown" /* DOM_EVENT.MOUSE_DOWN */] = types_1.MouseInteractionType.MouseDown,
_a["click" /* DOM_EVENT.CLICK */] = types_1.MouseInteractionType.Click,
_a["contextmenu" /* DOM_EVENT.CONTEXT_MENU */] = types_1.MouseInteractionType.ContextMenu,
_a["dblclick" /* DOM_EVENT.DBL_CLICK */] = types_1.MouseInteractionType.DblClick,
_a["focus" /* DOM_EVENT.FOCUS */] = types_1.MouseInteractionType.Focus,
_a["blur" /* DOM_EVENT.BLUR */] = types_1.MouseInteractionType.Blur,
_a["touchstart" /* DOM_EVENT.TOUCH_START */] = types_1.MouseInteractionType.TouchStart,
_a["touchend" /* DOM_EVENT.TOUCH_END */] = types_1.MouseInteractionType.TouchEnd,
_a);

@@ -33,0 +33,0 @@ function initMouseInteractionObserver(cb, defaultPrivacyLevel) {

import type { MousePosition } from '../../../types';
import { IncrementalSource } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type MousemoveCallBack = (p: MousePosition[], source: typeof IncrementalSource.MouseMove | typeof IncrementalSource.TouchMove) => void;
export type MousemoveCallBack = (p: MousePosition[], source: typeof IncrementalSource.MouseMove | typeof IncrementalSource.TouchMove) => void;
export declare function initMoveObserver(cb: MousemoveCallBack): ListenerHandler;

@@ -6,0 +6,0 @@ export declare function tryToComputeCoordinates(event: MouseEvent | TouchEvent): {

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

}).throttled;
return (0, browser_core_1.addEventListeners)(document, ["mousemove" /* MOUSE_MOVE */, "touchmove" /* TOUCH_MOVE */], updatePosition, {
return (0, browser_core_1.addEventListeners)(document, ["mousemove" /* DOM_EVENT.MOUSE_MOVE */, "touchmove" /* DOM_EVENT.TOUCH_MOVE */], updatePosition, {
capture: true,

@@ -33,0 +33,0 @@ passive: true,

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

import type { ShadowRootsController } from '../shadowRootsController';
export declare type MutationCallBack = (m: BrowserMutationPayload) => void;
export type MutationCallBack = (m: BrowserMutationPayload) => void;
interface RumCharacterDataMutationRecord {

@@ -24,3 +24,3 @@ type: 'characterData';

}
export declare type RumMutationRecord = RumCharacterDataMutationRecord | RumAttributesMutationRecord | RumChildListMutationRecord;
export type RumMutationRecord = RumCharacterDataMutationRecord | RumAttributesMutationRecord | RumChildListMutationRecord;
/**

@@ -27,0 +27,0 @@ * Buffers and aggregate mutations generated by a MutationObserver into MutationPayload

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

parentNodePrivacyLevel: parentNodePrivacyLevel,
serializationContext: { status: 2 /* MUTATION */, shadowRootsController: shadowRootsController },
serializationContext: { status: 2 /* SerializationContextStatus.MUTATION */, shadowRootsController: shadowRootsController },
configuration: configuration,

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

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

import type { ListenerHandler } from './utils';
export declare type ScrollCallback = (p: ScrollPosition) => void;
export type ScrollCallback = (p: ScrollPosition) => void;
export declare function initScrollObserver(cb: ScrollCallback, defaultPrivacyLevel: DefaultPrivacyLevel, elementsScrollPositions: ElementsScrollPositions): ListenerHandler;

@@ -36,5 +36,5 @@ "use strict";

}, SCROLL_OBSERVER_THRESHOLD).throttled;
return (0, browser_core_1.addEventListener)(document, "scroll" /* SCROLL */, updatePosition, { capture: true, passive: true }).stop;
return (0, browser_core_1.addEventListener)(document, "scroll" /* DOM_EVENT.SCROLL */, updatePosition, { capture: true, passive: true }).stop;
}
exports.initScrollObserver = initScrollObserver;
//# sourceMappingURL=scrollObserver.js.map
import type { StyleSheetRule } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type StyleSheetCallback = (s: StyleSheetRule) => void;
export type StyleSheetCallback = (s: StyleSheetRule) => void;
export declare function initStyleSheetObserver(cb: StyleSheetCallback): ListenerHandler;

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

export declare type ListenerHandler = () => void;
export type ListenerHandler = () => void;
export declare function forEach<List extends {

@@ -3,0 +3,0 @@ [index: number]: any;

import type { ViewportResizeDimension, VisualViewportRecord } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type ViewportResizeCallback = (d: ViewportResizeDimension) => void;
export declare type VisualViewportResizeCallback = (data: VisualViewportRecord['data']) => void;
export type ViewportResizeCallback = (d: ViewportResizeDimension) => void;
export type VisualViewportResizeCallback = (data: VisualViewportRecord['data']) => void;
export declare function initViewportResizeObserver(cb: ViewportResizeCallback): ListenerHandler;
export declare function initVisualViewportResizeObserver(cb: VisualViewportResizeCallback): ListenerHandler;

@@ -13,11 +13,12 @@ "use strict";

function initVisualViewportResizeObserver(cb) {
if (!window.visualViewport) {
var visualViewport = window.visualViewport;
if (!visualViewport) {
return browser_core_1.noop;
}
var _a = (0, browser_core_1.throttle)(function () {
cb((0, viewports_1.getVisualViewport)());
cb((0, viewports_1.getVisualViewport)(visualViewport));
}, VISUAL_VIEWPORT_OBSERVER_THRESHOLD, {
trailing: false,
}), updateDimension = _a.throttled, cancelThrottle = _a.cancel;
var removeListener = (0, browser_core_1.addEventListeners)(window.visualViewport, ["resize" /* RESIZE */, "scroll" /* SCROLL */], updateDimension, {
var removeListener = (0, browser_core_1.addEventListeners)(visualViewport, ["resize" /* DOM_EVENT.RESIZE */, "scroll" /* DOM_EVENT.SCROLL */], updateDimension, {
capture: true,

@@ -24,0 +25,0 @@ passive: true,

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

if (serializationContext === void 0) { serializationContext = {
status: 0 /* INITIAL_FULL_SNAPSHOT */,
status: 0 /* SerializationContextStatus.INITIAL_FULL_SNAPSHOT */,
elementsScrollPositions: elementsScrollPositions,

@@ -63,3 +63,3 @@ shadowRootsController: shadowRootsController,

emit({
data: (0, viewports_1.getVisualViewport)(),
data: (0, viewports_1.getVisualViewport)(window.visualViewport),
type: types_1.RecordType.VisualViewport,

@@ -115,3 +115,3 @@ timestamp: timestamp,

shadowRootsController: shadowRootsController,
status: 1 /* SUBSEQUENT_FULL_SNAPSHOT */,
status: 1 /* SerializationContextStatus.SUBSEQUENT_FULL_SNAPSHOT */,
elementsScrollPositions: elementsScrollPositions,

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

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

import type { ShadowRootsController } from '../shadowRootsController';
declare type ParentNodePrivacyLevel = typeof NodePrivacyLevel.ALLOW | typeof NodePrivacyLevel.MASK | typeof NodePrivacyLevel.MASK_USER_INPUT;
type ParentNodePrivacyLevel = typeof NodePrivacyLevel.ALLOW | typeof NodePrivacyLevel.MASK | typeof NodePrivacyLevel.MASK_USER_INPUT;
export declare const enum SerializationContextStatus {

@@ -12,3 +12,3 @@ INITIAL_FULL_SNAPSHOT = 0,

}
export declare type SerializationContext = {
export type SerializationContext = {
status: SerializationContextStatus.MUTATION;

@@ -32,5 +32,5 @@ shadowRootsController: ShadowRootsController;

}
export declare type NodeWithSerializedNode = Node & {
export type NodeWithSerializedNode = Node & {
s: 'Node with serialized node';
};
export {};

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

switch (serializationContext.status) {
case 0 /* INITIAL_FULL_SNAPSHOT */:
case 0 /* SerializationContextStatus.INITIAL_FULL_SNAPSHOT */:
scrollTop = Math.round(element.scrollTop);

@@ -98,3 +98,3 @@ scrollLeft = Math.round(element.scrollLeft);

break;
case 1 /* SUBSEQUENT_FULL_SNAPSHOT */:
case 1 /* SerializationContextStatus.SUBSEQUENT_FULL_SNAPSHOT */:
if (serializationContext.elementsScrollPositions.has(element)) {

@@ -101,0 +101,0 @@ ;

@@ -81,5 +81,3 @@ "use strict";

isShadowRoot: isShadowRoot,
adoptedStyleSheets: isShadowRoot
? (0, serializeStyleSheets_1.serializeStyleSheets)(element.adoptedStyleSheets)
: undefined,
adoptedStyleSheets: isShadowRoot ? (0, serializeStyleSheets_1.serializeStyleSheets)(element.adoptedStyleSheets) : undefined,
};

@@ -86,0 +84,0 @@ }

import type { RumConfiguration } from '@datadog/browser-rum-core';
import type { InputCallback, MutationCallBack } from './observers';
export declare type ShadowRootCallBack = (shadowRoot: ShadowRoot) => void;
export type ShadowRootCallBack = (shadowRoot: ShadowRoot) => void;
export interface ShadowRootsController {

@@ -5,0 +5,0 @@ addShadowRoot: ShadowRootCallBack;

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

target: shadowRoot,
domEvents: ["change" /* CHANGE */],
domEvents: ["change" /* DOM_EVENT.CHANGE */],
});

@@ -18,0 +18,0 @@ controllerByShadowRoot.set(shadowRoot, {

@@ -19,5 +19,5 @@ /**

export declare const convertMouseEventToLayoutCoordinates: (clientX: number, clientY: number) => LayoutCoordinates;
export declare const getVisualViewport: () => VisualViewportRecord['data'];
export declare const getVisualViewport: (visualViewport: VisualViewport) => VisualViewportRecord['data'];
export declare function getScrollX(): number;
export declare function getScrollY(): number;
export {};

@@ -21,10 +21,9 @@ "use strict";

*/
function isVisualViewportFactoredIn() {
var visual = window.visualViewport;
return (Math.abs(visual.pageTop - visual.offsetTop - window.scrollY) > TOLERANCE ||
Math.abs(visual.pageLeft - visual.offsetLeft - window.scrollX) > TOLERANCE);
function isVisualViewportFactoredIn(visualViewport) {
return (Math.abs(visualViewport.pageTop - visualViewport.offsetTop - window.scrollY) > TOLERANCE ||
Math.abs(visualViewport.pageLeft - visualViewport.offsetLeft - window.scrollX) > TOLERANCE);
}
var convertMouseEventToLayoutCoordinates = function (clientX, clientY) {
var visual = window.visualViewport;
var normalised = {
var visualViewport = window.visualViewport;
var normalized = {
layoutViewportX: clientX,

@@ -35,31 +34,28 @@ layoutViewportY: clientY,

};
if (!visual) {
// On old browsers, we cannot normalise, so fallback to clientX/Y
return normalised;
if (!visualViewport) {
// On old browsers, we cannot normalize, so fallback to clientX/Y
return normalized;
}
else if (isVisualViewportFactoredIn()) {
else if (isVisualViewportFactoredIn(visualViewport)) {
// Typically Mobile Devices
normalised.layoutViewportX = Math.round(clientX + visual.offsetLeft);
normalised.layoutViewportY = Math.round(clientY + visual.offsetTop);
normalized.layoutViewportX = Math.round(clientX + visualViewport.offsetLeft);
normalized.layoutViewportY = Math.round(clientY + visualViewport.offsetTop);
}
else {
// Typically Desktop Devices
normalised.visualViewportX = Math.round(clientX - visual.offsetLeft);
normalised.visualViewportY = Math.round(clientY - visual.offsetTop);
normalized.visualViewportX = Math.round(clientX - visualViewport.offsetLeft);
normalized.visualViewportY = Math.round(clientY - visualViewport.offsetTop);
}
return normalised;
return normalized;
};
exports.convertMouseEventToLayoutCoordinates = convertMouseEventToLayoutCoordinates;
var getVisualViewport = function () {
var visual = window.visualViewport;
return {
scale: visual.scale,
offsetLeft: visual.offsetLeft,
offsetTop: visual.offsetTop,
pageLeft: visual.pageLeft,
pageTop: visual.pageTop,
height: visual.height,
width: visual.width,
};
};
var getVisualViewport = function (visualViewport) { return ({
scale: visualViewport.scale,
offsetLeft: visualViewport.offsetLeft,
offsetTop: visualViewport.offsetTop,
pageLeft: visualViewport.pageLeft,
pageTop: visualViewport.pageTop,
height: visualViewport.height,
width: visualViewport.width,
}); };
exports.getVisualViewport = getVisualViewport;

@@ -66,0 +62,0 @@ function getScrollX() {

import type { BrowserRecord, BrowserSegmentMetadata, CreationReason, SegmentContext } from '../../types';
import type { DeflateWorker } from './deflateWorker';
export declare type FlushReason = Exclude<CreationReason, 'init'> | 'stop';
export type FlushReason = Exclude<CreationReason, 'init'> | 'stop';
export declare class Segment {

@@ -5,0 +5,0 @@ private worker;

@@ -43,13 +43,13 @@ "use strict";

var state = {
status: 0 /* WaitingForInitialRecord */,
status: 0 /* SegmentCollectionStatus.WaitingForInitialRecord */,
nextSegmentCreationReason: 'init',
};
var unsubscribeViewCreated = lifeCycle.subscribe(2 /* VIEW_CREATED */, function () {
var unsubscribeViewCreated = lifeCycle.subscribe(2 /* LifeCycleEventType.VIEW_CREATED */, function () {
flushSegment('view_change');
}).unsubscribe;
var unsubscribePageExited = lifeCycle.subscribe(9 /* PAGE_EXITED */, function (pageExitEvent) {
var unsubscribePageExited = lifeCycle.subscribe(9 /* LifeCycleEventType.PAGE_EXITED */, function (pageExitEvent) {
flushSegment(pageExitEvent.reason);
}).unsubscribe;
function flushSegment(flushReason) {
if (state.status === 1 /* SegmentPending */) {
if (state.status === 1 /* SegmentCollectionStatus.SegmentPending */) {
state.segment.flush(flushReason);

@@ -60,3 +60,3 @@ (0, browser_core_1.clearTimeout)(state.expirationTimeoutId);

state = {
status: 0 /* WaitingForInitialRecord */,
status: 0 /* SegmentCollectionStatus.WaitingForInitialRecord */,
nextSegmentCreationReason: flushReason,

@@ -67,3 +67,3 @@ };

state = {
status: 2 /* Stopped */,
status: 2 /* SegmentCollectionStatus.Stopped */,
};

@@ -91,3 +91,3 @@ }

state = {
status: 1 /* SegmentPending */,
status: 1 /* SegmentCollectionStatus.SegmentPending */,
segment: segment,

@@ -102,6 +102,6 @@ expirationTimeoutId: (0, browser_core_1.setTimeout)(function () {

switch (state.status) {
case 0 /* WaitingForInitialRecord */:
case 0 /* SegmentCollectionStatus.WaitingForInitialRecord */:
createNewSegment(state.nextSegmentCreationReason, record);
break;
case 1 /* SegmentPending */:
case 1 /* SegmentCollectionStatus.SegmentPending */:
state.segment.addRecord(record);

@@ -108,0 +108,0 @@ break;

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

var deflateWorker_1 = require("./deflateWorker");
var state = { status: 0 /* Nil */ };
var state = { status: 0 /* DeflateWorkerStatus.Nil */ };
function startDeflateWorker(callback, createDeflateWorkerImpl) {
if (createDeflateWorkerImpl === void 0) { createDeflateWorkerImpl = deflateWorker_1.createDeflateWorker; }
switch (state.status) {
case 0 /* Nil */:
state = { status: 1 /* Loading */, callbacks: [callback] };
case 0 /* DeflateWorkerStatus.Nil */:
state = { status: 1 /* DeflateWorkerStatus.Loading */, callbacks: [callback] };
doStartDeflateWorker(createDeflateWorkerImpl);
break;
case 1 /* Loading */:
case 1 /* DeflateWorkerStatus.Loading */:
state.callbacks.push(callback);
break;
case 2 /* Error */:
case 2 /* DeflateWorkerStatus.Error */:
callback();
break;
case 3 /* Initialized */:
case 3 /* DeflateWorkerStatus.Initialized */:
callback(state.worker);

@@ -28,3 +28,3 @@ break;

function resetDeflateWorkerState() {
state = { status: 0 /* Nil */ };
state = { status: 0 /* DeflateWorkerStatus.Nil */ };
}

@@ -64,9 +64,9 @@ exports.resetDeflateWorkerState = resetDeflateWorkerState;

function onInitialized(worker) {
if (state.status === 1 /* Loading */) {
if (state.status === 1 /* DeflateWorkerStatus.Loading */) {
state.callbacks.forEach(function (callback) { return callback(worker); });
state = { status: 3 /* Initialized */, worker: worker };
state = { status: 3 /* DeflateWorkerStatus.Initialized */, worker: worker };
}
}
function onError(error) {
if (state.status === 1 /* Loading */) {
if (state.status === 1 /* DeflateWorkerStatus.Loading */) {
browser_core_1.display.error('Session Replay recording failed to start: an error occurred while creating the Worker:', error);

@@ -81,3 +81,3 @@ if (error instanceof Event || (error instanceof Error && isMessageCspRelated(error.message))) {

state.callbacks.forEach(function (callback) { return callback(); });
state = { status: 2 /* Error */ };
state = { status: 2 /* DeflateWorkerStatus.Error */ };
}

@@ -84,0 +84,0 @@ else {

@@ -28,2 +28,3 @@ export { DefaultPrivacyLevel } from '@datadog/browser-core';

};
stopSession: () => void;
startSessionReplayRecording: () => void;

@@ -30,0 +31,0 @@ stopSessionReplayRecording: () => void;

@@ -29,2 +29,3 @@ export { CommonProperties, RumPublicApi as RumGlobal, RumInitConfiguration, RumEvent, RumActionEvent, RumErrorEvent, RumLongTaskEvent, RumResourceEvent, RumViewEvent, RumEventDomainContext, RumViewEventDomainContext, RumErrorEventDomainContext, RumActionEventDomainContext, RumFetchResourceEventDomainContext, RumXhrResourceEventDomainContext, RumOtherResourceEventDomainContext, RumLongTaskEventDomainContext, } from '@datadog/browser-rum-core';

};
stopSession: () => void;
startSessionReplayRecording: () => void;

@@ -31,0 +32,0 @@ stopSessionReplayRecording: () => void;

@@ -7,3 +7,3 @@ /**

*/
export declare type BrowserSegment = BrowserSegmentMetadata & {
export type BrowserSegment = BrowserSegmentMetadata & {
/**

@@ -17,3 +17,3 @@ * The records contained by this Segment.

*/
export declare type BrowserSegmentMetadata = SegmentContext & CommonSegmentMetadataSchema & {
export type BrowserSegmentMetadata = SegmentContext & CommonSegmentMetadataSchema & {
/**

@@ -28,11 +28,11 @@ * The source of this record

*/
export declare type CreationReason = 'init' | 'segment_duration_limit' | 'segment_bytes_limit' | 'view_change' | 'before_unload' | 'visibility_hidden' | 'page_frozen';
export type CreationReason = 'init' | 'segment_duration_limit' | 'segment_bytes_limit' | 'view_change' | 'before_unload' | 'visibility_hidden' | 'page_frozen';
/**
* Browser-specific. Schema of a Session Replay Record.
*/
export declare type BrowserRecord = BrowserFullSnapshotRecord | BrowserIncrementalSnapshotRecord | MetaRecord | FocusRecord | ViewEndRecord | VisualViewportRecord | FrustrationRecord;
export type BrowserRecord = BrowserFullSnapshotRecord | BrowserIncrementalSnapshotRecord | MetaRecord | FocusRecord | ViewEndRecord | VisualViewportRecord | FrustrationRecord;
/**
* Browser-specific. Schema of a Record type which contains the full snapshot of a screen.
*/
export declare type BrowserFullSnapshotRecord = CommonRecordSchema & {
export type BrowserFullSnapshotRecord = CommonRecordSchema & {
/**

@@ -47,3 +47,3 @@ * The type of this Record.

*/
export declare type SerializedNodeWithId = {
export type SerializedNodeWithId = {
id: number;

@@ -54,7 +54,7 @@ } & SerializedNode;

*/
export declare type SerializedNode = DocumentNode | DocumentFragmentNode | DocumentTypeNode | ElementNode | TextNode | CDataNode;
export type SerializedNode = DocumentNode | DocumentFragmentNode | DocumentTypeNode | ElementNode | TextNode | CDataNode;
/**
* Browser-specific. Schema of a Record type which contains mutations of a screen.
*/
export declare type BrowserIncrementalSnapshotRecord = CommonRecordSchema & {
export type BrowserIncrementalSnapshotRecord = CommonRecordSchema & {
/**

@@ -70,7 +70,7 @@ * The type of this Record.

*/
export declare type BrowserIncrementalData = BrowserMutationData | MousemoveData | MouseInteractionData | ScrollData | InputData | MediaInteractionData | StyleSheetRuleData | ViewportResizeData | PointerInteractionData;
export type BrowserIncrementalData = BrowserMutationData | MousemoveData | MouseInteractionData | ScrollData | InputData | MediaInteractionData | StyleSheetRuleData | ViewportResizeData | PointerInteractionData;
/**
* Browser-specific. Schema of a MutationData.
*/
export declare type BrowserMutationData = {
export type BrowserMutationData = {
/**

@@ -84,3 +84,3 @@ * The source of this type of incremental data.

*/
export declare type BrowserMutationPayload = {
export type BrowserMutationPayload = {
/**

@@ -106,3 +106,3 @@ * Contains the newly added nodes.

*/
export declare type MouseInteractionData = {
export type MouseInteractionData = {
/**

@@ -116,3 +116,3 @@ * The source of this type of incremental data.

*/
export declare type MouseInteraction = {
export type MouseInteraction = {
/**

@@ -147,3 +147,3 @@ * The type of MouseInteraction: 0=mouseup, 1=mousedown, 2=click, 3=contextmenu, 4=dblclick, 7=touchstart, 9=touchend

*/
export declare type ScrollData = {
export type ScrollData = {
/**

@@ -157,3 +157,3 @@ * The source of this type of incremental data.

*/
export declare type InputData = {
export type InputData = {
/**

@@ -171,3 +171,3 @@ * The source of this type of incremental data.

*/
export declare type InputState = {
export type InputState = {
/**

@@ -186,3 +186,3 @@ * Text value for this InputState.

*/
export declare type MediaInteractionData = {
export type MediaInteractionData = {
/**

@@ -196,3 +196,3 @@ * The source of this type of incremental data.

*/
export declare type StyleSheetRuleData = {
export type StyleSheetRuleData = {
/**

@@ -206,3 +206,3 @@ * The source of this type of incremental data.

*/
export declare type ViewportResizeData = {
export type ViewportResizeData = {
/**

@@ -216,3 +216,3 @@ * The source of this type of incremental data.

*/
export declare type PointerInteractionData = {
export type PointerInteractionData = {
/**

@@ -226,3 +226,3 @@ * The source of this type of incremental data.

*/
export declare type MetaRecord = CommonRecordSchema & {
export type MetaRecord = CommonRecordSchema & {
/**

@@ -253,3 +253,3 @@ * The type of this Record.

*/
export declare type FocusRecord = CommonRecordSchema & {
export type FocusRecord = CommonRecordSchema & {
/**

@@ -269,3 +269,3 @@ * The type of this Record.

*/
export declare type ViewEndRecord = CommonRecordSchema & {
export type ViewEndRecord = CommonRecordSchema & {
/**

@@ -279,3 +279,3 @@ * The type of this Record.

*/
export declare type VisualViewportRecord = CommonRecordSchema & {
export type VisualViewportRecord = CommonRecordSchema & {
data: {

@@ -298,3 +298,3 @@ height: number;

*/
export declare type FrustrationRecord = CommonRecordSchema & {
export type FrustrationRecord = CommonRecordSchema & {
/**

@@ -301,0 +301,0 @@ * The type of this Record.

@@ -11,3 +11,3 @@ import type * as SessionReplay from './sessionReplay';

};
export declare type RecordType = (typeof RecordType)[keyof typeof RecordType];
export type RecordType = (typeof RecordType)[keyof typeof RecordType];
export declare const NodeType: {

@@ -21,3 +21,3 @@ Document: SessionReplay.DocumentNode['type'];

};
export declare type NodeType = (typeof NodeType)[keyof typeof NodeType];
export type NodeType = (typeof NodeType)[keyof typeof NodeType];
export declare const IncrementalSource: {

@@ -34,3 +34,3 @@ Mutation: SessionReplay.BrowserMutationData['source'];

};
export declare type IncrementalSource = (typeof IncrementalSource)[keyof typeof IncrementalSource];
export type IncrementalSource = (typeof IncrementalSource)[keyof typeof IncrementalSource];
export declare const MouseInteractionType: {

@@ -47,3 +47,3 @@ readonly MouseUp: 0;

};
export declare type MouseInteractionType = (typeof MouseInteractionType)[keyof typeof MouseInteractionType];
export type MouseInteractionType = (typeof MouseInteractionType)[keyof typeof MouseInteractionType];
export declare const MediaInteractionType: {

@@ -53,2 +53,2 @@ readonly Play: 0;

};
export declare type MediaInteractionType = (typeof MediaInteractionType)[keyof typeof MediaInteractionType];
export type MediaInteractionType = (typeof MediaInteractionType)[keyof typeof MediaInteractionType];
import type { RecorderApi } from '@datadog/browser-rum-core';
import { startDeflateWorker } from '../domain/segmentCollection';
import type { startRecording } from './startRecording';
export declare type StartRecording = typeof startRecording;
export type StartRecording = typeof startRecording;
export declare function makeRecorderApi(startRecordingImpl: StartRecording, startDeflateWorkerImpl?: typeof startDeflateWorker): RecorderApi;

@@ -16,9 +16,9 @@ import { canUseEventBridge, noop, runOnReadyState } from '@datadog/browser-core';

var state = {
status: 0 /* Stopped */,
status: 0 /* RecorderStatus.Stopped */,
};
var startStrategy = function () {
state = { status: 1 /* IntentToStart */ };
state = { status: 1 /* RecorderStatus.IntentToStart */ };
};
var stopStrategy = function () {
state = { status: 0 /* Stopped */ };
state = { status: 0 /* RecorderStatus.Stopped */ };
};

@@ -30,10 +30,10 @@ return {

onRumStart: function (lifeCycle, configuration, sessionManager, viewContexts) {
lifeCycle.subscribe(7 /* SESSION_EXPIRED */, function () {
if (state.status === 2 /* Starting */ || state.status === 3 /* Started */) {
lifeCycle.subscribe(7 /* LifeCycleEventType.SESSION_EXPIRED */, function () {
if (state.status === 2 /* RecorderStatus.Starting */ || state.status === 3 /* RecorderStatus.Started */) {
stopStrategy();
state = { status: 1 /* IntentToStart */ };
state = { status: 1 /* RecorderStatus.IntentToStart */ };
}
});
lifeCycle.subscribe(8 /* SESSION_RENEWED */, function () {
if (state.status === 1 /* IntentToStart */) {
lifeCycle.subscribe(8 /* LifeCycleEventType.SESSION_RENEWED */, function () {
if (state.status === 1 /* RecorderStatus.IntentToStart */) {
startStrategy();

@@ -45,15 +45,15 @@ }

if (!session || !session.sessionReplayAllowed) {
state = { status: 1 /* IntentToStart */ };
state = { status: 1 /* RecorderStatus.IntentToStart */ };
return;
}
if (state.status === 2 /* Starting */ || state.status === 3 /* Started */) {
if (state.status === 2 /* RecorderStatus.Starting */ || state.status === 3 /* RecorderStatus.Started */) {
return;
}
state = { status: 2 /* Starting */ };
state = { status: 2 /* RecorderStatus.Starting */ };
runOnReadyState('interactive', function () {
if (state.status !== 2 /* Starting */) {
if (state.status !== 2 /* RecorderStatus.Starting */) {
return;
}
startDeflateWorkerImpl(function (worker) {
if (state.status !== 2 /* Starting */) {
if (state.status !== 2 /* RecorderStatus.Starting */) {
return;

@@ -63,3 +63,3 @@ }

state = {
status: 0 /* Stopped */,
status: 0 /* RecorderStatus.Stopped */,
};

@@ -70,3 +70,3 @@ return;

state = {
status: 3 /* Started */,
status: 3 /* RecorderStatus.Started */,
stopRecording: stopRecording,

@@ -78,17 +78,17 @@ };

stopStrategy = function () {
if (state.status === 0 /* Stopped */) {
if (state.status === 0 /* RecorderStatus.Stopped */) {
return;
}
if (state.status === 3 /* Started */) {
if (state.status === 3 /* RecorderStatus.Started */) {
state.stopRecording();
}
state = {
status: 0 /* Stopped */,
status: 0 /* RecorderStatus.Stopped */,
};
};
if (state.status === 1 /* IntentToStart */) {
if (state.status === 1 /* RecorderStatus.IntentToStart */) {
startStrategy();
}
},
isRecording: function () { return state.status === 3 /* Started */; },
isRecording: function () { return state.status === 3 /* RecorderStatus.Started */; },
};

@@ -95,0 +95,0 @@ }

@@ -7,3 +7,3 @@ import { timeStampNow, createHttpRequest } from '@datadog/browser-core';

var reportError = function (error) {
lifeCycle.notify(12 /* RAW_ERROR_COLLECTED */, { error: error });
lifeCycle.notify(12 /* LifeCycleEventType.RAW_ERROR_COLLECTED */, { error: error });
};

@@ -17,3 +17,3 @@ var replayRequest = httpRequest || createHttpRequest(configuration.sessionReplayEndpointBuilder, SEGMENT_BYTES_LIMIT, reportError);

}), stopRecording = _b.stop, takeSubsequentFullSnapshot = _b.takeSubsequentFullSnapshot, flushMutations = _b.flushMutations;
var unsubscribeViewEnded = lifeCycle.subscribe(4 /* VIEW_ENDED */, function () {
var unsubscribeViewEnded = lifeCycle.subscribe(4 /* LifeCycleEventType.VIEW_ENDED */, function () {
flushMutations();

@@ -25,3 +25,3 @@ addRecord({

}).unsubscribe;
var unsubscribeViewCreated = lifeCycle.subscribe(2 /* VIEW_CREATED */, function (view) {
var unsubscribeViewCreated = lifeCycle.subscribe(2 /* LifeCycleEventType.VIEW_CREATED */, function (view) {
takeSubsequentFullSnapshot(view.startClocks.timeStamp);

@@ -28,0 +28,0 @@ }).unsubscribe;

@@ -8,3 +8,3 @@ export declare const NodePrivacyLevel: {

};
export declare type NodePrivacyLevel = (typeof NodePrivacyLevel)[keyof typeof NodePrivacyLevel];
export type NodePrivacyLevel = (typeof NodePrivacyLevel)[keyof typeof NodePrivacyLevel];
export declare const PRIVACY_ATTR_NAME = "data-dd-privacy";

@@ -11,0 +11,0 @@ export declare const PRIVACY_ATTR_VALUE_ALLOW = "allow";

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

export declare type ElementsScrollPositions = ReturnType<typeof createElementsScrollPositions>;
export declare type ScrollPositions = {
export type ElementsScrollPositions = ReturnType<typeof createElementsScrollPositions>;
export type ScrollPositions = {
scrollLeft: number;

@@ -4,0 +4,0 @@ scrollTop: number;

import type { FocusRecord } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type FocusCallback = (data: FocusRecord['data']) => void;
export type FocusCallback = (data: FocusRecord['data']) => void;
export declare function initFocusObserver(focusCb: FocusCallback): ListenerHandler;
import { addEventListeners } from '@datadog/browser-core';
export function initFocusObserver(focusCb) {
return addEventListeners(window, ["focus" /* FOCUS */, "blur" /* BLUR */], function () {
return addEventListeners(window, ["focus" /* DOM_EVENT.FOCUS */, "blur" /* DOM_EVENT.BLUR */], function () {
focusCb({ has_focus: document.hasFocus() });

@@ -5,0 +5,0 @@ }).stop;

import type { LifeCycle } from '@datadog/browser-rum-core';
import type { FrustrationRecord } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type FrustrationCallback = (record: FrustrationRecord) => void;
export type FrustrationCallback = (record: FrustrationRecord) => void;
export declare function initFrustrationObserver(lifeCycle: LifeCycle, frustrationCb: FrustrationCallback): ListenerHandler;
import { RecordType } from '../../../types';
import { getRecordIdForEvent } from './utils';
export function initFrustrationObserver(lifeCycle, frustrationCb) {
return lifeCycle.subscribe(10 /* RAW_RUM_EVENT_COLLECTED */, function (data) {
return lifeCycle.subscribe(10 /* LifeCycleEventType.RAW_RUM_EVENT_COLLECTED */, function (data) {
var _a, _b, _c;
if (data.rawRumEvent.type === "action" /* ACTION */ &&
data.rawRumEvent.action.type === "click" /* CLICK */ &&
if (data.rawRumEvent.type === "action" /* RumEventType.ACTION */ &&
data.rawRumEvent.action.type === "click" /* ActionType.CLICK */ &&
((_b = (_a = data.rawRumEvent.action.frustration) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.length) &&

@@ -9,0 +9,0 @@ 'events' in data.domainContext &&

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

import type { ListenerHandler } from './utils';
declare type InputObserverOptions = {
type InputObserverOptions = {
domEvents?: Array<DOM_EVENT.INPUT | DOM_EVENT.CHANGE>;
target?: Node;
};
export declare type InputCallback = (v: InputState & {
export type InputCallback = (v: InputState & {
id: number;

@@ -12,0 +12,0 @@ }) => void;

@@ -7,3 +7,3 @@ import { instrumentSetter, assign, addEventListeners } from '@datadog/browser-core';

export function initInputObserver(cb, defaultPrivacyLevel, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.domEvents, domEvents = _c === void 0 ? ["input" /* INPUT */, "change" /* CHANGE */] : _c, _d = _b.target, target = _d === void 0 ? document : _d;
var _b = _a === void 0 ? {} : _a, _c = _b.domEvents, domEvents = _c === void 0 ? ["input" /* DOM_EVENT.INPUT */, "change" /* DOM_EVENT.CHANGE */] : _c, _d = _b.target, target = _d === void 0 ? document : _d;
var lastInputStateMap = new WeakMap();

@@ -10,0 +10,0 @@ function onElementChange(target) {

import type { DefaultPrivacyLevel } from '@datadog/browser-core';
import type { MediaInteraction } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type MediaInteractionCallback = (p: MediaInteraction) => void;
export type MediaInteractionCallback = (p: MediaInteraction) => void;
export declare function initMediaInteractionObserver(mediaInteractionCb: MediaInteractionCallback, defaultPrivacyLevel: DefaultPrivacyLevel): ListenerHandler;

@@ -17,7 +17,7 @@ import { addEventListeners } from '@datadog/browser-core';

id: getSerializedNodeId(target),
type: event.type === "play" /* PLAY */ ? MediaInteractionType.Play : MediaInteractionType.Pause,
type: event.type === "play" /* DOM_EVENT.PLAY */ ? MediaInteractionType.Play : MediaInteractionType.Pause,
});
};
return addEventListeners(document, ["play" /* PLAY */, "pause" /* PAUSE */], handler, { capture: true, passive: true }).stop;
return addEventListeners(document, ["play" /* DOM_EVENT.PLAY */, "pause" /* DOM_EVENT.PAUSE */], handler, { capture: true, passive: true }).stop;
}
//# sourceMappingURL=mediaInteractionObserver.js.map
import type { DefaultPrivacyLevel } from '@datadog/browser-core';
import type { BrowserIncrementalSnapshotRecord } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type MouseInteractionCallBack = (record: BrowserIncrementalSnapshotRecord) => void;
export type MouseInteractionCallBack = (record: BrowserIncrementalSnapshotRecord) => void;
export declare function initMouseInteractionObserver(cb: MouseInteractionCallBack, defaultPrivacyLevel: DefaultPrivacyLevel): ListenerHandler;

@@ -19,11 +19,11 @@ var _a;

// `PointerInteraction/Up` records that we could reference from `Frustration` records.
_a["pointerup" /* POINTER_UP */] = MouseInteractionType.MouseUp,
_a["mousedown" /* MOUSE_DOWN */] = MouseInteractionType.MouseDown,
_a["click" /* CLICK */] = MouseInteractionType.Click,
_a["contextmenu" /* CONTEXT_MENU */] = MouseInteractionType.ContextMenu,
_a["dblclick" /* DBL_CLICK */] = MouseInteractionType.DblClick,
_a["focus" /* FOCUS */] = MouseInteractionType.Focus,
_a["blur" /* BLUR */] = MouseInteractionType.Blur,
_a["touchstart" /* TOUCH_START */] = MouseInteractionType.TouchStart,
_a["touchend" /* TOUCH_END */] = MouseInteractionType.TouchEnd,
_a["pointerup" /* DOM_EVENT.POINTER_UP */] = MouseInteractionType.MouseUp,
_a["mousedown" /* DOM_EVENT.MOUSE_DOWN */] = MouseInteractionType.MouseDown,
_a["click" /* DOM_EVENT.CLICK */] = MouseInteractionType.Click,
_a["contextmenu" /* DOM_EVENT.CONTEXT_MENU */] = MouseInteractionType.ContextMenu,
_a["dblclick" /* DOM_EVENT.DBL_CLICK */] = MouseInteractionType.DblClick,
_a["focus" /* DOM_EVENT.FOCUS */] = MouseInteractionType.Focus,
_a["blur" /* DOM_EVENT.BLUR */] = MouseInteractionType.Blur,
_a["touchstart" /* DOM_EVENT.TOUCH_START */] = MouseInteractionType.TouchStart,
_a["touchend" /* DOM_EVENT.TOUCH_END */] = MouseInteractionType.TouchEnd,
_a);

@@ -30,0 +30,0 @@ export function initMouseInteractionObserver(cb, defaultPrivacyLevel) {

import type { MousePosition } from '../../../types';
import { IncrementalSource } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type MousemoveCallBack = (p: MousePosition[], source: typeof IncrementalSource.MouseMove | typeof IncrementalSource.TouchMove) => void;
export type MousemoveCallBack = (p: MousePosition[], source: typeof IncrementalSource.MouseMove | typeof IncrementalSource.TouchMove) => void;
export declare function initMoveObserver(cb: MousemoveCallBack): ListenerHandler;

@@ -6,0 +6,0 @@ export declare function tryToComputeCoordinates(event: MouseEvent | TouchEvent): {

@@ -27,3 +27,3 @@ import { addEventListeners, addTelemetryDebug, throttle } from '@datadog/browser-core';

}).throttled;
return addEventListeners(document, ["mousemove" /* MOUSE_MOVE */, "touchmove" /* TOUCH_MOVE */], updatePosition, {
return addEventListeners(document, ["mousemove" /* DOM_EVENT.MOUSE_MOVE */, "touchmove" /* DOM_EVENT.TOUCH_MOVE */], updatePosition, {
capture: true,

@@ -30,0 +30,0 @@ passive: true,

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

import type { ShadowRootsController } from '../shadowRootsController';
export declare type MutationCallBack = (m: BrowserMutationPayload) => void;
export type MutationCallBack = (m: BrowserMutationPayload) => void;
interface RumCharacterDataMutationRecord {

@@ -24,3 +24,3 @@ type: 'characterData';

}
export declare type RumMutationRecord = RumCharacterDataMutationRecord | RumAttributesMutationRecord | RumChildListMutationRecord;
export type RumMutationRecord = RumCharacterDataMutationRecord | RumAttributesMutationRecord | RumChildListMutationRecord;
/**

@@ -27,0 +27,0 @@ * Buffers and aggregate mutations generated by a MutationObserver into MutationPayload

@@ -128,3 +128,3 @@ import { monitor, noop } from '@datadog/browser-core';

parentNodePrivacyLevel: parentNodePrivacyLevel,
serializationContext: { status: 2 /* MUTATION */, shadowRootsController: shadowRootsController },
serializationContext: { status: 2 /* SerializationContextStatus.MUTATION */, shadowRootsController: shadowRootsController },
configuration: configuration,

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

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

import type { ListenerHandler } from './utils';
export declare type ScrollCallback = (p: ScrollPosition) => void;
export type ScrollCallback = (p: ScrollPosition) => void;
export declare function initScrollObserver(cb: ScrollCallback, defaultPrivacyLevel: DefaultPrivacyLevel, elementsScrollPositions: ElementsScrollPositions): ListenerHandler;

@@ -33,4 +33,4 @@ import { throttle, addEventListener } from '@datadog/browser-core';

}, SCROLL_OBSERVER_THRESHOLD).throttled;
return addEventListener(document, "scroll" /* SCROLL */, updatePosition, { capture: true, passive: true }).stop;
return addEventListener(document, "scroll" /* DOM_EVENT.SCROLL */, updatePosition, { capture: true, passive: true }).stop;
}
//# sourceMappingURL=scrollObserver.js.map
import type { StyleSheetRule } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type StyleSheetCallback = (s: StyleSheetRule) => void;
export type StyleSheetCallback = (s: StyleSheetRule) => void;
export declare function initStyleSheetObserver(cb: StyleSheetCallback): ListenerHandler;

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

export declare type ListenerHandler = () => void;
export type ListenerHandler = () => void;
export declare function forEach<List extends {

@@ -3,0 +3,0 @@ [index: number]: any;

import type { ViewportResizeDimension, VisualViewportRecord } from '../../../types';
import type { ListenerHandler } from './utils';
export declare type ViewportResizeCallback = (d: ViewportResizeDimension) => void;
export declare type VisualViewportResizeCallback = (data: VisualViewportRecord['data']) => void;
export type ViewportResizeCallback = (d: ViewportResizeDimension) => void;
export type VisualViewportResizeCallback = (data: VisualViewportRecord['data']) => void;
export declare function initViewportResizeObserver(cb: ViewportResizeCallback): ListenerHandler;
export declare function initVisualViewportResizeObserver(cb: VisualViewportResizeCallback): ListenerHandler;

@@ -9,11 +9,12 @@ import { throttle, addEventListeners, noop } from '@datadog/browser-core';

export function initVisualViewportResizeObserver(cb) {
if (!window.visualViewport) {
var visualViewport = window.visualViewport;
if (!visualViewport) {
return noop;
}
var _a = throttle(function () {
cb(getVisualViewport());
cb(getVisualViewport(visualViewport));
}, VISUAL_VIEWPORT_OBSERVER_THRESHOLD, {
trailing: false,
}), updateDimension = _a.throttled, cancelThrottle = _a.cancel;
var removeListener = addEventListeners(window.visualViewport, ["resize" /* RESIZE */, "scroll" /* SCROLL */], updateDimension, {
var removeListener = addEventListeners(visualViewport, ["resize" /* DOM_EVENT.RESIZE */, "scroll" /* DOM_EVENT.SCROLL */], updateDimension, {
capture: true,

@@ -20,0 +21,0 @@ passive: true,

@@ -25,3 +25,3 @@ import { timeStampNow } from '@datadog/browser-core';

if (serializationContext === void 0) { serializationContext = {
status: 0 /* INITIAL_FULL_SNAPSHOT */,
status: 0 /* SerializationContextStatus.INITIAL_FULL_SNAPSHOT */,
elementsScrollPositions: elementsScrollPositions,

@@ -60,3 +60,3 @@ shadowRootsController: shadowRootsController,

emit({
data: getVisualViewport(),
data: getVisualViewport(window.visualViewport),
type: RecordType.VisualViewport,

@@ -112,3 +112,3 @@ timestamp: timestamp,

shadowRootsController: shadowRootsController,
status: 1 /* SUBSEQUENT_FULL_SNAPSHOT */,
status: 1 /* SerializationContextStatus.SUBSEQUENT_FULL_SNAPSHOT */,
elementsScrollPositions: elementsScrollPositions,

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

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

import type { ShadowRootsController } from '../shadowRootsController';
declare type ParentNodePrivacyLevel = typeof NodePrivacyLevel.ALLOW | typeof NodePrivacyLevel.MASK | typeof NodePrivacyLevel.MASK_USER_INPUT;
type ParentNodePrivacyLevel = typeof NodePrivacyLevel.ALLOW | typeof NodePrivacyLevel.MASK | typeof NodePrivacyLevel.MASK_USER_INPUT;
export declare const enum SerializationContextStatus {

@@ -12,3 +12,3 @@ INITIAL_FULL_SNAPSHOT = 0,

}
export declare type SerializationContext = {
export type SerializationContext = {
status: SerializationContextStatus.MUTATION;

@@ -32,5 +32,5 @@ shadowRootsController: ShadowRootsController;

}
export declare type NodeWithSerializedNode = Node & {
export type NodeWithSerializedNode = Node & {
s: 'Node with serialized node';
};
export {};

@@ -87,3 +87,3 @@ import { NodePrivacyLevel } from '../../../constants';

switch (serializationContext.status) {
case 0 /* INITIAL_FULL_SNAPSHOT */:
case 0 /* SerializationContextStatus.INITIAL_FULL_SNAPSHOT */:
scrollTop = Math.round(element.scrollTop);

@@ -95,3 +95,3 @@ scrollLeft = Math.round(element.scrollLeft);

break;
case 1 /* SUBSEQUENT_FULL_SNAPSHOT */:
case 1 /* SerializationContextStatus.SUBSEQUENT_FULL_SNAPSHOT */:
if (serializationContext.elementsScrollPositions.has(element)) {

@@ -98,0 +98,0 @@ ;

@@ -74,5 +74,3 @@ import { isNodeShadowRoot, isNodeShadowHost } from '@datadog/browser-rum-core';

isShadowRoot: isShadowRoot,
adoptedStyleSheets: isShadowRoot
? serializeStyleSheets(element.adoptedStyleSheets)
: undefined,
adoptedStyleSheets: isShadowRoot ? serializeStyleSheets(element.adoptedStyleSheets) : undefined,
};

@@ -79,0 +77,0 @@ }

import type { RumConfiguration } from '@datadog/browser-rum-core';
import type { InputCallback, MutationCallBack } from './observers';
export declare type ShadowRootCallBack = (shadowRoot: ShadowRoot) => void;
export type ShadowRootCallBack = (shadowRoot: ShadowRoot) => void;
export interface ShadowRootsController {

@@ -5,0 +5,0 @@ addShadowRoot: ShadowRootCallBack;

@@ -12,3 +12,3 @@ import { addTelemetryDebug, isExperimentalFeatureEnabled } from '@datadog/browser-core';

target: shadowRoot,
domEvents: ["change" /* CHANGE */],
domEvents: ["change" /* DOM_EVENT.CHANGE */],
});

@@ -15,0 +15,0 @@ controllerByShadowRoot.set(shadowRoot, {

@@ -19,5 +19,5 @@ /**

export declare const convertMouseEventToLayoutCoordinates: (clientX: number, clientY: number) => LayoutCoordinates;
export declare const getVisualViewport: () => VisualViewportRecord['data'];
export declare const getVisualViewport: (visualViewport: VisualViewport) => VisualViewportRecord['data'];
export declare function getScrollX(): number;
export declare function getScrollY(): number;
export {};

@@ -18,10 +18,9 @@ /**

*/
function isVisualViewportFactoredIn() {
var visual = window.visualViewport;
return (Math.abs(visual.pageTop - visual.offsetTop - window.scrollY) > TOLERANCE ||
Math.abs(visual.pageLeft - visual.offsetLeft - window.scrollX) > TOLERANCE);
function isVisualViewportFactoredIn(visualViewport) {
return (Math.abs(visualViewport.pageTop - visualViewport.offsetTop - window.scrollY) > TOLERANCE ||
Math.abs(visualViewport.pageLeft - visualViewport.offsetLeft - window.scrollX) > TOLERANCE);
}
export var convertMouseEventToLayoutCoordinates = function (clientX, clientY) {
var visual = window.visualViewport;
var normalised = {
var visualViewport = window.visualViewport;
var normalized = {
layoutViewportX: clientX,

@@ -32,30 +31,27 @@ layoutViewportY: clientY,

};
if (!visual) {
// On old browsers, we cannot normalise, so fallback to clientX/Y
return normalised;
if (!visualViewport) {
// On old browsers, we cannot normalize, so fallback to clientX/Y
return normalized;
}
else if (isVisualViewportFactoredIn()) {
else if (isVisualViewportFactoredIn(visualViewport)) {
// Typically Mobile Devices
normalised.layoutViewportX = Math.round(clientX + visual.offsetLeft);
normalised.layoutViewportY = Math.round(clientY + visual.offsetTop);
normalized.layoutViewportX = Math.round(clientX + visualViewport.offsetLeft);
normalized.layoutViewportY = Math.round(clientY + visualViewport.offsetTop);
}
else {
// Typically Desktop Devices
normalised.visualViewportX = Math.round(clientX - visual.offsetLeft);
normalised.visualViewportY = Math.round(clientY - visual.offsetTop);
normalized.visualViewportX = Math.round(clientX - visualViewport.offsetLeft);
normalized.visualViewportY = Math.round(clientY - visualViewport.offsetTop);
}
return normalised;
return normalized;
};
export var getVisualViewport = function () {
var visual = window.visualViewport;
return {
scale: visual.scale,
offsetLeft: visual.offsetLeft,
offsetTop: visual.offsetTop,
pageLeft: visual.pageLeft,
pageTop: visual.pageTop,
height: visual.height,
width: visual.width,
};
};
export var getVisualViewport = function (visualViewport) { return ({
scale: visualViewport.scale,
offsetLeft: visualViewport.offsetLeft,
offsetTop: visualViewport.offsetTop,
pageLeft: visualViewport.pageLeft,
pageTop: visualViewport.pageTop,
height: visualViewport.height,
width: visualViewport.width,
}); };
export function getScrollX() {

@@ -62,0 +58,0 @@ var scrollX;

import type { BrowserRecord, BrowserSegmentMetadata, CreationReason, SegmentContext } from '../../types';
import type { DeflateWorker } from './deflateWorker';
export declare type FlushReason = Exclude<CreationReason, 'init'> | 'stop';
export type FlushReason = Exclude<CreationReason, 'init'> | 'stop';
export declare class Segment {

@@ -5,0 +5,0 @@ private worker;

@@ -39,13 +39,13 @@ import { isPageExitReason, ONE_SECOND, clearTimeout, setTimeout } from '@datadog/browser-core';

var state = {
status: 0 /* WaitingForInitialRecord */,
status: 0 /* SegmentCollectionStatus.WaitingForInitialRecord */,
nextSegmentCreationReason: 'init',
};
var unsubscribeViewCreated = lifeCycle.subscribe(2 /* VIEW_CREATED */, function () {
var unsubscribeViewCreated = lifeCycle.subscribe(2 /* LifeCycleEventType.VIEW_CREATED */, function () {
flushSegment('view_change');
}).unsubscribe;
var unsubscribePageExited = lifeCycle.subscribe(9 /* PAGE_EXITED */, function (pageExitEvent) {
var unsubscribePageExited = lifeCycle.subscribe(9 /* LifeCycleEventType.PAGE_EXITED */, function (pageExitEvent) {
flushSegment(pageExitEvent.reason);
}).unsubscribe;
function flushSegment(flushReason) {
if (state.status === 1 /* SegmentPending */) {
if (state.status === 1 /* SegmentCollectionStatus.SegmentPending */) {
state.segment.flush(flushReason);

@@ -56,3 +56,3 @@ clearTimeout(state.expirationTimeoutId);

state = {
status: 0 /* WaitingForInitialRecord */,
status: 0 /* SegmentCollectionStatus.WaitingForInitialRecord */,
nextSegmentCreationReason: flushReason,

@@ -63,3 +63,3 @@ };

state = {
status: 2 /* Stopped */,
status: 2 /* SegmentCollectionStatus.Stopped */,
};

@@ -87,3 +87,3 @@ }

state = {
status: 1 /* SegmentPending */,
status: 1 /* SegmentCollectionStatus.SegmentPending */,
segment: segment,

@@ -98,6 +98,6 @@ expirationTimeoutId: setTimeout(function () {

switch (state.status) {
case 0 /* WaitingForInitialRecord */:
case 0 /* SegmentCollectionStatus.WaitingForInitialRecord */:
createNewSegment(state.nextSegmentCreationReason, record);
break;
case 1 /* SegmentPending */:
case 1 /* SegmentCollectionStatus.SegmentPending */:
state.segment.addRecord(record);

@@ -104,0 +104,0 @@ break;

import { addTelemetryError, display, includes, monitor } from '@datadog/browser-core';
import { createDeflateWorker } from './deflateWorker';
var state = { status: 0 /* Nil */ };
var state = { status: 0 /* DeflateWorkerStatus.Nil */ };
export function startDeflateWorker(callback, createDeflateWorkerImpl) {
if (createDeflateWorkerImpl === void 0) { createDeflateWorkerImpl = createDeflateWorker; }
switch (state.status) {
case 0 /* Nil */:
state = { status: 1 /* Loading */, callbacks: [callback] };
case 0 /* DeflateWorkerStatus.Nil */:
state = { status: 1 /* DeflateWorkerStatus.Loading */, callbacks: [callback] };
doStartDeflateWorker(createDeflateWorkerImpl);
break;
case 1 /* Loading */:
case 1 /* DeflateWorkerStatus.Loading */:
state.callbacks.push(callback);
break;
case 2 /* Error */:
case 2 /* DeflateWorkerStatus.Error */:
callback();
break;
case 3 /* Initialized */:
case 3 /* DeflateWorkerStatus.Initialized */:
callback(state.worker);

@@ -23,3 +23,3 @@ break;

export function resetDeflateWorkerState() {
state = { status: 0 /* Nil */ };
state = { status: 0 /* DeflateWorkerStatus.Nil */ };
}

@@ -57,9 +57,9 @@ /**

function onInitialized(worker) {
if (state.status === 1 /* Loading */) {
if (state.status === 1 /* DeflateWorkerStatus.Loading */) {
state.callbacks.forEach(function (callback) { return callback(worker); });
state = { status: 3 /* Initialized */, worker: worker };
state = { status: 3 /* DeflateWorkerStatus.Initialized */, worker: worker };
}
}
function onError(error) {
if (state.status === 1 /* Loading */) {
if (state.status === 1 /* DeflateWorkerStatus.Loading */) {
display.error('Session Replay recording failed to start: an error occurred while creating the Worker:', error);

@@ -74,3 +74,3 @@ if (error instanceof Event || (error instanceof Error && isMessageCspRelated(error.message))) {

state.callbacks.forEach(function (callback) { return callback(); });
state = { status: 2 /* Error */ };
state = { status: 2 /* DeflateWorkerStatus.Error */ };
}

@@ -77,0 +77,0 @@ else {

@@ -28,2 +28,3 @@ export { DefaultPrivacyLevel } from '@datadog/browser-core';

};
stopSession: () => void;
startSessionReplayRecording: () => void;

@@ -30,0 +31,0 @@ stopSessionReplayRecording: () => void;

@@ -29,2 +29,3 @@ export { CommonProperties, RumPublicApi as RumGlobal, RumInitConfiguration, RumEvent, RumActionEvent, RumErrorEvent, RumLongTaskEvent, RumResourceEvent, RumViewEvent, RumEventDomainContext, RumViewEventDomainContext, RumErrorEventDomainContext, RumActionEventDomainContext, RumFetchResourceEventDomainContext, RumXhrResourceEventDomainContext, RumOtherResourceEventDomainContext, RumLongTaskEventDomainContext, } from '@datadog/browser-rum-core';

};
stopSession: () => void;
startSessionReplayRecording: () => void;

@@ -31,0 +32,0 @@ stopSessionReplayRecording: () => void;

@@ -7,3 +7,3 @@ /**

*/
export declare type BrowserSegment = BrowserSegmentMetadata & {
export type BrowserSegment = BrowserSegmentMetadata & {
/**

@@ -17,3 +17,3 @@ * The records contained by this Segment.

*/
export declare type BrowserSegmentMetadata = SegmentContext & CommonSegmentMetadataSchema & {
export type BrowserSegmentMetadata = SegmentContext & CommonSegmentMetadataSchema & {
/**

@@ -28,11 +28,11 @@ * The source of this record

*/
export declare type CreationReason = 'init' | 'segment_duration_limit' | 'segment_bytes_limit' | 'view_change' | 'before_unload' | 'visibility_hidden' | 'page_frozen';
export type CreationReason = 'init' | 'segment_duration_limit' | 'segment_bytes_limit' | 'view_change' | 'before_unload' | 'visibility_hidden' | 'page_frozen';
/**
* Browser-specific. Schema of a Session Replay Record.
*/
export declare type BrowserRecord = BrowserFullSnapshotRecord | BrowserIncrementalSnapshotRecord | MetaRecord | FocusRecord | ViewEndRecord | VisualViewportRecord | FrustrationRecord;
export type BrowserRecord = BrowserFullSnapshotRecord | BrowserIncrementalSnapshotRecord | MetaRecord | FocusRecord | ViewEndRecord | VisualViewportRecord | FrustrationRecord;
/**
* Browser-specific. Schema of a Record type which contains the full snapshot of a screen.
*/
export declare type BrowserFullSnapshotRecord = CommonRecordSchema & {
export type BrowserFullSnapshotRecord = CommonRecordSchema & {
/**

@@ -47,3 +47,3 @@ * The type of this Record.

*/
export declare type SerializedNodeWithId = {
export type SerializedNodeWithId = {
id: number;

@@ -54,7 +54,7 @@ } & SerializedNode;

*/
export declare type SerializedNode = DocumentNode | DocumentFragmentNode | DocumentTypeNode | ElementNode | TextNode | CDataNode;
export type SerializedNode = DocumentNode | DocumentFragmentNode | DocumentTypeNode | ElementNode | TextNode | CDataNode;
/**
* Browser-specific. Schema of a Record type which contains mutations of a screen.
*/
export declare type BrowserIncrementalSnapshotRecord = CommonRecordSchema & {
export type BrowserIncrementalSnapshotRecord = CommonRecordSchema & {
/**

@@ -70,7 +70,7 @@ * The type of this Record.

*/
export declare type BrowserIncrementalData = BrowserMutationData | MousemoveData | MouseInteractionData | ScrollData | InputData | MediaInteractionData | StyleSheetRuleData | ViewportResizeData | PointerInteractionData;
export type BrowserIncrementalData = BrowserMutationData | MousemoveData | MouseInteractionData | ScrollData | InputData | MediaInteractionData | StyleSheetRuleData | ViewportResizeData | PointerInteractionData;
/**
* Browser-specific. Schema of a MutationData.
*/
export declare type BrowserMutationData = {
export type BrowserMutationData = {
/**

@@ -84,3 +84,3 @@ * The source of this type of incremental data.

*/
export declare type BrowserMutationPayload = {
export type BrowserMutationPayload = {
/**

@@ -106,3 +106,3 @@ * Contains the newly added nodes.

*/
export declare type MouseInteractionData = {
export type MouseInteractionData = {
/**

@@ -116,3 +116,3 @@ * The source of this type of incremental data.

*/
export declare type MouseInteraction = {
export type MouseInteraction = {
/**

@@ -147,3 +147,3 @@ * The type of MouseInteraction: 0=mouseup, 1=mousedown, 2=click, 3=contextmenu, 4=dblclick, 7=touchstart, 9=touchend

*/
export declare type ScrollData = {
export type ScrollData = {
/**

@@ -157,3 +157,3 @@ * The source of this type of incremental data.

*/
export declare type InputData = {
export type InputData = {
/**

@@ -171,3 +171,3 @@ * The source of this type of incremental data.

*/
export declare type InputState = {
export type InputState = {
/**

@@ -186,3 +186,3 @@ * Text value for this InputState.

*/
export declare type MediaInteractionData = {
export type MediaInteractionData = {
/**

@@ -196,3 +196,3 @@ * The source of this type of incremental data.

*/
export declare type StyleSheetRuleData = {
export type StyleSheetRuleData = {
/**

@@ -206,3 +206,3 @@ * The source of this type of incremental data.

*/
export declare type ViewportResizeData = {
export type ViewportResizeData = {
/**

@@ -216,3 +216,3 @@ * The source of this type of incremental data.

*/
export declare type PointerInteractionData = {
export type PointerInteractionData = {
/**

@@ -226,3 +226,3 @@ * The source of this type of incremental data.

*/
export declare type MetaRecord = CommonRecordSchema & {
export type MetaRecord = CommonRecordSchema & {
/**

@@ -253,3 +253,3 @@ * The type of this Record.

*/
export declare type FocusRecord = CommonRecordSchema & {
export type FocusRecord = CommonRecordSchema & {
/**

@@ -269,3 +269,3 @@ * The type of this Record.

*/
export declare type ViewEndRecord = CommonRecordSchema & {
export type ViewEndRecord = CommonRecordSchema & {
/**

@@ -279,3 +279,3 @@ * The type of this Record.

*/
export declare type VisualViewportRecord = CommonRecordSchema & {
export type VisualViewportRecord = CommonRecordSchema & {
data: {

@@ -298,3 +298,3 @@ height: number;

*/
export declare type FrustrationRecord = CommonRecordSchema & {
export type FrustrationRecord = CommonRecordSchema & {
/**

@@ -301,0 +301,0 @@ * The type of this Record.

@@ -11,3 +11,3 @@ import type * as SessionReplay from './sessionReplay';

};
export declare type RecordType = (typeof RecordType)[keyof typeof RecordType];
export type RecordType = (typeof RecordType)[keyof typeof RecordType];
export declare const NodeType: {

@@ -21,3 +21,3 @@ Document: SessionReplay.DocumentNode['type'];

};
export declare type NodeType = (typeof NodeType)[keyof typeof NodeType];
export type NodeType = (typeof NodeType)[keyof typeof NodeType];
export declare const IncrementalSource: {

@@ -34,3 +34,3 @@ Mutation: SessionReplay.BrowserMutationData['source'];

};
export declare type IncrementalSource = (typeof IncrementalSource)[keyof typeof IncrementalSource];
export type IncrementalSource = (typeof IncrementalSource)[keyof typeof IncrementalSource];
export declare const MouseInteractionType: {

@@ -47,3 +47,3 @@ readonly MouseUp: 0;

};
export declare type MouseInteractionType = (typeof MouseInteractionType)[keyof typeof MouseInteractionType];
export type MouseInteractionType = (typeof MouseInteractionType)[keyof typeof MouseInteractionType];
export declare const MediaInteractionType: {

@@ -53,2 +53,2 @@ readonly Play: 0;

};
export declare type MediaInteractionType = (typeof MediaInteractionType)[keyof typeof MediaInteractionType];
export type MediaInteractionType = (typeof MediaInteractionType)[keyof typeof MediaInteractionType];
{
"name": "@datadog/browser-rum",
"version": "4.36.0",
"version": "4.37.0",
"license": "Apache-2.0",

@@ -15,7 +15,7 @@ "main": "cjs/entries/main.js",

"dependencies": {
"@datadog/browser-core": "4.36.0",
"@datadog/browser-rum-core": "4.36.0"
"@datadog/browser-core": "4.37.0",
"@datadog/browser-rum-core": "4.37.0"
},
"peerDependencies": {
"@datadog/browser-logs": "4.36.0"
"@datadog/browser-logs": "4.37.0"
},

@@ -39,3 +39,3 @@ "peerDependenciesMeta": {

},
"gitHead": "bcd2446e1d5f38c915f5fb581421bfd3fdd8dab6"
"gitHead": "058831610a12a72ff5e650e47a6ce8cfe9e20012"
}

@@ -7,4 +7,4 @@ import { isIE, noop } from '@datadog/browser-core'

import { createRumSessionManagerMock } from '../../../rum-core/test/mockRumSessionManager'
import type { TestSetupBuilder } from '../../../rum-core/test/specHelper'
import { setup } from '../../../rum-core/test/specHelper'
import type { TestSetupBuilder } from '../../../rum-core/test/testSetupBuilder'
import { setup } from '../../../rum-core/test/testSetupBuilder'
import type { DeflateWorker, startDeflateWorker } from '../domain/segmentCollection'

@@ -11,0 +11,0 @@ import type { StartRecording } from './recorderApi'

@@ -10,4 +10,4 @@ import type { TimeStamp, HttpRequest } from '@datadog/browser-core'

import type { TestSetupBuilder } from '../../../rum-core/test/specHelper'
import { setup } from '../../../rum-core/test/specHelper'
import type { TestSetupBuilder } from '../../../rum-core/test/testSetupBuilder'
import { setup } from '../../../rum-core/test/testSetupBuilder'
import { recordsPerFullSnapshot } from '../../test/utils'

@@ -14,0 +14,0 @@ import { setSegmentBytesLimit, startDeflateWorker } from '../domain/segmentCollection'

@@ -18,3 +18,4 @@ import { throttle, DOM_EVENT, addEventListeners, noop } from '@datadog/browser-core'

export function initVisualViewportResizeObserver(cb: VisualViewportResizeCallback): ListenerHandler {
if (!window.visualViewport) {
const visualViewport = window.visualViewport
if (!visualViewport) {
return noop

@@ -24,3 +25,3 @@ }

() => {
cb(getVisualViewport())
cb(getVisualViewport(visualViewport))
},

@@ -32,11 +33,6 @@ VISUAL_VIEWPORT_OBSERVER_THRESHOLD,

)
const removeListener = addEventListeners(
window.visualViewport,
[DOM_EVENT.RESIZE, DOM_EVENT.SCROLL],
updateDimension,
{
capture: true,
passive: true,
}
).stop
const removeListener = addEventListeners(visualViewport, [DOM_EVENT.RESIZE, DOM_EVENT.SCROLL], updateDimension, {
capture: true,
passive: true,
}).stop

@@ -43,0 +39,0 @@ return function stop() {

@@ -96,3 +96,3 @@ import type { TimeStamp } from '@datadog/browser-core'

emit({
data: getVisualViewport(),
data: getVisualViewport(window.visualViewport),
type: RecordType.VisualViewport,

@@ -99,0 +99,0 @@ timestamp,

@@ -19,3 +19,2 @@ import { isIE, noop } from '@datadog/browser-core'

import type { ShadowRootCallBack, ShadowRootsController } from '../shadowRootsController'
import type { WithAdoptedStyleSheets } from '../browser.types'
import { isAdoptedStyleSheetsSupported } from '../../../../../core/test/specHelper'

@@ -812,3 +811,3 @@ import {

styleSheet.insertRule('div { width: 100%; }')
;(isolatedDom.document as WithAdoptedStyleSheets).adoptedStyleSheets = [styleSheet]
isolatedDom.document.adoptedStyleSheets = [styleSheet]
expect(serializeDocument(isolatedDom.document, DEFAULT_CONFIGURATION, DEFAULT_SERIALIZATION_CONTEXT)).toEqual({

@@ -815,0 +814,0 @@ type: NodeType.Document,

@@ -14,3 +14,2 @@ import { isNodeShadowRoot, isNodeShadowHost } from '@datadog/browser-rum-core'

import { NodeType } from '../../../types'
import type { WithAdoptedStyleSheets } from '../browser.types'
import { NodePrivacyLevel, PRIVACY_ATTR_NAME, PRIVACY_ATTR_VALUE_HIDDEN } from '../../../constants'

@@ -77,3 +76,3 @@ import { reducePrivacyLevel, getNodeSelfPrivacyLevel, getTextContent } from '../privacy'

childNodes: serializeChildNodes(document, options),
adoptedStyleSheets: serializeStyleSheets((document as WithAdoptedStyleSheets).adoptedStyleSheets),
adoptedStyleSheets: serializeStyleSheets(document.adoptedStyleSheets),
}

@@ -100,5 +99,3 @@ }

isShadowRoot,
adoptedStyleSheets: isShadowRoot
? serializeStyleSheets((element as WithAdoptedStyleSheets).adoptedStyleSheets)
: undefined,
adoptedStyleSheets: isShadowRoot ? serializeStyleSheets(element.adoptedStyleSheets) : undefined,
}

@@ -105,0 +102,0 @@ }

@@ -22,7 +22,6 @@ /**

*/
function isVisualViewportFactoredIn() {
const visual = window.visualViewport
function isVisualViewportFactoredIn(visualViewport: VisualViewport) {
return (
Math.abs(visual.pageTop - visual.offsetTop - window.scrollY) > TOLERANCE ||
Math.abs(visual.pageLeft - visual.offsetLeft - window.scrollX) > TOLERANCE
Math.abs(visualViewport.pageTop - visualViewport.offsetTop - window.scrollY) > TOLERANCE ||
Math.abs(visualViewport.pageLeft - visualViewport.offsetLeft - window.scrollX) > TOLERANCE
)

@@ -39,4 +38,4 @@ }

export const convertMouseEventToLayoutCoordinates = (clientX: number, clientY: number): LayoutCoordinates => {
const visual = window.visualViewport
const normalised: LayoutCoordinates = {
const visualViewport = window.visualViewport
const normalized: LayoutCoordinates = {
layoutViewportX: clientX,

@@ -48,29 +47,26 @@ layoutViewportY: clientY,

if (!visual) {
// On old browsers, we cannot normalise, so fallback to clientX/Y
return normalised
} else if (isVisualViewportFactoredIn()) {
if (!visualViewport) {
// On old browsers, we cannot normalize, so fallback to clientX/Y
return normalized
} else if (isVisualViewportFactoredIn(visualViewport)) {
// Typically Mobile Devices
normalised.layoutViewportX = Math.round(clientX + visual.offsetLeft)
normalised.layoutViewportY = Math.round(clientY + visual.offsetTop)
normalized.layoutViewportX = Math.round(clientX + visualViewport.offsetLeft)
normalized.layoutViewportY = Math.round(clientY + visualViewport.offsetTop)
} else {
// Typically Desktop Devices
normalised.visualViewportX = Math.round(clientX - visual.offsetLeft)
normalised.visualViewportY = Math.round(clientY - visual.offsetTop)
normalized.visualViewportX = Math.round(clientX - visualViewport.offsetLeft)
normalized.visualViewportY = Math.round(clientY - visualViewport.offsetTop)
}
return normalised
return normalized
}
export const getVisualViewport = (): VisualViewportRecord['data'] => {
const visual = window.visualViewport
return {
scale: visual.scale,
offsetLeft: visual.offsetLeft,
offsetTop: visual.offsetTop,
pageLeft: visual.pageLeft,
pageTop: visual.pageTop,
height: visual.height,
width: visual.width,
}
}
export const getVisualViewport = (visualViewport: VisualViewport): VisualViewportRecord['data'] => ({
scale: visualViewport.scale,
offsetLeft: visualViewport.offsetLeft,
offsetTop: visualViewport.offsetTop,
pageLeft: visualViewport.pageLeft,
pageTop: visualViewport.pageTop,
height: visualViewport.height,
width: visualViewport.width,
})

@@ -77,0 +73,0 @@ export function getScrollX() {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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