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

@datadog/browser-core

Package Overview
Dependencies
Maintainers
1
Versions
258
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-core - npm Package Compare versions

Comparing version 4.9.0 to 4.10.0

cjs/transport/failedSendBeacon.d.ts

2

cjs/boot/init.js

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

var publicApi = (0, utils_1.assign)({
version: "4.9.0",
version: "4.10.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

@@ -8,3 +8,7 @@ import type { InitConfiguration } from './configuration';

declare type EndpointType = keyof typeof ENDPOINTS;
export declare const INTAKE_SITE_STAGING = "datad0g.com";
export declare const INTAKE_SITE_US = "datadoghq.com";
export declare const INTAKE_SITE_US3 = "us3.datadoghq.com";
export declare const INTAKE_SITE_US5 = "us5.datadoghq.com";
export declare const INTAKE_SITE_EU = "datadoghq.eu";
export declare type EndpointBuilder = ReturnType<typeof createEndpointBuilder>;

@@ -14,3 +18,4 @@ export declare function createEndpointBuilder(initConfiguration: InitConfiguration, endpointType: EndpointType, tags: string[], source?: string): {

buildIntakeUrl(): string;
endpointType: "logs" | "rum" | "sessionReplay";
};
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createEndpointBuilder = exports.INTAKE_SITE_US = exports.ENDPOINTS = void 0;
exports.createEndpointBuilder = exports.INTAKE_SITE_EU = exports.INTAKE_SITE_US5 = exports.INTAKE_SITE_US3 = exports.INTAKE_SITE_US = exports.INTAKE_SITE_STAGING = exports.ENDPOINTS = void 0;
var timeUtils_1 = require("../../tools/timeUtils");

@@ -17,3 +17,7 @@ var urlPolyfill_1 = require("../../tools/urlPolyfill");

};
exports.INTAKE_SITE_STAGING = 'datad0g.com';
exports.INTAKE_SITE_US = 'datadoghq.com';
exports.INTAKE_SITE_US3 = 'us3.datadoghq.com';
exports.INTAKE_SITE_US5 = 'us5.datadoghq.com';
exports.INTAKE_SITE_EU = 'datadoghq.eu';
function createEndpointBuilder(initConfiguration, endpointType, tags, source) {

@@ -29,5 +33,5 @@ var _a = initConfiguration.site, site = _a === void 0 ? exports.INTAKE_SITE_US : _a, clientToken = initConfiguration.clientToken;

var parameters = "ddsource=".concat(source || 'browser') +
"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.9.0")].concat(tags).join(','))) +
"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.10.0")].concat(tags).join(','))) +
"&dd-api-key=".concat(clientToken) +
"&dd-evp-origin-version=".concat(encodeURIComponent("4.9.0")) +
"&dd-evp-origin-version=".concat(encodeURIComponent("4.10.0")) +
'&dd-evp-origin=browser' +

@@ -44,2 +48,3 @@ "&dd-request-id=".concat((0, utils_1.generateUUID)());

},
endpointType: endpointType,
};

@@ -46,0 +51,0 @@ }

export { Configuration, InitConfiguration, buildCookieOptions, DefaultPrivacyLevel, validateAndBuildConfiguration, } from './configuration';
export { createEndpointBuilder, EndpointBuilder } from './endpointBuilder';
export { createEndpointBuilder, EndpointBuilder, INTAKE_SITE_STAGING, INTAKE_SITE_US5, INTAKE_SITE_US, INTAKE_SITE_US3, INTAKE_SITE_EU, } from './endpointBuilder';
export { isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, } from './experimentalFeatures';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resetExperimentalFeatures = exports.updateExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.createEndpointBuilder = exports.validateAndBuildConfiguration = exports.DefaultPrivacyLevel = exports.buildCookieOptions = void 0;
exports.resetExperimentalFeatures = exports.updateExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.INTAKE_SITE_EU = exports.INTAKE_SITE_US3 = exports.INTAKE_SITE_US = exports.INTAKE_SITE_US5 = exports.INTAKE_SITE_STAGING = exports.createEndpointBuilder = exports.validateAndBuildConfiguration = exports.DefaultPrivacyLevel = exports.buildCookieOptions = void 0;
var configuration_1 = require("./configuration");

@@ -10,2 +10,7 @@ Object.defineProperty(exports, "buildCookieOptions", { enumerable: true, get: function () { return configuration_1.buildCookieOptions; } });

Object.defineProperty(exports, "createEndpointBuilder", { enumerable: true, get: function () { return endpointBuilder_1.createEndpointBuilder; } });
Object.defineProperty(exports, "INTAKE_SITE_STAGING", { enumerable: true, get: function () { return endpointBuilder_1.INTAKE_SITE_STAGING; } });
Object.defineProperty(exports, "INTAKE_SITE_US5", { enumerable: true, get: function () { return endpointBuilder_1.INTAKE_SITE_US5; } });
Object.defineProperty(exports, "INTAKE_SITE_US", { enumerable: true, get: function () { return endpointBuilder_1.INTAKE_SITE_US; } });
Object.defineProperty(exports, "INTAKE_SITE_US3", { enumerable: true, get: function () { return endpointBuilder_1.INTAKE_SITE_US3; } });
Object.defineProperty(exports, "INTAKE_SITE_EU", { enumerable: true, get: function () { return endpointBuilder_1.INTAKE_SITE_EU; } });
var experimentalFeatures_1 = require("./experimentalFeatures");

@@ -12,0 +17,0 @@ Object.defineProperty(exports, "isExperimentalFeatureEnabled", { enumerable: true, get: function () { return experimentalFeatures_1.isExperimentalFeatureEnabled; } });

@@ -10,2 +10,3 @@ import type { InitConfiguration } from './configuration';

replica?: ReplicaConfiguration;
site: string;
}

@@ -12,0 +13,0 @@ export interface ReplicaConfiguration {

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

replica: replicaConfiguration,
site: initConfiguration.site || endpointBuilder_1.INTAKE_SITE_US,
}, endpointBuilders);

@@ -17,0 +18,0 @@ }

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

export { InternalMonitoring, MonitoringMessage, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, startInternalMonitoring, } from './internalMonitoring';
export { InternalMonitoring, MonitoringMessage, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, startInternalMonitoring, isTelemetryReplicationAllowed, } from './internalMonitoring';
export { TelemetryEvent } from './telemetryEvent.types';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startInternalMonitoring = exports.setDebugMode = exports.resetInternalMonitoring = exports.startFakeInternalMonitoring = exports.addMonitoringError = exports.addMonitoringMessage = exports.callMonitored = exports.monitor = exports.monitored = void 0;
exports.isTelemetryReplicationAllowed = exports.startInternalMonitoring = exports.setDebugMode = exports.resetInternalMonitoring = exports.startFakeInternalMonitoring = exports.addMonitoringError = exports.addMonitoringMessage = exports.callMonitored = exports.monitor = exports.monitored = void 0;
var internalMonitoring_1 = require("./internalMonitoring");

@@ -14,2 +14,3 @@ Object.defineProperty(exports, "monitored", { enumerable: true, get: function () { return internalMonitoring_1.monitored; } });

Object.defineProperty(exports, "startInternalMonitoring", { enumerable: true, get: function () { return internalMonitoring_1.startInternalMonitoring; } });
Object.defineProperty(exports, "isTelemetryReplicationAllowed", { enumerable: true, get: function () { return internalMonitoring_1.isTelemetryReplicationAllowed; } });
//# sourceMappingURL=index.js.map

@@ -26,2 +26,7 @@ import type { Context } from '../../tools/context';

export declare function resetInternalMonitoring(): void;
/**
* Avoid mixing telemetry events from different data centers
* but keep replicating staging events for reliability
*/
export declare function isTelemetryReplicationAllowed(configuration: Configuration): boolean;
export declare function monitored<T extends (...params: any[]) => unknown>(_: any, __: string, descriptor: TypedPropertyDescriptor<T>): void;

@@ -28,0 +33,0 @@ export declare function monitor<T extends (...args: any[]) => any>(fn: T): T;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setDebugMode = exports.addMonitoringError = exports.addMonitoringMessage = exports.callMonitored = exports.monitor = exports.monitored = exports.resetInternalMonitoring = exports.startFakeInternalMonitoring = exports.startInternalMonitoring = void 0;
exports.setDebugMode = exports.addMonitoringError = exports.addMonitoringMessage = exports.callMonitored = exports.monitor = exports.monitored = exports.isTelemetryReplicationAllowed = exports.resetInternalMonitoring = exports.startFakeInternalMonitoring = exports.startInternalMonitoring = void 0;
var display_1 = require("../../tools/display");

@@ -11,2 +11,8 @@ var error_1 = require("../../tools/error");

var configuration_1 = require("../configuration");
var TELEMETRY_ALLOWED_SITES = [
// INTAKE_SITE_US5,
// INTAKE_SITE_US3,
// INTAKE_SITE_EU,
// INTAKE_SITE_US,
];
var monitoringConfiguration = { maxMessagesPerPage: 0, sentMessageCount: 0, telemetryEnabled: false };

@@ -22,3 +28,4 @@ var onInternalMonitoringMessageCollected;

monitoringMessageObservable.notify(withContext(message));
if ((0, configuration_1.isExperimentalFeatureEnabled)('telemetry') && monitoringConfiguration.telemetryEnabled) {
if (((0, configuration_1.isExperimentalFeatureEnabled)('telemetry') || (0, utils_1.includes)(TELEMETRY_ALLOWED_SITES, configuration.site)) &&
monitoringConfiguration.telemetryEnabled) {
telemetryEventObservable.notify(toTelemetryEvent(message));

@@ -39,3 +46,3 @@ }

service: 'browser-sdk',
version: "4.9.0",
version: "4.10.0",
source: 'browser',

@@ -77,2 +84,10 @@ _dd: {

exports.resetInternalMonitoring = resetInternalMonitoring;
/**
* Avoid mixing telemetry events from different data centers
* but keep replicating staging events for reliability
*/
function isTelemetryReplicationAllowed(configuration) {
return configuration.site === configuration_1.INTAKE_SITE_STAGING;
}
exports.isTelemetryReplicationAllowed = isTelemetryReplicationAllowed;
function monitored(_, __, descriptor) {

@@ -79,0 +94,0 @@ var originalMethod = descriptor.value;

@@ -6,7 +6,7 @@ export { Configuration, InitConfiguration, buildCookieOptions, validateAndBuildConfiguration, DefaultPrivacyLevel, EndpointBuilder, isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, } from './domain/configuration';

export { initReportObservable, RawReport, RawReportType } from './domain/report/reportObservable';
export { startInternalMonitoring, InternalMonitoring, MonitoringMessage, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, TelemetryEvent, } from './domain/internalMonitoring';
export { startInternalMonitoring, InternalMonitoring, MonitoringMessage, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, TelemetryEvent, isTelemetryReplicationAllowed, } from './domain/internalMonitoring';
export { Observable, Subscription } from './tools/observable';
export { startSessionManager, SessionManager, stopSessionManager, } from './domain/session/sessionManager';
export { SESSION_TIME_OUT_DELAY, } from './domain/session/sessionStore';
export { HttpRequest, Batch, canUseEventBridge, getEventBridge, startBatchWithReplica } from './transport';
export { HttpRequest, Batch, canUseEventBridge, getEventBridge, startBatchWithReplica, startFlushFailedSendBeacons, } from './transport';
export * from './tools/display';

@@ -13,0 +13,0 @@ export * from './tools/urlPolyfill';

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.createContextManager = exports.catchUserErrors = exports.BoundedBuffer = exports.ConsoleApiName = exports.initConsoleObservable = exports.initFetchObservable = exports.initXhrObservable = exports.COOKIE_ACCESS_DELAY = exports.deleteCookie = exports.setCookie = exports.getCookie = exports.areCookiesAuthorized = exports.getFileFromStackTraceString = exports.toStackTraceString = exports.createHandlingStack = exports.formatUnknownError = exports.ErrorSource = exports.instrumentSetter = exports.instrumentMethodAndCallOriginal = exports.instrumentMethod = exports.startBatchWithReplica = exports.getEventBridge = exports.canUseEventBridge = exports.Batch = exports.HttpRequest = exports.SESSION_TIME_OUT_DELAY = exports.stopSessionManager = exports.startSessionManager = exports.Observable = exports.setDebugMode = exports.resetInternalMonitoring = exports.startFakeInternalMonitoring = exports.addMonitoringError = exports.addMonitoringMessage = exports.callMonitored = exports.monitor = exports.monitored = exports.startInternalMonitoring = exports.RawReportType = exports.initReportObservable = exports.makePublicApi = exports.defineGlobal = exports.computeStackTrace = exports.trackRuntimeError = exports.resetExperimentalFeatures = exports.updateExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.DefaultPrivacyLevel = exports.validateAndBuildConfiguration = exports.buildCookieOptions = void 0;
exports.SESSION_COOKIE_NAME = exports.CLEAR_OLD_CONTEXTS_INTERVAL = exports.ContextHistory = exports.limitModification = void 0;
exports.BoundedBuffer = exports.ConsoleApiName = exports.initConsoleObservable = exports.initFetchObservable = exports.initXhrObservable = exports.COOKIE_ACCESS_DELAY = exports.deleteCookie = exports.setCookie = exports.getCookie = exports.areCookiesAuthorized = exports.getFileFromStackTraceString = exports.toStackTraceString = exports.createHandlingStack = exports.formatUnknownError = exports.ErrorSource = exports.instrumentSetter = exports.instrumentMethodAndCallOriginal = exports.instrumentMethod = exports.startFlushFailedSendBeacons = exports.startBatchWithReplica = exports.getEventBridge = exports.canUseEventBridge = exports.Batch = exports.HttpRequest = exports.SESSION_TIME_OUT_DELAY = exports.stopSessionManager = exports.startSessionManager = exports.Observable = exports.isTelemetryReplicationAllowed = exports.setDebugMode = exports.resetInternalMonitoring = exports.startFakeInternalMonitoring = exports.addMonitoringError = exports.addMonitoringMessage = exports.callMonitored = exports.monitor = exports.monitored = exports.startInternalMonitoring = exports.RawReportType = exports.initReportObservable = exports.makePublicApi = exports.defineGlobal = exports.computeStackTrace = exports.trackRuntimeError = exports.resetExperimentalFeatures = exports.updateExperimentalFeatures = exports.isExperimentalFeatureEnabled = exports.DefaultPrivacyLevel = exports.validateAndBuildConfiguration = exports.buildCookieOptions = void 0;
exports.SESSION_COOKIE_NAME = exports.CLEAR_OLD_CONTEXTS_INTERVAL = exports.ContextHistory = exports.limitModification = exports.createContextManager = exports.catchUserErrors = void 0;
var configuration_1 = require("./domain/configuration");

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

Object.defineProperty(exports, "setDebugMode", { enumerable: true, get: function () { return internalMonitoring_1.setDebugMode; } });
Object.defineProperty(exports, "isTelemetryReplicationAllowed", { enumerable: true, get: function () { return internalMonitoring_1.isTelemetryReplicationAllowed; } });
var observable_1 = require("./tools/observable");

@@ -62,2 +63,3 @@ Object.defineProperty(exports, "Observable", { enumerable: true, get: function () { return observable_1.Observable; } });

Object.defineProperty(exports, "startBatchWithReplica", { enumerable: true, get: function () { return transport_1.startBatchWithReplica; } });
Object.defineProperty(exports, "startFlushFailedSendBeacons", { enumerable: true, get: function () { return transport_1.startFlushFailedSendBeacons; } });
__exportStar(require("./tools/display"), exports);

@@ -64,0 +66,0 @@ __exportStar(require("./tools/urlPolyfill"), exports);

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

};
export declare function startsWith(candidate: string, search: string): boolean;
/**

@@ -106,0 +107,0 @@ * inspired by https://mathiasbynens.be/notes/globalthis

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeDuplicates = exports.setToArray = exports.requestIdleCallback = exports.combine = exports.deepClone = exports.mergeInto = exports.getType = exports.runOnReadyState = exports.addEventListeners = exports.addEventListener = exports.safeTruncate = exports.findCommaSeparatedValue = exports.getLinkElementOrigin = exports.getLocationOrigin = exports.getGlobalObject = exports.mapValues = exports.isEmptyObject = exports.objectEntries = exports.objectHasValue = exports.objectValues = exports.isNumber = exports.isPercentage = exports.findLast = exports.find = exports.includes = exports.jsonStringify = exports.noop = exports.round = exports.performDraw = exports.generateUUID = exports.shallowClone = exports.assign = exports.throttle = exports.ONE_KILO_BYTE = exports.ONE_YEAR = exports.ONE_DAY = exports.ONE_HOUR = exports.ONE_MINUTE = exports.ONE_SECOND = void 0;
exports.removeDuplicates = exports.setToArray = exports.requestIdleCallback = exports.combine = exports.deepClone = exports.mergeInto = exports.getType = exports.runOnReadyState = exports.addEventListeners = exports.addEventListener = exports.safeTruncate = exports.findCommaSeparatedValue = exports.getLinkElementOrigin = exports.getLocationOrigin = exports.getGlobalObject = exports.startsWith = exports.mapValues = exports.isEmptyObject = exports.objectEntries = exports.objectHasValue = exports.objectValues = exports.isNumber = exports.isPercentage = exports.findLast = exports.find = exports.includes = exports.jsonStringify = exports.noop = exports.round = exports.performDraw = exports.generateUUID = exports.shallowClone = exports.assign = exports.throttle = exports.ONE_KILO_BYTE = exports.ONE_YEAR = exports.ONE_DAY = exports.ONE_HOUR = exports.ONE_MINUTE = exports.ONE_SECOND = void 0;
var internalMonitoring_1 = require("../domain/internalMonitoring");

@@ -201,2 +201,6 @@ exports.ONE_SECOND = 1000;

exports.mapValues = mapValues;
function startsWith(candidate, search) {
return candidate.slice(0, search.length) === search;
}
exports.startsWith = startsWith;
/**

@@ -203,0 +207,0 @@ * inspired by https://mathiasbynens.be/notes/globalthis

@@ -17,3 +17,3 @@ import type { Context } from '../tools/context';

upsert(message: Context, key: string): void;
flush(): void;
flush(reason?: string): void;
sizeInBytes(candidate: string): number;

@@ -20,0 +20,0 @@ private addOrUpdate;

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

};
Batch.prototype.flush = function () {
Batch.prototype.flush = function (reason) {
if (this.bufferMessageCount !== 0) {
var messages = this.pushOnlyBuffer.concat((0, utils_1.objectValues)(this.upsertBuffer));
this.request.send(messages.join('\n'), this.bufferBytesSize);
this.request.send(messages.join('\n'), this.bufferBytesSize, reason);
this.pushOnlyBuffer = [];

@@ -63,7 +63,7 @@ this.upsertBuffer = {};

if (this.willReachedBytesLimitWith(messageBytesSize)) {
this.flush();
this.flush('max_size');
}
this.push(processedMessage, messageBytesSize, key);
if (this.isFull()) {
this.flush();
this.flush('max_messages_count');
}

@@ -113,3 +113,3 @@ };

setTimeout((0, internalMonitoring_1.monitor)(function () {
_this.flush();
_this.flush('max_duration');
_this.flushPeriodically();

@@ -137,3 +137,3 @@ }), this.flushTimeout);

if (document.visibilityState === 'hidden') {
_this.flush();
_this.flush('visibility_hidden');
}

@@ -146,3 +146,3 @@ });

*/
(0, utils_1.addEventListener)(window, "beforeunload" /* BEFORE_UNLOAD */, function () { return _this.flush(); });
(0, utils_1.addEventListener)(window, "beforeunload" /* BEFORE_UNLOAD */, function () { return _this.flush('before_unload'); });
}

@@ -149,0 +149,0 @@ };

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

constructor(endpointBuilder: EndpointBuilder, bytesLimit: number);
send(data: string | FormData, size: number): void;
send(data: string | FormData, size: number, reason?: string): void;
}

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

var internalMonitoring_1 = require("../domain/internalMonitoring");
var failedSendBeacon_1 = require("./failedSendBeacon");
/**

@@ -19,3 +20,3 @@ * Use POST request without content type to:

}
HttpRequest.prototype.send = function (data, size) {
HttpRequest.prototype.send = function (data, size, reason) {
var url = this.endpointBuilder.build();

@@ -29,2 +30,3 @@ var canUseBeacon = !!navigator.sendBeacon && size < this.bytesLimit;

}
(0, failedSendBeacon_1.addFailedSendBeacon)(this.endpointBuilder.endpointType, size, reason);
}

@@ -31,0 +33,0 @@ catch (e) {

@@ -5,1 +5,2 @@ export { HttpRequest } from './httpRequest';

export { startBatchWithReplica } from './startBatchWithReplica';
export { startFlushFailedSendBeacons } from './failedSendBeacon';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startBatchWithReplica = exports.getEventBridge = exports.canUseEventBridge = exports.Batch = exports.HttpRequest = void 0;
exports.startFlushFailedSendBeacons = exports.startBatchWithReplica = exports.getEventBridge = exports.canUseEventBridge = exports.Batch = exports.HttpRequest = void 0;
var httpRequest_1 = require("./httpRequest");

@@ -13,2 +13,4 @@ Object.defineProperty(exports, "HttpRequest", { enumerable: true, get: function () { return httpRequest_1.HttpRequest; } });

Object.defineProperty(exports, "startBatchWithReplica", { enumerable: true, get: function () { return startBatchWithReplica_1.startBatchWithReplica; } });
var failedSendBeacon_1 = require("./failedSendBeacon");
Object.defineProperty(exports, "startFlushFailedSendBeacons", { enumerable: true, get: function () { return failedSendBeacon_1.startFlushFailedSendBeacons; } });
//# sourceMappingURL=index.js.map
import type { Configuration, EndpointBuilder } from '../domain/configuration';
import type { Context } from '../tools/context';
export declare function startBatchWithReplica<T extends Context>(configuration: Configuration, endpoint: EndpointBuilder, replicaEndpoint?: EndpointBuilder): {
add(message: T): void;
add(message: T, replicated?: boolean): void;
};

@@ -15,5 +15,6 @@ "use strict";

return {
add: function (message) {
add: function (message, replicated) {
if (replicated === void 0) { replicated = true; }
primaryBatch.add(message);
if (replicaBatch) {
if (replicaBatch && replicated) {
replicaBatch.add(message);

@@ -20,0 +21,0 @@ }

@@ -6,3 +6,3 @@ import { setDebugMode } from '../domain/internalMonitoring';

var publicApi = assign({
version: "4.9.0",
version: "4.10.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

@@ -8,3 +8,7 @@ import type { InitConfiguration } from './configuration';

declare type EndpointType = keyof typeof ENDPOINTS;
export declare const INTAKE_SITE_STAGING = "datad0g.com";
export declare const INTAKE_SITE_US = "datadoghq.com";
export declare const INTAKE_SITE_US3 = "us3.datadoghq.com";
export declare const INTAKE_SITE_US5 = "us5.datadoghq.com";
export declare const INTAKE_SITE_EU = "datadoghq.eu";
export declare type EndpointBuilder = ReturnType<typeof createEndpointBuilder>;

@@ -14,3 +18,4 @@ export declare function createEndpointBuilder(initConfiguration: InitConfiguration, endpointType: EndpointType, tags: string[], source?: string): {

buildIntakeUrl(): string;
endpointType: "logs" | "rum" | "sessionReplay";
};
export {};

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

};
export var INTAKE_SITE_STAGING = 'datad0g.com';
export var INTAKE_SITE_US = 'datadoghq.com';
export var INTAKE_SITE_US3 = 'us3.datadoghq.com';
export var INTAKE_SITE_US5 = 'us5.datadoghq.com';
export var INTAKE_SITE_EU = 'datadoghq.eu';
export function createEndpointBuilder(initConfiguration, endpointType, tags, source) {

@@ -26,5 +30,5 @@ var _a = initConfiguration.site, site = _a === void 0 ? INTAKE_SITE_US : _a, clientToken = initConfiguration.clientToken;

var parameters = "ddsource=".concat(source || 'browser') +
"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.9.0")].concat(tags).join(','))) +
"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.10.0")].concat(tags).join(','))) +
"&dd-api-key=".concat(clientToken) +
"&dd-evp-origin-version=".concat(encodeURIComponent("4.9.0")) +
"&dd-evp-origin-version=".concat(encodeURIComponent("4.10.0")) +
'&dd-evp-origin=browser' +

@@ -41,4 +45,5 @@ "&dd-request-id=".concat(generateUUID());

},
endpointType: endpointType,
};
}
//# sourceMappingURL=endpointBuilder.js.map
export { Configuration, InitConfiguration, buildCookieOptions, DefaultPrivacyLevel, validateAndBuildConfiguration, } from './configuration';
export { createEndpointBuilder, EndpointBuilder } from './endpointBuilder';
export { createEndpointBuilder, EndpointBuilder, INTAKE_SITE_STAGING, INTAKE_SITE_US5, INTAKE_SITE_US, INTAKE_SITE_US3, INTAKE_SITE_EU, } from './endpointBuilder';
export { isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, } from './experimentalFeatures';
export { buildCookieOptions, DefaultPrivacyLevel, validateAndBuildConfiguration, } from './configuration';
export { createEndpointBuilder } from './endpointBuilder';
export { createEndpointBuilder, INTAKE_SITE_STAGING, INTAKE_SITE_US5, INTAKE_SITE_US, INTAKE_SITE_US3, INTAKE_SITE_EU, } from './endpointBuilder';
export { isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, } from './experimentalFeatures';
//# sourceMappingURL=index.js.map

@@ -10,2 +10,3 @@ import type { InitConfiguration } from './configuration';

replica?: ReplicaConfiguration;
site: string;
}

@@ -12,0 +13,0 @@ export interface ReplicaConfiguration {

@@ -12,2 +12,3 @@ import { assign, objectValues } from '../../tools/utils';

replica: replicaConfiguration,
site: initConfiguration.site || INTAKE_SITE_US,
}, endpointBuilders);

@@ -14,0 +15,0 @@ }

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

export { InternalMonitoring, MonitoringMessage, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, startInternalMonitoring, } from './internalMonitoring';
export { InternalMonitoring, MonitoringMessage, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, startInternalMonitoring, isTelemetryReplicationAllowed, } from './internalMonitoring';
export { TelemetryEvent } from './telemetryEvent.types';

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

export { monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, startInternalMonitoring, } from './internalMonitoring';
export { monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, startInternalMonitoring, isTelemetryReplicationAllowed, } from './internalMonitoring';
//# sourceMappingURL=index.js.map

@@ -26,2 +26,7 @@ import type { Context } from '../../tools/context';

export declare function resetInternalMonitoring(): void;
/**
* Avoid mixing telemetry events from different data centers
* but keep replicating staging events for reliability
*/
export declare function isTelemetryReplicationAllowed(configuration: Configuration): boolean;
export declare function monitored<T extends (...params: any[]) => unknown>(_: any, __: string, descriptor: TypedPropertyDescriptor<T>): void;

@@ -28,0 +33,0 @@ export declare function monitor<T extends (...args: any[]) => any>(fn: T): T;

import { display } from '../../tools/display';
import { toStackTraceString } from '../../tools/error';
import { assign, combine, jsonStringify, performDraw } from '../../tools/utils';
import { assign, combine, jsonStringify, performDraw, includes } from '../../tools/utils';
import { computeStackTrace } from '../tracekit';
import { Observable } from '../../tools/observable';
import { timeStampNow } from '../../tools/timeUtils';
import { isExperimentalFeatureEnabled } from '../configuration';
import { isExperimentalFeatureEnabled, INTAKE_SITE_STAGING } from '../configuration';
var TELEMETRY_ALLOWED_SITES = [
// INTAKE_SITE_US5,
// INTAKE_SITE_US3,
// INTAKE_SITE_EU,
// INTAKE_SITE_US,
];
var monitoringConfiguration = { maxMessagesPerPage: 0, sentMessageCount: 0, telemetryEnabled: false };

@@ -18,3 +24,4 @@ var onInternalMonitoringMessageCollected;

monitoringMessageObservable.notify(withContext(message));
if (isExperimentalFeatureEnabled('telemetry') && monitoringConfiguration.telemetryEnabled) {
if ((isExperimentalFeatureEnabled('telemetry') || includes(TELEMETRY_ALLOWED_SITES, configuration.site)) &&
monitoringConfiguration.telemetryEnabled) {
telemetryEventObservable.notify(toTelemetryEvent(message));

@@ -35,3 +42,3 @@ }

service: 'browser-sdk',
version: "4.9.0",
version: "4.10.0",
source: 'browser',

@@ -70,2 +77,9 @@ _dd: {

}
/**
* Avoid mixing telemetry events from different data centers
* but keep replicating staging events for reliability
*/
export function isTelemetryReplicationAllowed(configuration) {
return configuration.site === INTAKE_SITE_STAGING;
}
export function monitored(_, __, descriptor) {

@@ -72,0 +86,0 @@ var originalMethod = descriptor.value;

@@ -6,7 +6,7 @@ export { Configuration, InitConfiguration, buildCookieOptions, validateAndBuildConfiguration, DefaultPrivacyLevel, EndpointBuilder, isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, } from './domain/configuration';

export { initReportObservable, RawReport, RawReportType } from './domain/report/reportObservable';
export { startInternalMonitoring, InternalMonitoring, MonitoringMessage, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, TelemetryEvent, } from './domain/internalMonitoring';
export { startInternalMonitoring, InternalMonitoring, MonitoringMessage, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, TelemetryEvent, isTelemetryReplicationAllowed, } from './domain/internalMonitoring';
export { Observable, Subscription } from './tools/observable';
export { startSessionManager, SessionManager, stopSessionManager, } from './domain/session/sessionManager';
export { SESSION_TIME_OUT_DELAY, } from './domain/session/sessionStore';
export { HttpRequest, Batch, canUseEventBridge, getEventBridge, startBatchWithReplica } from './transport';
export { HttpRequest, Batch, canUseEventBridge, getEventBridge, startBatchWithReplica, startFlushFailedSendBeacons, } from './transport';
export * from './tools/display';

@@ -13,0 +13,0 @@ export * from './tools/urlPolyfill';

@@ -6,3 +6,3 @@ export { buildCookieOptions, validateAndBuildConfiguration, DefaultPrivacyLevel, isExperimentalFeatureEnabled, updateExperimentalFeatures, resetExperimentalFeatures, } from './domain/configuration';

export { initReportObservable, RawReportType } from './domain/report/reportObservable';
export { startInternalMonitoring, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, } from './domain/internalMonitoring';
export { startInternalMonitoring, monitored, monitor, callMonitored, addMonitoringMessage, addMonitoringError, startFakeInternalMonitoring, resetInternalMonitoring, setDebugMode, isTelemetryReplicationAllowed, } from './domain/internalMonitoring';
export { Observable } from './tools/observable';

@@ -14,3 +14,3 @@ export { startSessionManager,

} from './domain/session/sessionStore';
export { HttpRequest, Batch, canUseEventBridge, getEventBridge, startBatchWithReplica } from './transport';
export { HttpRequest, Batch, canUseEventBridge, getEventBridge, startBatchWithReplica, startFlushFailedSendBeacons, } from './transport';
export * from './tools/display';

@@ -17,0 +17,0 @@ export * from './tools/urlPolyfill';

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

};
export declare function startsWith(candidate: string, search: string): boolean;
/**

@@ -106,0 +107,0 @@ * inspired by https://mathiasbynens.be/notes/globalthis

@@ -180,2 +180,5 @@ import { monitor } from '../domain/internalMonitoring';

}
export function startsWith(candidate, search) {
return candidate.slice(0, search.length) === search;
}
/**

@@ -182,0 +185,0 @@ * inspired by https://mathiasbynens.be/notes/globalthis

@@ -17,3 +17,3 @@ import type { Context } from '../tools/context';

upsert(message: Context, key: string): void;
flush(): void;
flush(reason?: string): void;
sizeInBytes(candidate: string): number;

@@ -20,0 +20,0 @@ private addOrUpdate;

@@ -29,6 +29,6 @@ import { display } from '../tools/display';

};
Batch.prototype.flush = function () {
Batch.prototype.flush = function (reason) {
if (this.bufferMessageCount !== 0) {
var messages = this.pushOnlyBuffer.concat(objectValues(this.upsertBuffer));
this.request.send(messages.join('\n'), this.bufferBytesSize);
this.request.send(messages.join('\n'), this.bufferBytesSize, reason);
this.pushOnlyBuffer = [];

@@ -60,7 +60,7 @@ this.upsertBuffer = {};

if (this.willReachedBytesLimitWith(messageBytesSize)) {
this.flush();
this.flush('max_size');
}
this.push(processedMessage, messageBytesSize, key);
if (this.isFull()) {
this.flush();
this.flush('max_messages_count');
}

@@ -110,3 +110,3 @@ };

setTimeout(monitor(function () {
_this.flush();
_this.flush('max_duration');
_this.flushPeriodically();

@@ -134,3 +134,3 @@ }), this.flushTimeout);

if (document.visibilityState === 'hidden') {
_this.flush();
_this.flush('visibility_hidden');
}

@@ -143,3 +143,3 @@ });

*/
addEventListener(window, "beforeunload" /* BEFORE_UNLOAD */, function () { return _this.flush(); });
addEventListener(window, "beforeunload" /* BEFORE_UNLOAD */, function () { return _this.flush('before_unload'); });
}

@@ -146,0 +146,0 @@ };

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

constructor(endpointBuilder: EndpointBuilder, bytesLimit: number);
send(data: string | FormData, size: number): void;
send(data: string | FormData, size: number, reason?: string): void;
}
import { addMonitoringError } from '../domain/internalMonitoring';
import { addFailedSendBeacon } from './failedSendBeacon';
/**

@@ -15,3 +16,3 @@ * Use POST request without content type to:

}
HttpRequest.prototype.send = function (data, size) {
HttpRequest.prototype.send = function (data, size, reason) {
var url = this.endpointBuilder.build();

@@ -25,2 +26,3 @@ var canUseBeacon = !!navigator.sendBeacon && size < this.bytesLimit;

}
addFailedSendBeacon(this.endpointBuilder.endpointType, size, reason);
}

@@ -27,0 +29,0 @@ catch (e) {

@@ -5,1 +5,2 @@ export { HttpRequest } from './httpRequest';

export { startBatchWithReplica } from './startBatchWithReplica';
export { startFlushFailedSendBeacons } from './failedSendBeacon';

@@ -5,2 +5,3 @@ export { HttpRequest } from './httpRequest';

export { startBatchWithReplica } from './startBatchWithReplica';
export { startFlushFailedSendBeacons } from './failedSendBeacon';
//# sourceMappingURL=index.js.map
import type { Configuration, EndpointBuilder } from '../domain/configuration';
import type { Context } from '../tools/context';
export declare function startBatchWithReplica<T extends Context>(configuration: Configuration, endpoint: EndpointBuilder, replicaEndpoint?: EndpointBuilder): {
add(message: T): void;
add(message: T, replicated?: boolean): void;
};

@@ -12,5 +12,6 @@ import { Batch, HttpRequest } from './index';

return {
add: function (message) {
add: function (message, replicated) {
if (replicated === void 0) { replicated = true; }
primaryBatch.add(message);
if (replicaBatch) {
if (replicaBatch && replicated) {
replicaBatch.add(message);

@@ -17,0 +18,0 @@ }

{
"name": "@datadog/browser-core",
"version": "4.9.0",
"version": "4.10.0",
"license": "Apache-2.0",

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

},
"gitHead": "c642198789f3f9c1d399cc00527437376b6f210c"
"gitHead": "0d9e40c8625d33d9b725f3a5bf81a711b318796c"
}

@@ -23,3 +23,7 @@ import { timeStampNow } from '../../tools/timeUtils'

export const INTAKE_SITE_STAGING = 'datad0g.com'
export const INTAKE_SITE_US = 'datadoghq.com'
export const INTAKE_SITE_US3 = 'us3.datadoghq.com'
export const INTAKE_SITE_US5 = 'us5.datadoghq.com'
export const INTAKE_SITE_EU = 'datadoghq.eu'

@@ -62,3 +66,4 @@ export type EndpointBuilder = ReturnType<typeof createEndpointBuilder>

},
endpointType,
}
}

@@ -8,4 +8,12 @@ export {

} from './configuration'
export { createEndpointBuilder, EndpointBuilder } from './endpointBuilder'
export {
createEndpointBuilder,
EndpointBuilder,
INTAKE_SITE_STAGING,
INTAKE_SITE_US5,
INTAKE_SITE_US,
INTAKE_SITE_US3,
INTAKE_SITE_EU,
} from './endpointBuilder'
export {
isExperimentalFeatureEnabled,

@@ -12,0 +20,0 @@ updateExperimentalFeatures,

@@ -26,2 +26,3 @@ import type { BuildEnvWindow } from '../../../test/specHelper'

expect(configuration.rumEndpointBuilder.build()).toContain('datadoghq.com')
expect(configuration.site).toBe('datadoghq.com')
})

@@ -32,2 +33,3 @@

expect(configuration.rumEndpointBuilder.build()).toContain('foo.com')
expect(configuration.site).toBe('foo.com')
})

@@ -34,0 +36,0 @@ })

@@ -14,2 +14,3 @@ import { assign, objectValues } from '../../tools/utils'

replica?: ReplicaConfiguration
site: string
}

@@ -36,2 +37,3 @@

replica: replicaConfiguration,
site: initConfiguration.site || INTAKE_SITE_US,
},

@@ -38,0 +40,0 @@ endpointBuilders

@@ -13,3 +13,4 @@ export {

startInternalMonitoring,
isTelemetryReplicationAllowed,
} from './internalMonitoring'
export { TelemetryEvent } from './telemetryEvent.types'
import type { Context } from '../../tools/context'
import { display } from '../../tools/display'
import type { Configuration } from '../configuration'
import { updateExperimentalFeatures, resetExperimentalFeatures } from '../configuration'
import {
updateExperimentalFeatures,
resetExperimentalFeatures,
INTAKE_SITE_US,
INTAKE_SITE_US3,
INTAKE_SITE_EU,
INTAKE_SITE_US5,
} from '../configuration'
import type { InternalMonitoring, MonitoringMessage } from './internalMonitoring'

@@ -245,2 +252,27 @@ import {

describe('rollout', () => {
;[
{ site: INTAKE_SITE_US5, enabled: false },
{ site: INTAKE_SITE_US3, enabled: false },
{ site: INTAKE_SITE_EU, enabled: false },
{ site: INTAKE_SITE_US, enabled: false },
].forEach(({ site, enabled }) => {
it(`should be ${enabled ? 'enabled' : 'disabled'} on ${site}`, () => {
internalMonitoring = startInternalMonitoring({ ...configuration, site } as Configuration)
notifySpy = jasmine.createSpy('notified')
internalMonitoring.telemetryEventObservable.subscribe(notifySpy)
callMonitored(() => {
throw new Error('message')
})
if (enabled) {
expect(notifySpy).toHaveBeenCalled()
} else {
expect(notifySpy).not.toHaveBeenCalled()
}
})
})
})
describe('when enabled', () => {

@@ -247,0 +279,0 @@ beforeEach(() => {

import type { Context } from '../../tools/context'
import { display } from '../../tools/display'
import { toStackTraceString } from '../../tools/error'
import { assign, combine, jsonStringify, performDraw } from '../../tools/utils'
import { assign, combine, jsonStringify, performDraw, includes } from '../../tools/utils'
import type { Configuration } from '../configuration'

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

import { timeStampNow } from '../../tools/timeUtils'
import { isExperimentalFeatureEnabled } from '../configuration'
import { isExperimentalFeatureEnabled, INTAKE_SITE_STAGING } from '../configuration'
import type { TelemetryEvent } from './telemetryEvent.types'

@@ -38,2 +38,9 @@

const TELEMETRY_ALLOWED_SITES: string[] = [
// INTAKE_SITE_US5,
// INTAKE_SITE_US3,
// INTAKE_SITE_EU,
// INTAKE_SITE_US,
]
const monitoringConfiguration: {

@@ -58,3 +65,6 @@ debugMode?: boolean

monitoringMessageObservable.notify(withContext(message))
if (isExperimentalFeatureEnabled('telemetry') && monitoringConfiguration.telemetryEnabled) {
if (
(isExperimentalFeatureEnabled('telemetry') || includes(TELEMETRY_ALLOWED_SITES, configuration.site)) &&
monitoringConfiguration.telemetryEnabled
) {
telemetryEventObservable.notify(toTelemetryEvent(message))

@@ -125,2 +135,10 @@ }

/**
* Avoid mixing telemetry events from different data centers
* but keep replicating staging events for reliability
*/
export function isTelemetryReplicationAllowed(configuration: Configuration) {
return configuration.site === INTAKE_SITE_STAGING
}
export function monitored<T extends (...params: any[]) => unknown>(

@@ -127,0 +145,0 @@ _: any,

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

TelemetryEvent,
isTelemetryReplicationAllowed,
} from './domain/internalMonitoring'

@@ -41,3 +42,10 @@ export { Observable, Subscription } from './tools/observable'

} from './domain/session/sessionStore'
export { HttpRequest, Batch, canUseEventBridge, getEventBridge, startBatchWithReplica } from './transport'
export {
HttpRequest,
Batch,
canUseEventBridge,
getEventBridge,
startBatchWithReplica,
startFlushFailedSendBeacons,
} from './transport'
export * from './tools/display'

@@ -44,0 +52,0 @@ export * from './tools/urlPolyfill'

@@ -13,2 +13,3 @@ import type { Clock } from '../../test/specHelper'

safeTruncate,
startsWith,
throttle,

@@ -562,1 +563,11 @@ } from './utils'

})
describe('startWith', () => {
it('should return true if the candidate does not start with the searched string', () => {
expect(startsWith('foobar', 'foo')).toEqual(true)
})
it('should return false if the candidate does not start with the searched string', () => {
expect(startsWith('barfoo', 'foo')).toEqual(false)
})
})

@@ -269,2 +269,6 @@ import { monitor } from '../domain/internalMonitoring'

export function startsWith(candidate: string, search: string) {
return candidate.slice(0, search.length) === search
}
/**

@@ -271,0 +275,0 @@ * inspired by https://mathiasbynens.be/notes/globalthis

@@ -26,3 +26,3 @@ /* eslint-disable @typescript-eslint/unbound-method */

expect(transport.send).toHaveBeenCalledWith('{"message":"hello"}', jasmine.any(Number))
expect(transport.send).toHaveBeenCalledWith('{"message":"hello"}', jasmine.any(Number), undefined)
})

@@ -54,3 +54,4 @@

'{"message":"1"}\n{"message":"2"}\n{"message":"3"}',
jasmine.any(Number)
jasmine.any(Number),
'max_messages_count'
)

@@ -64,6 +65,10 @@ })

batch.add({ message: '60 bytes - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' })
expect(transport.send).toHaveBeenCalledWith('{"message":"50 bytes - xxxxxxxxxxxxxxxxxxxxxxxxx"}', 50)
expect(transport.send).toHaveBeenCalledWith('{"message":"50 bytes - xxxxxxxxxxxxxxxxxxxxxxxxx"}', 50, 'max_size')
batch.flush()
expect(transport.send).toHaveBeenCalledWith('{"message":"60 bytes - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}', 60)
expect(transport.send).toHaveBeenCalledWith(
'{"message":"60 bytes - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}',
60,
undefined
)
})

@@ -76,3 +81,7 @@

expect(transport.send).toHaveBeenCalledWith('{"message":"30 bytes - xxxxx"}\n{"message":"30 bytes - xxxxx"}', 61)
expect(transport.send).toHaveBeenCalledWith(
'{"message":"30 bytes - xxxxx"}\n{"message":"30 bytes - xxxxx"}',
61,
jasmine.any(String)
)
})

@@ -83,3 +92,3 @@

batch.add({ message })
expect(transport.send).toHaveBeenCalledWith(`{"message":"${message}"}`, 101)
expect(transport.send).toHaveBeenCalledWith(`{"message":"${message}"}`, 101, jasmine.any(String))
})

@@ -123,3 +132,4 @@

'{"message":"2"}\n{"message":"3"}\n{"message":"4"}',
jasmine.any(Number)
jasmine.any(Number),
jasmine.any(String)
)

@@ -133,3 +143,4 @@

'{"message":"5"}\n{"message":"6"}\n{"message":"7"}',
jasmine.any(Number)
jasmine.any(Number),
jasmine.any(String)
)

@@ -143,4 +154,4 @@

expect(transport.send).toHaveBeenCalledWith('{"message":"10"}\n{"message":"11"}', jasmine.any(Number))
expect(transport.send).toHaveBeenCalledWith('{"message":"10"}\n{"message":"11"}', jasmine.any(Number), undefined)
})
})

@@ -37,6 +37,6 @@ import { display } from '../tools/display'

flush() {
flush(reason?: string) {
if (this.bufferMessageCount !== 0) {
const messages = this.pushOnlyBuffer.concat(objectValues(this.upsertBuffer))
this.request.send(messages.join('\n'), this.bufferBytesSize)
this.request.send(messages.join('\n'), this.bufferBytesSize, reason)
this.pushOnlyBuffer = []

@@ -72,7 +72,7 @@ this.upsertBuffer = {}

if (this.willReachedBytesLimitWith(messageBytesSize)) {
this.flush()
this.flush('max_size')
}
this.push(processedMessage, messageBytesSize, key)
if (this.isFull()) {
this.flush()
this.flush('max_messages_count')
}

@@ -128,3 +128,3 @@ }

monitor(() => {
this.flush()
this.flush('max_duration')
this.flushPeriodically()

@@ -155,3 +155,3 @@ }),

if (document.visibilityState === 'hidden') {
this.flush()
this.flush('visibility_hidden')
}

@@ -164,5 +164,5 @@ })

*/
addEventListener(window, DOM_EVENT.BEFORE_UNLOAD, () => this.flush())
addEventListener(window, DOM_EVENT.BEFORE_UNLOAD, () => this.flush('before_unload'))
}
}
}
import type { EndpointBuilder } from '../domain/configuration'
import { addMonitoringError } from '../domain/internalMonitoring'
import { addFailedSendBeacon } from './failedSendBeacon'

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

send(data: string | FormData, size: number) {
send(data: string | FormData, size: number, reason?: string) {
const url = this.endpointBuilder.build()

@@ -25,2 +26,4 @@ const canUseBeacon = !!navigator.sendBeacon && size < this.bytesLimit

}
addFailedSendBeacon(this.endpointBuilder.endpointType, size, reason)
} catch (e) {

@@ -27,0 +30,0 @@ reportBeaconError(e)

@@ -5,1 +5,2 @@ export { HttpRequest } from './httpRequest'

export { startBatchWithReplica } from './startBatchWithReplica'
export { startFlushFailedSendBeacons } from './failedSendBeacon'

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

return {
add(message: T) {
add(message: T, replicated = true) {
primaryBatch.add(message)
if (replicaBatch) {
if (replicaBatch && replicated) {
replicaBatch.add(message)

@@ -32,0 +32,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc