Socket
Socket
Sign inDemoInstall

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 5.10.0 to 5.11.0

2

cjs/boot/preStartRum.js

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

function overrideInitConfigurationForBridge(initConfiguration) {
var _a, _b;
return (0, browser_core_1.assign)({}, initConfiguration, {

@@ -128,4 +129,5 @@ applicationId: '00000000-aaaa-0000-aaaa-000000000000',

sessionSampleRate: 100,
defaultPrivacyLevel: (_a = initConfiguration.defaultPrivacyLevel) !== null && _a !== void 0 ? _a : (_b = (0, browser_core_1.getEventBridge)()) === null || _b === void 0 ? void 0 : _b.getPrivacyLevel(),
});
}
//# sourceMappingURL=preStartRum.js.map

2

cjs/boot/startRum.js

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

cleanupTasks.push(stopPerformanceCollection);
var vitalCollection = (0, vitalCollection_1.startVitalCollection)(lifeCycle);
var vitalCollection = (0, vitalCollection_1.startVitalCollection)(lifeCycle, pageStateHistory);
var internalContext = (0, internalContext_1.startInternalContext)(configuration.applicationId, session, viewContexts, actionContexts, urlContexts);

@@ -91,0 +91,0 @@ return {

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

type: "action" /* RumEventType.ACTION */,
view: { in_foreground: pageStateHistory.isInActivePageStateAt(action.startClocks.relative) },
view: { in_foreground: pageStateHistory.wasInPageStateAt("active" /* PageState.ACTIVE */, action.startClocks.relative) },
}, autoActionProperties);

@@ -65,0 +65,0 @@ return {

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

},
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "5.10.0" : undefined,
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "5.11.0" : undefined,
},

@@ -64,0 +64,0 @@ application: {

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

findAll: (startTime: RelativeTime, duration: Duration) => PageStateServerEntry[] | undefined;
isInActivePageStateAt: (startTime: RelativeTime) => boolean;
wasInPageStateAt: (state: PageState, startTime: RelativeTime) => boolean;
wasInPageStateDuringPeriod: (state: PageState, startTime: RelativeTime, duration: Duration) => boolean;
addPageState(nextPageState: PageState, startTime?: RelativeTime): void;

@@ -23,0 +24,0 @@ stop: () => void;

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

if (maxPageStateEntriesSelectable === void 0) { maxPageStateEntriesSelectable = exports.MAX_PAGE_STATE_ENTRIES_SELECTABLE; }
var pageStateHistory = new browser_core_1.ValueHistory(exports.PAGE_STATE_CONTEXT_TIME_OUT_DELAY, exports.MAX_PAGE_STATE_ENTRIES);
var pageStateEntryHistory = new browser_core_1.ValueHistory(exports.PAGE_STATE_CONTEXT_TIME_OUT_DELAY, exports.MAX_PAGE_STATE_ENTRIES);
var currentPageState;

@@ -33,8 +33,8 @@ addPageState(getPageState(), (0, browser_core_1.relativeNow)());

currentPageState = nextPageState;
pageStateHistory.closeActive(startTime);
pageStateHistory.add({ state: currentPageState, startTime: startTime }, startTime);
pageStateEntryHistory.closeActive(startTime);
pageStateEntryHistory.add({ state: currentPageState, startTime: startTime }, startTime);
}
return {
var pageStateHistory = {
findAll: function (eventStartTime, duration) {
var pageStateEntries = pageStateHistory.findAll(eventStartTime, duration);
var pageStateEntries = pageStateEntryHistory.findAll(eventStartTime, duration);
if (pageStateEntries.length === 0) {

@@ -58,12 +58,15 @@ return;

},
isInActivePageStateAt: function (startTime) {
var pageStateEntry = pageStateHistory.find(startTime);
return pageStateEntry !== undefined && pageStateEntry.state === "active" /* PageState.ACTIVE */;
wasInPageStateAt: function (state, startTime) {
return pageStateHistory.wasInPageStateDuringPeriod(state, startTime, 0);
},
wasInPageStateDuringPeriod: function (state, startTime, duration) {
return pageStateEntryHistory.findAll(startTime, duration).some(function (pageState) { return pageState.state === state; });
},
addPageState: addPageState,
stop: function () {
stopEventListeners();
pageStateHistory.stop();
pageStateEntryHistory.stop();
},
};
return pageStateHistory;
}

@@ -70,0 +73,0 @@ exports.startPageStateHistory = startPageStateHistory;

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

type: "error" /* RumEventType.ERROR */,
view: { in_foreground: pageStateHistory.isInActivePageStateAt(error.startClocks.relative) },
view: { in_foreground: pageStateHistory.wasInPageStateAt("active" /* PageState.ACTIVE */, error.startClocks.relative) },
};

@@ -65,0 +65,0 @@ var featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(error.startClocks.relative);

@@ -154,9 +154,8 @@ "use strict";

function computeRequestDuration(pageStateHistory, startClocks, duration) {
var _a;
var requestCrossedFrozenState = (_a = pageStateHistory
.findAll(startClocks.relative, duration)) === null || _a === void 0 ? void 0 : _a.some(function (pageState) { return pageState.state === "frozen" /* PageState.FROZEN */; });
return !requestCrossedFrozenState ? (0, browser_core_1.toServerDuration)(duration) : undefined;
return !pageStateHistory.wasInPageStateDuringPeriod("frozen" /* PageState.FROZEN */, startClocks.relative, duration)
? (0, browser_core_1.toServerDuration)(duration)
: undefined;
}
/**
* The status is 0 for cross origin resources without CORS headers, so the status is meaningless and we shouldn't report it
* The status is 0 for cross-origin resources without CORS headers, so the status is meaningless, and we shouldn't report it
* https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStatus#cross-origin_response_status_codes

@@ -163,0 +162,0 @@ */

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

id: '00000000-aaaa-0000-aaaa-000000000000',
sessionReplayAllowed: false,
sessionReplayAllowed: (0, browser_core_1.bridgeSupports)("records" /* BridgeCapability.RECORDS */),
};

@@ -39,0 +39,0 @@ return {

import type { ClocksState, Context } from '@datadog/browser-core';
import type { LifeCycle } from '../lifeCycle';
import type { PageStateHistory } from '../contexts/pageStateHistory';
export interface DurationVitalStart {

@@ -13,5 +14,5 @@ name: string;

}
export declare function startVitalCollection(lifeCycle: LifeCycle): {
export declare function startVitalCollection(lifeCycle: LifeCycle, pageStateHistory: PageStateHistory): {
startDurationVital: (vitalStart: DurationVitalStart) => void;
stopDurationVital: (vitalStop: DurationVitalStop) => void;
};

@@ -5,4 +5,11 @@ "use strict";

var browser_core_1 = require("@datadog/browser-core");
function startVitalCollection(lifeCycle) {
function startVitalCollection(lifeCycle, pageStateHistory) {
var vitalStartsByName = new Map();
lifeCycle.subscribe(10 /* LifeCycleEventType.SESSION_RENEWED */, function () {
// Discard all the vitals that have not been stopped to avoid memory leaks
vitalStartsByName.clear();
});
function isValid(vital) {
return !pageStateHistory.wasInPageStateDuringPeriod("frozen" /* PageState.FROZEN */, vital.startClocks.relative, vital.value);
}
return {

@@ -17,11 +24,7 @@ startDurationVital: function (vitalStart) {

}
var vital = {
name: vitalStart.name,
type: "duration" /* VitalType.DURATION */,
startClocks: vitalStart.startClocks,
value: (0, browser_core_1.elapsed)(vitalStart.startClocks.timeStamp, vitalStop.stopClocks.timeStamp),
context: (0, browser_core_1.combine)(vitalStart.context, vitalStop.context),
};
lifeCycle.notify(12 /* LifeCycleEventType.RAW_RUM_EVENT_COLLECTED */, processVital(vital));
vitalStartsByName.delete(vitalStop.name);
var vital = buildDurationVital(vitalStart, vitalStop);
vitalStartsByName.delete(vital.name);
if (isValid(vital)) {
lifeCycle.notify(12 /* LifeCycleEventType.RAW_RUM_EVENT_COLLECTED */, processVital(vital));
}
},

@@ -31,2 +34,11 @@ };

exports.startVitalCollection = startVitalCollection;
function buildDurationVital(vitalStart, vitalStop) {
return {
name: vitalStart.name,
type: "duration" /* VitalType.DURATION */,
startClocks: vitalStart.startClocks,
value: (0, browser_core_1.elapsed)(vitalStart.startClocks.timeStamp, vitalStop.stopClocks.timeStamp),
context: (0, browser_core_1.combine)(vitalStart.context, vitalStop.context),
};
}
function processVital(vital) {

@@ -33,0 +45,0 @@ var _a;

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

import { BoundedBuffer, display, canUseEventBridge, displayAlreadyInitializedError, willSyntheticsInjectRum, noop, timeStampNow, clocksNow, assign, } from '@datadog/browser-core';
import { BoundedBuffer, display, canUseEventBridge, displayAlreadyInitializedError, willSyntheticsInjectRum, noop, timeStampNow, clocksNow, assign, getEventBridge, } from '@datadog/browser-core';
import { validateAndBuildRumConfiguration, } from '../domain/configuration';

@@ -119,2 +119,3 @@ export function createPreStartStrategy(_a, getCommonContext, trackingConsentState, doStartRum) {

function overrideInitConfigurationForBridge(initConfiguration) {
var _a, _b;
return assign({}, initConfiguration, {

@@ -124,4 +125,5 @@ applicationId: '00000000-aaaa-0000-aaaa-000000000000',

sessionSampleRate: 100,
defaultPrivacyLevel: (_a = initConfiguration.defaultPrivacyLevel) !== null && _a !== void 0 ? _a : (_b = getEventBridge()) === null || _b === void 0 ? void 0 : _b.getPrivacyLevel(),
});
}
//# sourceMappingURL=preStartRum.js.map

@@ -85,3 +85,3 @@ import { sendToExtension, createPageExitObservable, addTelemetryConfiguration, startTelemetry, canUseEventBridge, getEventBridge, addTelemetryDebug, } from '@datadog/browser-core';

cleanupTasks.push(stopPerformanceCollection);
var vitalCollection = startVitalCollection(lifeCycle);
var vitalCollection = startVitalCollection(lifeCycle, pageStateHistory);
var internalContext = startInternalContext(configuration.applicationId, session, viewContexts, actionContexts, urlContexts);

@@ -88,0 +88,0 @@ return {

@@ -58,3 +58,3 @@ import { noop, assign, combine, toServerDuration, generateUUID } from '@datadog/browser-core';

type: "action" /* RumEventType.ACTION */,
view: { in_foreground: pageStateHistory.isInActivePageStateAt(action.startClocks.relative) },
view: { in_foreground: pageStateHistory.wasInPageStateAt("active" /* PageState.ACTIVE */, action.startClocks.relative) },
}, autoActionProperties);

@@ -61,0 +61,0 @@ return {

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

},
browser_sdk_version: canUseEventBridge() ? "5.10.0" : undefined,
browser_sdk_version: canUseEventBridge() ? "5.11.0" : undefined,
},

@@ -61,0 +61,0 @@ application: {

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

findAll: (startTime: RelativeTime, duration: Duration) => PageStateServerEntry[] | undefined;
isInActivePageStateAt: (startTime: RelativeTime) => boolean;
wasInPageStateAt: (state: PageState, startTime: RelativeTime) => boolean;
wasInPageStateDuringPeriod: (state: PageState, startTime: RelativeTime, duration: Duration) => boolean;
addPageState(nextPageState: PageState, startTime?: RelativeTime): void;

@@ -23,0 +24,0 @@ stop: () => void;

@@ -9,3 +9,3 @@ import { elapsed, ValueHistory, SESSION_TIME_OUT_DELAY, toServerDuration, addEventListeners, relativeNow, DOM_EVENT, } from '@datadog/browser-core';

if (maxPageStateEntriesSelectable === void 0) { maxPageStateEntriesSelectable = MAX_PAGE_STATE_ENTRIES_SELECTABLE; }
var pageStateHistory = new ValueHistory(PAGE_STATE_CONTEXT_TIME_OUT_DELAY, MAX_PAGE_STATE_ENTRIES);
var pageStateEntryHistory = new ValueHistory(PAGE_STATE_CONTEXT_TIME_OUT_DELAY, MAX_PAGE_STATE_ENTRIES);
var currentPageState;

@@ -30,8 +30,8 @@ addPageState(getPageState(), relativeNow());

currentPageState = nextPageState;
pageStateHistory.closeActive(startTime);
pageStateHistory.add({ state: currentPageState, startTime: startTime }, startTime);
pageStateEntryHistory.closeActive(startTime);
pageStateEntryHistory.add({ state: currentPageState, startTime: startTime }, startTime);
}
return {
var pageStateHistory = {
findAll: function (eventStartTime, duration) {
var pageStateEntries = pageStateHistory.findAll(eventStartTime, duration);
var pageStateEntries = pageStateEntryHistory.findAll(eventStartTime, duration);
if (pageStateEntries.length === 0) {

@@ -55,12 +55,15 @@ return;

},
isInActivePageStateAt: function (startTime) {
var pageStateEntry = pageStateHistory.find(startTime);
return pageStateEntry !== undefined && pageStateEntry.state === "active" /* PageState.ACTIVE */;
wasInPageStateAt: function (state, startTime) {
return pageStateHistory.wasInPageStateDuringPeriod(state, startTime, 0);
},
wasInPageStateDuringPeriod: function (state, startTime, duration) {
return pageStateEntryHistory.findAll(startTime, duration).some(function (pageState) { return pageState.state === state; });
},
addPageState: addPageState,
stop: function () {
stopEventListeners();
pageStateHistory.stop();
pageStateEntryHistory.stop();
},
};
return pageStateHistory;
}

@@ -67,0 +70,0 @@ function computePageState(event) {

@@ -57,3 +57,3 @@ import { isEmptyObject, assign, ErrorSource, generateUUID, computeRawError, computeStackTrace, Observable, trackRuntimeError, } from '@datadog/browser-core';

type: "error" /* RumEventType.ERROR */,
view: { in_foreground: pageStateHistory.isInActivePageStateAt(error.startClocks.relative) },
view: { in_foreground: pageStateHistory.wasInPageStateAt("active" /* PageState.ACTIVE */, error.startClocks.relative) },
};

@@ -60,0 +60,0 @@ var featureFlagContext = featureFlagContexts.findFeatureFlagEvaluations(error.startClocks.relative);

@@ -150,9 +150,8 @@ import { combine, generateUUID, toServerDuration, relativeToClocks, assign, isNumber, isExperimentalFeatureEnabled, ExperimentalFeature, } from '@datadog/browser-core';

function computeRequestDuration(pageStateHistory, startClocks, duration) {
var _a;
var requestCrossedFrozenState = (_a = pageStateHistory
.findAll(startClocks.relative, duration)) === null || _a === void 0 ? void 0 : _a.some(function (pageState) { return pageState.state === "frozen" /* PageState.FROZEN */; });
return !requestCrossedFrozenState ? toServerDuration(duration) : undefined;
return !pageStateHistory.wasInPageStateDuringPeriod("frozen" /* PageState.FROZEN */, startClocks.relative, duration)
? toServerDuration(duration)
: undefined;
}
/**
* The status is 0 for cross origin resources without CORS headers, so the status is meaningless and we shouldn't report it
* The status is 0 for cross-origin resources without CORS headers, so the status is meaningless, and we shouldn't report it
* https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStatus#cross-origin_response_status_codes

@@ -159,0 +158,0 @@ */

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

import { Observable, noop, performDraw, startSessionManager } from '@datadog/browser-core';
import { Observable, bridgeSupports, noop, performDraw, startSessionManager, } from '@datadog/browser-core';
export var RUM_SESSION_KEY = 'rum';

@@ -32,3 +32,3 @@ export function startRumSessionManager(configuration, lifeCycle, trackingConsentState) {

id: '00000000-aaaa-0000-aaaa-000000000000',
sessionReplayAllowed: false,
sessionReplayAllowed: bridgeSupports("records" /* BridgeCapability.RECORDS */),
};

@@ -35,0 +35,0 @@ return {

import type { ClocksState, Context } from '@datadog/browser-core';
import type { LifeCycle } from '../lifeCycle';
import type { PageStateHistory } from '../contexts/pageStateHistory';
export interface DurationVitalStart {

@@ -13,5 +14,5 @@ name: string;

}
export declare function startVitalCollection(lifeCycle: LifeCycle): {
export declare function startVitalCollection(lifeCycle: LifeCycle, pageStateHistory: PageStateHistory): {
startDurationVital: (vitalStart: DurationVitalStart) => void;
stopDurationVital: (vitalStop: DurationVitalStop) => void;
};
import { combine, elapsed, generateUUID } from '@datadog/browser-core';
export function startVitalCollection(lifeCycle) {
export function startVitalCollection(lifeCycle, pageStateHistory) {
var vitalStartsByName = new Map();
lifeCycle.subscribe(10 /* LifeCycleEventType.SESSION_RENEWED */, function () {
// Discard all the vitals that have not been stopped to avoid memory leaks
vitalStartsByName.clear();
});
function isValid(vital) {
return !pageStateHistory.wasInPageStateDuringPeriod("frozen" /* PageState.FROZEN */, vital.startClocks.relative, vital.value);
}
return {

@@ -13,14 +20,19 @@ startDurationVital: function (vitalStart) {

}
var vital = {
name: vitalStart.name,
type: "duration" /* VitalType.DURATION */,
startClocks: vitalStart.startClocks,
value: elapsed(vitalStart.startClocks.timeStamp, vitalStop.stopClocks.timeStamp),
context: combine(vitalStart.context, vitalStop.context),
};
lifeCycle.notify(12 /* LifeCycleEventType.RAW_RUM_EVENT_COLLECTED */, processVital(vital));
vitalStartsByName.delete(vitalStop.name);
var vital = buildDurationVital(vitalStart, vitalStop);
vitalStartsByName.delete(vital.name);
if (isValid(vital)) {
lifeCycle.notify(12 /* LifeCycleEventType.RAW_RUM_EVENT_COLLECTED */, processVital(vital));
}
},
};
}
function buildDurationVital(vitalStart, vitalStop) {
return {
name: vitalStart.name,
type: "duration" /* VitalType.DURATION */,
startClocks: vitalStart.startClocks,
value: elapsed(vitalStart.startClocks.timeStamp, vitalStop.stopClocks.timeStamp),
context: combine(vitalStart.context, vitalStop.context),
};
}
function processVital(vital) {

@@ -27,0 +39,0 @@ var _a;

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

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

"dependencies": {
"@datadog/browser-core": "5.10.0"
"@datadog/browser-core": "5.11.0"
},

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

},
"gitHead": "406566926cdbe6d4534be5a9774b973cb210d5e9"
"gitHead": "1e90f71c41375d4a9281b904207312c21c72b24a"
}

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

assign,
getEventBridge,
} from '@datadog/browser-core'

@@ -183,3 +184,4 @@ import type { TrackingConsentState, DeflateWorker } from '@datadog/browser-core'

sessionSampleRate: 100,
defaultPrivacyLevel: initConfiguration.defaultPrivacyLevel ?? getEventBridge()?.getPrivacyLevel(),
})
}

@@ -173,3 +173,3 @@ import type {

const vitalCollection = startVitalCollection(lifeCycle)
const vitalCollection = startVitalCollection(lifeCycle, pageStateHistory)
const internalContext = startInternalContext(

@@ -176,0 +176,0 @@ configuration.applicationId,

@@ -11,2 +11,3 @@ import type { ClocksState, Context, Observable } from '@datadog/browser-core'

import type { PageStateHistory } from '../contexts/pageStateHistory'
import { PageState } from '../contexts/pageStateHistory'
import type { ActionContexts, ClickAction } from './trackClickActions'

@@ -99,3 +100,3 @@ import { trackClickActions } from './trackClickActions'

type: RumEventType.ACTION as const,
view: { in_foreground: pageStateHistory.isInActivePageStateAt(action.startClocks.relative) },
view: { in_foreground: pageStateHistory.wasInPageStateAt(PageState.ACTIVE, action.startClocks.relative) },
},

@@ -102,0 +103,0 @@ autoActionProperties

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

const ciTestContext = getCiTestContext()
lifeCycle.subscribe(

@@ -129,0 +128,0 @@ LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,

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

findAll: (startTime: RelativeTime, duration: Duration) => PageStateServerEntry[] | undefined
isInActivePageStateAt: (startTime: RelativeTime) => boolean
wasInPageStateAt: (state: PageState, startTime: RelativeTime) => boolean
wasInPageStateDuringPeriod: (state: PageState, startTime: RelativeTime, duration: Duration) => boolean
addPageState(nextPageState: PageState, startTime?: RelativeTime): void

@@ -43,3 +44,6 @@ stop: () => void

): PageStateHistory {
const pageStateHistory = new ValueHistory<PageStateEntry>(PAGE_STATE_CONTEXT_TIME_OUT_DELAY, MAX_PAGE_STATE_ENTRIES)
const pageStateEntryHistory = new ValueHistory<PageStateEntry>(
PAGE_STATE_CONTEXT_TIME_OUT_DELAY,
MAX_PAGE_STATE_ENTRIES
)

@@ -73,9 +77,9 @@ let currentPageState: PageState

currentPageState = nextPageState
pageStateHistory.closeActive(startTime)
pageStateHistory.add({ state: currentPageState, startTime }, startTime)
pageStateEntryHistory.closeActive(startTime)
pageStateEntryHistory.add({ state: currentPageState, startTime }, startTime)
}
return {
const pageStateHistory = {
findAll: (eventStartTime: RelativeTime, duration: Duration): PageStateServerEntry[] | undefined => {
const pageStateEntries = pageStateHistory.findAll(eventStartTime, duration)
const pageStateEntries = pageStateEntryHistory.findAll(eventStartTime, duration)

@@ -104,12 +108,13 @@ if (pageStateEntries.length === 0) {

},
isInActivePageStateAt: (startTime: RelativeTime) => {
const pageStateEntry = pageStateHistory.find(startTime)
return pageStateEntry !== undefined && pageStateEntry.state === PageState.ACTIVE
},
wasInPageStateAt: (state: PageState, startTime: RelativeTime) =>
pageStateHistory.wasInPageStateDuringPeriod(state, startTime, 0 as Duration),
wasInPageStateDuringPeriod: (state: PageState, startTime: RelativeTime, duration: Duration) =>
pageStateEntryHistory.findAll(startTime, duration).some((pageState) => pageState.state === state),
addPageState,
stop: () => {
stopEventListeners()
pageStateHistory.stop()
pageStateEntryHistory.stop()
},
}
return pageStateHistory
}

@@ -116,0 +121,0 @@

@@ -22,2 +22,3 @@ import type { Context, RawError, ClocksState } from '@datadog/browser-core'

import type { PageStateHistory } from '../contexts/pageStateHistory'
import { PageState } from '../contexts/pageStateHistory'
import { trackConsoleError } from './trackConsoleError'

@@ -113,3 +114,3 @@ import { trackReportError } from './trackReportError'

type: RumEventType.ERROR as const,
view: { in_foreground: pageStateHistory.isInActivePageStateAt(error.startClocks.relative) },
view: { in_foreground: pageStateHistory.wasInPageStateAt(PageState.ACTIVE, error.startClocks.relative) },
}

@@ -116,0 +117,0 @@

@@ -24,2 +24,3 @@ import type { Context, PageExitEvent, RawError, RelativeTime } from '@datadog/browser-core'

REQUEST_COMPLETED,
// The SESSION_EXPIRED lifecycle event has been introduced to represent when a session has expired

@@ -26,0 +27,0 @@ // and trigger cleanup tasks related to this, prior to renewing the session. Its implementation is

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

import type { ClocksState, Duration } from '@datadog/browser-core'
import {

@@ -13,3 +14,2 @@ combine,

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

@@ -233,11 +233,9 @@ import type { RumPerformanceResourceTiming } from '../../browser/performanceCollection'

function computeRequestDuration(pageStateHistory: PageStateHistory, startClocks: ClocksState, duration: Duration) {
const requestCrossedFrozenState = pageStateHistory
.findAll(startClocks.relative, duration)
?.some((pageState) => pageState.state === PageState.FROZEN)
return !requestCrossedFrozenState ? toServerDuration(duration) : undefined
return !pageStateHistory.wasInPageStateDuringPeriod(PageState.FROZEN, startClocks.relative, duration)
? toServerDuration(duration)
: undefined
}
/**
* The status is 0 for cross origin resources without CORS headers, so the status is meaningless and we shouldn't report it
* The status is 0 for cross-origin resources without CORS headers, so the status is meaningless, and we shouldn't report it
* https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStatus#cross-origin_response_status_codes

@@ -244,0 +242,0 @@ */

import type { RelativeTime, TrackingConsentState } from '@datadog/browser-core'
import { Observable, noop, performDraw, startSessionManager } from '@datadog/browser-core'
import {
BridgeCapability,
Observable,
bridgeSupports,
noop,
performDraw,
startSessionManager,
} from '@datadog/browser-core'
import type { RumConfiguration } from './configuration'

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

id: '00000000-aaaa-0000-aaaa-000000000000',
sessionReplayAllowed: false,
sessionReplayAllowed: bridgeSupports(BridgeCapability.RECORDS),
}

@@ -71,0 +78,0 @@ return {

import type { ClocksState, Duration, Context } from '@datadog/browser-core'
import { combine, elapsed, generateUUID } from '@datadog/browser-core'
import type { LifeCycle, RawRumEventCollectedData } from '../lifeCycle'
import { LifeCycleEventType } from '../lifeCycle'
import type { LifeCycle, RawRumEventCollectedData } from '../lifeCycle'
import type { RawRumVitalEvent } from '../../rawRumEvent.types'
import { RumEventType, VitalType } from '../../rawRumEvent.types'
import type { PageStateHistory } from '../contexts/pageStateHistory'
import { PageState } from '../contexts/pageStateHistory'

@@ -28,4 +30,14 @@ export interface DurationVitalStart {

export function startVitalCollection(lifeCycle: LifeCycle) {
export function startVitalCollection(lifeCycle: LifeCycle, pageStateHistory: PageStateHistory) {
const vitalStartsByName = new Map<string, DurationVitalStart>()
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, () => {
// Discard all the vitals that have not been stopped to avoid memory leaks
vitalStartsByName.clear()
})
function isValid(vital: DurationVital) {
return !pageStateHistory.wasInPageStateDuringPeriod(PageState.FROZEN, vital.startClocks.relative, vital.value)
}
return {

@@ -40,11 +52,7 @@ startDurationVital: (vitalStart: DurationVitalStart) => {

}
const vital = {
name: vitalStart.name,
type: VitalType.DURATION,
startClocks: vitalStart.startClocks,
value: elapsed(vitalStart.startClocks.timeStamp, vitalStop.stopClocks.timeStamp),
context: combine(vitalStart.context, vitalStop.context),
const vital = buildDurationVital(vitalStart, vitalStop)
vitalStartsByName.delete(vital.name)
if (isValid(vital)) {
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processVital(vital))
}
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processVital(vital))
vitalStartsByName.delete(vitalStop.name)
},

@@ -54,2 +62,12 @@ }

function buildDurationVital(vitalStart: DurationVitalStart, vitalStop: DurationVitalStop) {
return {
name: vitalStart.name,
type: VitalType.DURATION,
startClocks: vitalStart.startClocks,
value: elapsed(vitalStart.startClocks.timeStamp, vitalStop.stopClocks.timeStamp),
context: combine(vitalStart.context, vitalStop.context),
}
}
function processVital(vital: DurationVital): RawRumEventCollectedData<RawRumVitalEvent> {

@@ -56,0 +74,0 @@ return {

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