Socket
Socket
Sign inDemoInstall

@datadog/browser-core

Package Overview
Dependencies
0
Maintainers
1
Versions
248
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.20.0 to 5.21.0

2

cjs/boot/init.js

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

var publicApi = (0, polyfills_1.assign)({
version: "5.20.0",
version: "5.21.0",
// This API method is intentionally not monitored, since the only thing executed is the

@@ -13,0 +13,0 @@ // user-provided 'callback'. All SDK usages executed in the callback should be monitored, and

@@ -17,28 +17,113 @@ import type { Duration } from '../../tools/utils/timeUtils';

export interface InitConfiguration {
/**
* The client token for Datadog. Required for authenticating your application with Datadog.
*/
clientToken: string;
beforeSend?: GenericBeforeSendCallback | undefined;
/**
* The percentage of sessions tracked. A value between 0 and 100.
* @default 100
*/
sessionSampleRate?: number | undefined;
/**
* The percentage of telemetry events sent. A value between 0 and 100.
* @default 20
*/
telemetrySampleRate?: number | undefined;
/**
* Initialization fails silently if the RUM Browser SDK is already initialized on the page.
* @default false
*/
silentMultipleInit?: boolean | undefined;
/**
* Allows the use of localStorage when cookies cannot be set. This enables the RUM Browser SDK to run in environments that do not provide cookie support.
* See [Monitor Electron Applications Using the Browser SDK](https://docs.datadoghq.com/real_user_monitoring/guide/monitor-electron-applications-using-browser-sdk) for further information.
* @default false
*/
allowFallbackToLocalStorage?: boolean | undefined;
/**
* Allow listening to DOM events dispatched programmatically ([untrusted events](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted)). Enabling this option can be useful if you heavily rely on programmatic events, such as in an automated UI test environment.
* @default false
*/
allowUntrustedEvents?: boolean | undefined;
/**
* Store global context and user context in localStorage to preserve them along the user navigation.
* See [Contexts life cycle](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#contexts-life-cycle) for further information.
* @default false
*/
storeContextsAcrossPages?: boolean | undefined;
/**
* Set the initial user tracking consent state.
* See [User tracking consent](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#user-tracking-consent) for further information.
* @default granted
*/
trackingConsent?: TrackingConsent | undefined;
/**
* Optional proxy URL, for example: https://www.proxy.com/path.
* See [Proxy Your Browser RUM Data](https://docs.datadoghq.com/real_user_monitoring/guide/proxy-rum-data) for further information.
*/
proxy?: string | ProxyFn | undefined;
/**
* The Datadog [site](https://docs.datadoghq.com/getting_started/site) parameter of your organization.
* @default datadoghq.com
*/
site?: string | undefined;
/**
* The service name for your application. Follows the [tag syntax requirements](https://docs.datadoghq.com/getting_started/tagging/#define-tags).
*/
service?: string | undefined | null;
/**
* The application’s environment, for example: prod, pre-prod, and staging. Follows the [tag syntax requirements](https://docs.datadoghq.com/getting_started/tagging/#define-tags).
*/
env?: string | undefined | null;
/**
* The application’s version, for example: 1.2.3, 6c44da20, and 2020.02.13. Follows the [tag syntax requirements](https://docs.datadoghq.com/getting_started/tagging/#define-tags).
*/
version?: string | undefined | null;
/**
* Whether a secure cross-site session cookie is used
* @default false
* @deprecated use usePartitionedCrossSiteSessionCookie instead
*/
useCrossSiteSessionCookie?: boolean | undefined;
/**
* Use a partitioned secure cross-site session cookie. This allows the RUM Browser SDK to run when the site is loaded from another one (iframe). Implies `useSecureSessionCookie`.
* @default false
*/
usePartitionedCrossSiteSessionCookie?: boolean | undefined;
/**
* Use a secure session cookie. This disables RUM events sent on insecure (non-HTTPS) connections.
* @default false
*/
useSecureSessionCookie?: boolean | undefined;
/**
* Preserve the session across subdomains for the same site.
* @default false
*/
trackSessionAcrossSubdomains?: boolean | undefined;
/**
* [Internal option] Enable experimental features
*/
enableExperimentalFeatures?: string[] | undefined;
/**
* [Internal option] Configure the dual chipping to another datacenter
*/
replica?: ReplicaUserConfiguration | undefined;
/**
* [Internal option] Set the datacenter from where the data is dual chipped
*/
datacenter?: string;
/**
* [Internal option] Datadog internal analytics subdomain
*/
internalAnalyticsSubdomain?: string;
/**
* [Internal option] The percentage of telemetry configuration sent. A value between 0 and 100.
* @default 5
*/
telemetryConfigurationSampleRate?: number;
/**
* [Internal option] The percentage of telemetry usage sent. A value between 0 and 100.
* @default 5
*/
telemetryUsageSampleRate?: number;

@@ -70,2 +155,3 @@ }

trackingConsent: TrackingConsent;
storeContextsAcrossPages: boolean;
eventRateLimiterThreshold: number;

@@ -72,0 +158,0 @@ maxTelemetryEventsPerPage: number;

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

var display_1 = require("../../tools/display");
var experimentalFeatures_1 = require("../../tools/experimentalFeatures");
var timeUtils_1 = require("../../tools/utils/timeUtils");

@@ -77,8 +76,2 @@ var numberUtils_1 = require("../../tools/utils/numberUtils");

}
// Set the experimental feature flags as early as possible, so we can use them in most places
if (Array.isArray(initConfiguration.enableExperimentalFeatures)) {
(0, experimentalFeatures_1.addExperimentalFeatures)(initConfiguration.enableExperimentalFeatures.filter(function (flag) {
return (0, objectUtils_1.objectHasValue)(experimentalFeatures_1.ExperimentalFeature, flag);
}));
}
return (0, polyfills_1.assign)({

@@ -95,2 +88,3 @@ beforeSend: initConfiguration.beforeSend && (0, catchUserErrors_1.catchUserErrors)(initConfiguration.beforeSend, 'beforeSend threw an error:'),

trackingConsent: (_e = initConfiguration.trackingConsent) !== null && _e !== void 0 ? _e : trackingConsent_1.TrackingConsent.GRANTED,
storeContextsAcrossPages: !!initConfiguration.storeContextsAcrossPages,
/**

@@ -97,0 +91,0 @@ * beacon payload max queue size implementation is 64kb

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

var retry = _b.retry, encoding = _b.encoding;
var tags = ["sdk_version:".concat("5.20.0"), "api:".concat(api)].concat(configurationTags);
var tags = ["sdk_version:".concat("5.21.0"), "api:".concat(api)].concat(configurationTags);
if (retry) {

@@ -69,3 +69,3 @@ tags.push("retry_count:".concat(retry.count), "retry_after:".concat(retry.lastFailureStatus));

"dd-api-key=".concat(clientToken),
"dd-evp-origin-version=".concat(encodeURIComponent("5.20.0")),
"dd-evp-origin-version=".concat(encodeURIComponent("5.21.0")),
'dd-evp-origin=browser',

@@ -72,0 +72,0 @@ "dd-request-id=".concat((0, stringUtils_1.generateUUID)()),

@@ -6,2 +6,3 @@ import { Observable } from '../../tools/observable';

import type { TrackingConsentState } from '../trackingConsent';
import type { SessionState } from './sessionState';
export interface SessionManager<TrackingType extends string> {

@@ -13,3 +14,8 @@ findSession: (startTime?: RelativeTime, options?: {

expireObservable: Observable<void>;
sessionStateUpdateObservable: Observable<{
previousState: SessionState;
newState: SessionState;
}>;
expire: () => void;
updateSessionState: (state: Partial<SessionState>) => void;
}

@@ -19,2 +25,3 @@ export interface SessionContext<TrackingType extends string> extends Context {

trackingType: TrackingType;
isReplayForced: boolean;
}

@@ -21,0 +28,0 @@ export declare const VISIBILITY_CHECK_DELAY: number;

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

trackingType: sessionStore.getSession()[productKey],
isReplayForced: !!sessionStore.getSession().forcedReplay,
};

@@ -60,3 +61,5 @@ }

expireObservable: expireObservable,
sessionStateUpdateObservable: sessionStore.sessionStateUpdateObservable,
expire: sessionStore.expire,
updateSessionState: sessionStore.updateSessionState,
};

@@ -63,0 +66,0 @@ }

@@ -12,4 +12,9 @@ import { Observable } from '../../tools/observable';

expireObservable: Observable<void>;
sessionStateUpdateObservable: Observable<{
previousState: SessionState;
newState: SessionState;
}>;
expire: () => void;
stop: () => void;
updateSessionState: (state: Partial<SessionState>) => void;
}

@@ -16,0 +21,0 @@ /**

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

var stringUtils_1 = require("../../tools/utils/stringUtils");
var polyfills_1 = require("../../tools/utils/polyfills");
var sessionInCookie_1 = require("./storeStrategies/sessionInCookie");

@@ -41,2 +42,3 @@ var sessionState_1 = require("./sessionState");

var expireObservable = new observable_1.Observable();
var sessionStateUpdateObservable = new observable_1.Observable();
var sessionStoreStrategy = sessionStoreStrategyType.type === 'Cookie'

@@ -92,2 +94,3 @@ ? (0, sessionInCookie_1.initCookieStrategy)(sessionStoreStrategyType.cookieOptions)

else {
sessionStateUpdateObservable.notify({ previousState: sessionCache, newState: sessionState });
sessionCache = sessionState;

@@ -136,2 +139,8 @@ }

}
function updateSessionState(partialSessionState) {
(0, sessionStoreOperations_1.processSessionStoreOperations)({
process: function (sessionState) { return (0, polyfills_1.assign)({}, sessionState, partialSessionState); },
after: synchronizeSession,
}, sessionStoreStrategy);
}
return {

@@ -143,2 +152,3 @@ expandOrRenewSession: throttledExpandOrRenewSession,

expireObservable: expireObservable,
sessionStateUpdateObservable: sessionStateUpdateObservable,
restartSession: startSession,

@@ -153,2 +163,3 @@ expire: function () {

},
updateSessionState: updateSessionState,
};

@@ -155,0 +166,0 @@ }

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

service: telemetryService,
version: "5.20.0",
version: "5.21.0",
source: 'browser',

@@ -67,0 +67,0 @@ _dd: {

export { Configuration, InitConfiguration, validateAndBuildConfiguration, DefaultPrivacyLevel, TraceContextInjection, EndpointBuilder, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration';
export { TrackingConsent, TrackingConsentState, createTrackingConsentState } from './domain/trackingConsent';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, ExperimentalFeature, } from './tools/experimentalFeatures';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, initFeatureFlags, ExperimentalFeature, } from './tools/experimentalFeatures';
export { trackRuntimeError } from './domain/error/trackRuntimeError';

@@ -5,0 +5,0 @@ export { computeStackTrace, StackTrace } from './tools/stackTrace/computeStackTrace';

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.getZoneJsOriginalValue = exports.runOnReadyState = exports.sendToExtension = exports.AbstractLifeCycle = exports.createIdentityEncoder = exports.createFlushController = exports.startBatchWithReplica = exports.bridgeSupports = exports.getEventBridge = exports.canUseEventBridge = exports.createHttpRequest = exports.SESSION_TIME_OUT_DELAY = exports.stopSessionManager = exports.startSessionManager = exports.Observable = exports.setDebugMode = exports.callMonitored = exports.monitor = exports.monitored = exports.drainPreStartTelemetry = exports.addTelemetryUsage = exports.addTelemetryConfiguration = exports.isTelemetryReplicationAllowed = exports.resetTelemetry = exports.startFakeTelemetry = exports.addTelemetryError = exports.addTelemetryDebug = exports.startTelemetry = exports.RawReportType = exports.initReportObservable = exports.displayAlreadyInitializedError = exports.makePublicApi = exports.defineGlobal = exports.computeStackTrace = exports.trackRuntimeError = exports.ExperimentalFeature = exports.getExperimentalFeatures = exports.resetExperimentalFeatures = exports.addExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.createTrackingConsentState = exports.TrackingConsent = exports.INTAKE_SITE_EU1 = exports.INTAKE_SITE_US1_FED = exports.INTAKE_SITE_US1 = exports.INTAKE_SITE_STAGING = exports.serializeConfiguration = exports.TraceContextInjection = exports.DefaultPrivacyLevel = exports.validateAndBuildConfiguration = void 0;
exports.ErrorSource = exports.sanitizeUser = exports.checkUser = exports.getSyntheticsResultId = exports.getSyntheticsTestId = exports.willSyntheticsInjectRum = exports.SESSION_STORE_KEY = exports.STORAGE_POLL_DELAY = exports.readBytesFromStream = exports.CLEAR_OLD_VALUES_INTERVAL = exports.ValueHistory = exports.CUSTOMER_DATA_BYTES_LIMIT = exports.createCustomerDataTracker = exports.createCustomerDataTrackerManager = exports.removeStorageListeners = exports.storeContextManager = exports.createContextManager = exports.catchUserErrors = exports.BoundedBuffer = exports.resetConsoleObservable = exports.initConsoleObservable = exports.isPageExitReason = exports.PageExitReason = exports.createPageExitObservable = exports.initFetchObservable = exports.initXhrObservable = exports.resetInitCookies = exports.deleteCookie = exports.setCookie = exports.getInitCookie = exports.getCookie = exports.areCookiesAuthorized = exports.NO_ERROR_STACK_PRESENT_MESSAGE = exports.getFileFromStackTraceString = exports.computeRawError = exports.instrumentSetter = exports.instrumentMethod = void 0;
exports.runOnReadyState = exports.sendToExtension = exports.AbstractLifeCycle = exports.createIdentityEncoder = exports.createFlushController = exports.startBatchWithReplica = exports.bridgeSupports = exports.getEventBridge = exports.canUseEventBridge = exports.createHttpRequest = exports.SESSION_TIME_OUT_DELAY = exports.stopSessionManager = exports.startSessionManager = exports.Observable = exports.setDebugMode = exports.callMonitored = exports.monitor = exports.monitored = exports.drainPreStartTelemetry = exports.addTelemetryUsage = exports.addTelemetryConfiguration = exports.isTelemetryReplicationAllowed = exports.resetTelemetry = exports.startFakeTelemetry = exports.addTelemetryError = exports.addTelemetryDebug = exports.startTelemetry = exports.RawReportType = exports.initReportObservable = exports.displayAlreadyInitializedError = exports.makePublicApi = exports.defineGlobal = exports.computeStackTrace = exports.trackRuntimeError = exports.ExperimentalFeature = exports.initFeatureFlags = exports.getExperimentalFeatures = exports.resetExperimentalFeatures = exports.addExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.createTrackingConsentState = exports.TrackingConsent = exports.INTAKE_SITE_EU1 = exports.INTAKE_SITE_US1_FED = exports.INTAKE_SITE_US1 = exports.INTAKE_SITE_STAGING = exports.serializeConfiguration = exports.TraceContextInjection = exports.DefaultPrivacyLevel = exports.validateAndBuildConfiguration = void 0;
exports.ErrorSource = exports.sanitizeUser = exports.checkUser = exports.getSyntheticsResultId = exports.getSyntheticsTestId = exports.willSyntheticsInjectRum = exports.SESSION_STORE_KEY = exports.STORAGE_POLL_DELAY = exports.readBytesFromStream = exports.CLEAR_OLD_VALUES_INTERVAL = exports.ValueHistory = exports.CUSTOMER_DATA_BYTES_LIMIT = exports.createCustomerDataTracker = exports.createCustomerDataTrackerManager = exports.removeStorageListeners = exports.storeContextManager = exports.createContextManager = exports.catchUserErrors = exports.BoundedBuffer = exports.resetConsoleObservable = exports.initConsoleObservable = exports.isPageExitReason = exports.PageExitReason = exports.createPageExitObservable = exports.initFetchObservable = exports.initXhrObservable = exports.resetInitCookies = exports.deleteCookie = exports.setCookie = exports.getInitCookie = exports.getCookie = exports.areCookiesAuthorized = exports.NO_ERROR_STACK_PRESENT_MESSAGE = exports.getFileFromStackTraceString = exports.computeRawError = exports.instrumentSetter = exports.instrumentMethod = exports.getZoneJsOriginalValue = void 0;
var configuration_1 = require("./domain/configuration");

@@ -37,2 +37,3 @@ Object.defineProperty(exports, "validateAndBuildConfiguration", { enumerable: true, get: function () { return configuration_1.validateAndBuildConfiguration; } });

Object.defineProperty(exports, "getExperimentalFeatures", { enumerable: true, get: function () { return experimentalFeatures_1.getExperimentalFeatures; } });
Object.defineProperty(exports, "initFeatureFlags", { enumerable: true, get: function () { return experimentalFeatures_1.initFeatureFlags; } });
Object.defineProperty(exports, "ExperimentalFeature", { enumerable: true, get: function () { return experimentalFeatures_1.ExperimentalFeature; } });

@@ -39,0 +40,0 @@ var trackRuntimeError_1 = require("./domain/error/trackRuntimeError");

@@ -16,2 +16,3 @@ /**

}
export declare function initFeatureFlags(enableExperimentalFeatures?: string[] | undefined): void;
export declare function addExperimentalFeatures(enabledFeatures: ExperimentalFeature[]): void;

@@ -18,0 +19,0 @@ export declare function isExperimentalFeatureEnabled(featureName: ExperimentalFeature): boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExperimentalFeatures = exports.resetExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.addExperimentalFeatures = exports.ExperimentalFeature = void 0;
/**

@@ -15,2 +13,5 @@ * LIMITATION:

// string is an expected feature flag
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExperimentalFeatures = exports.resetExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.addExperimentalFeatures = exports.initFeatureFlags = exports.ExperimentalFeature = void 0;
var objectUtils_1 = require("./utils/objectUtils");
// eslint-disable-next-line no-restricted-syntax

@@ -25,2 +26,10 @@ var ExperimentalFeature;

var enabledExperimentalFeatures = new Set();
function initFeatureFlags(enableExperimentalFeatures) {
if (Array.isArray(enableExperimentalFeatures)) {
addExperimentalFeatures(enableExperimentalFeatures.filter(function (flag) {
return (0, objectUtils_1.objectHasValue)(ExperimentalFeature, flag);
}));
}
}
exports.initFeatureFlags = initFeatureFlags;
function addExperimentalFeatures(enabledFeatures) {

@@ -27,0 +36,0 @@ enabledFeatures.forEach(function (flag) {

@@ -21,1 +21,2 @@ export declare function includes(candidate: string, search: string): boolean;

export declare function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
export declare function assign<T, U, V, W, X>(target: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X;

@@ -7,3 +7,3 @@ import { catchUserErrors } from '../tools/catchUserErrors';

var publicApi = assign({
version: "5.20.0",
version: "5.21.0",
// This API method is intentionally not monitored, since the only thing executed is the

@@ -10,0 +10,0 @@ // user-provided 'callback'. All SDK usages executed in the callback should be monitored, and

@@ -17,28 +17,113 @@ import type { Duration } from '../../tools/utils/timeUtils';

export interface InitConfiguration {
/**
* The client token for Datadog. Required for authenticating your application with Datadog.
*/
clientToken: string;
beforeSend?: GenericBeforeSendCallback | undefined;
/**
* The percentage of sessions tracked. A value between 0 and 100.
* @default 100
*/
sessionSampleRate?: number | undefined;
/**
* The percentage of telemetry events sent. A value between 0 and 100.
* @default 20
*/
telemetrySampleRate?: number | undefined;
/**
* Initialization fails silently if the RUM Browser SDK is already initialized on the page.
* @default false
*/
silentMultipleInit?: boolean | undefined;
/**
* Allows the use of localStorage when cookies cannot be set. This enables the RUM Browser SDK to run in environments that do not provide cookie support.
* See [Monitor Electron Applications Using the Browser SDK](https://docs.datadoghq.com/real_user_monitoring/guide/monitor-electron-applications-using-browser-sdk) for further information.
* @default false
*/
allowFallbackToLocalStorage?: boolean | undefined;
/**
* Allow listening to DOM events dispatched programmatically ([untrusted events](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted)). Enabling this option can be useful if you heavily rely on programmatic events, such as in an automated UI test environment.
* @default false
*/
allowUntrustedEvents?: boolean | undefined;
/**
* Store global context and user context in localStorage to preserve them along the user navigation.
* See [Contexts life cycle](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#contexts-life-cycle) for further information.
* @default false
*/
storeContextsAcrossPages?: boolean | undefined;
/**
* Set the initial user tracking consent state.
* See [User tracking consent](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#user-tracking-consent) for further information.
* @default granted
*/
trackingConsent?: TrackingConsent | undefined;
/**
* Optional proxy URL, for example: https://www.proxy.com/path.
* See [Proxy Your Browser RUM Data](https://docs.datadoghq.com/real_user_monitoring/guide/proxy-rum-data) for further information.
*/
proxy?: string | ProxyFn | undefined;
/**
* The Datadog [site](https://docs.datadoghq.com/getting_started/site) parameter of your organization.
* @default datadoghq.com
*/
site?: string | undefined;
/**
* The service name for your application. Follows the [tag syntax requirements](https://docs.datadoghq.com/getting_started/tagging/#define-tags).
*/
service?: string | undefined | null;
/**
* The application’s environment, for example: prod, pre-prod, and staging. Follows the [tag syntax requirements](https://docs.datadoghq.com/getting_started/tagging/#define-tags).
*/
env?: string | undefined | null;
/**
* The application’s version, for example: 1.2.3, 6c44da20, and 2020.02.13. Follows the [tag syntax requirements](https://docs.datadoghq.com/getting_started/tagging/#define-tags).
*/
version?: string | undefined | null;
/**
* Whether a secure cross-site session cookie is used
* @default false
* @deprecated use usePartitionedCrossSiteSessionCookie instead
*/
useCrossSiteSessionCookie?: boolean | undefined;
/**
* Use a partitioned secure cross-site session cookie. This allows the RUM Browser SDK to run when the site is loaded from another one (iframe). Implies `useSecureSessionCookie`.
* @default false
*/
usePartitionedCrossSiteSessionCookie?: boolean | undefined;
/**
* Use a secure session cookie. This disables RUM events sent on insecure (non-HTTPS) connections.
* @default false
*/
useSecureSessionCookie?: boolean | undefined;
/**
* Preserve the session across subdomains for the same site.
* @default false
*/
trackSessionAcrossSubdomains?: boolean | undefined;
/**
* [Internal option] Enable experimental features
*/
enableExperimentalFeatures?: string[] | undefined;
/**
* [Internal option] Configure the dual chipping to another datacenter
*/
replica?: ReplicaUserConfiguration | undefined;
/**
* [Internal option] Set the datacenter from where the data is dual chipped
*/
datacenter?: string;
/**
* [Internal option] Datadog internal analytics subdomain
*/
internalAnalyticsSubdomain?: string;
/**
* [Internal option] The percentage of telemetry configuration sent. A value between 0 and 100.
* @default 5
*/
telemetryConfigurationSampleRate?: number;
/**
* [Internal option] The percentage of telemetry usage sent. A value between 0 and 100.
* @default 5
*/
telemetryUsageSampleRate?: number;

@@ -70,2 +155,3 @@ }

trackingConsent: TrackingConsent;
storeContextsAcrossPages: boolean;
eventRateLimiterThreshold: number;

@@ -72,0 +158,0 @@ maxTelemetryEventsPerPage: number;

import { catchUserErrors } from '../../tools/catchUserErrors';
import { DOCS_ORIGIN, display } from '../../tools/display';
import { ExperimentalFeature, addExperimentalFeatures } from '../../tools/experimentalFeatures';
import { ONE_SECOND } from '../../tools/utils/timeUtils';

@@ -73,8 +72,2 @@ import { isPercentage } from '../../tools/utils/numberUtils';

}
// Set the experimental feature flags as early as possible, so we can use them in most places
if (Array.isArray(initConfiguration.enableExperimentalFeatures)) {
addExperimentalFeatures(initConfiguration.enableExperimentalFeatures.filter(function (flag) {
return objectHasValue(ExperimentalFeature, flag);
}));
}
return assign({

@@ -91,2 +84,3 @@ beforeSend: initConfiguration.beforeSend && catchUserErrors(initConfiguration.beforeSend, 'beforeSend threw an error:'),

trackingConsent: (_e = initConfiguration.trackingConsent) !== null && _e !== void 0 ? _e : TrackingConsent.GRANTED,
storeContextsAcrossPages: !!initConfiguration.storeContextsAcrossPages,
/**

@@ -93,0 +87,0 @@ * beacon payload max queue size implementation is 64kb

@@ -56,3 +56,3 @@ import { timeStampNow } from '../../tools/utils/timeUtils';

var retry = _b.retry, encoding = _b.encoding;
var tags = ["sdk_version:".concat("5.20.0"), "api:".concat(api)].concat(configurationTags);
var tags = ["sdk_version:".concat("5.21.0"), "api:".concat(api)].concat(configurationTags);
if (retry) {

@@ -65,3 +65,3 @@ tags.push("retry_count:".concat(retry.count), "retry_after:".concat(retry.lastFailureStatus));

"dd-api-key=".concat(clientToken),
"dd-evp-origin-version=".concat(encodeURIComponent("5.20.0")),
"dd-evp-origin-version=".concat(encodeURIComponent("5.21.0")),
'dd-evp-origin=browser',

@@ -68,0 +68,0 @@ "dd-request-id=".concat(generateUUID()),

@@ -6,2 +6,3 @@ import { Observable } from '../../tools/observable';

import type { TrackingConsentState } from '../trackingConsent';
import type { SessionState } from './sessionState';
export interface SessionManager<TrackingType extends string> {

@@ -13,3 +14,8 @@ findSession: (startTime?: RelativeTime, options?: {

expireObservable: Observable<void>;
sessionStateUpdateObservable: Observable<{
previousState: SessionState;
newState: SessionState;
}>;
expire: () => void;
updateSessionState: (state: Partial<SessionState>) => void;
}

@@ -19,2 +25,3 @@ export interface SessionContext<TrackingType extends string> extends Context {

trackingType: TrackingType;
isReplayForced: boolean;
}

@@ -21,0 +28,0 @@ export declare const VISIBILITY_CHECK_DELAY: number;

@@ -50,2 +50,3 @@ import { Observable } from '../../tools/observable';

trackingType: sessionStore.getSession()[productKey],
isReplayForced: !!sessionStore.getSession().forcedReplay,
};

@@ -57,3 +58,5 @@ }

expireObservable: expireObservable,
sessionStateUpdateObservable: sessionStore.sessionStateUpdateObservable,
expire: sessionStore.expire,
updateSessionState: sessionStore.updateSessionState,
};

@@ -60,0 +63,0 @@ }

@@ -12,4 +12,9 @@ import { Observable } from '../../tools/observable';

expireObservable: Observable<void>;
sessionStateUpdateObservable: Observable<{
previousState: SessionState;
newState: SessionState;
}>;
expire: () => void;
stop: () => void;
updateSessionState: (state: Partial<SessionState>) => void;
}

@@ -16,0 +21,0 @@ /**

@@ -6,2 +6,3 @@ import { clearInterval, setInterval } from '../../tools/timer';

import { generateUUID } from '../../tools/utils/stringUtils';
import { assign } from '../../tools/utils/polyfills';
import { selectCookieStrategy, initCookieStrategy } from './storeStrategies/sessionInCookie';

@@ -37,2 +38,3 @@ import { getExpiredSessionState, isSessionInExpiredState, isSessionInNotStartedState, isSessionStarted, } from './sessionState';

var expireObservable = new Observable();
var sessionStateUpdateObservable = new Observable();
var sessionStoreStrategy = sessionStoreStrategyType.type === 'Cookie'

@@ -88,2 +90,3 @@ ? initCookieStrategy(sessionStoreStrategyType.cookieOptions)

else {
sessionStateUpdateObservable.notify({ previousState: sessionCache, newState: sessionState });
sessionCache = sessionState;

@@ -132,2 +135,8 @@ }

}
function updateSessionState(partialSessionState) {
processSessionStoreOperations({
process: function (sessionState) { return assign({}, sessionState, partialSessionState); },
after: synchronizeSession,
}, sessionStoreStrategy);
}
return {

@@ -139,2 +148,3 @@ expandOrRenewSession: throttledExpandOrRenewSession,

expireObservable: expireObservable,
sessionStateUpdateObservable: sessionStateUpdateObservable,
restartSession: startSession,

@@ -149,4 +159,5 @@ expire: function () {

},
updateSessionState: updateSessionState,
};
}
//# sourceMappingURL=sessionStore.js.map

@@ -61,3 +61,3 @@ import { ConsoleApiName } from '../../tools/display';

service: telemetryService,
version: "5.20.0",
version: "5.21.0",
source: 'browser',

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

export { Configuration, InitConfiguration, validateAndBuildConfiguration, DefaultPrivacyLevel, TraceContextInjection, EndpointBuilder, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration';
export { TrackingConsent, TrackingConsentState, createTrackingConsentState } from './domain/trackingConsent';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, ExperimentalFeature, } from './tools/experimentalFeatures';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, initFeatureFlags, ExperimentalFeature, } from './tools/experimentalFeatures';
export { trackRuntimeError } from './domain/error/trackRuntimeError';

@@ -5,0 +5,0 @@ export { computeStackTrace, StackTrace } from './tools/stackTrace/computeStackTrace';

export { validateAndBuildConfiguration, DefaultPrivacyLevel, TraceContextInjection, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration';
export { TrackingConsent, createTrackingConsentState } from './domain/trackingConsent';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, ExperimentalFeature, } from './tools/experimentalFeatures';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, initFeatureFlags, ExperimentalFeature, } from './tools/experimentalFeatures';
export { trackRuntimeError } from './domain/error/trackRuntimeError';

@@ -5,0 +5,0 @@ export { computeStackTrace } from './tools/stackTrace/computeStackTrace';

@@ -16,2 +16,3 @@ /**

}
export declare function initFeatureFlags(enableExperimentalFeatures?: string[] | undefined): void;
export declare function addExperimentalFeatures(enabledFeatures: ExperimentalFeature[]): void;

@@ -18,0 +19,0 @@ export declare function isExperimentalFeatureEnabled(featureName: ExperimentalFeature): boolean;

@@ -12,2 +12,3 @@ /**

// string is an expected feature flag
import { objectHasValue } from './utils/objectUtils';
// eslint-disable-next-line no-restricted-syntax

@@ -22,2 +23,9 @@ export var ExperimentalFeature;

var enabledExperimentalFeatures = new Set();
export function initFeatureFlags(enableExperimentalFeatures) {
if (Array.isArray(enableExperimentalFeatures)) {
addExperimentalFeatures(enableExperimentalFeatures.filter(function (flag) {
return objectHasValue(ExperimentalFeature, flag);
}));
}
}
export function addExperimentalFeatures(enabledFeatures) {

@@ -24,0 +32,0 @@ enabledFeatures.forEach(function (flag) {

@@ -21,1 +21,2 @@ export declare function includes(candidate: string, search: string): boolean;

export declare function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
export declare function assign<T, U, V, W, X>(target: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X;
{
"name": "@datadog/browser-core",
"version": "5.20.0",
"version": "5.21.0",
"license": "Apache-2.0",

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

},
"gitHead": "1dafdcfbf43a0f0ed8a0cbd5f13d16ba68378074"
"gitHead": "717e92a496147b5e5f4e0e23e56984944a9c0493"
}
import { catchUserErrors } from '../../tools/catchUserErrors'
import { DOCS_ORIGIN, display } from '../../tools/display'
import type { RawTelemetryConfiguration } from '../telemetry'
import { ExperimentalFeature, addExperimentalFeatures } from '../../tools/experimentalFeatures'
import type { Duration } from '../../tools/utils/timeUtils'

@@ -32,20 +31,70 @@ import { ONE_SECOND } from '../../tools/utils/timeUtils'

export interface InitConfiguration {
// global options
/**
* The client token for Datadog. Required for authenticating your application with Datadog.
*/
clientToken: string
beforeSend?: GenericBeforeSendCallback | undefined
/**
* The percentage of sessions tracked. A value between 0 and 100.
* @default 100
*/
sessionSampleRate?: number | undefined
/**
* The percentage of telemetry events sent. A value between 0 and 100.
* @default 20
*/
telemetrySampleRate?: number | undefined
/**
* Initialization fails silently if the RUM Browser SDK is already initialized on the page.
* @default false
*/
silentMultipleInit?: boolean | undefined
/**
* Allows the use of localStorage when cookies cannot be set. This enables the RUM Browser SDK to run in environments that do not provide cookie support.
* See [Monitor Electron Applications Using the Browser SDK](https://docs.datadoghq.com/real_user_monitoring/guide/monitor-electron-applications-using-browser-sdk) for further information.
* @default false
*/
allowFallbackToLocalStorage?: boolean | undefined
/**
* Allow listening to DOM events dispatched programmatically ([untrusted events](https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted)). Enabling this option can be useful if you heavily rely on programmatic events, such as in an automated UI test environment.
* @default false
*/
allowUntrustedEvents?: boolean | undefined
/**
* Store global context and user context in localStorage to preserve them along the user navigation.
* See [Contexts life cycle](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#contexts-life-cycle) for further information.
* @default false
*/
storeContextsAcrossPages?: boolean | undefined
/**
* Set the initial user tracking consent state.
* See [User tracking consent](https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#user-tracking-consent) for further information.
* @default granted
*/
trackingConsent?: TrackingConsent | undefined
// transport options
/**
* Optional proxy URL, for example: https://www.proxy.com/path.
* See [Proxy Your Browser RUM Data](https://docs.datadoghq.com/real_user_monitoring/guide/proxy-rum-data) for further information.
*/
proxy?: string | ProxyFn | undefined
/**
* The Datadog [site](https://docs.datadoghq.com/getting_started/site) parameter of your organization.
* @default datadoghq.com
*/
site?: string | undefined
// tag and context options
/**
* The service name for your application. Follows the [tag syntax requirements](https://docs.datadoghq.com/getting_started/tagging/#define-tags).
*/
service?: string | undefined | null
/**
* The application’s environment, for example: prod, pre-prod, and staging. Follows the [tag syntax requirements](https://docs.datadoghq.com/getting_started/tagging/#define-tags).
*/
env?: string | undefined | null
/**
* The application’s version, for example: 1.2.3, 6c44da20, and 2020.02.13. Follows the [tag syntax requirements](https://docs.datadoghq.com/getting_started/tagging/#define-tags).
*/
version?: string | undefined | null

@@ -55,17 +104,50 @@

/**
* Whether a secure cross-site session cookie is used
* @default false
* @deprecated use usePartitionedCrossSiteSessionCookie instead
*/
useCrossSiteSessionCookie?: boolean | undefined
/**
* Use a partitioned secure cross-site session cookie. This allows the RUM Browser SDK to run when the site is loaded from another one (iframe). Implies `useSecureSessionCookie`.
* @default false
*/
usePartitionedCrossSiteSessionCookie?: boolean | undefined
/**
* Use a secure session cookie. This disables RUM events sent on insecure (non-HTTPS) connections.
* @default false
*/
useSecureSessionCookie?: boolean | undefined
/**
* Preserve the session across subdomains for the same site.
* @default false
*/
trackSessionAcrossSubdomains?: boolean | undefined
// internal options
/**
* [Internal option] Enable experimental features
*/
enableExperimentalFeatures?: string[] | undefined
/**
* [Internal option] Configure the dual chipping to another datacenter
*/
replica?: ReplicaUserConfiguration | undefined
/**
* [Internal option] Set the datacenter from where the data is dual chipped
*/
datacenter?: string
/**
* [Internal option] Datadog internal analytics subdomain
*/
// TODO next major: remove this option and replace usages by proxyFn
internalAnalyticsSubdomain?: string
/**
* [Internal option] The percentage of telemetry configuration sent. A value between 0 and 100.
* @default 5
*/
telemetryConfigurationSampleRate?: number
/**
* [Internal option] The percentage of telemetry usage sent. A value between 0 and 100.
* @default 5
*/
telemetryUsageSampleRate?: number

@@ -101,2 +183,3 @@ }

trackingConsent: TrackingConsent
storeContextsAcrossPages: boolean

@@ -183,11 +266,2 @@ // Event limits

// Set the experimental feature flags as early as possible, so we can use them in most places
if (Array.isArray(initConfiguration.enableExperimentalFeatures)) {
addExperimentalFeatures(
initConfiguration.enableExperimentalFeatures.filter((flag): flag is ExperimentalFeature =>
objectHasValue(ExperimentalFeature, flag)
)
)
}
return assign(

@@ -206,3 +280,3 @@ {

trackingConsent: initConfiguration.trackingConsent ?? TrackingConsent.GRANTED,
storeContextsAcrossPages: !!initConfiguration.storeContextsAcrossPages,
/**

@@ -209,0 +283,0 @@ * beacon payload max queue size implementation is 64kb

@@ -12,2 +12,3 @@ import { Observable } from '../../tools/observable'

import { startSessionStore } from './sessionStore'
import type { SessionState } from './sessionState'

@@ -21,3 +22,5 @@ export interface SessionManager<TrackingType extends string> {

expireObservable: Observable<void>
sessionStateUpdateObservable: Observable<{ previousState: SessionState; newState: SessionState }>
expire: () => void
updateSessionState: (state: Partial<SessionState>) => void
}

@@ -28,2 +31,3 @@

trackingType: TrackingType
isReplayForced: boolean
}

@@ -85,2 +89,3 @@

trackingType: sessionStore.getSession()[productKey] as TrackingType,
isReplayForced: !!sessionStore.getSession().forcedReplay,
}

@@ -93,3 +98,5 @@ }

expireObservable,
sessionStateUpdateObservable: sessionStore.sessionStateUpdateObservable,
expire: sessionStore.expire,
updateSessionState: sessionStore.updateSessionState,
}

@@ -96,0 +103,0 @@ }

@@ -7,2 +7,3 @@ import { clearInterval, setInterval } from '../../tools/timer'

import type { InitConfiguration } from '../configuration'
import { assign } from '../../tools/utils/polyfills'
import { selectCookieStrategy, initCookieStrategy } from './storeStrategies/sessionInCookie'

@@ -27,4 +28,6 @@ import type { SessionStoreStrategyType } from './storeStrategies/sessionStoreStrategy'

expireObservable: Observable<void>
sessionStateUpdateObservable: Observable<{ previousState: SessionState; newState: SessionState }>
expire: () => void
stop: () => void
updateSessionState: (state: Partial<SessionState>) => void
}

@@ -66,2 +69,3 @@

const expireObservable = new Observable<void>()
const sessionStateUpdateObservable = new Observable<{ previousState: SessionState; newState: SessionState }>()

@@ -134,2 +138,3 @@ const sessionStoreStrategy =

} else {
sessionStateUpdateObservable.notify({ previousState: sessionCache, newState: sessionState })
sessionCache = sessionState

@@ -189,2 +194,12 @@ }

function updateSessionState(partialSessionState: Partial<SessionState>) {
processSessionStoreOperations(
{
process: (sessionState) => assign({}, sessionState, partialSessionState),
after: synchronizeSession,
},
sessionStoreStrategy
)
}
return {

@@ -196,2 +211,3 @@ expandOrRenewSession: throttledExpandOrRenewSession,

expireObservable,
sessionStateUpdateObservable,
restartSession: startSession,

@@ -206,3 +222,4 @@ expire: () => {

},
updateSessionState,
}
}

@@ -20,2 +20,3 @@ export {

getExperimentalFeatures,
initFeatureFlags,
ExperimentalFeature,

@@ -22,0 +23,0 @@ } from './tools/experimentalFeatures'

@@ -12,2 +12,5 @@ /**

// string is an expected feature flag
import { objectHasValue } from './utils/objectUtils'
// eslint-disable-next-line no-restricted-syntax

@@ -23,2 +26,12 @@ export enum ExperimentalFeature {

export function initFeatureFlags(enableExperimentalFeatures?: string[] | undefined) {
if (Array.isArray(enableExperimentalFeatures)) {
addExperimentalFeatures(
enableExperimentalFeatures.filter((flag): flag is ExperimentalFeature =>
objectHasValue(ExperimentalFeature, flag)
)
)
}
}
export function addExperimentalFeatures(enabledFeatures: ExperimentalFeature[]): void {

@@ -25,0 +38,0 @@ enabledFeatures.forEach((flag) => {

@@ -83,2 +83,3 @@ export function includes(candidate: string, search: string): boolean

export function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W
export function assign<T, U, V, W, X>(target: T, source1: U, source2: V, source3: W, source4: X): T & U & V & W & X
export function assign(target: Assignable, ...toAssign: Assignable[]) {

@@ -85,0 +86,0 @@ toAssign.forEach((source: Assignable) => {

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc