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

@datadog/browser-rum-core

Package Overview
Dependencies
Maintainers
1
Versions
182
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 3.8.0 to 3.9.0

cjs/domain/syntheticsContext.d.ts

2

cjs/boot/buildEnv.js

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

buildMode: 'release',
sdkVersion: '3.8.0',
sdkVersion: '3.9.0',
};
//# sourceMappingURL=buildEnv.js.map

@@ -25,3 +25,6 @@ import { Context, InitConfiguration, Configuration, InternalMonitoring, DefaultPrivacyLevel } from '@datadog/browser-core';

}
export declare function makeRumPublicApi<C extends RumInitConfiguration>(startRumImpl: StartRum<C>, recorderApi: RecorderApi): {
interface RumPublicApiOptions {
ignoreInitIfSyntheticsWillInjectRum?: boolean;
}
export declare function makeRumPublicApi<C extends RumInitConfiguration>(startRumImpl: StartRum<C>, recorderApi: RecorderApi, { ignoreInitIfSyntheticsWillInjectRum }?: RumPublicApiOptions): {
init: (initConfiguration: C) => void;

@@ -28,0 +31,0 @@ addRumGlobalContext: (key: string, value: any) => void;

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

var rawRumEvent_types_1 = require("../rawRumEvent.types");
var syntheticsContext_1 = require("../domain/syntheticsContext");
var buildEnv_1 = require("./buildEnv");
function makeRumPublicApi(startRumImpl, recorderApi) {
function makeRumPublicApi(startRumImpl, recorderApi, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.ignoreInitIfSyntheticsWillInjectRum, ignoreInitIfSyntheticsWillInjectRum = _c === void 0 ? true : _c;
var isAlreadyInitialized = false;

@@ -39,2 +41,9 @@ var globalContextManager = browser_core_1.createContextManager();

function initRum(initConfiguration) {
// If we are in a Synthetics test configured to automatically inject a RUM instance, we want to
// completely discard the customer application RUM instance by ignoring their init() call. But,
// we should not ignore the init() call from the Synthetics-injected RUM instance, so the
// internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
if (ignoreInitIfSyntheticsWillInjectRum && syntheticsContext_1.willSyntheticsInjectRum()) {
return;
}
if (browser_core_1.canUseEventBridge()) {

@@ -41,0 +50,0 @@ initConfiguration = overrideInitConfigurationForBridge(initConfiguration);

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

var rumSession_1 = require("../domain/rumSession");
var batch_1 = require("../transport/batch");
var startRumBatch_1 = require("../transport/startRumBatch");
var startRumEventBridge_1 = require("../transport/startRumEventBridge");

@@ -65,3 +65,3 @@ var urlContexts_1 = require("../domain/urlContexts");

;
(stopBatch = batch_1.startRumBatch(configuration, lifeCycle).stop);
(stopBatch = startRumBatch_1.startRumBatch(configuration, lifeCycle).stop);
}

@@ -68,0 +68,0 @@ assembly_1.startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, urlContexts, getCommonContext);

@@ -7,8 +7,2 @@ import { Configuration } from '@datadog/browser-core';

import { UrlContexts } from './urlContexts';
export interface BrowserWindow extends Window {
_DATADOG_SYNTHETICS_PUBLIC_ID?: string;
_DATADOG_SYNTHETICS_RESULT_ID?: string;
}
export declare function startRumAssembly(applicationId: string, configuration: Configuration, lifeCycle: LifeCycle, session: RumSession, parentContexts: ParentContexts, urlContexts: UrlContexts, getCommonContext: () => CommonContext): void;
export declare const SYNTHETICS_TEST_ID_COOKIE_NAME = "datadog-synthetics-public-id";
export declare const SYNTHETICS_RESULT_ID_COOKIE_NAME = "datadog-synthetics-result-id";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SYNTHETICS_RESULT_ID_COOKIE_NAME = exports.SYNTHETICS_TEST_ID_COOKIE_NAME = exports.startRumAssembly = void 0;
exports.startRumAssembly = void 0;
var tslib_1 = require("tslib");
var browser_core_1 = require("@datadog/browser-core");
var rawRumEvent_types_1 = require("../rawRumEvent.types");
var buildEnv_1 = require("../boot/buildEnv");
var syntheticsContext_1 = require("./syntheticsContext");
var lifeCycle_1 = require("./lifeCycle");

@@ -37,3 +39,3 @@ var rumSession_1 = require("./rumSession");

_a);
var syntheticsContext = getSyntheticsContext();
var syntheticsContext = syntheticsContext_1.getSyntheticsContext();
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (_a) {

@@ -53,2 +55,3 @@ var startTime = _a.startTime, rawRumEvent = _a.rawRumEvent, domainContext = _a.domainContext, savedCommonContext = _a.savedCommonContext, customerContext = _a.customerContext;

},
browser_sdk_version: browser_core_1.canUseEventBridge() ? buildEnv_1.buildEnv.sdkVersion : undefined,
},

@@ -104,14 +107,2 @@ application: {

}
exports.SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id';
exports.SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id';
function getSyntheticsContext() {
var testId = window._DATADOG_SYNTHETICS_PUBLIC_ID || browser_core_1.getCookie(exports.SYNTHETICS_TEST_ID_COOKIE_NAME);
var resultId = window._DATADOG_SYNTHETICS_RESULT_ID || browser_core_1.getCookie(exports.SYNTHETICS_RESULT_ID_COOKIE_NAME);
if (typeof testId === 'string' && typeof resultId === 'string') {
return {
test_id: testId,
result_id: resultId,
};
}
}
//# sourceMappingURL=assembly.js.map

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

var browser_core_1 = require("@datadog/browser-core");
var contextHistory_1 = require("../tools/contextHistory");
var lifeCycle_1 = require("./lifeCycle");
var contextHistory_1 = require("./contextHistory");
exports.VIEW_CONTEXT_TIME_OUT_DELAY = browser_core_1.SESSION_TIME_OUT_DELAY;

@@ -9,0 +9,0 @@ exports.ACTION_CONTEXT_TIME_OUT_DELAY = 5 * browser_core_1.ONE_MINUTE; // arbitrary

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

var browser_core_1 = require("@datadog/browser-core");
var contextHistory_1 = require("./contextHistory");
var contextHistory_1 = require("../tools/contextHistory");
var lifeCycle_1 = require("./lifeCycle");

@@ -8,0 +8,0 @@ /**

@@ -163,2 +163,3 @@ import { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp } from '@datadog/browser-core';

};
browser_sdk_version?: string;
};

@@ -165,0 +166,0 @@ }

@@ -141,2 +141,6 @@ /**

/**
* Source type of the error (the language or platform impacting the error stacktrace format)
*/
readonly source_type?: 'android' | 'browser' | 'ios' | 'react-native';
/**
* Resource properties of the error

@@ -258,3 +262,3 @@ */

*/
readonly type: 'document' | 'xhr' | 'beacon' | 'fetch' | 'css' | 'js' | 'image' | 'font' | 'media' | 'other';
readonly type: 'document' | 'xhr' | 'beacon' | 'fetch' | 'css' | 'js' | 'image' | 'font' | 'media' | 'other' | 'native';
/**

@@ -716,2 +720,6 @@ * HTTP method of the resource

readonly result_id: string;
/**
* Whether the event comes from a SDK instance injected by Synthetics
*/
readonly injected?: boolean;
[k: string]: unknown;

@@ -737,2 +745,6 @@ };

};
/**
* Browser SDK version
*/
readonly browser_sdk_version?: string;
[k: string]: unknown;

@@ -739,0 +751,0 @@ };

export var buildEnv = {
buildMode: 'release',
sdkVersion: '3.8.0',
sdkVersion: '3.9.0',
};
//# sourceMappingURL=buildEnv.js.map

@@ -25,3 +25,6 @@ import { Context, InitConfiguration, Configuration, InternalMonitoring, DefaultPrivacyLevel } from '@datadog/browser-core';

}
export declare function makeRumPublicApi<C extends RumInitConfiguration>(startRumImpl: StartRum<C>, recorderApi: RecorderApi): {
interface RumPublicApiOptions {
ignoreInitIfSyntheticsWillInjectRum?: boolean;
}
export declare function makeRumPublicApi<C extends RumInitConfiguration>(startRumImpl: StartRum<C>, recorderApi: RecorderApi, { ignoreInitIfSyntheticsWillInjectRum }?: RumPublicApiOptions): {
init: (initConfiguration: C) => void;

@@ -28,0 +31,0 @@ addRumGlobalContext: (key: string, value: any) => void;

import { __assign } from "tslib";
import { BoundedBuffer, buildCookieOptions, createContextManager, deepClone, isPercentage, makePublicApi, monitor, clocksNow, timeStampNow, display, commonInit, callMonitored, createHandlingStack, canUseEventBridge, areCookiesAuthorized, } from '@datadog/browser-core';
import { ActionType } from '../rawRumEvent.types';
import { willSyntheticsInjectRum } from '../domain/syntheticsContext';
import { buildEnv } from './buildEnv';
export function makeRumPublicApi(startRumImpl, recorderApi) {
export function makeRumPublicApi(startRumImpl, recorderApi, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.ignoreInitIfSyntheticsWillInjectRum, ignoreInitIfSyntheticsWillInjectRum = _c === void 0 ? true : _c;
var isAlreadyInitialized = false;

@@ -35,2 +37,9 @@ var globalContextManager = createContextManager();

function initRum(initConfiguration) {
// If we are in a Synthetics test configured to automatically inject a RUM instance, we want to
// completely discard the customer application RUM instance by ignoring their init() call. But,
// we should not ignore the init() call from the Synthetics-injected RUM instance, so the
// internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
if (ignoreInitIfSyntheticsWillInjectRum && willSyntheticsInjectRum()) {
return;
}
if (canUseEventBridge()) {

@@ -37,0 +46,0 @@ initConfiguration = overrideInitConfigurationForBridge(initConfiguration);

@@ -16,3 +16,3 @@ import { combine, canUseEventBridge } from '@datadog/browser-core';

import { startRumSession, startRumSessionStub } from '../domain/rumSession';
import { startRumBatch } from '../transport/batch';
import { startRumBatch } from '../transport/startRumBatch';
import { startRumEventBridge } from '../transport/startRumEventBridge';

@@ -19,0 +19,0 @@ import { startUrlContexts } from '../domain/urlContexts';

@@ -7,8 +7,2 @@ import { Configuration } from '@datadog/browser-core';

import { UrlContexts } from './urlContexts';
export interface BrowserWindow extends Window {
_DATADOG_SYNTHETICS_PUBLIC_ID?: string;
_DATADOG_SYNTHETICS_RESULT_ID?: string;
}
export declare function startRumAssembly(applicationId: string, configuration: Configuration, lifeCycle: LifeCycle, session: RumSession, parentContexts: ParentContexts, urlContexts: UrlContexts, getCommonContext: () => CommonContext): void;
export declare const SYNTHETICS_TEST_ID_COOKIE_NAME = "datadog-synthetics-public-id";
export declare const SYNTHETICS_RESULT_ID_COOKIE_NAME = "datadog-synthetics-result-id";
import { __spreadArrays } from "tslib";
import { combine, isEmptyObject, limitModification, timeStampNow, currentDrift, display, createEventRateLimiter, getCookie, } from '@datadog/browser-core';
import { combine, isEmptyObject, limitModification, timeStampNow, currentDrift, display, createEventRateLimiter, canUseEventBridge, } from '@datadog/browser-core';
import { RumEventType, } from '../rawRumEvent.types';
import { buildEnv } from '../boot/buildEnv';
import { getSyntheticsContext } from './syntheticsContext';
import { LifeCycleEventType } from './lifeCycle';

@@ -49,2 +51,3 @@ import { RumSessionPlan } from './rumSession';

},
browser_sdk_version: canUseEventBridge() ? buildEnv.sdkVersion : undefined,
},

@@ -99,14 +102,2 @@ application: {

}
export var SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id';
export var SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id';
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') {
return {
test_id: testId,
result_id: resultId,
};
}
}
//# sourceMappingURL=assembly.js.map
import { ONE_MINUTE, SESSION_TIME_OUT_DELAY } from '@datadog/browser-core';
import { ContextHistory } from '../tools/contextHistory';
import { LifeCycleEventType } from './lifeCycle';
import { ContextHistory } from './contextHistory';
export var VIEW_CONTEXT_TIME_OUT_DELAY = SESSION_TIME_OUT_DELAY;

@@ -5,0 +5,0 @@ export var ACTION_CONTEXT_TIME_OUT_DELAY = 5 * ONE_MINUTE; // arbitrary

import { SESSION_TIME_OUT_DELAY, relativeNow } from '@datadog/browser-core';
import { ContextHistory } from './contextHistory';
import { ContextHistory } from '../tools/contextHistory';
import { LifeCycleEventType } from './lifeCycle';

@@ -4,0 +4,0 @@ /**

@@ -163,2 +163,3 @@ import { Context, Duration, ErrorSource, ErrorHandling, ResourceType, ServerDuration, TimeStamp } from '@datadog/browser-core';

};
browser_sdk_version?: string;
};

@@ -165,0 +166,0 @@ }

@@ -141,2 +141,6 @@ /**

/**
* Source type of the error (the language or platform impacting the error stacktrace format)
*/
readonly source_type?: 'android' | 'browser' | 'ios' | 'react-native';
/**
* Resource properties of the error

@@ -258,3 +262,3 @@ */

*/
readonly type: 'document' | 'xhr' | 'beacon' | 'fetch' | 'css' | 'js' | 'image' | 'font' | 'media' | 'other';
readonly type: 'document' | 'xhr' | 'beacon' | 'fetch' | 'css' | 'js' | 'image' | 'font' | 'media' | 'other' | 'native';
/**

@@ -716,2 +720,6 @@ * HTTP method of the resource

readonly result_id: string;
/**
* Whether the event comes from a SDK instance injected by Synthetics
*/
readonly injected?: boolean;
[k: string]: unknown;

@@ -737,2 +745,6 @@ };

};
/**
* Browser SDK version
*/
readonly browser_sdk_version?: string;
[k: string]: unknown;

@@ -739,0 +751,0 @@ };

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

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

"dependencies": {
"@datadog/browser-core": "3.8.0",
"@datadog/browser-core": "3.9.0",
"tslib": "^1.10.0"

@@ -27,3 +27,3 @@ },

},
"gitHead": "523c091490bd41647d4cbc52a3d01e33b1ed1c55"
"gitHead": "bac81ffda4261d8e9f741c6ebe235392bf331411"
}

@@ -12,3 +12,9 @@ import {

import { initEventBridgeStub, deleteEventBridgeStub } from '../../../core/test/specHelper'
import { noopRecorderApi, setup, TestSetupBuilder } from '../../test/specHelper'
import {
cleanupSyntheticsWorkerValues,
mockSyntheticsWorkerValues,
noopRecorderApi,
setup,
TestSetupBuilder,
} from '../../test/specHelper'
import { ActionType } from '../rawRumEvent.types'

@@ -147,2 +153,38 @@ import {

describe('init', () => {
let startRumSpy: jasmine.Spy<StartRum>
beforeEach(() => {
startRumSpy = jasmine.createSpy()
})
afterEach(() => {
cleanupSyntheticsWorkerValues()
})
describe('skipInitIfSyntheticsWillInjectRum option', () => {
it('when true, ignores init() call if Synthetics will inject its own instance of RUM', () => {
mockSyntheticsWorkerValues({ injectsRum: true })
const rumPublicApi = makeRumPublicApi(startRumSpy, noopRecorderApi, {
ignoreInitIfSyntheticsWillInjectRum: true,
})
rumPublicApi.init(DEFAULT_INIT_CONFIGURATION)
expect(startRumSpy).not.toHaveBeenCalled()
})
it('when false, does not ignore init() call even if Synthetics will inject its own instance of RUM', () => {
mockSyntheticsWorkerValues({ injectsRum: true })
const rumPublicApi = makeRumPublicApi(startRumSpy, noopRecorderApi, {
ignoreInitIfSyntheticsWillInjectRum: false,
})
rumPublicApi.init(DEFAULT_INIT_CONFIGURATION)
expect(startRumSpy).toHaveBeenCalled()
})
})
})
describe('getInternalContext', () => {

@@ -149,0 +191,0 @@ let getInternalContextSpy: jasmine.Spy<ReturnType<StartRum>['getInternalContext']>

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

import { RumEvent } from '../rumEvent.types'
import { willSyntheticsInjectRum } from '../domain/syntheticsContext'
import { buildEnv } from './buildEnv'

@@ -69,4 +70,11 @@ import { startRum } from './startRum'

}
interface RumPublicApiOptions {
ignoreInitIfSyntheticsWillInjectRum?: boolean
}
export function makeRumPublicApi<C extends RumInitConfiguration>(startRumImpl: StartRum<C>, recorderApi: RecorderApi) {
export function makeRumPublicApi<C extends RumInitConfiguration>(
startRumImpl: StartRum<C>,
recorderApi: RecorderApi,
{ ignoreInitIfSyntheticsWillInjectRum = true }: RumPublicApiOptions = {}
) {
let isAlreadyInitialized = false

@@ -102,2 +110,10 @@

function initRum(initConfiguration: C) {
// If we are in a Synthetics test configured to automatically inject a RUM instance, we want to
// completely discard the customer application RUM instance by ignoring their init() call. But,
// we should not ignore the init() call from the Synthetics-injected RUM instance, so the
// internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
if (ignoreInitIfSyntheticsWillInjectRum && willSyntheticsInjectRum()) {
return
}
if (canUseEventBridge()) {

@@ -104,0 +120,0 @@ initConfiguration = overrideInitConfigurationForBridge(initConfiguration)

@@ -17,3 +17,3 @@ import { combine, Configuration, InternalMonitoring, canUseEventBridge, Observable } from '@datadog/browser-core'

import { CommonContext } from '../rawRumEvent.types'
import { startRumBatch } from '../transport/batch'
import { startRumBatch } from '../transport/startRumBatch'
import { startRumEventBridge } from '../transport/startRumEventBridge'

@@ -20,0 +20,0 @@ import { startUrlContexts } from '../domain/urlContexts'

@@ -1,21 +0,26 @@

import { ErrorSource, ONE_MINUTE, RawError, RelativeTime, display, setCookie } from '@datadog/browser-core'
import { deleteCookie } from 'packages/core/src/browser/cookie'
import { createRumSessionMock } from 'packages/rum-core/test/mockRumSession'
import {
ErrorSource,
ONE_MINUTE,
RawError,
RelativeTime,
display,
updateExperimentalFeatures,
resetExperimentalFeatures,
} from '@datadog/browser-core'
import { createRumSessionMock } from '../../test/mockRumSession'
import { createRawRumEvent } from '../../test/fixtures'
import { setup, TestSetupBuilder } from '../../test/specHelper'
import {
cleanupSyntheticsWorkerValues,
mockSyntheticsWorkerValues,
setup,
TestSetupBuilder,
} from '../../test/specHelper'
import { RumEventDomainContext } from '../domainContext.types'
import { CommonContext, RawRumActionEvent, RawRumErrorEvent, RawRumEvent, RumEventType } from '../rawRumEvent.types'
import { RumActionEvent, RumErrorEvent, RumEvent } from '../rumEvent.types'
import {
BrowserWindow,
startRumAssembly,
SYNTHETICS_RESULT_ID_COOKIE_NAME,
SYNTHETICS_TEST_ID_COOKIE_NAME,
} from './assembly'
import { initEventBridgeStub, deleteEventBridgeStub } from '../../../core/test/specHelper'
import { startRumAssembly } from './assembly'
import { LifeCycle, LifeCycleEventType, RawRumEventCollectedData } from './lifeCycle'
import { RumSessionPlan } from './rumSession'
// Duration to create a cookie lasting at least until the end of the test
const COOKIE_DURATION = 1000
describe('rum assembly', () => {

@@ -67,6 +72,6 @@ let setupBuilder: TestSetupBuilder

afterEach(() => {
resetExperimentalFeatures()
deleteEventBridgeStub()
setupBuilder.cleanup()
cleanupSyntheticsGlobals()
deleteCookie(SYNTHETICS_TEST_ID_COOKIE_NAME)
deleteCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME)
cleanupSyntheticsWorkerValues()
})

@@ -531,4 +536,4 @@

it('should detect synthetics sessions from global', () => {
setSyntheticsGlobals('foo', 'bar')
it('should detect synthetics sessions based on synthetics worker values', () => {
mockSyntheticsWorkerValues()

@@ -543,14 +548,2 @@ const { lifeCycle } = setupBuilder.build()

it('should detect synthetics sessions from cookies', () => {
setCookie(SYNTHETICS_TEST_ID_COOKIE_NAME, 'foo', COOKIE_DURATION)
setCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME, 'bar', COOKIE_DURATION)
const { lifeCycle } = setupBuilder.build()
notifyRawRumEvent(lifeCycle, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
})
expect(serverRumEvents[0].session.type).toEqual('synthetics')
})
it('should set the session.has_replay attribute if it is defined in the common context', () => {

@@ -578,4 +571,4 @@ const { lifeCycle } = setupBuilder.build()

describe('synthetics context', () => {
it('sets the synthetics context defined by global variables', () => {
setSyntheticsGlobals('foo', 'bar')
it('includes the synthetics context', () => {
mockSyntheticsWorkerValues()

@@ -587,55 +580,19 @@ const { lifeCycle } = setupBuilder.build()

expect(serverRumEvents[0].synthetics).toEqual({
test_id: 'foo',
result_id: 'bar',
})
expect(serverRumEvents[0].synthetics).toBeTruthy()
})
})
it('sets the synthetics context defined by global cookie', () => {
setCookie(SYNTHETICS_TEST_ID_COOKIE_NAME, 'foo', COOKIE_DURATION)
setCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME, 'bar', COOKIE_DURATION)
describe('if event bridge detected', () => {
it('includes the browser sdk version', () => {
const { lifeCycle } = setupBuilder.build()
notifyRawRumEvent(lifeCycle, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
})
notifyRawRumEvent(lifeCycle, { rawRumEvent: createRawRumEvent(RumEventType.VIEW) })
expect(serverRumEvents[0].synthetics).toEqual({
test_id: 'foo',
result_id: 'bar',
})
})
updateExperimentalFeatures(['event-bridge'])
initEventBridgeStub()
it('does not set synthetics context if one global variable is undefined', () => {
setSyntheticsGlobals('foo')
notifyRawRumEvent(lifeCycle, { rawRumEvent: createRawRumEvent(RumEventType.VIEW) })
const { lifeCycle } = setupBuilder.build()
notifyRawRumEvent(lifeCycle, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
})
expect(serverRumEvents[0].synthetics).toBeUndefined()
expect(serverRumEvents[0]._dd.browser_sdk_version).not.toBeDefined()
expect(serverRumEvents[1]._dd.browser_sdk_version).toBeDefined()
})
it('does not set synthetics context if global variables are not strings', () => {
setSyntheticsGlobals(1, 2)
const { lifeCycle } = setupBuilder.build()
notifyRawRumEvent(lifeCycle, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
})
expect(serverRumEvents[0].synthetics).toBeUndefined()
})
it('does not set synthetics context if one cookie is undefined', () => {
setCookie(SYNTHETICS_TEST_ID_COOKIE_NAME, 'foo', COOKIE_DURATION)
const { lifeCycle } = setupBuilder.build()
notifyRawRumEvent(lifeCycle, {
rawRumEvent: createRawRumEvent(RumEventType.VIEW),
})
expect(serverRumEvents[0].synthetics).toBeUndefined()
})
})

@@ -791,11 +748,1 @@

}
function setSyntheticsGlobals(publicId: any, resultId?: any) {
;(window as BrowserWindow)._DATADOG_SYNTHETICS_PUBLIC_ID = publicId
;(window as BrowserWindow)._DATADOG_SYNTHETICS_RESULT_ID = resultId
}
function cleanupSyntheticsGlobals() {
delete (window as BrowserWindow)._DATADOG_SYNTHETICS_PUBLIC_ID
delete (window as BrowserWindow)._DATADOG_SYNTHETICS_RESULT_ID
}

@@ -14,3 +14,3 @@ import {

EventRateLimiter,
getCookie,
canUseEventBridge,
} from '@datadog/browser-core'

@@ -29,2 +29,4 @@ import { RumEventDomainContext } from '../domainContext.types'

import { RumEvent } from '../rumEvent.types'
import { buildEnv } from '../boot/buildEnv'
import { getSyntheticsContext } from './syntheticsContext'
import { LifeCycle, LifeCycleEventType } from './lifeCycle'

@@ -35,7 +37,2 @@ import { ParentContexts } from './parentContexts'

export interface BrowserWindow extends Window {
_DATADOG_SYNTHETICS_PUBLIC_ID?: string
_DATADOG_SYNTHETICS_RESULT_ID?: string
}
enum SessionType {

@@ -100,2 +97,3 @@ SYNTHETICS = 'synthetics',

},
browser_sdk_version: canUseEventBridge() ? buildEnv.sdkVersion : undefined,
},

@@ -125,2 +123,3 @@ application: {

}
if (shouldSend(serverRumEvent, configuration.beforeSend, domainContext, eventRateLimiters)) {

@@ -166,17 +165,1 @@ if (isEmptyObject(serverRumEvent.context)) {

}
export const SYNTHETICS_TEST_ID_COOKIE_NAME = 'datadog-synthetics-public-id'
export const SYNTHETICS_RESULT_ID_COOKIE_NAME = 'datadog-synthetics-result-id'
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)
if (typeof testId === 'string' && typeof resultId === 'string') {
return {
test_id: testId,
result_id: resultId,
}
}
}
import { RelativeTime, relativeToClocks } from '@datadog/browser-core'
import { createRumSessionMock, RumSessionMock } from '../../test/mockRumSession'
import { setup, TestSetupBuilder } from '../../test/specHelper'
import { CLEAR_OLD_CONTEXTS_INTERVAL } from '../tools/contextHistory'
import { LifeCycleEventType } from './lifeCycle'

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

import { ViewCreatedEvent } from './rumEventsCollection/view/trackViews'
import { CLEAR_OLD_CONTEXTS_INTERVAL } from './contextHistory'

@@ -16,0 +16,0 @@ describe('parentContexts', () => {

import { ONE_MINUTE, RelativeTime, SESSION_TIME_OUT_DELAY } from '@datadog/browser-core'
import { ActionContext, ViewContext } from '../rawRumEvent.types'
import { ContextHistory } from '../tools/contextHistory'
import { LifeCycle, LifeCycleEventType } from './lifeCycle'

@@ -7,3 +8,2 @@ import { AutoAction, AutoActionCreatedEvent } from './rumEventsCollection/action/trackActions'

import { RumSession } from './rumSession'
import { ContextHistory } from './contextHistory'

@@ -10,0 +10,0 @@ export const VIEW_CONTEXT_TIME_OUT_DELAY = SESSION_TIME_OUT_DELAY

import { Context, DOM_EVENT, ClocksState, Observable } from '@datadog/browser-core'
import { Clock, createNewEvent } from '../../../../../core/test/specHelper'
import { RumEvent } from '../../../../../rum/src'
import { setup, TestSetupBuilder } from '../../../../test/specHelper'
import { RumEventType, ActionType } from '../../../rawRumEvent.types'
import { RumEvent } from '../../../rumEvent.types'
import { LifeCycleEventType } from '../../lifeCycle'

@@ -7,0 +7,0 @@ import { PAGE_ACTIVITY_VALIDATION_DELAY } from '../../waitIdlePage'

import { Context, objectValues } from '@datadog/browser-core'
import { RumEvent } from '../../../rum/src'
import { RumEvent } from '../rumEvent.types'
import { RumEventType } from '../rawRumEvent.types'

@@ -4,0 +4,0 @@ import { LifeCycle, LifeCycleEventType } from './lifeCycle'

import { RelativeTime, Observable, SESSION_TIME_OUT_DELAY, relativeNow } from '@datadog/browser-core'
import { UrlContext } from '../rawRumEvent.types'
import { LocationChange } from '../browser/locationChangeObservable'
import { ContextHistory } from './contextHistory'
import { ContextHistory } from '../tools/contextHistory'
import { LifeCycle, LifeCycleEventType } from './lifeCycle'

@@ -6,0 +6,0 @@

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

}
browser_sdk_version?: string
}

@@ -193,0 +194,0 @@ }

@@ -143,2 +143,6 @@ /* eslint-disable */

/**
* Source type of the error (the language or platform impacting the error stacktrace format)
*/
readonly source_type?: 'android' | 'browser' | 'ios' | 'react-native'
/**
* Resource properties of the error

@@ -274,3 +278,14 @@ */

*/
readonly type: 'document' | 'xhr' | 'beacon' | 'fetch' | 'css' | 'js' | 'image' | 'font' | 'media' | 'other'
readonly type:
| 'document'
| 'xhr'
| 'beacon'
| 'fetch'
| 'css'
| 'js'
| 'image'
| 'font'
| 'media'
| 'other'
| 'native'
/**

@@ -765,2 +780,6 @@ * HTTP method of the resource

readonly result_id: string
/**
* Whether the event comes from a SDK instance injected by Synthetics
*/
readonly injected?: boolean
[k: string]: unknown

@@ -786,2 +805,6 @@ }

}
/**
* Browser SDK version
*/
readonly browser_sdk_version?: string
[k: string]: unknown

@@ -788,0 +811,0 @@ }

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