Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 4.14.0 to 4.15.0

3

cjs/boot/rumPublicApi.js

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

var browser_core_1 = require("@datadog/browser-core");
var syntheticsContext_1 = require("../domain/contexts/syntheticsContext");
var configuration_1 = require("../domain/configuration");

@@ -43,3 +42,3 @@ function makeRumPublicApi(startRumImpl, recorderApi, _a) {

// internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
if (ignoreInitIfSyntheticsWillInjectRum && (0, syntheticsContext_1.willSyntheticsInjectRum)()) {
if (ignoreInitIfSyntheticsWillInjectRum && (0, browser_core_1.willSyntheticsInjectRum)()) {
return;

@@ -46,0 +45,0 @@ }

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

},
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.14.0" : undefined,
browser_sdk_version: (0, browser_core_1.canUseEventBridge)() ? "4.15.0" : undefined,
},

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

@@ -1,9 +0,1 @@

export declare const SYNTHETICS_TEST_ID_COOKIE_NAME = "datadog-synthetics-public-id";
export declare const SYNTHETICS_RESULT_ID_COOKIE_NAME = "datadog-synthetics-result-id";
export declare const SYNTHETICS_INJECTS_RUM_COOKIE_NAME = "datadog-synthetics-injects-rum";
export interface BrowserWindow extends Window {
_DATADOG_SYNTHETICS_PUBLIC_ID?: string;
_DATADOG_SYNTHETICS_RESULT_ID?: string;
_DATADOG_SYNTHETICS_INJECTS_RUM?: boolean;
}
export declare function getSyntheticsContext(): {

@@ -14,2 +6,1 @@ test_id: string;

} | undefined;
export declare function willSyntheticsInjectRum(): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.willSyntheticsInjectRum = exports.getSyntheticsContext = exports.SYNTHETICS_INJECTS_RUM_COOKIE_NAME = exports.SYNTHETICS_RESULT_ID_COOKIE_NAME = exports.SYNTHETICS_TEST_ID_COOKIE_NAME = void 0;
exports.getSyntheticsContext = void 0;
var browser_core_1 = require("@datadog/browser-core");
exports.SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id';
exports.SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id';
exports.SYNTHETICS_INJECTS_RUM_COOKIE_NAME = 'datadog-synthetics-injects-rum';
function getSyntheticsContext() {
var testId = window._DATADOG_SYNTHETICS_PUBLIC_ID || (0, browser_core_1.getCookie)(exports.SYNTHETICS_TEST_ID_COOKIE_NAME);
var resultId = window._DATADOG_SYNTHETICS_RESULT_ID || (0, browser_core_1.getCookie)(exports.SYNTHETICS_RESULT_ID_COOKIE_NAME);
if (typeof testId === 'string' && typeof resultId === 'string') {
var testId = (0, browser_core_1.getSyntheticsTestId)();
var resultId = (0, browser_core_1.getSyntheticsResultId)();
if (testId && resultId) {
return {
test_id: testId,
result_id: resultId,
injected: willSyntheticsInjectRum(),
injected: (0, browser_core_1.willSyntheticsInjectRum)(),
};

@@ -20,6 +17,2 @@ }

exports.getSyntheticsContext = getSyntheticsContext;
function willSyntheticsInjectRum() {
return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM || (0, browser_core_1.getCookie)(exports.SYNTHETICS_INJECTS_RUM_COOKIE_NAME));
}
exports.willSyntheticsInjectRum = willSyntheticsInjectRum;
//# sourceMappingURL=syntheticsContext.js.map

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

var pendingRequestsCount = 0;
subscriptions.push(domMutationObservable.subscribe(function () { return notifyPageActivity(pendingRequestsCount); }), lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
subscriptions.push(domMutationObservable.subscribe(notifyPageActivity), lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
if (entries.some(function (entry) { return entry.entryType === 'resource' && !isExcludedUrl(configuration, entry.name); })) {
notifyPageActivity(pendingRequestsCount);
notifyPageActivity();
}

@@ -93,3 +93,4 @@ }), lifeCycle.subscribe(5 /* REQUEST_STARTED */, function (startEvent) {

}
notifyPageActivity(++pendingRequestsCount);
pendingRequestsCount += 1;
notifyPageActivity();
}), lifeCycle.subscribe(6 /* REQUEST_COMPLETED */, function (request) {

@@ -102,9 +103,14 @@ if (isExcludedUrl(configuration, request.url) ||

}
notifyPageActivity(--pendingRequestsCount);
pendingRequestsCount -= 1;
notifyPageActivity();
}));
return function () { return subscriptions.forEach(function (s) { return s.unsubscribe(); }); };
var stopTrackingWindowOpen = trackWindowOpen(notifyPageActivity).stop;
return function () {
stopTrackingWindowOpen();
subscriptions.forEach(function (s) { return s.unsubscribe(); });
};
function notifyPageActivity() {
observable.notify({ isBusy: pendingRequestsCount > 0 });
}
});
function notifyPageActivity(pendingRequestsCount) {
observable.notify({ isBusy: pendingRequestsCount > 0 });
}
return observable;

@@ -116,2 +122,5 @@ }

}
function trackWindowOpen(callback) {
return (0, browser_core_1.instrumentMethodAndCallOriginal)(window, 'open', { before: callback });
}
//# sourceMappingURL=waitPageActivityEnd.js.map

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

import { assign, BoundedBuffer, buildCookieOptions, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, areCookiesAuthorized, } from '@datadog/browser-core';
import { willSyntheticsInjectRum } from '../domain/contexts/syntheticsContext';
import { willSyntheticsInjectRum, assign, BoundedBuffer, buildCookieOptions, createContextManager, deepClone, makePublicApi, monitor, clocksNow, timeStampNow, display, callMonitored, createHandlingStack, canUseEventBridge, areCookiesAuthorized, } from '@datadog/browser-core';
import { validateAndBuildRumConfiguration } from '../domain/configuration';

@@ -4,0 +3,0 @@ export function makeRumPublicApi(startRumImpl, recorderApi, _a) {

@@ -48,3 +48,3 @@ import { combine, isEmptyObject, limitModification, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, } from '@datadog/browser-core';

},
browser_sdk_version: canUseEventBridge() ? "4.14.0" : undefined,
browser_sdk_version: canUseEventBridge() ? "4.15.0" : undefined,
},

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

@@ -1,9 +0,1 @@

export declare const SYNTHETICS_TEST_ID_COOKIE_NAME = "datadog-synthetics-public-id";
export declare const SYNTHETICS_RESULT_ID_COOKIE_NAME = "datadog-synthetics-result-id";
export declare const SYNTHETICS_INJECTS_RUM_COOKIE_NAME = "datadog-synthetics-injects-rum";
export interface BrowserWindow extends Window {
_DATADOG_SYNTHETICS_PUBLIC_ID?: string;
_DATADOG_SYNTHETICS_RESULT_ID?: string;
_DATADOG_SYNTHETICS_INJECTS_RUM?: boolean;
}
export declare function getSyntheticsContext(): {

@@ -14,2 +6,1 @@ test_id: string;

} | undefined;
export declare function willSyntheticsInjectRum(): boolean;

@@ -1,9 +0,6 @@

import { getCookie } from '@datadog/browser-core';
export var SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id';
export var SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id';
export var SYNTHETICS_INJECTS_RUM_COOKIE_NAME = 'datadog-synthetics-injects-rum';
import { getSyntheticsResultId, getSyntheticsTestId, willSyntheticsInjectRum } from '@datadog/browser-core';
export function getSyntheticsContext() {
var testId = window._DATADOG_SYNTHETICS_PUBLIC_ID || getCookie(SYNTHETICS_TEST_ID_COOKIE_NAME);
var resultId = window._DATADOG_SYNTHETICS_RESULT_ID || getCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME);
if (typeof testId === 'string' && typeof resultId === 'string') {
var testId = getSyntheticsTestId();
var resultId = getSyntheticsResultId();
if (testId && resultId) {
return {

@@ -16,5 +13,2 @@ test_id: testId,

}
export function willSyntheticsInjectRum() {
return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM || getCookie(SYNTHETICS_INJECTS_RUM_COOKIE_NAME));
}
//# sourceMappingURL=syntheticsContext.js.map

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

import { matchList, monitor, Observable, timeStampNow } from '@datadog/browser-core';
import { instrumentMethodAndCallOriginal, matchList, monitor, Observable, timeStampNow } from '@datadog/browser-core';
// Delay to wait for a page activity to validate the tracking process

@@ -76,5 +76,5 @@ export var PAGE_ACTIVITY_VALIDATION_DELAY = 100;

var pendingRequestsCount = 0;
subscriptions.push(domMutationObservable.subscribe(function () { return notifyPageActivity(pendingRequestsCount); }), lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
subscriptions.push(domMutationObservable.subscribe(notifyPageActivity), lifeCycle.subscribe(0 /* PERFORMANCE_ENTRIES_COLLECTED */, function (entries) {
if (entries.some(function (entry) { return entry.entryType === 'resource' && !isExcludedUrl(configuration, entry.name); })) {
notifyPageActivity(pendingRequestsCount);
notifyPageActivity();
}

@@ -88,3 +88,4 @@ }), lifeCycle.subscribe(5 /* REQUEST_STARTED */, function (startEvent) {

}
notifyPageActivity(++pendingRequestsCount);
pendingRequestsCount += 1;
notifyPageActivity();
}), lifeCycle.subscribe(6 /* REQUEST_COMPLETED */, function (request) {

@@ -97,9 +98,14 @@ if (isExcludedUrl(configuration, request.url) ||

}
notifyPageActivity(--pendingRequestsCount);
pendingRequestsCount -= 1;
notifyPageActivity();
}));
return function () { return subscriptions.forEach(function (s) { return s.unsubscribe(); }); };
var stopTrackingWindowOpen = trackWindowOpen(notifyPageActivity).stop;
return function () {
stopTrackingWindowOpen();
subscriptions.forEach(function (s) { return s.unsubscribe(); });
};
function notifyPageActivity() {
observable.notify({ isBusy: pendingRequestsCount > 0 });
}
});
function notifyPageActivity(pendingRequestsCount) {
observable.notify({ isBusy: pendingRequestsCount > 0 });
}
return observable;

@@ -110,2 +116,5 @@ }

}
function trackWindowOpen(callback) {
return instrumentMethodAndCallOriginal(window, 'open', { before: callback });
}
//# sourceMappingURL=waitPageActivityEnd.js.map
{
"name": "@datadog/browser-rum-core",
"version": "4.14.0",
"version": "4.15.0",
"license": "Apache-2.0",

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

"dependencies": {
"@datadog/browser-core": "4.14.0"
"@datadog/browser-core": "4.15.0"
},

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

},
"gitHead": "80e51d802ddb40b5832a15f6e66d274b91f2a27c"
"gitHead": "66918992b8d349b6d76a509b5442fff51aa59225"
}
import type { RelativeTime, TimeStamp } from '@datadog/browser-core'
import { ONE_SECOND, getTimeStamp, display, DefaultPrivacyLevel } from '@datadog/browser-core'
import { cleanupSyntheticsWorkerValues, mockSyntheticsWorkerValues } from '../../../core/test/syntheticsWorkerValues'
import { initEventBridgeStub, deleteEventBridgeStub } from '../../../core/test/specHelper'
import type { TestSetupBuilder } from '../../test/specHelper'
import {
cleanupSyntheticsWorkerValues,
mockSyntheticsWorkerValues,
noopRecorderApi,
setup,
} from '../../test/specHelper'
import { noopRecorderApi, setup } from '../../test/specHelper'
import type { HybridInitConfiguration, RumInitConfiguration } from '../domain/configuration'

@@ -12,0 +8,0 @@ import { ActionType } from '../rawRumEvent.types'

import type { Context, InitConfiguration, TimeStamp, RelativeTime } from '@datadog/browser-core'
import {
willSyntheticsInjectRum,
assign,

@@ -23,3 +24,2 @@ BoundedBuffer,

import { ActionType } from '../rawRumEvent.types'
import { willSyntheticsInjectRum } from '../domain/contexts/syntheticsContext'
import type { RumConfiguration, RumInitConfiguration } from '../domain/configuration'

@@ -26,0 +26,0 @@ import { validateAndBuildRumConfiguration } from '../domain/configuration'

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

import type { TestSetupBuilder } from '../../test/specHelper'
import {
cleanupSyntheticsWorkerValues,
mockSyntheticsWorkerValues,
mockCiVisibilityWindowValues,
cleanupCiVisibilityWindowValues,
setup,
} from '../../test/specHelper'
import { mockCiVisibilityWindowValues, cleanupCiVisibilityWindowValues, setup } from '../../test/specHelper'
import type { RumEventDomainContext } from '../domainContext.types'

@@ -19,2 +13,3 @@ import type { CommonContext, RawRumActionEvent, RawRumErrorEvent, RawRumEvent } from '../rawRumEvent.types'

import { initEventBridgeStub, deleteEventBridgeStub } from '../../../core/test/specHelper'
import { cleanupSyntheticsWorkerValues, mockSyntheticsWorkerValues } from '../../../core/test/syntheticsWorkerValues'
import { startRumAssembly } from './assembly'

@@ -21,0 +16,0 @@ import type { LifeCycle, RawRumEventCollectedData } from './lifeCycle'

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

import { mockSyntheticsWorkerValues, cleanupSyntheticsWorkerValues } from '../../../test/specHelper'
import { getSyntheticsContext, willSyntheticsInjectRum } from './syntheticsContext'
import { cleanupSyntheticsWorkerValues, mockSyntheticsWorkerValues } from '../../../../core/test/syntheticsWorkerValues'
import { getSyntheticsContext } from './syntheticsContext'

@@ -53,31 +53,1 @@ describe('getSyntheticsContext', () => {

})
describe('willSyntheticsInjectRum', () => {
afterEach(() => {
cleanupSyntheticsWorkerValues()
})
it('returns false if nothing is defined', () => {
mockSyntheticsWorkerValues({}, 'globals')
expect(willSyntheticsInjectRum()).toBeFalse()
})
it('returns false if the INJECTS_RUM global variable is false', () => {
mockSyntheticsWorkerValues({ injectsRum: false }, 'globals')
expect(willSyntheticsInjectRum()).toBeFalse()
})
it('returns true if the INJECTS_RUM global variable is truthy', () => {
mockSyntheticsWorkerValues({ injectsRum: true }, 'globals')
expect(willSyntheticsInjectRum()).toBeTrue()
})
it('returns true if the INJECTS_RUM cookie is truthy', () => {
mockSyntheticsWorkerValues({ injectsRum: true }, 'cookies')
expect(willSyntheticsInjectRum()).toBeTrue()
})
})

@@ -1,19 +0,8 @@

import { getCookie } from '@datadog/browser-core'
import { getSyntheticsResultId, getSyntheticsTestId, willSyntheticsInjectRum } from '@datadog/browser-core'
export const SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id'
export const SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id'
export const SYNTHETICS_INJECTS_RUM_COOKIE_NAME = 'datadog-synthetics-injects-rum'
export interface BrowserWindow extends Window {
_DATADOG_SYNTHETICS_PUBLIC_ID?: string
_DATADOG_SYNTHETICS_RESULT_ID?: string
_DATADOG_SYNTHETICS_INJECTS_RUM?: boolean
}
export function getSyntheticsContext() {
const testId = (window as BrowserWindow)._DATADOG_SYNTHETICS_PUBLIC_ID || getCookie(SYNTHETICS_TEST_ID_COOKIE_NAME)
const resultId =
(window as BrowserWindow)._DATADOG_SYNTHETICS_RESULT_ID || getCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME)
const testId = getSyntheticsTestId()
const resultId = getSyntheticsResultId()
if (typeof testId === 'string' && typeof resultId === 'string') {
if (testId && resultId) {
return {

@@ -26,7 +15,1 @@ test_id: testId,

}
export function willSyntheticsInjectRum() {
return Boolean(
(window as BrowserWindow)._DATADOG_SYNTHETICS_INJECTS_RUM || getCookie(SYNTHETICS_INJECTS_RUM_COOKIE_NAME)
)
}

@@ -77,15 +77,5 @@ import type { RelativeTime, Subscription } from '@datadog/browser-core'

it('emits an activity event on resource collected', () => {
it('does not emit an activity event when a navigation occurs', () => {
const { lifeCycle } = setupBuilder.build()
const performanceTiming = {
entryType: 'resource',
name: EXCLUDED_FAKE_URL,
} as RumPerformanceResourceTiming
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, [performanceTiming])
expect(events).toEqual([])
})
it('ignores resources that should be excluded by configuration', () => {
const { lifeCycle } = setupBuilder.build()
const performanceTiming = {
entryType: 'navigation',

@@ -97,2 +87,9 @@ } as RumPerformanceNavigationTiming

it('emits an activity event when `window.open` is used', () => {
spyOn(window, 'open')
setupBuilder.build()
window.open('toto')
expect(events).toEqual([{ isBusy: false }])
})
it('stops emitting activities after calling stop()', () => {

@@ -142,2 +139,12 @@ const { domMutationObservable } = setupBuilder.build()

describe('excludedActivityUrls', () => {
it('ignores resources that should be excluded by configuration', () => {
const { lifeCycle } = setupBuilder.build()
const performanceTiming = {
entryType: 'resource',
name: EXCLUDED_FAKE_URL,
} as RumPerformanceResourceTiming
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, [performanceTiming])
expect(events).toEqual([])
})
it('ignores requests that should be excluded by configuration', () => {

@@ -144,0 +151,0 @@ const { lifeCycle } = setupBuilder.build()

import type { Subscription, TimeoutId, TimeStamp } from '@datadog/browser-core'
import { matchList, monitor, Observable, timeStampNow } from '@datadog/browser-core'
import { instrumentMethodAndCallOriginal, matchList, monitor, Observable, timeStampNow } from '@datadog/browser-core'
import type { RumConfiguration } from './configuration'

@@ -119,6 +119,6 @@ import type { LifeCycle } from './lifeCycle'

subscriptions.push(
domMutationObservable.subscribe(() => notifyPageActivity(pendingRequestsCount)),
domMutationObservable.subscribe(notifyPageActivity),
lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, (entries) => {
if (entries.some((entry) => entry.entryType === 'resource' && !isExcludedUrl(configuration, entry.name))) {
notifyPageActivity(pendingRequestsCount)
notifyPageActivity()
}

@@ -133,4 +133,4 @@ }),

}
notifyPageActivity(++pendingRequestsCount)
pendingRequestsCount += 1
notifyPageActivity()
}),

@@ -146,13 +146,19 @@ lifeCycle.subscribe(LifeCycleEventType.REQUEST_COMPLETED, (request) => {

}
notifyPageActivity(--pendingRequestsCount)
pendingRequestsCount -= 1
notifyPageActivity()
})
)
return () => subscriptions.forEach((s) => s.unsubscribe())
const { stop: stopTrackingWindowOpen } = trackWindowOpen(notifyPageActivity)
return () => {
stopTrackingWindowOpen()
subscriptions.forEach((s) => s.unsubscribe())
}
function notifyPageActivity() {
observable.notify({ isBusy: pendingRequestsCount > 0 })
}
})
function notifyPageActivity(pendingRequestsCount: number) {
observable.notify({ isBusy: pendingRequestsCount > 0 })
}
return observable

@@ -164,1 +170,5 @@ }

}
function trackWindowOpen(callback: () => void) {
return instrumentMethodAndCallOriginal(window, 'open', { before: callback })
}

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