Socket
Socket
Sign inDemoInstall

@datadog/browser-core

Package Overview
Dependencies
0
Maintainers
1
Versions
249
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.37.0 to 4.38.0

cjs/browser/runOnReadyState.d.ts

2

cjs/boot/init.js

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

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

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPageExitReason = exports.createPageExitObservable = exports.PageExitReason = void 0;
var configuration_1 = require("../domain/configuration");
var experimentalFeatures_1 = require("../tools/experimentalFeatures");
var observable_1 = require("../tools/observable");

@@ -16,3 +16,3 @@ var utils_1 = require("../tools/utils");

var observable = new observable_1.Observable(function () {
var pagehideEnabled = (0, configuration_1.isExperimentalFeatureEnabled)('pagehide');
var pagehideEnabled = (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.PAGEHIDE);
var stopListeners = (0, addEventListener_1.addEventListeners)(window, ["visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, "freeze" /* DOM_EVENT.FREEZE */, "pagehide" /* DOM_EVENT.PAGE_HIDE */], function (event) {

@@ -19,0 +19,0 @@ if (event.type === "pagehide" /* DOM_EVENT.PAGE_HIDE */ && pagehideEnabled) {

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

var utils_1 = require("../../tools/utils");
var experimentalFeatures_1 = require("./experimentalFeatures");
var experimentalFeatures_1 = require("../../tools/experimentalFeatures");
var transportConfiguration_1 = require("./transportConfiguration");

@@ -37,3 +37,7 @@ exports.DefaultPrivacyLevel = {

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

@@ -40,0 +44,0 @@ beforeSend: initConfiguration.beforeSend && (0, catchUserErrors_1.catchUserErrors)(initConfiguration.beforeSend, 'beforeSend threw an error:'),

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

var utils_1 = require("../../tools/utils");
var experimentalFeatures_1 = require("../../tools/experimentalFeatures");
var intakeSites_1 = require("./intakeSites");
var experimentalFeatures_1 = require("./experimentalFeatures");
exports.ENDPOINTS = {

@@ -70,4 +70,4 @@ logs: 'logs',

var clientToken = _a.clientToken, internalAnalyticsSubdomain = _a.internalAnalyticsSubdomain;
var tags = ["sdk_version:".concat("4.37.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && (0, experimentalFeatures_1.isExperimentalFeatureEnabled)('collect_flush_reason')) {
var tags = ["sdk_version:".concat("4.38.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.COLLECT_FLUSH_REASON)) {
tags.push("flush_reason:".concat(flushReason));

@@ -82,3 +82,3 @@ }

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

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

export { Configuration, InitConfiguration, buildCookieOptions, DefaultPrivacyLevel, validateAndBuildConfiguration, serializeConfiguration, } from './configuration';
export { createEndpointBuilder, EndpointBuilder, EndpointType } from './endpointBuilder';
export { isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, } from './experimentalFeatures';
export * from './intakeSites';

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.getExperimentalFeatures = exports.resetExperimentalFeatures = exports.updateExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.createEndpointBuilder = exports.serializeConfiguration = exports.validateAndBuildConfiguration = exports.DefaultPrivacyLevel = exports.buildCookieOptions = void 0;
exports.createEndpointBuilder = exports.serializeConfiguration = exports.validateAndBuildConfiguration = exports.DefaultPrivacyLevel = exports.buildCookieOptions = void 0;
var configuration_1 = require("./configuration");

@@ -26,8 +26,3 @@ Object.defineProperty(exports, "buildCookieOptions", { enumerable: true, get: function () { return configuration_1.buildCookieOptions; } });

Object.defineProperty(exports, "createEndpointBuilder", { enumerable: true, get: function () { return endpointBuilder_1.createEndpointBuilder; } });
var experimentalFeatures_1 = require("./experimentalFeatures");
Object.defineProperty(exports, "isExperimentalFeatureEnabled", { enumerable: true, get: function () { return experimentalFeatures_1.isExperimentalFeatureEnabled; } });
Object.defineProperty(exports, "updateExperimentalFeatures", { enumerable: true, get: function () { return experimentalFeatures_1.updateExperimentalFeatures; } });
Object.defineProperty(exports, "resetExperimentalFeatures", { enumerable: true, get: function () { return experimentalFeatures_1.resetExperimentalFeatures; } });
Object.defineProperty(exports, "getExperimentalFeatures", { enumerable: true, get: function () { return experimentalFeatures_1.getExperimentalFeatures; } });
__exportStar(require("./intakeSites"), exports);
//# sourceMappingURL=index.js.map

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

var tracekit_1 = require("../tracekit");
var error_1 = require("../../tools/error");
var error_1 = require("../error/error");
var observable_1 = require("../../tools/observable");

@@ -12,3 +12,3 @@ var utils_1 = require("../../tools/utils");

var sanitize_1 = require("../../tools/sanitize");
var configuration_1 = require("../configuration");
var experimentalFeatures_1 = require("../../tools/experimentalFeatures");
var consoleObservablesByApi = {};

@@ -64,3 +64,3 @@ function initConsoleObservable(apis) {

if (typeof param === 'string') {
return (0, configuration_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, sanitize_1.sanitize)(param) : param;
return (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.SANITIZE_INPUTS) ? (0, sanitize_1.sanitize)(param) : param;
}

@@ -70,4 +70,4 @@ if (param instanceof Error) {

}
return (0, utils_1.jsonStringify)((0, configuration_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, sanitize_1.sanitize)(param) : param, undefined, 2);
return (0, utils_1.jsonStringify)((0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.SANITIZE_INPUTS) ? (0, sanitize_1.sanitize)(param) : param, undefined, 2);
}
//# sourceMappingURL=consoleObservable.js.map

@@ -1,5 +0,5 @@

import type { RawError } from '../../tools/error';
import type { Observable } from '../../tools/observable';
import type { RawError } from './error';
export declare function trackRuntimeError(errorObservable: Observable<RawError>): {
stop: () => void;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.trackRuntimeError = void 0;
var error_1 = require("../../tools/error");
var timeUtils_1 = require("../../tools/timeUtils");
var tracekit_1 = require("../tracekit");
var error_1 = require("./error");
function trackRuntimeError(errorObservable) {

@@ -8,0 +8,0 @@ return (0, tracekit_1.startUnhandledErrorCollection)(function (stackTrace, originalError) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initReportObservable = exports.RawReportType = void 0;
var error_1 = require("../../tools/error");
var error_1 = require("../error/error");
var monitor_1 = require("../../tools/monitor");

@@ -6,0 +6,0 @@ var observable_1 = require("../../tools/observable");

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

var cookie_1 = require("../../browser/cookie");
var timer_1 = require("../../browser/timer");
var timer_1 = require("../../tools/timer");
var browserDetection_1 = require("../../tools/browserDetection");

@@ -31,0 +31,0 @@ var timeUtils_1 = require("../../tools/timeUtils");

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

var addEventListener_1 = require("../../browser/addEventListener");
var timer_1 = require("../../browser/timer");
var timer_1 = require("../../tools/timer");
var oldCookiesMigration_1 = require("./oldCookiesMigration");

@@ -34,0 +34,0 @@ var sessionStore_1 = require("./sessionStore");

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

var cookie_1 = require("../../browser/cookie");
var timer_1 = require("../../browser/timer");
var timer_1 = require("../../tools/timer");
var observable_1 = require("../../tools/observable");

@@ -31,0 +31,0 @@ var timeUtils_1 = require("../../tools/timeUtils");

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

var display_1 = require("../../tools/display");
var error_1 = require("../../tools/error");
var error_1 = require("../error/error");
var utils_1 = require("../../tools/utils");
var experimentalFeatures_1 = require("../../tools/experimentalFeatures");
var configuration_1 = require("../configuration");

@@ -48,3 +49,3 @@ var tracekit_1 = require("../tracekit");

service: telemetryService,
version: "4.37.0",
version: "4.38.0",
source: 'browser',

@@ -55,3 +56,3 @@ _dd: {

telemetry: event,
experimental_features: (0, utils_1.arrayFrom)((0, configuration_1.getExperimentalFeatures)()),
experimental_features: (0, utils_1.arrayFrom)((0, experimentalFeatures_1.getExperimentalFeatures)()),
}, contextProvider !== undefined ? contextProvider() : {});

@@ -58,0 +59,0 @@ }

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

export { Configuration, InitConfiguration, buildCookieOptions, validateAndBuildConfiguration, DefaultPrivacyLevel, EndpointBuilder, isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, serializeConfiguration, } from './domain/configuration';
export { Configuration, InitConfiguration, buildCookieOptions, validateAndBuildConfiguration, DefaultPrivacyLevel, EndpointBuilder, serializeConfiguration, } from './domain/configuration';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, ExperimentalFeature, } from './tools/experimentalFeatures';
export { trackRuntimeError } from './domain/error/trackRuntimeError';

@@ -17,9 +18,10 @@ export { computeStackTrace, StackTrace } from './domain/tracekit';

export * from './tools/sanitize';
export * from './tools/createEventRateLimiter';
export * from './tools/getGlobalObject';
export * from './domain/eventRateLimiter/createEventRateLimiter';
export * from './tools/browserDetection';
export { sendToExtension } from './tools/sendToExtension';
export { runOnReadyState } from './tools/runOnReadyState';
export { runOnReadyState } from './browser/runOnReadyState';
export { getZoneJsOriginalValue } from './tools/getZoneJsOriginalValue';
export { instrumentMethod, instrumentMethodAndCallOriginal, instrumentSetter } from './tools/instrumentMethod';
export { ErrorSource, ErrorHandling, computeRawError, createHandlingStack, RawError, RawErrorCause, ErrorWithCause, toStackTraceString, getFileFromStackTraceString, NO_ERROR_STACK_PRESENT_MESSAGE, PROVIDED_ERROR_MESSAGE_PREFIX, } from './tools/error';
export { ErrorSource, ErrorHandling, computeRawError, createHandlingStack, RawError, RawErrorCause, ErrorWithCause, toStackTraceString, getFileFromStackTraceString, NO_ERROR_STACK_PRESENT_MESSAGE, PROVIDED_ERROR_MESSAGE_PREFIX, } from './domain/error/error';
export { Context, ContextArray, ContextValue } from './tools/context';

@@ -31,3 +33,3 @@ export { areCookiesAuthorized, getCookie, setCookie, deleteCookie, COOKIE_ACCESS_DELAY } from './browser/cookie';

export * from './browser/addEventListener';
export * from './browser/timer';
export * from './tools/timer';
export { initConsoleObservable, ConsoleLog } from './domain/console/consoleObservable';

@@ -37,2 +39,3 @@ export { BoundedBuffer } from './tools/boundedBuffer';

export { createContextManager, ContextManager } from './tools/contextManager';
export { warnIfCustomerDataLimitReached, CustomerDataType } from './tools/heavyCustomerDataWarning';
export { limitModification } from './tools/limitModification';

@@ -39,0 +42,0 @@ export { ContextHistory, ContextHistoryEntry, CLEAR_OLD_CONTEXTS_INTERVAL } from './tools/contextHistory';

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteCookie = exports.setCookie = exports.getCookie = exports.areCookiesAuthorized = exports.PROVIDED_ERROR_MESSAGE_PREFIX = exports.NO_ERROR_STACK_PRESENT_MESSAGE = exports.getFileFromStackTraceString = exports.toStackTraceString = exports.createHandlingStack = exports.computeRawError = exports.ErrorSource = exports.instrumentSetter = exports.instrumentMethodAndCallOriginal = exports.instrumentMethod = exports.getZoneJsOriginalValue = exports.runOnReadyState = exports.sendToExtension = exports.startBatchWithReplica = exports.getEventBridge = exports.canUseEventBridge = exports.Batch = exports.createHttpRequest = exports.SESSION_TIME_OUT_DELAY = exports.stopSessionManager = exports.startSessionManager = exports.Observable = exports.setDebugMode = exports.callMonitored = exports.monitor = exports.monitored = exports.addTelemetryConfiguration = exports.isTelemetryReplicationAllowed = exports.resetTelemetry = exports.startFakeTelemetry = exports.addTelemetryError = exports.addTelemetryDebug = exports.startTelemetry = exports.RawReportType = exports.initReportObservable = exports.makePublicApi = exports.defineGlobal = exports.computeStackTrace = exports.trackRuntimeError = exports.serializeConfiguration = exports.resetExperimentalFeatures = exports.updateExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.DefaultPrivacyLevel = exports.validateAndBuildConfiguration = exports.buildCookieOptions = void 0;
exports.sanitizeUser = exports.checkUser = exports.getSyntheticsResultId = exports.getSyntheticsTestId = exports.willSyntheticsInjectRum = exports.SESSION_COOKIE_NAME = exports.readBytesFromStream = exports.CLEAR_OLD_CONTEXTS_INTERVAL = exports.ContextHistory = exports.limitModification = exports.createContextManager = exports.catchUserErrors = exports.BoundedBuffer = exports.initConsoleObservable = exports.isPageExitReason = exports.PageExitReason = exports.createPageExitObservable = exports.initFetchObservable = exports.initXhrObservable = exports.COOKIE_ACCESS_DELAY = void 0;
exports.getCookie = exports.areCookiesAuthorized = exports.PROVIDED_ERROR_MESSAGE_PREFIX = exports.NO_ERROR_STACK_PRESENT_MESSAGE = exports.getFileFromStackTraceString = exports.toStackTraceString = exports.createHandlingStack = exports.computeRawError = exports.ErrorSource = exports.instrumentSetter = exports.instrumentMethodAndCallOriginal = exports.instrumentMethod = exports.getZoneJsOriginalValue = exports.runOnReadyState = exports.sendToExtension = exports.startBatchWithReplica = exports.getEventBridge = exports.canUseEventBridge = exports.Batch = exports.createHttpRequest = exports.SESSION_TIME_OUT_DELAY = exports.stopSessionManager = exports.startSessionManager = exports.Observable = exports.setDebugMode = exports.callMonitored = exports.monitor = exports.monitored = exports.addTelemetryConfiguration = exports.isTelemetryReplicationAllowed = exports.resetTelemetry = exports.startFakeTelemetry = exports.addTelemetryError = exports.addTelemetryDebug = exports.startTelemetry = exports.RawReportType = exports.initReportObservable = exports.makePublicApi = exports.defineGlobal = exports.computeStackTrace = exports.trackRuntimeError = exports.ExperimentalFeature = exports.getExperimentalFeatures = exports.resetExperimentalFeatures = exports.addExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.serializeConfiguration = exports.DefaultPrivacyLevel = exports.validateAndBuildConfiguration = exports.buildCookieOptions = void 0;
exports.sanitizeUser = exports.checkUser = exports.getSyntheticsResultId = exports.getSyntheticsTestId = exports.willSyntheticsInjectRum = exports.SESSION_COOKIE_NAME = exports.readBytesFromStream = exports.CLEAR_OLD_CONTEXTS_INTERVAL = exports.ContextHistory = exports.limitModification = exports.warnIfCustomerDataLimitReached = exports.createContextManager = exports.catchUserErrors = exports.BoundedBuffer = exports.initConsoleObservable = exports.isPageExitReason = exports.PageExitReason = exports.createPageExitObservable = exports.initFetchObservable = exports.initXhrObservable = exports.COOKIE_ACCESS_DELAY = exports.deleteCookie = exports.setCookie = void 0;
var configuration_1 = require("./domain/configuration");

@@ -24,6 +24,9 @@ Object.defineProperty(exports, "buildCookieOptions", { enumerable: true, get: function () { return configuration_1.buildCookieOptions; } });

Object.defineProperty(exports, "DefaultPrivacyLevel", { enumerable: true, get: function () { return configuration_1.DefaultPrivacyLevel; } });
Object.defineProperty(exports, "isExperimentalFeatureEnabled", { enumerable: true, get: function () { return configuration_1.isExperimentalFeatureEnabled; } });
Object.defineProperty(exports, "updateExperimentalFeatures", { enumerable: true, get: function () { return configuration_1.updateExperimentalFeatures; } });
Object.defineProperty(exports, "resetExperimentalFeatures", { enumerable: true, get: function () { return configuration_1.resetExperimentalFeatures; } });
Object.defineProperty(exports, "serializeConfiguration", { enumerable: true, get: function () { return configuration_1.serializeConfiguration; } });
var experimentalFeatures_1 = require("./tools/experimentalFeatures");
Object.defineProperty(exports, "isExperimentalFeatureEnabled", { enumerable: true, get: function () { return experimentalFeatures_1.isExperimentalFeatureEnabled; } });
Object.defineProperty(exports, "addExperimentalFeatures", { enumerable: true, get: function () { return experimentalFeatures_1.addExperimentalFeatures; } });
Object.defineProperty(exports, "resetExperimentalFeatures", { enumerable: true, get: function () { return experimentalFeatures_1.resetExperimentalFeatures; } });
Object.defineProperty(exports, "getExperimentalFeatures", { enumerable: true, get: function () { return experimentalFeatures_1.getExperimentalFeatures; } });
Object.defineProperty(exports, "ExperimentalFeature", { enumerable: true, get: function () { return experimentalFeatures_1.ExperimentalFeature; } });
var trackRuntimeError_1 = require("./domain/error/trackRuntimeError");

@@ -71,7 +74,8 @@ Object.defineProperty(exports, "trackRuntimeError", { enumerable: true, get: function () { return trackRuntimeError_1.trackRuntimeError; } });

__exportStar(require("./tools/sanitize"), exports);
__exportStar(require("./tools/createEventRateLimiter"), exports);
__exportStar(require("./tools/getGlobalObject"), exports);
__exportStar(require("./domain/eventRateLimiter/createEventRateLimiter"), exports);
__exportStar(require("./tools/browserDetection"), exports);
var sendToExtension_1 = require("./tools/sendToExtension");
Object.defineProperty(exports, "sendToExtension", { enumerable: true, get: function () { return sendToExtension_1.sendToExtension; } });
var runOnReadyState_1 = require("./tools/runOnReadyState");
var runOnReadyState_1 = require("./browser/runOnReadyState");
Object.defineProperty(exports, "runOnReadyState", { enumerable: true, get: function () { return runOnReadyState_1.runOnReadyState; } });

@@ -84,3 +88,3 @@ var getZoneJsOriginalValue_1 = require("./tools/getZoneJsOriginalValue");

Object.defineProperty(exports, "instrumentSetter", { enumerable: true, get: function () { return instrumentMethod_1.instrumentSetter; } });
var error_1 = require("./tools/error");
var error_1 = require("./domain/error/error");
Object.defineProperty(exports, "ErrorSource", { enumerable: true, get: function () { return error_1.ErrorSource; } });

@@ -108,3 +112,3 @@ Object.defineProperty(exports, "computeRawError", { enumerable: true, get: function () { return error_1.computeRawError; } });

__exportStar(require("./browser/addEventListener"), exports);
__exportStar(require("./browser/timer"), exports);
__exportStar(require("./tools/timer"), exports);
var consoleObservable_1 = require("./domain/console/consoleObservable");

@@ -118,2 +122,4 @@ Object.defineProperty(exports, "initConsoleObservable", { enumerable: true, get: function () { return consoleObservable_1.initConsoleObservable; } });

Object.defineProperty(exports, "createContextManager", { enumerable: true, get: function () { return contextManager_1.createContextManager; } });
var heavyCustomerDataWarning_1 = require("./tools/heavyCustomerDataWarning");
Object.defineProperty(exports, "warnIfCustomerDataLimitReached", { enumerable: true, get: function () { return heavyCustomerDataWarning_1.warnIfCustomerDataLimitReached; } });
var limitModification_1 = require("./tools/limitModification");

@@ -120,0 +126,0 @@ Object.defineProperty(exports, "limitModification", { enumerable: true, get: function () { return limitModification_1.limitModification; } });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextHistory = exports.CLEAR_OLD_CONTEXTS_INTERVAL = void 0;
var timer_1 = require("../browser/timer");
var timer_1 = require("./timer");
var timeUtils_1 = require("./timeUtils");

@@ -6,0 +6,0 @@ var utils_1 = require("./utils");

import { computeBytesCount } from './utils';
import type { Context } from './context';
import type { CustomerDataType } from './heavyCustomerDataWarning';
export declare const BYTES_COMPUTATION_THROTTLING_DELAY = 200;
export type ContextManager = ReturnType<typeof createContextManager>;
export declare function createContextManager(computeBytesCountImpl?: typeof computeBytesCount): {
export declare function createContextManager(customerDataType: CustomerDataType, computeBytesCountImpl?: typeof computeBytesCount): {
getBytesCount: () => number;

@@ -6,0 +8,0 @@ /** @deprecated use getContext instead */

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createContextManager = void 0;
var configuration_1 = require("../domain/configuration");
exports.createContextManager = exports.BYTES_COMPUTATION_THROTTLING_DELAY = void 0;
var experimentalFeatures_1 = require("./experimentalFeatures");
var utils_1 = require("./utils");
var heavyCustomerDataWarning_1 = require("./heavyCustomerDataWarning");
var sanitize_1 = require("./sanitize");
function createContextManager(computeBytesCountImpl) {
exports.BYTES_COMPUTATION_THROTTLING_DELAY = 200;
function createContextManager(customerDataType, computeBytesCountImpl) {
if (computeBytesCountImpl === void 0) { computeBytesCountImpl = utils_1.computeBytesCount; }
var context = {};
var bytesCountCache;
var alreadyWarned = false;
// Throttle the bytes computation to minimize the impact on performance.
// Especially useful if the user call context APIs synchronously multiple times in a row
var computeBytesCountThrottled = (0, utils_1.throttle)(function (context) {
bytesCountCache = computeBytesCountImpl((0, utils_1.jsonStringify)(context));
if (!alreadyWarned) {
alreadyWarned = (0, heavyCustomerDataWarning_1.warnIfCustomerDataLimitReached)(bytesCountCache, customerDataType);
}
}, exports.BYTES_COMPUTATION_THROTTLING_DELAY).throttled;
return {
getBytesCount: function () {
if (bytesCountCache === undefined) {
bytesCountCache = computeBytesCountImpl((0, utils_1.jsonStringify)(context));
}
return bytesCountCache;
},
getBytesCount: function () { return bytesCountCache; },
/** @deprecated use getContext instead */

@@ -23,3 +29,3 @@ get: function () { return context; },

context[key] = value;
bytesCountCache = undefined;
computeBytesCountThrottled(context);
},

@@ -29,3 +35,3 @@ /** @deprecated renamed to removeContextProperty */

delete context[key];
bytesCountCache = undefined;
computeBytesCountThrottled(context);
},

@@ -35,20 +41,24 @@ /** @deprecated use setContext instead */

context = newContext;
bytesCountCache = undefined;
computeBytesCountThrottled(context);
},
getContext: function () { return (0, utils_1.deepClone)(context); },
setContext: function (newContext) {
context = (0, configuration_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, sanitize_1.sanitize)(newContext) : (0, utils_1.deepClone)(newContext);
bytesCountCache = undefined;
context = (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.SANITIZE_INPUTS)
? (0, sanitize_1.sanitize)(newContext)
: (0, utils_1.deepClone)(newContext);
computeBytesCountThrottled(context);
},
setContextProperty: function (key, property) {
context[key] = (0, configuration_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, sanitize_1.sanitize)(property) : (0, utils_1.deepClone)(property);
bytesCountCache = undefined;
context[key] = (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.SANITIZE_INPUTS)
? (0, sanitize_1.sanitize)(property)
: (0, utils_1.deepClone)(property);
computeBytesCountThrottled(context);
},
removeContextProperty: function (key) {
delete context[key];
bytesCountCache = undefined;
computeBytesCountThrottled(context);
},
clearContext: function () {
context = {};
bytesCountCache = undefined;
bytesCountCache = 0;
},

@@ -55,0 +65,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getZoneJsOriginalValue = void 0;
var getGlobalObject_1 = require("./getGlobalObject");
/**

@@ -18,3 +19,3 @@ * Gets the original value for a DOM API that was potentially patched by Zone.js.

function getZoneJsOriginalValue(target, name) {
var browserWindow = window;
var browserWindow = (0, getGlobalObject_1.getGlobalObject)();
var original;

@@ -21,0 +22,0 @@ if (browserWindow.Zone && typeof browserWindow.Zone.__symbol__ === 'function') {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.instrumentSetter = exports.instrumentMethodAndCallOriginal = exports.instrumentMethod = void 0;
var timer_1 = require("../browser/timer");
var timer_1 = require("./timer");
var monitor_1 = require("./monitor");

@@ -6,0 +6,0 @@ var utils_1 = require("./utils");

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.limitModification = void 0;
var configuration_1 = require("../domain/configuration");
var experimentalFeatures_1 = require("./experimentalFeatures");
var sanitize_1 = require("./sanitize");

@@ -20,3 +20,3 @@ var utils_1 = require("./utils");

if (newType === originalType) {
set(object, path, (0, configuration_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, sanitize_1.sanitize)(newValue) : newValue);
set(object, path, (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.SANITIZE_INPUTS) ? (0, sanitize_1.sanitize)(newValue) : newValue);
}

@@ -23,0 +23,0 @@ else if (originalType === 'object' && (newType === 'undefined' || newType === 'null')) {

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

var targetData = sanitizeProcessor(containerToProcess.source[key], containerToProcess.path, key, containerQueue, visitedObjectsWithPath);
accumulatedCharacterCount += JSON.stringify(targetData).length + separatorLength;
if (targetData !== undefined) {
accumulatedCharacterCount += JSON.stringify(targetData).length;
}
else {
// When an element of an Array (targetData) is undefined, it is serialized as null:
// JSON.stringify([undefined]) => '[null]' - This accounts for 4 characters
accumulatedCharacterCount += 4;
}
accumulatedCharacterCount += separatorLength;
separatorLength = 1;
if (accumulatedCharacterCount > maxCharacterCount) {

@@ -43,3 +52,3 @@ warnOverCharacterLimit(maxCharacterCount, 'truncated', source);

}
separatorLength = 1;
;
containerToProcess.target[key] = targetData;

@@ -52,4 +61,9 @@ }

var targetData = sanitizeProcessor(containerToProcess.source[key], containerToProcess.path, key, containerQueue, visitedObjectsWithPath);
accumulatedCharacterCount +=
JSON.stringify(targetData).length + separatorLength + key.length + KEY_DECORATION_LENGTH;
// When a property of an object has an undefined value, it will be dropped during serialization:
// JSON.stringify({a:undefined}) => '{}'
if (targetData !== undefined) {
accumulatedCharacterCount +=
JSON.stringify(targetData).length + separatorLength + key.length + KEY_DECORATION_LENGTH;
separatorLength = 1;
}
if (accumulatedCharacterCount > maxCharacterCount) {

@@ -59,3 +73,3 @@ warnOverCharacterLimit(maxCharacterCount, 'truncated', source);

}
separatorLength = 1;
;
containerToProcess.target[key] = targetData;

@@ -62,0 +76,0 @@ }

@@ -41,3 +41,8 @@ "use strict";

if (checkURLSupported()) {
return base !== undefined ? new URL(url, base) : new URL(url);
try {
return base !== undefined ? new URL(url, base) : new URL(url);
}
catch (error) {
throw new Error("Failed to construct URL. ".concat((0, utils_1.jsonStringify)({ url: url, base: base })));
}
}

@@ -44,0 +49,0 @@ if (base === undefined && !/:/.test(url)) {

@@ -47,2 +47,3 @@ export declare const ONE_SECOND = 1000;

export declare function noop(): void;
export type ListenerHandler = () => void;
/**

@@ -67,2 +68,5 @@ * Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that

export declare function findLast<T, S extends T>(array: T[], predicate: (item: T, index: number, array: T[]) => item is S): S | undefined;
export declare function forEach<List extends {
[index: number]: any;
}>(list: List, callback: (value: List[number], index: number, parent: List) => void): void;
export declare function isPercentage(value: unknown): boolean;

@@ -87,6 +91,2 @@ export declare function isNumber(value: unknown): value is number;

export declare function endsWith(candidate: string, search: string): boolean;
/**
* inspired by https://mathiasbynens.be/notes/globalthis
*/
export declare function getGlobalObject<T>(): T;
export declare function getLocationOrigin(): string;

@@ -93,0 +93,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tryToClone = exports.computeBytesCount = exports.cssEscape = exports.matchList = exports.isMatchOption = exports.removeDuplicates = exports.requestIdleCallback = exports.combine = exports.deepClone = exports.mergeInto = exports.getType = exports.elementMatches = exports.safeTruncate = exports.findCommaSeparatedValue = exports.getLinkElementOrigin = exports.getLocationOrigin = exports.getGlobalObject = exports.endsWith = exports.startsWith = exports.mapValues = exports.isEmptyObject = exports.objectEntries = exports.objectHasValue = exports.objectValues = exports.isNumber = exports.isPercentage = exports.findLast = exports.find = exports.arrayFrom = exports.includes = exports.detachToJsonMethod = exports.jsonStringify = exports.noop = exports.round = exports.performDraw = exports.generateUUID = exports.shallowClone = exports.assign = exports.throttle = exports.ONE_MEBI_BYTE = exports.ONE_KIBI_BYTE = exports.ONE_YEAR = exports.ONE_DAY = exports.ONE_HOUR = exports.ONE_MINUTE = exports.ONE_SECOND = void 0;
var timer_1 = require("../browser/timer");
exports.tryToClone = exports.computeBytesCount = exports.cssEscape = exports.matchList = exports.isMatchOption = exports.removeDuplicates = exports.requestIdleCallback = exports.combine = exports.deepClone = exports.mergeInto = exports.getType = exports.elementMatches = exports.safeTruncate = exports.findCommaSeparatedValue = exports.getLinkElementOrigin = exports.getLocationOrigin = exports.endsWith = exports.startsWith = exports.mapValues = exports.isEmptyObject = exports.objectEntries = exports.objectHasValue = exports.objectValues = exports.isNumber = exports.isPercentage = exports.forEach = exports.findLast = exports.find = exports.arrayFrom = exports.includes = exports.detachToJsonMethod = exports.jsonStringify = exports.noop = exports.round = exports.performDraw = exports.generateUUID = exports.shallowClone = exports.assign = exports.throttle = exports.ONE_MEBI_BYTE = exports.ONE_KIBI_BYTE = exports.ONE_YEAR = exports.ONE_DAY = exports.ONE_HOUR = exports.ONE_MINUTE = exports.ONE_SECOND = void 0;
var timer_1 = require("./timer");
var display_1 = require("./display");

@@ -183,2 +183,6 @@ var monitor_1 = require("./monitor");

exports.findLast = findLast;
function forEach(list, callback) {
Array.prototype.forEach.call(list, callback);
}
exports.forEach = forEach;
function isPercentage(value) {

@@ -225,35 +229,2 @@ return isNumber(value) && value >= 0 && value <= 100;

exports.endsWith = endsWith;
/**
* inspired by https://mathiasbynens.be/notes/globalthis
*/
function getGlobalObject() {
if (typeof globalThis === 'object') {
return globalThis;
}
Object.defineProperty(Object.prototype, '_dd_temp_', {
get: function () {
return this;
},
configurable: true,
});
// @ts-ignore _dd_temp is defined using defineProperty
var globalObject = _dd_temp_;
// @ts-ignore _dd_temp is defined using defineProperty
delete Object.prototype._dd_temp_;
if (typeof globalObject !== 'object') {
// on safari _dd_temp_ is available on window but not globally
// fallback on other browser globals check
if (typeof self === 'object') {
globalObject = self;
}
else if (typeof window === 'object') {
globalObject = window;
}
else {
globalObject = {};
}
}
return globalObject;
}
exports.getGlobalObject = getGlobalObject;
function getLocationOrigin() {

@@ -260,0 +231,0 @@ return getLinkElementOrigin(window.location);

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

var observable_1 = require("../tools/observable");
var timer_1 = require("../browser/timer");
var timer_1 = require("../tools/timer");
var Batch = /** @class */ (function () {

@@ -10,0 +10,0 @@ function Batch(request, batchMessagesLimit, batchBytesLimit, messageBytesLimit, flushTimeout, pageExitObservable) {

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

var utils_1 = require("../tools/utils");
var getGlobalObject_1 = require("../tools/getGlobalObject");
function getEventBridge() {

@@ -23,3 +24,3 @@ var eventBridgeGlobal = getEventBridgeGlobal();

var _a;
if (currentHost === void 0) { currentHost = (_a = (0, utils_1.getGlobalObject)().location) === null || _a === void 0 ? void 0 : _a.hostname; }
if (currentHost === void 0) { currentHost = (_a = (0, getGlobalObject_1.getGlobalObject)().location) === null || _a === void 0 ? void 0 : _a.hostname; }
var bridge = getEventBridge();

@@ -33,4 +34,4 @@ return (!!bridge &&

function getEventBridgeGlobal() {
return (0, utils_1.getGlobalObject)().DatadogEventBridge;
return (0, getGlobalObject_1.getGlobalObject)().DatadogEventBridge;
}
//# sourceMappingURL=eventBridge.js.map
import type { EndpointBuilder } from '../domain/configuration';
import type { Context } from '../tools/context';
import type { RawError } from '../tools/error';
import type { RawError } from '../domain/error/error';
import type { FlushReason } from './batch';

@@ -5,0 +5,0 @@ /**

import type { EndpointType } from '../domain/configuration';
import type { RawError } from '../tools/error';
import type { RawError } from '../domain/error/error';
import type { Payload, HttpResponse } from './httpRequest';

@@ -4,0 +4,0 @@ export declare const MAX_ONGOING_BYTES_COUNT: number;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.newRetryState = exports.sendWithRetryStrategy = exports.INITIAL_BACKOFF_TIME = exports.MAX_BACKOFF_TIME = exports.MAX_QUEUE_BYTES_COUNT = exports.MAX_ONGOING_REQUESTS = exports.MAX_ONGOING_BYTES_COUNT = void 0;
var timer_1 = require("../browser/timer");
var timer_1 = require("../tools/timer");
var timeUtils_1 = require("../tools/timeUtils");
var utils_1 = require("../tools/utils");
var error_1 = require("../tools/error");
var error_1 = require("../domain/error/error");
exports.MAX_ONGOING_BYTES_COUNT = 80 * utils_1.ONE_KIBI_BYTE;

@@ -9,0 +9,0 @@ exports.MAX_ONGOING_REQUESTS = 32;

import type { Configuration, EndpointBuilder } from '../domain/configuration';
import type { RawError } from '../tools/error';
import type { RawError } from '../domain/error/error';
import type { Context } from '../tools/context';

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

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

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

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

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

import { isExperimentalFeatureEnabled } from '../domain/configuration';
import { isExperimentalFeatureEnabled, ExperimentalFeature } from '../tools/experimentalFeatures';
import { Observable } from '../tools/observable';

@@ -13,3 +13,3 @@ import { includes, noop, objectValues } from '../tools/utils';

var observable = new Observable(function () {
var pagehideEnabled = isExperimentalFeatureEnabled('pagehide');
var pagehideEnabled = isExperimentalFeatureEnabled(ExperimentalFeature.PAGEHIDE);
var stopListeners = addEventListeners(window, ["visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, "freeze" /* DOM_EVENT.FREEZE */, "pagehide" /* DOM_EVENT.PAGE_HIDE */], function (event) {

@@ -16,0 +16,0 @@ if (event.type === "pagehide" /* DOM_EVENT.PAGE_HIDE */ && pagehideEnabled) {

import { getCurrentSite } from '../../browser/cookie';
import { catchUserErrors } from '../../tools/catchUserErrors';
import { display } from '../../tools/display';
import { assign, isPercentage, ONE_KIBI_BYTE, ONE_SECOND } from '../../tools/utils';
import { updateExperimentalFeatures } from './experimentalFeatures';
import { assign, isPercentage, objectHasValue, ONE_KIBI_BYTE, ONE_SECOND } from '../../tools/utils';
import { ExperimentalFeature, addExperimentalFeatures } from '../../tools/experimentalFeatures';
import { computeTransportConfiguration } from './transportConfiguration';

@@ -33,3 +33,7 @@ export var DefaultPrivacyLevel = {

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

@@ -36,0 +40,0 @@ beforeSend: initConfiguration.beforeSend && catchUserErrors(initConfiguration.beforeSend, 'beforeSend threw an error:'),

import { timeStampNow } from '../../tools/timeUtils';
import { normalizeUrl } from '../../tools/urlPolyfill';
import { generateUUID } from '../../tools/utils';
import { ExperimentalFeature, isExperimentalFeatureEnabled } from '../../tools/experimentalFeatures';
import { INTAKE_SITE_AP1, INTAKE_SITE_US1 } from './intakeSites';
import { isExperimentalFeatureEnabled } from './experimentalFeatures';
export var ENDPOINTS = {

@@ -65,4 +65,4 @@ logs: 'logs',

var clientToken = _a.clientToken, internalAnalyticsSubdomain = _a.internalAnalyticsSubdomain;
var tags = ["sdk_version:".concat("4.37.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && isExperimentalFeatureEnabled('collect_flush_reason')) {
var tags = ["sdk_version:".concat("4.38.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && isExperimentalFeatureEnabled(ExperimentalFeature.COLLECT_FLUSH_REASON)) {
tags.push("flush_reason:".concat(flushReason));

@@ -77,3 +77,3 @@ }

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

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

export { Configuration, InitConfiguration, buildCookieOptions, DefaultPrivacyLevel, validateAndBuildConfiguration, serializeConfiguration, } from './configuration';
export { createEndpointBuilder, EndpointBuilder, EndpointType } from './endpointBuilder';
export { isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, } from './experimentalFeatures';
export * from './intakeSites';
export { buildCookieOptions, DefaultPrivacyLevel, validateAndBuildConfiguration, serializeConfiguration, } from './configuration';
export { createEndpointBuilder } from './endpointBuilder';
export { isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, } from './experimentalFeatures';
export * from './intakeSites';
//# sourceMappingURL=index.js.map
import { computeStackTrace } from '../tracekit';
import { createHandlingStack, formatErrorMessage, toStackTraceString } from '../../tools/error';
import { createHandlingStack, formatErrorMessage, toStackTraceString } from '../error/error';
import { mergeObservables, Observable } from '../../tools/observable';

@@ -8,3 +8,3 @@ import { find, jsonStringify } from '../../tools/utils';

import { sanitize } from '../../tools/sanitize';
import { isExperimentalFeatureEnabled } from '../configuration';
import { ExperimentalFeature, isExperimentalFeatureEnabled } from '../../tools/experimentalFeatures';
var consoleObservablesByApi = {};

@@ -59,3 +59,3 @@ export function initConsoleObservable(apis) {

if (typeof param === 'string') {
return isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(param) : param;
return isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(param) : param;
}

@@ -65,4 +65,4 @@ if (param instanceof Error) {

}
return jsonStringify(isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(param) : param, undefined, 2);
return jsonStringify(isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(param) : param, undefined, 2);
}
//# sourceMappingURL=consoleObservable.js.map

@@ -1,5 +0,5 @@

import type { RawError } from '../../tools/error';
import type { Observable } from '../../tools/observable';
import type { RawError } from './error';
export declare function trackRuntimeError(errorObservable: Observable<RawError>): {
stop: () => void;
};

@@ -1,4 +0,4 @@

import { ErrorSource, computeRawError } from '../../tools/error';
import { clocksNow } from '../../tools/timeUtils';
import { startUnhandledErrorCollection } from '../tracekit';
import { ErrorSource, computeRawError } from './error';
export function trackRuntimeError(errorObservable) {

@@ -5,0 +5,0 @@ return startUnhandledErrorCollection(function (stackTrace, originalError) {

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

import { toStackTraceString } from '../../tools/error';
import { toStackTraceString } from '../error/error';
import { monitor } from '../../tools/monitor';

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

import { deleteCookie, getCookie, setCookie } from '../../browser/cookie';
import { setTimeout } from '../../browser/timer';
import { setTimeout } from '../../tools/timer';
import { isChromium } from '../../tools/browserDetection';

@@ -4,0 +4,0 @@ import { dateNow } from '../../tools/timeUtils';

@@ -5,3 +5,3 @@ import * as utils from '../../tools/utils';

import { addEventListener, addEventListeners } from '../../browser/addEventListener';
import { clearInterval, setInterval } from '../../browser/timer';
import { clearInterval, setInterval } from '../../tools/timer';
import { tryOldCookiesMigration } from './oldCookiesMigration';

@@ -8,0 +8,0 @@ import { startSessionStore } from './sessionStore';

import { COOKIE_ACCESS_DELAY } from '../../browser/cookie';
import { clearInterval, setInterval } from '../../browser/timer';
import { clearInterval, setInterval } from '../../tools/timer';
import { Observable } from '../../tools/observable';

@@ -4,0 +4,0 @@ import { dateNow } from '../../tools/timeUtils';

import { ConsoleApiName } from '../../tools/display';
import { toStackTraceString } from '../../tools/error';
import { toStackTraceString } from '../error/error';
import { assign, combine, jsonStringify, performDraw, includes, startsWith, arrayFrom } from '../../tools/utils';
import { getExperimentalFeatures, INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../configuration';
import { getExperimentalFeatures } from '../../tools/experimentalFeatures';
import { INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../configuration';
import { computeStackTrace } from '../tracekit';

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

service: telemetryService,
version: "4.37.0",
version: "4.38.0",
source: 'browser',

@@ -47,0 +48,0 @@ _dd: {

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

export { Configuration, InitConfiguration, buildCookieOptions, validateAndBuildConfiguration, DefaultPrivacyLevel, EndpointBuilder, isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, serializeConfiguration, } from './domain/configuration';
export { Configuration, InitConfiguration, buildCookieOptions, validateAndBuildConfiguration, DefaultPrivacyLevel, EndpointBuilder, serializeConfiguration, } from './domain/configuration';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, ExperimentalFeature, } from './tools/experimentalFeatures';
export { trackRuntimeError } from './domain/error/trackRuntimeError';

@@ -17,9 +18,10 @@ export { computeStackTrace, StackTrace } from './domain/tracekit';

export * from './tools/sanitize';
export * from './tools/createEventRateLimiter';
export * from './tools/getGlobalObject';
export * from './domain/eventRateLimiter/createEventRateLimiter';
export * from './tools/browserDetection';
export { sendToExtension } from './tools/sendToExtension';
export { runOnReadyState } from './tools/runOnReadyState';
export { runOnReadyState } from './browser/runOnReadyState';
export { getZoneJsOriginalValue } from './tools/getZoneJsOriginalValue';
export { instrumentMethod, instrumentMethodAndCallOriginal, instrumentSetter } from './tools/instrumentMethod';
export { ErrorSource, ErrorHandling, computeRawError, createHandlingStack, RawError, RawErrorCause, ErrorWithCause, toStackTraceString, getFileFromStackTraceString, NO_ERROR_STACK_PRESENT_MESSAGE, PROVIDED_ERROR_MESSAGE_PREFIX, } from './tools/error';
export { ErrorSource, ErrorHandling, computeRawError, createHandlingStack, RawError, RawErrorCause, ErrorWithCause, toStackTraceString, getFileFromStackTraceString, NO_ERROR_STACK_PRESENT_MESSAGE, PROVIDED_ERROR_MESSAGE_PREFIX, } from './domain/error/error';
export { Context, ContextArray, ContextValue } from './tools/context';

@@ -31,3 +33,3 @@ export { areCookiesAuthorized, getCookie, setCookie, deleteCookie, COOKIE_ACCESS_DELAY } from './browser/cookie';

export * from './browser/addEventListener';
export * from './browser/timer';
export * from './tools/timer';
export { initConsoleObservable, ConsoleLog } from './domain/console/consoleObservable';

@@ -37,2 +39,3 @@ export { BoundedBuffer } from './tools/boundedBuffer';

export { createContextManager, ContextManager } from './tools/contextManager';
export { warnIfCustomerDataLimitReached, CustomerDataType } from './tools/heavyCustomerDataWarning';
export { limitModification } from './tools/limitModification';

@@ -39,0 +42,0 @@ export { ContextHistory, ContextHistoryEntry, CLEAR_OLD_CONTEXTS_INTERVAL } from './tools/contextHistory';

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

export { buildCookieOptions, validateAndBuildConfiguration, DefaultPrivacyLevel, isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, serializeConfiguration, } from './domain/configuration';
export { buildCookieOptions, validateAndBuildConfiguration, DefaultPrivacyLevel, serializeConfiguration, } from './domain/configuration';
export { isExperimentalFeatureEnabled, addExperimentalFeatures, resetExperimentalFeatures, getExperimentalFeatures, ExperimentalFeature, } from './tools/experimentalFeatures';
export { trackRuntimeError } from './domain/error/trackRuntimeError';

@@ -20,9 +21,10 @@ export { computeStackTrace } from './domain/tracekit';

export * from './tools/sanitize';
export * from './tools/createEventRateLimiter';
export * from './tools/getGlobalObject';
export * from './domain/eventRateLimiter/createEventRateLimiter';
export * from './tools/browserDetection';
export { sendToExtension } from './tools/sendToExtension';
export { runOnReadyState } from './tools/runOnReadyState';
export { runOnReadyState } from './browser/runOnReadyState';
export { getZoneJsOriginalValue } from './tools/getZoneJsOriginalValue';
export { instrumentMethod, instrumentMethodAndCallOriginal, instrumentSetter } from './tools/instrumentMethod';
export { ErrorSource, computeRawError, createHandlingStack, toStackTraceString, getFileFromStackTraceString, NO_ERROR_STACK_PRESENT_MESSAGE, PROVIDED_ERROR_MESSAGE_PREFIX, } from './tools/error';
export { ErrorSource, computeRawError, createHandlingStack, toStackTraceString, getFileFromStackTraceString, NO_ERROR_STACK_PRESENT_MESSAGE, PROVIDED_ERROR_MESSAGE_PREFIX, } from './domain/error/error';
export { areCookiesAuthorized, getCookie, setCookie, deleteCookie, COOKIE_ACCESS_DELAY } from './browser/cookie';

@@ -33,3 +35,3 @@ export { initXhrObservable } from './browser/xhrObservable';

export * from './browser/addEventListener';
export * from './browser/timer';
export * from './tools/timer';
export { initConsoleObservable } from './domain/console/consoleObservable';

@@ -39,2 +41,3 @@ export { BoundedBuffer } from './tools/boundedBuffer';

export { createContextManager } from './tools/contextManager';
export { warnIfCustomerDataLimitReached } from './tools/heavyCustomerDataWarning';
export { limitModification } from './tools/limitModification';

@@ -41,0 +44,0 @@ export { ContextHistory, CLEAR_OLD_CONTEXTS_INTERVAL } from './tools/contextHistory';

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

import { setInterval, clearInterval } from '../browser/timer';
import { setInterval, clearInterval } from './timer';
import { relativeNow } from './timeUtils';

@@ -3,0 +3,0 @@ import { ONE_MINUTE } from './utils';

import { computeBytesCount } from './utils';
import type { Context } from './context';
import type { CustomerDataType } from './heavyCustomerDataWarning';
export declare const BYTES_COMPUTATION_THROTTLING_DELAY = 200;
export type ContextManager = ReturnType<typeof createContextManager>;
export declare function createContextManager(computeBytesCountImpl?: typeof computeBytesCount): {
export declare function createContextManager(customerDataType: CustomerDataType, computeBytesCountImpl?: typeof computeBytesCount): {
getBytesCount: () => number;

@@ -6,0 +8,0 @@ /** @deprecated use getContext instead */

@@ -1,15 +0,21 @@

import { isExperimentalFeatureEnabled } from '../domain/configuration';
import { computeBytesCount, deepClone, jsonStringify } from './utils';
import { ExperimentalFeature, isExperimentalFeatureEnabled } from './experimentalFeatures';
import { computeBytesCount, deepClone, jsonStringify, throttle } from './utils';
import { warnIfCustomerDataLimitReached } from './heavyCustomerDataWarning';
import { sanitize } from './sanitize';
export function createContextManager(computeBytesCountImpl) {
export var BYTES_COMPUTATION_THROTTLING_DELAY = 200;
export function createContextManager(customerDataType, computeBytesCountImpl) {
if (computeBytesCountImpl === void 0) { computeBytesCountImpl = computeBytesCount; }
var context = {};
var bytesCountCache;
var alreadyWarned = false;
// Throttle the bytes computation to minimize the impact on performance.
// Especially useful if the user call context APIs synchronously multiple times in a row
var computeBytesCountThrottled = throttle(function (context) {
bytesCountCache = computeBytesCountImpl(jsonStringify(context));
if (!alreadyWarned) {
alreadyWarned = warnIfCustomerDataLimitReached(bytesCountCache, customerDataType);
}
}, BYTES_COMPUTATION_THROTTLING_DELAY).throttled;
return {
getBytesCount: function () {
if (bytesCountCache === undefined) {
bytesCountCache = computeBytesCountImpl(jsonStringify(context));
}
return bytesCountCache;
},
getBytesCount: function () { return bytesCountCache; },
/** @deprecated use getContext instead */

@@ -20,3 +26,3 @@ get: function () { return context; },

context[key] = value;
bytesCountCache = undefined;
computeBytesCountThrottled(context);
},

@@ -26,3 +32,3 @@ /** @deprecated renamed to removeContextProperty */

delete context[key];
bytesCountCache = undefined;
computeBytesCountThrottled(context);
},

@@ -32,20 +38,24 @@ /** @deprecated use setContext instead */

context = newContext;
bytesCountCache = undefined;
computeBytesCountThrottled(context);
},
getContext: function () { return deepClone(context); },
setContext: function (newContext) {
context = isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(newContext) : deepClone(newContext);
bytesCountCache = undefined;
context = isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS)
? sanitize(newContext)
: deepClone(newContext);
computeBytesCountThrottled(context);
},
setContextProperty: function (key, property) {
context[key] = isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(property) : deepClone(property);
bytesCountCache = undefined;
context[key] = isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS)
? sanitize(property)
: deepClone(property);
computeBytesCountThrottled(context);
},
removeContextProperty: function (key) {
delete context[key];
bytesCountCache = undefined;
computeBytesCountThrottled(context);
},
clearContext: function () {
context = {};
bytesCountCache = undefined;
bytesCountCache = 0;
},

@@ -52,0 +62,0 @@ };

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

import { getGlobalObject } from './getGlobalObject';
/**

@@ -15,3 +16,3 @@ * Gets the original value for a DOM API that was potentially patched by Zone.js.

export function getZoneJsOriginalValue(target, name) {
var browserWindow = window;
var browserWindow = getGlobalObject();
var original;

@@ -18,0 +19,0 @@ if (browserWindow.Zone && typeof browserWindow.Zone.__symbol__ === 'function') {

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

import { setTimeout } from '../browser/timer';
import { setTimeout } from './timer';
import { callMonitored } from './monitor';

@@ -3,0 +3,0 @@ import { noop } from './utils';

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

import { isExperimentalFeatureEnabled } from '../domain/configuration';
import { ExperimentalFeature, isExperimentalFeatureEnabled } from './experimentalFeatures';
import { sanitize } from './sanitize';

@@ -17,3 +17,3 @@ import { deepClone, getType } from './utils';

if (newType === originalType) {
set(object, path, isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(newValue) : newValue);
set(object, path, isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(newValue) : newValue);
}

@@ -20,0 +20,0 @@ else if (originalType === 'object' && (newType === 'undefined' || newType === 'null')) {

@@ -34,3 +34,12 @@ import { display } from './display';

var targetData = sanitizeProcessor(containerToProcess.source[key], containerToProcess.path, key, containerQueue, visitedObjectsWithPath);
accumulatedCharacterCount += JSON.stringify(targetData).length + separatorLength;
if (targetData !== undefined) {
accumulatedCharacterCount += JSON.stringify(targetData).length;
}
else {
// When an element of an Array (targetData) is undefined, it is serialized as null:
// JSON.stringify([undefined]) => '[null]' - This accounts for 4 characters
accumulatedCharacterCount += 4;
}
accumulatedCharacterCount += separatorLength;
separatorLength = 1;
if (accumulatedCharacterCount > maxCharacterCount) {

@@ -40,3 +49,3 @@ warnOverCharacterLimit(maxCharacterCount, 'truncated', source);

}
separatorLength = 1;
;
containerToProcess.target[key] = targetData;

@@ -49,4 +58,9 @@ }

var targetData = sanitizeProcessor(containerToProcess.source[key], containerToProcess.path, key, containerQueue, visitedObjectsWithPath);
accumulatedCharacterCount +=
JSON.stringify(targetData).length + separatorLength + key.length + KEY_DECORATION_LENGTH;
// When a property of an object has an undefined value, it will be dropped during serialization:
// JSON.stringify({a:undefined}) => '{}'
if (targetData !== undefined) {
accumulatedCharacterCount +=
JSON.stringify(targetData).length + separatorLength + key.length + KEY_DECORATION_LENGTH;
separatorLength = 1;
}
if (accumulatedCharacterCount > maxCharacterCount) {

@@ -56,3 +70,3 @@ warnOverCharacterLimit(maxCharacterCount, 'truncated', source);

}
separatorLength = 1;
;
containerToProcess.target[key] = targetData;

@@ -59,0 +73,0 @@ }

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

import { getLinkElementOrigin, getLocationOrigin } from './utils';
import { getLinkElementOrigin, getLocationOrigin, jsonStringify } from './utils';
export function normalizeUrl(url) {

@@ -31,3 +31,8 @@ return buildUrl(url, getLocationOrigin()).href;

if (checkURLSupported()) {
return base !== undefined ? new URL(url, base) : new URL(url);
try {
return base !== undefined ? new URL(url, base) : new URL(url);
}
catch (error) {
throw new Error("Failed to construct URL. ".concat(jsonStringify({ url: url, base: base })));
}
}

@@ -34,0 +39,0 @@ if (base === undefined && !/:/.test(url)) {

@@ -47,2 +47,3 @@ export declare const ONE_SECOND = 1000;

export declare function noop(): void;
export type ListenerHandler = () => void;
/**

@@ -67,2 +68,5 @@ * Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that

export declare function findLast<T, S extends T>(array: T[], predicate: (item: T, index: number, array: T[]) => item is S): S | undefined;
export declare function forEach<List extends {
[index: number]: any;
}>(list: List, callback: (value: List[number], index: number, parent: List) => void): void;
export declare function isPercentage(value: unknown): boolean;

@@ -87,6 +91,2 @@ export declare function isNumber(value: unknown): value is number;

export declare function endsWith(candidate: string, search: string): boolean;
/**
* inspired by https://mathiasbynens.be/notes/globalthis
*/
export declare function getGlobalObject<T>(): T;
export declare function getLocationOrigin(): string;

@@ -93,0 +93,0 @@ /**

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

import { setTimeout, clearTimeout } from '../browser/timer';
import { setTimeout, clearTimeout } from './timer';
import { display } from './display';

@@ -167,2 +167,5 @@ import { monitor } from './monitor';

}
export function forEach(list, callback) {
Array.prototype.forEach.call(list, callback);
}
export function isPercentage(value) {

@@ -200,34 +203,2 @@ return isNumber(value) && value >= 0 && value <= 100;

}
/**
* inspired by https://mathiasbynens.be/notes/globalthis
*/
export function getGlobalObject() {
if (typeof globalThis === 'object') {
return globalThis;
}
Object.defineProperty(Object.prototype, '_dd_temp_', {
get: function () {
return this;
},
configurable: true,
});
// @ts-ignore _dd_temp is defined using defineProperty
var globalObject = _dd_temp_;
// @ts-ignore _dd_temp is defined using defineProperty
delete Object.prototype._dd_temp_;
if (typeof globalObject !== 'object') {
// on safari _dd_temp_ is available on window but not globally
// fallback on other browser globals check
if (typeof self === 'object') {
globalObject = self;
}
else if (typeof window === 'object') {
globalObject = window;
}
else {
globalObject = {};
}
}
return globalObject;
}
export function getLocationOrigin() {

@@ -234,0 +205,0 @@ return getLinkElementOrigin(window.location);

import { display } from '../tools/display';
import { computeBytesCount, jsonStringify, objectValues } from '../tools/utils';
import { Observable } from '../tools/observable';
import { setTimeout } from '../browser/timer';
import { setTimeout } from '../tools/timer';
var Batch = /** @class */ (function () {

@@ -6,0 +6,0 @@ function Batch(request, batchMessagesLimit, batchBytesLimit, messageBytesLimit, flushTimeout, pageExitObservable) {

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

import { endsWith, getGlobalObject } from '../tools/utils';
import { endsWith } from '../tools/utils';
import { getGlobalObject } from '../tools/getGlobalObject';
export function getEventBridge() {

@@ -3,0 +4,0 @@ var eventBridgeGlobal = getEventBridgeGlobal();

import type { EndpointBuilder } from '../domain/configuration';
import type { Context } from '../tools/context';
import type { RawError } from '../tools/error';
import type { RawError } from '../domain/error/error';
import type { FlushReason } from './batch';

@@ -5,0 +5,0 @@ /**

import type { EndpointType } from '../domain/configuration';
import type { RawError } from '../tools/error';
import type { RawError } from '../domain/error/error';
import type { Payload, HttpResponse } from './httpRequest';

@@ -4,0 +4,0 @@ export declare const MAX_ONGOING_BYTES_COUNT: number;

@@ -1,5 +0,5 @@

import { setTimeout } from '../browser/timer';
import { setTimeout } from '../tools/timer';
import { clocksNow } from '../tools/timeUtils';
import { ONE_KIBI_BYTE, ONE_MEBI_BYTE, ONE_SECOND, ONE_MINUTE } from '../tools/utils';
import { ErrorSource } from '../tools/error';
import { ErrorSource } from '../domain/error/error';
export var MAX_ONGOING_BYTES_COUNT = 80 * ONE_KIBI_BYTE;

@@ -6,0 +6,0 @@ export var MAX_ONGOING_REQUESTS = 32;

import type { Configuration, EndpointBuilder } from '../domain/configuration';
import type { RawError } from '../tools/error';
import type { RawError } from '../domain/error/error';
import type { Context } from '../tools/context';

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

{
"name": "@datadog/browser-core",
"version": "4.37.0",
"version": "4.38.0",
"license": "Apache-2.0",

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

},
"gitHead": "058831610a12a72ff5e650e47a6ce8cfe9e20012"
"gitHead": "61ff7fdf8c51ea1bb789cb3d865ad094bfcdcf71"
}

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

import { stubZoneJs } from '../../test/stubZoneJs'
import { stubZoneJs } from '../../test'
import { noop } from '../tools/utils'

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

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

import type { FetchStub, FetchStubManager, FetchStubPromise } from '../../test/specHelper'
import { stubFetch } from '../../test/specHelper'
import type { FetchStub, FetchStubManager, FetchStubPromise } from '../../test'
import { stubFetch } from '../../test'
import { isIE } from '../tools/browserDetection'

@@ -4,0 +4,0 @@ import type { Subscription } from '../tools/observable'

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

import { createNewEvent, restorePageVisibility, setPageVisibility } from '../../test/specHelper'
import { resetExperimentalFeatures, updateExperimentalFeatures } from '../domain/configuration'
import { createNewEvent, restorePageVisibility, setPageVisibility } from '../../test'
import { resetExperimentalFeatures, addExperimentalFeatures, ExperimentalFeature } from '../tools/experimentalFeatures'
import type { Subscription } from '../tools/observable'

@@ -23,3 +23,3 @@ import type { PageExitEvent } from './pageExitObservable'

it('notifies when the page fires pagehide if ff pagehide is enabled', () => {
updateExperimentalFeatures(['pagehide'])
addExperimentalFeatures([ExperimentalFeature.PAGEHIDE])
onExitSpy = jasmine.createSpy()

@@ -26,0 +26,0 @@ pageExitSubscription = createPageExitObservable().subscribe(onExitSpy)

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

import { isExperimentalFeatureEnabled } from '../domain/configuration'
import { isExperimentalFeatureEnabled, ExperimentalFeature } from '../tools/experimentalFeatures'
import { Observable } from '../tools/observable'

@@ -21,3 +21,3 @@ import { includes, noop, objectValues } from '../tools/utils'

const observable = new Observable<PageExitEvent>(() => {
const pagehideEnabled = isExperimentalFeatureEnabled('pagehide')
const pagehideEnabled = isExperimentalFeatureEnabled(ExperimentalFeature.PAGEHIDE)
const { stop: stopListeners } = addEventListeners(

@@ -24,0 +24,0 @@ window,

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

import { stubXhr, withXhr } from '../../test/specHelper'
import { withXhr, stubXhr } from '../../test'
import { isIE } from '../tools/browserDetection'

@@ -3,0 +3,0 @@ import type { Subscription } from '../tools/observable'

import type { RumEvent } from '../../../../rum-core/src'
import { display } from '../../tools/display'
import {
ExperimentalFeature,
isExperimentalFeatureEnabled,
resetExperimentalFeatures,
} from '../../tools/experimentalFeatures'
import type { InitConfiguration } from './configuration'
import { validateAndBuildConfiguration } from './configuration'
import { isExperimentalFeatureEnabled, updateExperimentalFeatures } from './experimentalFeatures'

@@ -10,9 +14,32 @@ describe('validateAndBuildConfiguration', () => {

beforeEach(() => {
updateExperimentalFeatures([])
afterEach(() => {
resetExperimentalFeatures()
})
it('updates experimental feature flags', () => {
validateAndBuildConfiguration({ clientToken, enableExperimentalFeatures: ['foo'] })
expect(isExperimentalFeatureEnabled('foo')).toBeTrue()
describe('experimentalFeatures', () => {
const TEST_FEATURE_FLAG = 'foo' as ExperimentalFeature
beforeEach(() => {
;(ExperimentalFeature as any).FOO = TEST_FEATURE_FLAG
})
afterEach(() => {
delete (ExperimentalFeature as any).FOO
})
it('updates experimental feature flags', () => {
validateAndBuildConfiguration({ clientToken, enableExperimentalFeatures: ['foo'] })
expect(isExperimentalFeatureEnabled(TEST_FEATURE_FLAG)).toBeTrue()
})
it('ignores unknown experimental features', () => {
validateAndBuildConfiguration({
clientToken,
enableExperimentalFeatures: ['bar', undefined as any, null as any, 11 as any],
})
expect(isExperimentalFeatureEnabled('bar' as any)).toBeFalse()
expect(isExperimentalFeatureEnabled(undefined as any)).toBeFalse()
expect(isExperimentalFeatureEnabled(null as any)).toBeFalse()
expect(isExperimentalFeatureEnabled(11 as any)).toBeFalse()
})
})

@@ -19,0 +46,0 @@

@@ -5,5 +5,5 @@ import type { CookieOptions } from '../../browser/cookie'

import { display } from '../../tools/display'
import { assign, isPercentage, ONE_KIBI_BYTE, ONE_SECOND } from '../../tools/utils'
import { assign, isPercentage, objectHasValue, ONE_KIBI_BYTE, ONE_SECOND } from '../../tools/utils'
import type { RawTelemetryConfiguration } from '../telemetry'
import { updateExperimentalFeatures } from './experimentalFeatures'
import { ExperimentalFeature, addExperimentalFeatures } from '../../tools/experimentalFeatures'
import type { TransportConfiguration } from './transportConfiguration'

@@ -116,3 +116,9 @@ import { computeTransportConfiguration } from './transportConfiguration'

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

@@ -119,0 +125,0 @@ return assign(

@@ -1,6 +0,10 @@

import type { BuildEnvWindow } from '../../../test/specHelper'
import type { BuildEnvWindow } from '../../../test'
import { startsWith } from '../../tools/utils'
import {
ExperimentalFeature,
resetExperimentalFeatures,
addExperimentalFeatures,
} from '../../tools/experimentalFeatures'
import type { InitConfiguration } from './configuration'
import { createEndpointBuilder } from './endpointBuilder'
import { resetExperimentalFeatures, updateExperimentalFeatures } from './experimentalFeatures'

@@ -129,3 +133,3 @@ describe('endpointBuilder', () => {

it('should contain flush reason when ff collect_flush_reason is enabled', () => {
updateExperimentalFeatures(['collect_flush_reason'])
addExperimentalFeatures([ExperimentalFeature.COLLECT_FLUSH_REASON])
expect(createEndpointBuilder(initConfiguration, 'rum', []).build('xhr', 'batch_bytes_limit')).toContain(

@@ -132,0 +136,0 @@ 'flush_reason%3Abatch_bytes_limit'

@@ -5,5 +5,5 @@ import type { RetryInfo, FlushReason } from '../../transport'

import { generateUUID } from '../../tools/utils'
import { ExperimentalFeature, isExperimentalFeatureEnabled } from '../../tools/experimentalFeatures'
import type { InitConfiguration } from './configuration'
import { INTAKE_SITE_AP1, INTAKE_SITE_US1 } from './intakeSites'
import { isExperimentalFeatureEnabled } from './experimentalFeatures'

@@ -108,3 +108,3 @@ // replaced at build time

const tags = [`sdk_version:${__BUILD_ENV__SDK_VERSION__}`, `api:${api}`].concat(configurationTags)
if (flushReason && isExperimentalFeatureEnabled('collect_flush_reason')) {
if (flushReason && isExperimentalFeatureEnabled(ExperimentalFeature.COLLECT_FLUSH_REASON)) {
tags.push(`flush_reason:${flushReason}`)

@@ -111,0 +111,0 @@ }

@@ -10,8 +10,2 @@ export {

export { createEndpointBuilder, EndpointBuilder, EndpointType } from './endpointBuilder'
export {
isExperimentalFeatureEnabled,
updateExperimentalFeatures,
resetExperimentalFeatures,
getExperimentalFeatures,
} from './experimentalFeatures'
export * from './intakeSites'
import { computeStackTrace } from '../tracekit'
import { createHandlingStack, formatErrorMessage, toStackTraceString } from '../../tools/error'
import { createHandlingStack, formatErrorMessage, toStackTraceString } from '../error/error'
import { mergeObservables, Observable } from '../../tools/observable'

@@ -8,3 +8,3 @@ import { find, jsonStringify } from '../../tools/utils'

import { sanitize } from '../../tools/sanitize'
import { isExperimentalFeatureEnabled } from '../configuration'
import { ExperimentalFeature, isExperimentalFeatureEnabled } from '../../tools/experimentalFeatures'

@@ -74,3 +74,3 @@ export interface ConsoleLog {

if (typeof param === 'string') {
return isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(param) : param
return isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(param) : param
}

@@ -80,3 +80,7 @@ if (param instanceof Error) {

}
return jsonStringify(isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(param) : param, undefined, 2)
return jsonStringify(
isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(param) : param,
undefined,
2
)
}

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

import type { RawError } from '../../tools/error'
import { Observable } from '../../tools/observable'
import type { RawError } from './error'
import { trackRuntimeError } from './trackRuntimeError'

@@ -4,0 +4,0 @@

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

import type { RawError } from '../../tools/error'
import { ErrorSource, computeRawError, ErrorHandling } from '../../tools/error'
import type { Observable } from '../../tools/observable'
import { clocksNow } from '../../tools/timeUtils'
import { startUnhandledErrorCollection } from '../tracekit'
import { ErrorSource, computeRawError, ErrorHandling } from './error'
import type { RawError } from './error'

@@ -7,0 +7,0 @@ export function trackRuntimeError(errorObservable: Observable<RawError>) {

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

import { stubReportingObserver, stubCspEventListener } from '../../../test'
import type { Subscription } from '../../tools/observable'
import { stubReportingObserver, stubCspEventListener } from '../../../test/stubReportApis'
import { initReportObservable, RawReportType } from './reportObservable'

@@ -4,0 +4,0 @@

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

import { toStackTraceString } from '../../tools/error'
import { toStackTraceString } from '../error/error'
import { monitor } from '../../tools/monitor'

@@ -3,0 +3,0 @@ import { mergeObservables, Observable } from '../../tools/observable'

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

import { stubCookie, mockClock } from '../../../test/specHelper'
import { mockClock, stubCookie } from '../../../test'
import { isChromium } from '../../tools/browserDetection'

@@ -3,0 +3,0 @@ import {

import type { CookieOptions } from '../../browser/cookie'
import { deleteCookie, getCookie, setCookie } from '../../browser/cookie'
import { setTimeout } from '../../browser/timer'
import { setTimeout } from '../../tools/timer'
import { isChromium } from '../../tools/browserDetection'

@@ -5,0 +5,0 @@ import { dateNow } from '../../tools/timeUtils'

@@ -0,5 +1,5 @@

import { createNewEvent, mockClock, restorePageVisibility, setPageVisibility } from '../../../test'
import type { Clock } from '../../../test'
import type { CookieOptions } from '../../browser/cookie'
import { COOKIE_ACCESS_DELAY, getCookie, setCookie } from '../../browser/cookie'
import type { Clock } from '../../../test/specHelper'
import { mockClock, restorePageVisibility, setPageVisibility, createNewEvent } from '../../../test/specHelper'
import { ONE_HOUR, ONE_SECOND } from '../../tools/utils'

@@ -6,0 +6,0 @@ import type { RelativeTime } from '../../tools/timeUtils'

@@ -9,3 +9,3 @@ import type { CookieOptions } from '../../browser/cookie'

import { DOM_EVENT, addEventListener, addEventListeners } from '../../browser/addEventListener'
import { clearInterval, setInterval } from '../../browser/timer'
import { clearInterval, setInterval } from '../../tools/timer'
import { tryOldCookiesMigration } from './oldCookiesMigration'

@@ -12,0 +12,0 @@ import { startSessionStore } from './sessionStore'

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

import type { Clock } from '../../../test/specHelper'
import { mockClock } from '../../../test/specHelper'
import type { Clock } from '../../../test'
import { mockClock } from '../../../test'
import type { CookieOptions } from '../../browser/cookie'

@@ -4,0 +4,0 @@ import { getCookie, setCookie, COOKIE_ACCESS_DELAY } from '../../browser/cookie'

import type { CookieOptions } from '../../browser/cookie'
import { COOKIE_ACCESS_DELAY } from '../../browser/cookie'
import { clearInterval, setInterval } from '../../browser/timer'
import { clearInterval, setInterval } from '../../tools/timer'
import { Observable } from '../../tools/observable'

@@ -5,0 +5,0 @@ import { dateNow } from '../../tools/timeUtils'

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

import { mockSyntheticsWorkerValues, cleanupSyntheticsWorkerValues } from '../../../test/syntheticsWorkerValues'
import { mockSyntheticsWorkerValues, cleanupSyntheticsWorkerValues } from '../../../test'
import { getSyntheticsResultId, getSyntheticsTestId, willSyntheticsInjectRum } from './syntheticsWorkerValues'

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

import type { StackTrace } from '@datadog/browser-core'
import { callMonitored } from '../../tools/monitor'
import type { ExperimentalFeature } from '../../tools/experimentalFeatures'
import { resetExperimentalFeatures, addExperimentalFeatures } from '../../tools/experimentalFeatures'
import type { Configuration } from '../configuration'
import { INTAKE_SITE_US1, INTAKE_SITE_US1_FED } from '../configuration'
import {
resetExperimentalFeatures,
updateExperimentalFeatures,
INTAKE_SITE_US1,
INTAKE_SITE_US1_FED,
} from '../configuration'
import {
resetTelemetry,

@@ -77,3 +74,3 @@ startTelemetry,

it('should contains feature flags', () => {
updateExperimentalFeatures(['foo'])
addExperimentalFeatures(['foo' as ExperimentalFeature])
const { notifySpy } = startAndSpyTelemetry()

@@ -80,0 +77,0 @@ callMonitored(() => {

import type { Context } from '../../tools/context'
import { ConsoleApiName } from '../../tools/display'
import { toStackTraceString } from '../../tools/error'
import { toStackTraceString } from '../error/error'
import { assign, combine, jsonStringify, performDraw, includes, startsWith, arrayFrom } from '../../tools/utils'
import { getExperimentalFeatures } from '../../tools/experimentalFeatures'
import type { Configuration } from '../configuration'
import { getExperimentalFeatures, INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../configuration'
import { INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../configuration'
import type { StackTrace } from '../tracekit'

@@ -8,0 +9,0 @@ import { computeStackTrace } from '../tracekit'

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

import { isSafari } from '../../../test/specHelper'
import * as CapturedExceptions from '../../../test/capturedExceptions'
import { isSafari } from '../../../test'
import * as CapturedExceptions from './capturedExceptions.specHelper'
import { computeStackTrace } from './computeStackTrace'

@@ -4,0 +4,0 @@

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

import { disableJasmineUncaughtErrorHandler } from '../../../test/specHelper'
import { disableJasmineUncaughtErrorHandler } from '../../../test'
import { startUnhandledErrorCollection } from './tracekit'

@@ -3,0 +3,0 @@ import type { UnhandledErrorCallback } from './types'

@@ -8,7 +8,11 @@ export {

EndpointBuilder,
serializeConfiguration,
} from './domain/configuration'
export {
isExperimentalFeatureEnabled,
updateExperimentalFeatures,
addExperimentalFeatures,
resetExperimentalFeatures,
serializeConfiguration,
} from './domain/configuration'
getExperimentalFeatures,
ExperimentalFeature,
} from './tools/experimentalFeatures'
export { trackRuntimeError } from './domain/error/trackRuntimeError'

@@ -61,6 +65,7 @@ export { computeStackTrace, StackTrace } from './domain/tracekit'

export * from './tools/sanitize'
export * from './tools/createEventRateLimiter'
export * from './tools/getGlobalObject'
export * from './domain/eventRateLimiter/createEventRateLimiter'
export * from './tools/browserDetection'
export { sendToExtension } from './tools/sendToExtension'
export { runOnReadyState } from './tools/runOnReadyState'
export { runOnReadyState } from './browser/runOnReadyState'
export { getZoneJsOriginalValue } from './tools/getZoneJsOriginalValue'

@@ -80,3 +85,3 @@ export { instrumentMethod, instrumentMethodAndCallOriginal, instrumentSetter } from './tools/instrumentMethod'

PROVIDED_ERROR_MESSAGE_PREFIX,
} from './tools/error'
} from './domain/error/error'
export { Context, ContextArray, ContextValue } from './tools/context'

@@ -88,3 +93,3 @@ export { areCookiesAuthorized, getCookie, setCookie, deleteCookie, COOKIE_ACCESS_DELAY } from './browser/cookie'

export * from './browser/addEventListener'
export * from './browser/timer'
export * from './tools/timer'
export { initConsoleObservable, ConsoleLog } from './domain/console/consoleObservable'

@@ -94,2 +99,3 @@ export { BoundedBuffer } from './tools/boundedBuffer'

export { createContextManager, ContextManager } from './tools/contextManager'
export { warnIfCustomerDataLimitReached, CustomerDataType } from './tools/heavyCustomerDataWarning'
export { limitModification } from './tools/limitModification'

@@ -96,0 +102,0 @@ export { ContextHistory, ContextHistoryEntry, CLEAR_OLD_CONTEXTS_INTERVAL } from './tools/contextHistory'

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

import type { Clock } from '../../test/specHelper'
import { mockClock } from '../../test/specHelper'
import type { Clock } from '../../test'
import { mockClock } from '../../test'
import type { Duration, RelativeTime } from './timeUtils'

@@ -4,0 +4,0 @@ import { addDuration } from './timeUtils'

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

import { setInterval, clearInterval } from '../browser/timer'
import type { TimeoutId } from '../browser/timer'
import { setInterval, clearInterval } from './timer'
import type { TimeoutId } from './timer'
import type { RelativeTime } from './timeUtils'

@@ -4,0 +4,0 @@ import { relativeNow } from './timeUtils'

@@ -1,6 +0,23 @@

import { createContextManager } from './contextManager'
import type { Clock } from '../../test'
import { mockClock } from '../../test'
import { BYTES_COMPUTATION_THROTTLING_DELAY, createContextManager } from './contextManager'
import { display } from './display'
import { CustomerDataType, CUSTOMER_DATA_BYTES_LIMIT } from './heavyCustomerDataWarning'
describe('createContextManager', () => {
let clock: Clock
let displaySpy: jasmine.Spy<typeof display.warn>
beforeEach(() => {
clock = mockClock()
displaySpy = spyOn(display, 'warn')
})
afterEach(() => {
clock.cleanup()
})
it('starts with an empty context', () => {
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
expect(manager.get()).toEqual({})

@@ -10,4 +27,5 @@ })

it('updates the context', () => {
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
manager.set({ bar: 'foo' })
expect(manager.get()).toEqual({ bar: 'foo' })

@@ -17,3 +35,3 @@ })

it('updates the context without copy', () => {
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
const context = {}

@@ -25,3 +43,3 @@ manager.set(context)

it('completely replaces the context', () => {
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
manager.set({ a: 'foo' })

@@ -34,3 +52,3 @@ expect(manager.get()).toEqual({ a: 'foo' })

it('sets a context value', () => {
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
manager.add('foo', 'bar')

@@ -41,3 +59,3 @@ expect(manager.get()).toEqual({ foo: 'bar' })

it('removes a context value', () => {
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
manager.set({ a: 'foo', b: 'bar' })

@@ -51,3 +69,3 @@ manager.remove('a')

it('should get a clone of the context from getContext', () => {
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
expect(manager.getContext()).toEqual(manager.getContext())

@@ -60,3 +78,3 @@ expect(manager.getContext()).not.toBe(manager.getContext())

const context = { nested: nestedObject }
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
manager.setContext(context)

@@ -69,3 +87,3 @@ expect(manager.getContext().nested).toEqual(nestedObject)

const nestedObject = { foo: 'bar' }
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
manager.setContextProperty('nested', nestedObject)

@@ -78,3 +96,3 @@ expect(manager.getContext().nested).toEqual(nestedObject)

const context = { foo: 'bar' }
const manager = createContextManager()
const manager = createContextManager(CustomerDataType.User)
manager.setContext(context)

@@ -86,27 +104,58 @@ expect(manager.getContext()).toEqual(context)

it('should compute the bytes count only if the context has been updated', () => {
const computeBytesCountStub = jasmine.createSpy('computeBytesCountStub').and.returnValue(1)
const manager = createContextManager(computeBytesCountStub)
describe('bytes count computation', () => {
it('should be done every time the context is updated', () => {
const computeBytesCountStub = jasmine.createSpy('computeBytesCountStub').and.returnValue(1)
const manager = createContextManager(CustomerDataType.User, computeBytesCountStub)
manager.getBytesCount()
manager.add('foo', 'bar')
clock.tick(BYTES_COMPUTATION_THROTTLING_DELAY)
manager.remove('foo')
manager.getBytesCount()
manager.remove('foo')
clock.tick(BYTES_COMPUTATION_THROTTLING_DELAY)
manager.set({ foo: 'bar' })
manager.getBytesCount()
manager.set({ foo: 'bar' })
clock.tick(BYTES_COMPUTATION_THROTTLING_DELAY)
manager.removeContextProperty('foo')
manager.getBytesCount()
manager.setContextProperty('foo', 'bar')
clock.tick(BYTES_COMPUTATION_THROTTLING_DELAY)
manager.setContext({ foo: 'bar' })
manager.getBytesCount()
manager.removeContextProperty('foo')
clock.tick(BYTES_COMPUTATION_THROTTLING_DELAY)
manager.clearContext()
manager.getBytesCount()
const bytesCount = manager.getBytesCount()
manager.setContext({ foo: 'bar' })
clock.tick(BYTES_COMPUTATION_THROTTLING_DELAY)
expect(bytesCount).toEqual(1)
expect(computeBytesCountStub).toHaveBeenCalledTimes(6)
manager.clearContext()
const bytesCount = manager.getBytesCount()
expect(bytesCount).toEqual(0)
expect(computeBytesCountStub).toHaveBeenCalledTimes(6)
})
it('should be throttled to minimize the impact on performance', () => {
const computeBytesCountStub = jasmine.createSpy('computeBytesCountStub').and.returnValue(1)
const manager = createContextManager(CustomerDataType.User, computeBytesCountStub)
manager.setContextProperty('1', 'foo') // leading call executed synchronously
manager.setContextProperty('2', 'bar') // ignored
manager.setContextProperty('3', 'bar') // trailing call executed after BYTES_COMPUTATION_THROTTLING_DELAY
clock.tick(BYTES_COMPUTATION_THROTTLING_DELAY)
expect(computeBytesCountStub).toHaveBeenCalledTimes(2)
})
})
it('should warn once if the context bytes limit is reached', () => {
const computeBytesCountStub = jasmine
.createSpy('computeBytesCountStub')
.and.returnValue(CUSTOMER_DATA_BYTES_LIMIT + 1)
const manager = createContextManager(CustomerDataType.User, computeBytesCountStub)
manager.setContext({})
clock.tick(BYTES_COMPUTATION_THROTTLING_DELAY)
manager.setContext({})
clock.tick(BYTES_COMPUTATION_THROTTLING_DELAY)
expect(displaySpy).toHaveBeenCalledTimes(1)
})
})

@@ -1,19 +0,28 @@

import { isExperimentalFeatureEnabled } from '../domain/configuration'
import { computeBytesCount, deepClone, jsonStringify } from './utils'
import { ExperimentalFeature, isExperimentalFeatureEnabled } from './experimentalFeatures'
import { computeBytesCount, deepClone, jsonStringify, throttle } from './utils'
import type { Context, ContextValue } from './context'
import type { CustomerDataType } from './heavyCustomerDataWarning'
import { warnIfCustomerDataLimitReached } from './heavyCustomerDataWarning'
import { sanitize } from './sanitize'
export const BYTES_COMPUTATION_THROTTLING_DELAY = 200
export type ContextManager = ReturnType<typeof createContextManager>
export function createContextManager(computeBytesCountImpl = computeBytesCount) {
export function createContextManager(customerDataType: CustomerDataType, computeBytesCountImpl = computeBytesCount) {
let context: Context = {}
let bytesCountCache: number | undefined
let bytesCountCache: number
let alreadyWarned = false
// Throttle the bytes computation to minimize the impact on performance.
// Especially useful if the user call context APIs synchronously multiple times in a row
const { throttled: computeBytesCountThrottled } = throttle((context: Context) => {
bytesCountCache = computeBytesCountImpl(jsonStringify(context)!)
if (!alreadyWarned) {
alreadyWarned = warnIfCustomerDataLimitReached(bytesCountCache, customerDataType)
}
}, BYTES_COMPUTATION_THROTTLING_DELAY)
return {
getBytesCount: () => {
if (bytesCountCache === undefined) {
bytesCountCache = computeBytesCountImpl(jsonStringify(context)!)
}
return bytesCountCache
},
getBytesCount: () => bytesCountCache,
/** @deprecated use getContext instead */

@@ -25,3 +34,3 @@ get: () => context,

context[key] = value as ContextValue
bytesCountCache = undefined
computeBytesCountThrottled(context)
},

@@ -32,3 +41,3 @@

delete context[key]
bytesCountCache = undefined
computeBytesCountThrottled(context)
},

@@ -39,3 +48,3 @@

context = newContext as Context
bytesCountCache = undefined
computeBytesCountThrottled(context)
},

@@ -46,9 +55,13 @@

setContext: (newContext: Context) => {
context = isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(newContext) : deepClone(newContext)
bytesCountCache = undefined
context = isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS)
? sanitize(newContext)
: deepClone(newContext)
computeBytesCountThrottled(context)
},
setContextProperty: (key: string, property: any) => {
context[key] = isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(property) : deepClone(property)
bytesCountCache = undefined
context[key] = isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS)
? sanitize(property)
: deepClone(property)
computeBytesCountThrottled(context)
},

@@ -58,3 +71,3 @@

delete context[key]
bytesCountCache = undefined
computeBytesCountThrottled(context)
},

@@ -64,5 +77,5 @@

context = {}
bytesCountCache = undefined
bytesCountCache = 0
},
}
}

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

import { stubZoneJs } from '../../test/stubZoneJs'
import { stubZoneJs } from '../../test'

@@ -3,0 +3,0 @@ import type { BrowserWindowWithZoneJs } from './getZoneJsOriginalValue'

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

import { getGlobalObject } from './getGlobalObject'
export interface BrowserWindowWithZoneJs extends Window {

@@ -27,3 +29,3 @@ Zone?: {

): Target[Name] {
const browserWindow = window as BrowserWindowWithZoneJs
const browserWindow = getGlobalObject<BrowserWindowWithZoneJs>()
let original: Target[Name] | undefined

@@ -30,0 +32,0 @@ if (browserWindow.Zone && typeof browserWindow.Zone.__symbol__ === 'function') {

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

import { stubZoneJs } from '../../test/stubZoneJs'
import type { Clock } from '../../test/specHelper'
import { mockClock } from '../../test/specHelper'
import { mockClock, stubZoneJs } from '../../test'
import type { Clock } from '../../test'
import { instrumentMethod, instrumentSetter } from './instrumentMethod'

@@ -5,0 +4,0 @@ import { noop } from './utils'

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

import { setTimeout } from '../browser/timer'
import { setTimeout } from './timer'
import { callMonitored } from './monitor'

@@ -3,0 +3,0 @@ import { noop } from './utils'

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

import { resetExperimentalFeatures, updateExperimentalFeatures } from '../domain/configuration'
import { ExperimentalFeature, resetExperimentalFeatures, addExperimentalFeatures } from './experimentalFeatures'
import type { Context } from './context'

@@ -161,3 +161,3 @@ import { limitModification } from './limitModification'

it('should call sanitize on newly provided values', () => {
updateExperimentalFeatures(['sanitize_inputs'])
addExperimentalFeatures([ExperimentalFeature.SANITIZE_INPUTS])
const object: Context = { bar: { baz: 42 } }

@@ -164,0 +164,0 @@

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

import { isExperimentalFeatureEnabled } from '../domain/configuration'
import { ExperimentalFeature, isExperimentalFeatureEnabled } from './experimentalFeatures'
import type { Context } from './context'

@@ -23,3 +23,7 @@ import { sanitize } from './sanitize'

if (newType === originalType) {
set(object, path, isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(newValue) : newValue)
set(
object,
path,
isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(newValue) : newValue
)
} else if (originalType === 'object' && (newType === 'undefined' || newType === 'null')) {

@@ -26,0 +30,0 @@ set(object, path, {})

@@ -115,2 +115,7 @@ import { isIE } from './browserDetection'

})
it('should handle objects with properties including null or undefined', () => {
const obj = { a: null, b: undefined }
expect(sanitize(obj)).toEqual({ a: null, b: undefined })
})
})

@@ -126,2 +131,7 @@

})
it('should handle arrays containing null or undefined', () => {
const arr = [null, undefined]
expect(sanitize(arr)).toEqual([null, undefined])
})
})

@@ -245,3 +255,20 @@

})
it('should count size properly when array contains undefined values', () => {
// This is a special case: JSON.stringify([undefined]) => '[null]'
const displaySpy = spyOn(display, 'warn')
const arr = [undefined, undefined] // Length of 11 after JSON.stringify
const sanitized = sanitize(arr, 10)
expect(sanitized).toEqual([undefined])
expect(displaySpy).toHaveBeenCalled()
})
it('should count size properly when an object contains properties with undefined values', () => {
const displaySpy = spyOn(display, 'warn')
const obj = { a: undefined, b: 42 } // Length of 8 after JSON.stringify
const sanitized = sanitize(obj, 8)
expect(sanitized).toEqual({ a: undefined, b: 42 })
expect(displaySpy).not.toHaveBeenCalled()
})
})
})

@@ -82,3 +82,12 @@ import type { Context, ContextArray, ContextValue } from './context'

)
accumulatedCharacterCount += JSON.stringify(targetData).length + separatorLength
if (targetData !== undefined) {
accumulatedCharacterCount += JSON.stringify(targetData).length
} else {
// When an element of an Array (targetData) is undefined, it is serialized as null:
// JSON.stringify([undefined]) => '[null]' - This accounts for 4 characters
accumulatedCharacterCount += 4
}
accumulatedCharacterCount += separatorLength
separatorLength = 1
if (accumulatedCharacterCount > maxCharacterCount) {

@@ -88,3 +97,2 @@ warnOverCharacterLimit(maxCharacterCount, 'truncated', source)

}
separatorLength = 1
;(containerToProcess.target as ContextArray)[key] = targetData

@@ -102,4 +110,9 @@ }

)
accumulatedCharacterCount +=
JSON.stringify(targetData).length + separatorLength + key.length + KEY_DECORATION_LENGTH
// When a property of an object has an undefined value, it will be dropped during serialization:
// JSON.stringify({a:undefined}) => '{}'
if (targetData !== undefined) {
accumulatedCharacterCount +=
JSON.stringify(targetData).length + separatorLength + key.length + KEY_DECORATION_LENGTH
separatorLength = 1
}
if (accumulatedCharacterCount > maxCharacterCount) {

@@ -109,3 +122,2 @@ warnOverCharacterLimit(maxCharacterCount, 'truncated', source)

}
separatorLength = 1
;(containerToProcess.target as Context)[key] = targetData

@@ -112,0 +124,0 @@ }

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

import { isFirefox } from '../../test/specHelper'
import { isFirefox } from '../../test'
import { getHash, getOrigin, getPathName, getSearch, isValidUrl, normalizeUrl } from './urlPolyfill'

@@ -3,0 +3,0 @@ import { getLocationOrigin } from './utils'

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

import { getLinkElementOrigin, getLocationOrigin } from './utils'
import { getLinkElementOrigin, getLocationOrigin, jsonStringify } from './utils'

@@ -38,3 +38,7 @@ export function normalizeUrl(url: string) {

if (checkURLSupported()) {
return base !== undefined ? new URL(url, base) : new URL(url)
try {
return base !== undefined ? new URL(url, base) : new URL(url)
} catch (error) {
throw new Error(`Failed to construct URL. ${jsonStringify({ url, base })!}`)
}
}

@@ -41,0 +45,0 @@ if (base === undefined && !/:/.test(url)) {

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

import type { Clock } from '../../test/specHelper'
import { mockClock } from '../../test/specHelper'
import type { Clock } from '../../test'
import { mockClock } from '../../test'
import { display } from './display'

@@ -4,0 +4,0 @@ import {

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

import type { TimeoutId } from '../browser/timer'
import { setTimeout, clearTimeout } from '../browser/timer'
import type { TimeoutId } from './timer'
import { setTimeout, clearTimeout } from './timer'
import { display } from './display'

@@ -120,2 +120,4 @@ import { monitor } from './monitor'

export type ListenerHandler = () => void
/**

@@ -227,2 +229,9 @@ * Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that

export function forEach<List extends { [index: number]: any }>(
list: List,
callback: (value: List[number], index: number, parent: List) => void
) {
Array.prototype.forEach.call(list, callback as any)
}
export function isPercentage(value: unknown) {

@@ -268,33 +277,2 @@ return isNumber(value) && value >= 0 && value <= 100

/**
* inspired by https://mathiasbynens.be/notes/globalthis
*/
export function getGlobalObject<T>(): T {
if (typeof globalThis === 'object') {
return globalThis as unknown as T
}
Object.defineProperty(Object.prototype, '_dd_temp_', {
get() {
return this as object
},
configurable: true,
})
// @ts-ignore _dd_temp is defined using defineProperty
let globalObject: unknown = _dd_temp_
// @ts-ignore _dd_temp is defined using defineProperty
delete Object.prototype._dd_temp_
if (typeof globalObject !== 'object') {
// on safari _dd_temp_ is available on window but not globally
// fallback on other browser globals check
if (typeof self === 'object') {
globalObject = self
} else if (typeof window === 'object') {
globalObject = window
} else {
globalObject = {}
}
}
return globalObject as T
}
export function getLocationOrigin() {

@@ -301,0 +279,0 @@ return getLinkElementOrigin(window.location)

@@ -5,3 +5,3 @@ import { display } from '../tools/display'

import { Observable } from '../tools/observable'
import { setTimeout } from '../browser/timer'
import { setTimeout } from '../tools/timer'
import type { PageExitEvent } from '../browser/pageExitObservable'

@@ -8,0 +8,0 @@ import type { HttpRequest } from './httpRequest'

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

import { deleteEventBridgeStub, initEventBridgeStub } from '../../test/specHelper'
import { deleteEventBridgeStub, initEventBridgeStub } from '../../test'
import { getEventBridge, canUseEventBridge } from './eventBridge'

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

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

import { endsWith, getGlobalObject } from '../tools/utils'
import { endsWith } from '../tools/utils'
import { getGlobalObject } from '../tools/getGlobalObject'

@@ -3,0 +4,0 @@ export interface BrowserWindowWithEventBridge extends Window {

@@ -1,7 +0,6 @@

import { stubEndpointBuilder, interceptRequests } from '../../test/specHelper'
import type { Request } from '../../test/specHelper'
import { collectAsyncCalls, stubEndpointBuilder, interceptRequests } from '../../test'
import type { Request } from '../../test'
import type { EndpointBuilder } from '../domain/configuration'
import { createEndpointBuilder } from '../domain/configuration'
import { noop } from '../tools/utils'
import { collectAsyncCalls } from '../../test/collectAsyncCalls'
import { createHttpRequest, fetchKeepAliveStrategy, sendXHR } from './httpRequest'

@@ -93,3 +92,2 @@ import type { HttpRequest } from './httpRequest'

})
const { waitAsyncCalls, expectNoExtraAsyncCall } = collectAsyncCalls(fetchSpy)

@@ -100,3 +98,3 @@ interceptor.withFetch(fetchSpy)

waitAsyncCalls(2, () => expectNoExtraAsyncCall(done))
collectAsyncCalls(fetchSpy, 2, () => done())
})

@@ -103,0 +101,0 @@ })

@@ -5,3 +5,3 @@ import type { EndpointBuilder } from '../domain/configuration'

import { monitor } from '../tools/monitor'
import type { RawError } from '../tools/error'
import type { RawError } from '../domain/error/error'
import { newRetryState, sendWithRetryStrategy } from './sendWithRetryStrategy'

@@ -8,0 +8,0 @@ import type { FlushReason } from './batch'

@@ -1,4 +0,4 @@

import { mockClock, restoreNavigatorOnLine, setNavigatorOnLine } from '../../test/specHelper'
import type { Clock } from '../../test/specHelper'
import { ErrorSource } from '../tools/error'
import { mockClock, restoreNavigatorOnLine, setNavigatorOnLine } from '../../test'
import type { Clock } from '../../test'
import { ErrorSource } from '../domain/error/error'
import type { RetryState } from './sendWithRetryStrategy'

@@ -5,0 +5,0 @@ import {

import type { EndpointType } from '../domain/configuration'
import { setTimeout } from '../browser/timer'
import type { RawError } from '../tools/error'
import { setTimeout } from '../tools/timer'
import type { RawError } from '../domain/error/error'
import { clocksNow } from '../tools/timeUtils'
import { ONE_KIBI_BYTE, ONE_MEBI_BYTE, ONE_SECOND, ONE_MINUTE } from '../tools/utils'
import { ErrorSource } from '../tools/error'
import { ErrorSource } from '../domain/error/error'
import type { Payload, HttpResponse } from './httpRequest'

@@ -8,0 +8,0 @@

import type { Configuration, EndpointBuilder } from '../domain/configuration'
import type { RawError } from '../tools/error'
import type { RawError } from '../domain/error/error'
import type { Context } from '../tools/context'

@@ -4,0 +4,0 @@ import type { Observable } from '../tools/observable'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc