Socket
Socket
Sign inDemoInstall

@datadog/browser-core

Package Overview
Dependencies
Maintainers
1
Versions
256
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.46.0 to 4.47.0

2

cjs/boot/init.js

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

var publicApi = (0, polyfills_1.assign)({
version: "4.46.0",
version: "4.47.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

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

import type { Configuration } from '../domain/configuration';
import type { VisualViewport, VisualViewportEventMap } from './types';

@@ -57,3 +58,3 @@ export declare const enum DOM_EVENT {

*/
export declare function addEventListener<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(eventTarget: Target, eventName: EventName, listener: (event: EventMapFor<Target>[EventName]) => void, options?: AddEventListenerOptions): {
export declare function addEventListener<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(configuration: Configuration, eventTarget: Target, eventName: EventName, listener: (event: EventMapFor<Target>[EventName]) => void, options?: AddEventListenerOptions): {
stop: () => void;

@@ -73,5 +74,5 @@ };

*/
export declare function addEventListeners<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(eventTarget: Target, eventNames: EventName[], listener: (event: EventMapFor<Target>[EventName]) => void, { once, capture, passive }?: AddEventListenerOptions): {
export declare function addEventListeners<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(_: Configuration, eventTarget: Target, eventNames: EventName[], listener: (event: EventMapFor<Target>[EventName]) => void, { once, capture, passive }?: AddEventListenerOptions): {
stop: () => void;
};
export {};

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

*/
function addEventListener(eventTarget, eventName, listener, options) {
return addEventListeners(eventTarget, [eventName], listener, options);
function addEventListener(configuration, eventTarget, eventName, listener, options) {
return addEventListeners(configuration, eventTarget, [eventName], listener, options);
}

@@ -33,3 +33,3 @@ exports.addEventListener = addEventListener;

*/
function addEventListeners(eventTarget, eventNames, listener, _a) {
function addEventListeners(_, eventTarget, eventNames, listener, _a) {
var _b = _a === void 0 ? {} : _a, once = _b.once, capture = _b.capture, passive = _b.passive;

@@ -36,0 +36,0 @@ var wrappedListener = (0, monitor_1.monitor)(once

import { Observable } from '../tools/observable';
import type { Configuration } from '../domain/configuration';
export declare const PageExitReason: {

@@ -12,3 +13,3 @@ readonly HIDDEN: "visibility_hidden";

}
export declare function createPageExitObservable(): Observable<PageExitEvent>;
export declare function createPageExitObservable(configuration: Configuration): Observable<PageExitEvent>;
export declare function isPageExitReason(reason: string | undefined): reason is PageExitReason;

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

};
function createPageExitObservable() {
function createPageExitObservable(configuration) {
var observable = new observable_1.Observable(function () {
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) {
var stopListeners = (0, addEventListener_1.addEventListeners)(configuration, window, ["visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, "freeze" /* DOM_EVENT.FREEZE */, "pagehide" /* DOM_EVENT.PAGE_HIDE */], function (event) {
if (event.type === "pagehide" /* DOM_EVENT.PAGE_HIDE */ && pagehideEnabled) {

@@ -43,3 +43,3 @@ /**

if (!pagehideEnabled) {
stopBeforeUnloadListener = (0, addEventListener_1.addEventListener)(window, "beforeunload" /* DOM_EVENT.BEFORE_UNLOAD */, function () {
stopBeforeUnloadListener = (0, addEventListener_1.addEventListener)(configuration, window, "beforeunload" /* DOM_EVENT.BEFORE_UNLOAD */, function () {
observable.notify({ reason: exports.PageExitReason.UNLOADING });

@@ -46,0 +46,0 @@ }).stop;

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

export declare function runOnReadyState(expectedReadyState: 'complete' | 'interactive', callback: () => void): void;
import type { Configuration } from '../domain/configuration';
export declare function runOnReadyState(configuration: Configuration, expectedReadyState: 'complete' | 'interactive', callback: () => void): void;

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

var addEventListener_1 = require("./addEventListener");
function runOnReadyState(expectedReadyState, callback) {
function runOnReadyState(configuration, expectedReadyState, callback) {
if (document.readyState === expectedReadyState || document.readyState === 'complete') {

@@ -12,3 +12,3 @@ callback();

var eventName = expectedReadyState === 'complete' ? "load" /* DOM_EVENT.LOAD */ : "DOMContentLoaded" /* DOM_EVENT.DOM_CONTENT_LOADED */;
(0, addEventListener_1.addEventListener)(window, eventName, callback, { once: true });
(0, addEventListener_1.addEventListener)(configuration, window, eventName, callback, { once: true });
}

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

import { Observable } from '../tools/observable';
import type { Duration, RelativeTime, ClocksState } from '../tools/utils/timeUtils';
import type { Configuration } from '../domain/configuration';
export interface XhrOpenContext {

@@ -21,2 +22,2 @@ state: 'open';

export type XhrContext = XhrOpenContext | XhrStartContext | XhrCompleteContext;
export declare function initXhrObservable(): Observable<XhrContext>;
export declare function initXhrObservable(configuration: Configuration): Observable<XhrContext>;

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

var xhrContexts = new WeakMap();
function initXhrObservable() {
function initXhrObservable(configuration) {
if (!xhrObservable) {
xhrObservable = createXhrObservable();
xhrObservable = createXhrObservable(configuration);
}

@@ -20,3 +20,3 @@ return xhrObservable;

exports.initXhrObservable = initXhrObservable;
function createXhrObservable() {
function createXhrObservable(configuration) {
var observable = new observable_1.Observable(function () {

@@ -28,3 +28,3 @@ var stopInstrumentingStart = (0, instrumentMethod_1.instrumentMethodAndCallOriginal)(XMLHttpRequest.prototype, 'open', {

before: function () {
sendXhr.call(this, observable);
sendXhr.call(this, configuration, observable);
},

@@ -50,3 +50,3 @@ }).stop;

}
function sendXhr(observable) {
function sendXhr(configuration, observable) {
var _this = this;

@@ -88,3 +88,3 @@ var context = xhrContexts.get(this);

};
var unsubscribeLoadEndListener = (0, addEventListener_1.addEventListener)(this, 'loadend', onEnd).stop;
var unsubscribeLoadEndListener = (0, addEventListener_1.addEventListener)(configuration, this, 'loadend', onEnd).stop;
observable.notify(startContext);

@@ -91,0 +91,0 @@ }

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

var clientToken = _a.clientToken, internalAnalyticsSubdomain = _a.internalAnalyticsSubdomain;
var tags = ["sdk_version:".concat("4.46.0"), "api:".concat(api)].concat(configurationTags);
var tags = ["sdk_version:".concat("4.47.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.COLLECT_FLUSH_REASON)) {

@@ -81,3 +81,3 @@ tags.push("flush_reason:".concat(flushReason));

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

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

import { Observable } from '../../tools/observable';
import type { Configuration } from '../configuration';
export declare const RawReportType: {

@@ -14,2 +15,2 @@ readonly intervention: "intervention";

}
export declare function initReportObservable(apis: RawReportType[]): Observable<RawReport>;
export declare function initReportObservable(configuration: Configuration, apis: RawReportType[]): Observable<RawReport>;

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

};
function initReportObservable(apis) {
function initReportObservable(configuration, apis) {
var observables = [];
if ((0, polyfills_1.includes)(apis, exports.RawReportType.cspViolation)) {
observables.push(createCspViolationReportObservable());
observables.push(createCspViolationReportObservable(configuration));
}

@@ -49,5 +49,5 @@ var reportTypes = apis.filter(function (api) { return api !== exports.RawReportType.cspViolation; });

}
function createCspViolationReportObservable() {
function createCspViolationReportObservable(configuration) {
var observable = new observable_1.Observable(function () {
var stop = (0, addEventListener_1.addEventListener)(document, "securitypolicyviolation" /* DOM_EVENT.SECURITY_POLICY_VIOLATION */, function (event) {
var stop = (0, addEventListener_1.addEventListener)(configuration, document, "securitypolicyviolation" /* DOM_EVENT.SECURITY_POLICY_VIOLATION */, function (event) {
observable.notify(buildRawReportFromCspViolation(event));

@@ -54,0 +54,0 @@ }).stop;

import type { Observable } from '../../tools/observable';
import type { Context } from '../../tools/serialisation/context';
import type { RelativeTime } from '../../tools/utils/timeUtils';
import type { SessionStoreStrategyType } from './storeStrategies/sessionStoreStrategy';
import type { Configuration } from '../configuration';
export interface SessionManager<TrackingType extends string> {

@@ -16,3 +16,3 @@ findActiveSession: (startTime?: RelativeTime) => SessionContext<TrackingType> | undefined;

export declare const VISIBILITY_CHECK_DELAY: number;
export declare function startSessionManager<TrackingType extends string>(sessionStoreStrategyType: SessionStoreStrategyType, productKey: string, computeSessionState: (rawTrackingType?: string) => {
export declare function startSessionManager<TrackingType extends string>(configuration: Configuration, productKey: string, computeSessionState: (rawTrackingType?: string) => {
trackingType: TrackingType;

@@ -19,0 +19,0 @@ isTracked: boolean;

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

var stopCallbacks = [];
function startSessionManager(sessionStoreStrategyType, productKey, computeSessionState) {
var sessionStore = (0, sessionStore_1.startSessionStore)(sessionStoreStrategyType, productKey, computeSessionState);
function startSessionManager(configuration, productKey, computeSessionState) {
// TODO - Improve configuration type and remove assertion
var sessionStore = (0, sessionStore_1.startSessionStore)(configuration.sessionStoreStrategyType, productKey, computeSessionState);
stopCallbacks.push(function () { return sessionStore.stop(); });

@@ -27,4 +28,4 @@ var sessionContextHistory = new valueHistory_1.ValueHistory(SESSION_CONTEXT_TIMEOUT_DELAY);

sessionContextHistory.add(buildSessionContext(), (0, timeUtils_1.clocksOrigin)().relative);
trackActivity(function () { return sessionStore.expandOrRenewSession(); });
trackVisibility(function () { return sessionStore.expandSession(); });
trackActivity(configuration, function () { return sessionStore.expandOrRenewSession(); });
trackVisibility(configuration, function () { return sessionStore.expandSession(); });
function buildSessionContext() {

@@ -49,7 +50,7 @@ return {

exports.stopSessionManager = stopSessionManager;
function trackActivity(expandOrRenewSession) {
var stop = (0, addEventListener_1.addEventListeners)(window, ["click" /* DOM_EVENT.CLICK */, "touchstart" /* DOM_EVENT.TOUCH_START */, "keydown" /* DOM_EVENT.KEY_DOWN */, "scroll" /* DOM_EVENT.SCROLL */], expandOrRenewSession, { capture: true, passive: true }).stop;
function trackActivity(configuration, expandOrRenewSession) {
var stop = (0, addEventListener_1.addEventListeners)(configuration, window, ["click" /* DOM_EVENT.CLICK */, "touchstart" /* DOM_EVENT.TOUCH_START */, "keydown" /* DOM_EVENT.KEY_DOWN */, "scroll" /* DOM_EVENT.SCROLL */], expandOrRenewSession, { capture: true, passive: true }).stop;
stopCallbacks.push(stop);
}
function trackVisibility(expandSession) {
function trackVisibility(configuration, expandSession) {
var expandSessionWhenVisible = function () {

@@ -60,3 +61,3 @@ if (document.visibilityState === 'visible') {

};
var stop = (0, addEventListener_1.addEventListener)(document, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, expandSessionWhenVisible).stop;
var stop = (0, addEventListener_1.addEventListener)(configuration, document, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, expandSessionWhenVisible).stop;
stopCallbacks.push(stop);

@@ -63,0 +64,0 @@ var visibilityCheckInterval = (0, timer_1.setInterval)(expandSessionWhenVisible, exports.VISIBILITY_CHECK_DELAY);

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

use_excluded_activity_urls?: boolean | undefined;
use_worker_url?: boolean | undefined;
track_frustrations?: boolean | undefined;

@@ -63,0 +64,0 @@ track_views_manually?: boolean | undefined;

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

service: telemetryService,
version: "4.46.0",
version: "4.47.0",
source: 'browser',

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

@@ -119,3 +119,3 @@ /**

/**
* Whether a proxy configured is used
* Whether a proxy is used
*/

@@ -184,2 +184,6 @@ use_proxy?: boolean;

/**
* Whether the Worker is loaded from an external URL
*/
use_worker_url?: boolean;
/**
* Whether user frustrations are tracked

@@ -186,0 +190,0 @@ */

/**
* inspired by https://mathiasbynens.be/notes/globalthis
*/
export declare function getGlobalObject<T>(): T;
export declare function getGlobalObject<T = typeof globalThis>(): T;

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

export type TimeoutId = ReturnType<typeof window.setTimeout>;
export type TimeoutId = ReturnType<typeof globalThis.setTimeout>;
export declare function setTimeout(callback: () => void, delay?: number): TimeoutId;

@@ -3,0 +3,0 @@ export declare function clearTimeout(timeoutId: TimeoutId | undefined): void;

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

function setInterval(callback, delay) {
return (0, getZoneJsOriginalValue_1.getZoneJsOriginalValue)(window, 'setInterval')((0, monitor_1.monitor)(callback), delay);
return (0, getZoneJsOriginalValue_1.getZoneJsOriginalValue)((0, getGlobalObject_1.getGlobalObject)(), 'setInterval')((0, monitor_1.monitor)(callback), delay);
}
exports.setInterval = setInterval;
function clearInterval(timeoutId) {
(0, getZoneJsOriginalValue_1.getZoneJsOriginalValue)(window, 'clearInterval')(timeoutId);
(0, getZoneJsOriginalValue_1.getZoneJsOriginalValue)((0, getGlobalObject_1.getGlobalObject)(), 'clearInterval')(timeoutId);
}
exports.clearInterval = clearInterval;
//# sourceMappingURL=timer.js.map

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

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

@@ -28,3 +28,3 @@ import type { RawError } from '../domain/error/error.types';

}
export declare function createHttpRequest(endpointBuilder: EndpointBuilder, bytesLimit: number, reportError: (error: RawError) => void): {
export declare function createHttpRequest(configuration: Configuration, endpointBuilder: EndpointBuilder, bytesLimit: number, reportError: (error: RawError) => void): {
send: (payload: Payload) => void;

@@ -37,3 +37,3 @@ /**

};
export declare function fetchKeepAliveStrategy(endpointBuilder: EndpointBuilder, bytesLimit: number, { data, bytesCount, flushReason, retry }: Payload, onResponse?: (r: HttpResponse) => void): void;
export declare function sendXHR(url: string, data: Payload['data'], onResponse?: (r: HttpResponse) => void): void;
export declare function fetchKeepAliveStrategy(configuration: Configuration, endpointBuilder: EndpointBuilder, bytesLimit: number, { data, bytesCount, flushReason, retry }: Payload, onResponse?: (r: HttpResponse) => void): void;
export declare function sendXHR(configuration: Configuration, url: string, data: Payload['data'], onResponse?: (r: HttpResponse) => void): void;

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

var sendWithRetryStrategy_1 = require("./sendWithRetryStrategy");
function createHttpRequest(endpointBuilder, bytesLimit, reportError) {
function createHttpRequest(configuration, endpointBuilder, bytesLimit, reportError) {
var retryState = (0, sendWithRetryStrategy_1.newRetryState)();
var sendStrategyForRetry = function (payload, onResponse) {
return fetchKeepAliveStrategy(endpointBuilder, bytesLimit, payload, onResponse);
return fetchKeepAliveStrategy(configuration, endpointBuilder, bytesLimit, payload, onResponse);
};

@@ -23,3 +23,3 @@ return {

sendOnExit: function (payload) {
sendBeaconStrategy(endpointBuilder, bytesLimit, payload);
sendBeaconStrategy(configuration, endpointBuilder, bytesLimit, payload);
},

@@ -29,3 +29,3 @@ };

exports.createHttpRequest = createHttpRequest;
function sendBeaconStrategy(endpointBuilder, bytesLimit, _a) {
function sendBeaconStrategy(configuration, endpointBuilder, bytesLimit, _a) {
var data = _a.data, bytesCount = _a.bytesCount, flushReason = _a.flushReason;

@@ -46,3 +46,3 @@ var canUseBeacon = !!navigator.sendBeacon && bytesCount < bytesLimit;

var xhrUrl = endpointBuilder.build('xhr', flushReason);
sendXHR(xhrUrl, data);
sendXHR(configuration, xhrUrl, data);
}

@@ -56,3 +56,3 @@ var hasReportedBeaconError = false;

}
function fetchKeepAliveStrategy(endpointBuilder, bytesLimit, _a, onResponse) {
function fetchKeepAliveStrategy(configuration, endpointBuilder, bytesLimit, _a, onResponse) {
var data = _a.data, bytesCount = _a.bytesCount, flushReason = _a.flushReason, retry = _a.retry;

@@ -65,3 +65,3 @@ var canUseKeepAlive = isKeepAliveSupported() && bytesCount < bytesLimit;

// failed to queue the request
sendXHR(xhrUrl, data, onResponse);
sendXHR(configuration, xhrUrl, data, onResponse);
}));

@@ -71,3 +71,3 @@ }

var xhrUrl = endpointBuilder.build('xhr', flushReason, retry);
sendXHR(xhrUrl, data, onResponse);
sendXHR(configuration, xhrUrl, data, onResponse);
}

@@ -85,6 +85,6 @@ }

}
function sendXHR(url, data, onResponse) {
function sendXHR(configuration, url, data, onResponse) {
var request = new XMLHttpRequest();
request.open('POST', url, true);
(0, addEventListener_1.addEventListener)(request, 'loadend', function () {
(0, addEventListener_1.addEventListener)(configuration, request, 'loadend', function () {
onResponse === null || onResponse === void 0 ? void 0 : onResponse({ status: request.status });

@@ -91,0 +91,0 @@ }, {

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

function startBatchWithReplica(configuration, endpoint, reportError, pageExitObservable, sessionExpireObservable, replicaEndpoint) {
var primaryBatch = createBatch(endpoint);
var primaryBatch = createBatch(configuration, endpoint);
var replicaBatch;
if (replicaEndpoint) {
replicaBatch = createBatch(replicaEndpoint);
replicaBatch = createBatch(configuration, replicaEndpoint);
}
function createBatch(endpointBuilder) {
return new batch_1.Batch((0, httpRequest_1.createHttpRequest)(endpointBuilder, configuration.batchBytesLimit, reportError), (0, flushController_1.createFlushController)({
function createBatch(configuration, endpointBuilder) {
return new batch_1.Batch((0, httpRequest_1.createHttpRequest)(configuration, endpointBuilder, configuration.batchBytesLimit, reportError), (0, flushController_1.createFlushController)({
messagesLimit: configuration.batchMessagesLimit,

@@ -17,0 +17,0 @@ bytesLimit: configuration.batchBytesLimit,

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

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

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

import type { Configuration } from '../domain/configuration';
import type { VisualViewport, VisualViewportEventMap } from './types';

@@ -57,3 +58,3 @@ export declare const enum DOM_EVENT {

*/
export declare function addEventListener<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(eventTarget: Target, eventName: EventName, listener: (event: EventMapFor<Target>[EventName]) => void, options?: AddEventListenerOptions): {
export declare function addEventListener<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(configuration: Configuration, eventTarget: Target, eventName: EventName, listener: (event: EventMapFor<Target>[EventName]) => void, options?: AddEventListenerOptions): {
stop: () => void;

@@ -73,5 +74,5 @@ };

*/
export declare function addEventListeners<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(eventTarget: Target, eventNames: EventName[], listener: (event: EventMapFor<Target>[EventName]) => void, { once, capture, passive }?: AddEventListenerOptions): {
export declare function addEventListeners<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(_: Configuration, eventTarget: Target, eventNames: EventName[], listener: (event: EventMapFor<Target>[EventName]) => void, { once, capture, passive }?: AddEventListenerOptions): {
stop: () => void;
};
export {};

@@ -13,4 +13,4 @@ import { monitor } from '../tools/monitor';

*/
export function addEventListener(eventTarget, eventName, listener, options) {
return addEventListeners(eventTarget, [eventName], listener, options);
export function addEventListener(configuration, eventTarget, eventName, listener, options) {
return addEventListeners(configuration, eventTarget, [eventName], listener, options);
}

@@ -29,3 +29,3 @@ /**

*/
export function addEventListeners(eventTarget, eventNames, listener, _a) {
export function addEventListeners(_, eventTarget, eventNames, listener, _a) {
var _b = _a === void 0 ? {} : _a, once = _b.once, capture = _b.capture, passive = _b.passive;

@@ -32,0 +32,0 @@ var wrappedListener = monitor(once

import { Observable } from '../tools/observable';
import type { Configuration } from '../domain/configuration';
export declare const PageExitReason: {

@@ -12,3 +13,3 @@ readonly HIDDEN: "visibility_hidden";

}
export declare function createPageExitObservable(): Observable<PageExitEvent>;
export declare function createPageExitObservable(configuration: Configuration): Observable<PageExitEvent>;
export declare function isPageExitReason(reason: string | undefined): reason is PageExitReason;

@@ -12,6 +12,6 @@ import { isExperimentalFeatureEnabled, ExperimentalFeature } from '../tools/experimentalFeatures';

};
export function createPageExitObservable() {
export function createPageExitObservable(configuration) {
var observable = new Observable(function () {
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) {
var stopListeners = addEventListeners(configuration, window, ["visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, "freeze" /* DOM_EVENT.FREEZE */, "pagehide" /* DOM_EVENT.PAGE_HIDE */], function (event) {
if (event.type === "pagehide" /* DOM_EVENT.PAGE_HIDE */ && pagehideEnabled) {

@@ -40,3 +40,3 @@ /**

if (!pagehideEnabled) {
stopBeforeUnloadListener = addEventListener(window, "beforeunload" /* DOM_EVENT.BEFORE_UNLOAD */, function () {
stopBeforeUnloadListener = addEventListener(configuration, window, "beforeunload" /* DOM_EVENT.BEFORE_UNLOAD */, function () {
observable.notify({ reason: PageExitReason.UNLOADING });

@@ -43,0 +43,0 @@ }).stop;

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

export declare function runOnReadyState(expectedReadyState: 'complete' | 'interactive', callback: () => void): void;
import type { Configuration } from '../domain/configuration';
export declare function runOnReadyState(configuration: Configuration, expectedReadyState: 'complete' | 'interactive', callback: () => void): void;
import { addEventListener } from './addEventListener';
export function runOnReadyState(expectedReadyState, callback) {
export function runOnReadyState(configuration, expectedReadyState, callback) {
if (document.readyState === expectedReadyState || document.readyState === 'complete') {

@@ -8,5 +8,5 @@ callback();

var eventName = expectedReadyState === 'complete' ? "load" /* DOM_EVENT.LOAD */ : "DOMContentLoaded" /* DOM_EVENT.DOM_CONTENT_LOADED */;
addEventListener(window, eventName, callback, { once: true });
addEventListener(configuration, window, eventName, callback, { once: true });
}
}
//# sourceMappingURL=runOnReadyState.js.map
import { Observable } from '../tools/observable';
import type { Duration, RelativeTime, ClocksState } from '../tools/utils/timeUtils';
import type { Configuration } from '../domain/configuration';
export interface XhrOpenContext {

@@ -21,2 +22,2 @@ state: 'open';

export type XhrContext = XhrOpenContext | XhrStartContext | XhrCompleteContext;
export declare function initXhrObservable(): Observable<XhrContext>;
export declare function initXhrObservable(configuration: Configuration): Observable<XhrContext>;

@@ -9,9 +9,9 @@ import { instrumentMethodAndCallOriginal } from '../tools/instrumentMethod';

var xhrContexts = new WeakMap();
export function initXhrObservable() {
export function initXhrObservable(configuration) {
if (!xhrObservable) {
xhrObservable = createXhrObservable();
xhrObservable = createXhrObservable(configuration);
}
return xhrObservable;
}
function createXhrObservable() {
function createXhrObservable(configuration) {
var observable = new Observable(function () {

@@ -23,3 +23,3 @@ var stopInstrumentingStart = instrumentMethodAndCallOriginal(XMLHttpRequest.prototype, 'open', {

before: function () {
sendXhr.call(this, observable);
sendXhr.call(this, configuration, observable);
},

@@ -45,3 +45,3 @@ }).stop;

}
function sendXhr(observable) {
function sendXhr(configuration, observable) {
var _this = this;

@@ -83,3 +83,3 @@ var context = xhrContexts.get(this);

};
var unsubscribeLoadEndListener = addEventListener(this, 'loadend', onEnd).stop;
var unsubscribeLoadEndListener = addEventListener(configuration, this, 'loadend', onEnd).stop;
observable.notify(startContext);

@@ -86,0 +86,0 @@ }

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

var clientToken = _a.clientToken, internalAnalyticsSubdomain = _a.internalAnalyticsSubdomain;
var tags = ["sdk_version:".concat("4.46.0"), "api:".concat(api)].concat(configurationTags);
var tags = ["sdk_version:".concat("4.47.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && isExperimentalFeatureEnabled(ExperimentalFeature.COLLECT_FLUSH_REASON)) {

@@ -77,3 +77,3 @@ tags.push("flush_reason:".concat(flushReason));

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

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

import { Observable } from '../../tools/observable';
import type { Configuration } from '../configuration';
export declare const RawReportType: {

@@ -14,2 +15,2 @@ readonly intervention: "intervention";

}
export declare function initReportObservable(apis: RawReportType[]): Observable<RawReport>;
export declare function initReportObservable(configuration: Configuration, apis: RawReportType[]): Observable<RawReport>;

@@ -12,6 +12,6 @@ import { toStackTraceString } from '../error/error';

};
export function initReportObservable(apis) {
export function initReportObservable(configuration, apis) {
var observables = [];
if (includes(apis, RawReportType.cspViolation)) {
observables.push(createCspViolationReportObservable());
observables.push(createCspViolationReportObservable(configuration));
}

@@ -45,5 +45,5 @@ var reportTypes = apis.filter(function (api) { return api !== RawReportType.cspViolation; });

}
function createCspViolationReportObservable() {
function createCspViolationReportObservable(configuration) {
var observable = new Observable(function () {
var stop = addEventListener(document, "securitypolicyviolation" /* DOM_EVENT.SECURITY_POLICY_VIOLATION */, function (event) {
var stop = addEventListener(configuration, document, "securitypolicyviolation" /* DOM_EVENT.SECURITY_POLICY_VIOLATION */, function (event) {
observable.notify(buildRawReportFromCspViolation(event));

@@ -50,0 +50,0 @@ }).stop;

import type { Observable } from '../../tools/observable';
import type { Context } from '../../tools/serialisation/context';
import type { RelativeTime } from '../../tools/utils/timeUtils';
import type { SessionStoreStrategyType } from './storeStrategies/sessionStoreStrategy';
import type { Configuration } from '../configuration';
export interface SessionManager<TrackingType extends string> {

@@ -16,3 +16,3 @@ findActiveSession: (startTime?: RelativeTime) => SessionContext<TrackingType> | undefined;

export declare const VISIBILITY_CHECK_DELAY: number;
export declare function startSessionManager<TrackingType extends string>(sessionStoreStrategyType: SessionStoreStrategyType, productKey: string, computeSessionState: (rawTrackingType?: string) => {
export declare function startSessionManager<TrackingType extends string>(configuration: Configuration, productKey: string, computeSessionState: (rawTrackingType?: string) => {
trackingType: TrackingType;

@@ -19,0 +19,0 @@ isTracked: boolean;

@@ -10,4 +10,5 @@ import { ValueHistory } from '../../tools/valueHistory';

var stopCallbacks = [];
export function startSessionManager(sessionStoreStrategyType, productKey, computeSessionState) {
var sessionStore = startSessionStore(sessionStoreStrategyType, productKey, computeSessionState);
export function startSessionManager(configuration, productKey, computeSessionState) {
// TODO - Improve configuration type and remove assertion
var sessionStore = startSessionStore(configuration.sessionStoreStrategyType, productKey, computeSessionState);
stopCallbacks.push(function () { return sessionStore.stop(); });

@@ -24,4 +25,4 @@ var sessionContextHistory = new ValueHistory(SESSION_CONTEXT_TIMEOUT_DELAY);

sessionContextHistory.add(buildSessionContext(), clocksOrigin().relative);
trackActivity(function () { return sessionStore.expandOrRenewSession(); });
trackVisibility(function () { return sessionStore.expandSession(); });
trackActivity(configuration, function () { return sessionStore.expandOrRenewSession(); });
trackVisibility(configuration, function () { return sessionStore.expandSession(); });
function buildSessionContext() {

@@ -44,7 +45,7 @@ return {

}
function trackActivity(expandOrRenewSession) {
var stop = addEventListeners(window, ["click" /* DOM_EVENT.CLICK */, "touchstart" /* DOM_EVENT.TOUCH_START */, "keydown" /* DOM_EVENT.KEY_DOWN */, "scroll" /* DOM_EVENT.SCROLL */], expandOrRenewSession, { capture: true, passive: true }).stop;
function trackActivity(configuration, expandOrRenewSession) {
var stop = addEventListeners(configuration, window, ["click" /* DOM_EVENT.CLICK */, "touchstart" /* DOM_EVENT.TOUCH_START */, "keydown" /* DOM_EVENT.KEY_DOWN */, "scroll" /* DOM_EVENT.SCROLL */], expandOrRenewSession, { capture: true, passive: true }).stop;
stopCallbacks.push(stop);
}
function trackVisibility(expandSession) {
function trackVisibility(configuration, expandSession) {
var expandSessionWhenVisible = function () {

@@ -55,3 +56,3 @@ if (document.visibilityState === 'visible') {

};
var stop = addEventListener(document, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, expandSessionWhenVisible).stop;
var stop = addEventListener(configuration, document, "visibilitychange" /* DOM_EVENT.VISIBILITY_CHANGE */, expandSessionWhenVisible).stop;
stopCallbacks.push(stop);

@@ -58,0 +59,0 @@ var visibilityCheckInterval = setInterval(expandSessionWhenVisible, VISIBILITY_CHECK_DELAY);

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

use_excluded_activity_urls?: boolean | undefined;
use_worker_url?: boolean | undefined;
track_frustrations?: boolean | undefined;

@@ -63,0 +64,0 @@ track_views_manually?: boolean | undefined;

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

service: telemetryService,
version: "4.46.0",
version: "4.47.0",
source: 'browser',

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

@@ -119,3 +119,3 @@ /**

/**
* Whether a proxy configured is used
* Whether a proxy is used
*/

@@ -184,2 +184,6 @@ use_proxy?: boolean;

/**
* Whether the Worker is loaded from an external URL
*/
use_worker_url?: boolean;
/**
* Whether user frustrations are tracked

@@ -186,0 +190,0 @@ */

/**
* inspired by https://mathiasbynens.be/notes/globalthis
*/
export declare function getGlobalObject<T>(): T;
export declare function getGlobalObject<T = typeof globalThis>(): T;

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

export type TimeoutId = ReturnType<typeof window.setTimeout>;
export type TimeoutId = ReturnType<typeof globalThis.setTimeout>;
export declare function setTimeout(callback: () => void, delay?: number): TimeoutId;

@@ -3,0 +3,0 @@ export declare function clearTimeout(timeoutId: TimeoutId | undefined): void;

@@ -11,7 +11,7 @@ import { getZoneJsOriginalValue } from './getZoneJsOriginalValue';

export function setInterval(callback, delay) {
return getZoneJsOriginalValue(window, 'setInterval')(monitor(callback), delay);
return getZoneJsOriginalValue(getGlobalObject(), 'setInterval')(monitor(callback), delay);
}
export function clearInterval(timeoutId) {
getZoneJsOriginalValue(window, 'clearInterval')(timeoutId);
getZoneJsOriginalValue(getGlobalObject(), 'clearInterval')(timeoutId);
}
//# sourceMappingURL=timer.js.map

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

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

@@ -28,3 +28,3 @@ import type { RawError } from '../domain/error/error.types';

}
export declare function createHttpRequest(endpointBuilder: EndpointBuilder, bytesLimit: number, reportError: (error: RawError) => void): {
export declare function createHttpRequest(configuration: Configuration, endpointBuilder: EndpointBuilder, bytesLimit: number, reportError: (error: RawError) => void): {
send: (payload: Payload) => void;

@@ -37,3 +37,3 @@ /**

};
export declare function fetchKeepAliveStrategy(endpointBuilder: EndpointBuilder, bytesLimit: number, { data, bytesCount, flushReason, retry }: Payload, onResponse?: (r: HttpResponse) => void): void;
export declare function sendXHR(url: string, data: Payload['data'], onResponse?: (r: HttpResponse) => void): void;
export declare function fetchKeepAliveStrategy(configuration: Configuration, endpointBuilder: EndpointBuilder, bytesLimit: number, { data, bytesCount, flushReason, retry }: Payload, onResponse?: (r: HttpResponse) => void): void;
export declare function sendXHR(configuration: Configuration, url: string, data: Payload['data'], onResponse?: (r: HttpResponse) => void): void;

@@ -5,6 +5,6 @@ import { addTelemetryError } from '../domain/telemetry';

import { newRetryState, sendWithRetryStrategy } from './sendWithRetryStrategy';
export function createHttpRequest(endpointBuilder, bytesLimit, reportError) {
export function createHttpRequest(configuration, endpointBuilder, bytesLimit, reportError) {
var retryState = newRetryState();
var sendStrategyForRetry = function (payload, onResponse) {
return fetchKeepAliveStrategy(endpointBuilder, bytesLimit, payload, onResponse);
return fetchKeepAliveStrategy(configuration, endpointBuilder, bytesLimit, payload, onResponse);
};

@@ -20,7 +20,7 @@ return {

sendOnExit: function (payload) {
sendBeaconStrategy(endpointBuilder, bytesLimit, payload);
sendBeaconStrategy(configuration, endpointBuilder, bytesLimit, payload);
},
};
}
function sendBeaconStrategy(endpointBuilder, bytesLimit, _a) {
function sendBeaconStrategy(configuration, endpointBuilder, bytesLimit, _a) {
var data = _a.data, bytesCount = _a.bytesCount, flushReason = _a.flushReason;

@@ -41,3 +41,3 @@ var canUseBeacon = !!navigator.sendBeacon && bytesCount < bytesLimit;

var xhrUrl = endpointBuilder.build('xhr', flushReason);
sendXHR(xhrUrl, data);
sendXHR(configuration, xhrUrl, data);
}

@@ -51,3 +51,3 @@ var hasReportedBeaconError = false;

}
export function fetchKeepAliveStrategy(endpointBuilder, bytesLimit, _a, onResponse) {
export function fetchKeepAliveStrategy(configuration, endpointBuilder, bytesLimit, _a, onResponse) {
var data = _a.data, bytesCount = _a.bytesCount, flushReason = _a.flushReason, retry = _a.retry;

@@ -60,3 +60,3 @@ var canUseKeepAlive = isKeepAliveSupported() && bytesCount < bytesLimit;

// failed to queue the request
sendXHR(xhrUrl, data, onResponse);
sendXHR(configuration, xhrUrl, data, onResponse);
}));

@@ -66,3 +66,3 @@ }

var xhrUrl = endpointBuilder.build('xhr', flushReason, retry);
sendXHR(xhrUrl, data, onResponse);
sendXHR(configuration, xhrUrl, data, onResponse);
}

@@ -79,6 +79,6 @@ }

}
export function sendXHR(url, data, onResponse) {
export function sendXHR(configuration, url, data, onResponse) {
var request = new XMLHttpRequest();
request.open('POST', url, true);
addEventListener(request, 'loadend', function () {
addEventListener(configuration, request, 'loadend', function () {
onResponse === null || onResponse === void 0 ? void 0 : onResponse({ status: request.status });

@@ -85,0 +85,0 @@ }, {

@@ -5,9 +5,9 @@ import { Batch } from './batch';

export function startBatchWithReplica(configuration, endpoint, reportError, pageExitObservable, sessionExpireObservable, replicaEndpoint) {
var primaryBatch = createBatch(endpoint);
var primaryBatch = createBatch(configuration, endpoint);
var replicaBatch;
if (replicaEndpoint) {
replicaBatch = createBatch(replicaEndpoint);
replicaBatch = createBatch(configuration, replicaEndpoint);
}
function createBatch(endpointBuilder) {
return new Batch(createHttpRequest(endpointBuilder, configuration.batchBytesLimit, reportError), createFlushController({
function createBatch(configuration, endpointBuilder) {
return new Batch(createHttpRequest(configuration, endpointBuilder, configuration.batchBytesLimit, reportError), createFlushController({
messagesLimit: configuration.batchMessagesLimit,

@@ -14,0 +14,0 @@ bytesLimit: configuration.batchBytesLimit,

{
"name": "@datadog/browser-core",
"version": "4.46.0",
"version": "4.47.0",
"license": "Apache-2.0",

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

},
"gitHead": "fdd9a6034d8e1460cbb3dfdac188f102de10347f"
"gitHead": "8aa80956202b4b2eb82b15ffd0f815c58679873d"
}
import { monitor } from '../tools/monitor'
import { getZoneJsOriginalValue } from '../tools/getZoneJsOriginalValue'
import type { Configuration } from '../domain/configuration'
import type { VisualViewport, VisualViewportEventMap } from './types'

@@ -85,2 +86,3 @@

export function addEventListener<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(
configuration: Configuration,
eventTarget: Target,

@@ -91,3 +93,3 @@ eventName: EventName,

) {
return addEventListeners(eventTarget, [eventName], listener, options)
return addEventListeners(configuration, eventTarget, [eventName], listener, options)
}

@@ -108,2 +110,3 @@

export function addEventListeners<Target extends EventTarget, EventName extends keyof EventMapFor<Target> & string>(
_: Configuration,
eventTarget: Target,

@@ -110,0 +113,0 @@ eventNames: EventName[],

@@ -5,2 +5,3 @@ import { isExperimentalFeatureEnabled, ExperimentalFeature } from '../tools/experimentalFeatures'

import { noop } from '../tools/utils/functionUtils'
import type { Configuration } from '../domain/configuration'
import { addEventListeners, addEventListener, DOM_EVENT } from './addEventListener'

@@ -21,6 +22,7 @@

export function createPageExitObservable(): Observable<PageExitEvent> {
export function createPageExitObservable(configuration: Configuration): Observable<PageExitEvent> {
const observable = new Observable<PageExitEvent>(() => {
const pagehideEnabled = isExperimentalFeatureEnabled(ExperimentalFeature.PAGEHIDE)
const { stop: stopListeners } = addEventListeners(
configuration,
window,

@@ -53,3 +55,3 @@ [DOM_EVENT.VISIBILITY_CHANGE, DOM_EVENT.FREEZE, DOM_EVENT.PAGE_HIDE],

if (!pagehideEnabled) {
stopBeforeUnloadListener = addEventListener(window, DOM_EVENT.BEFORE_UNLOAD, () => {
stopBeforeUnloadListener = addEventListener(configuration, window, DOM_EVENT.BEFORE_UNLOAD, () => {
observable.notify({ reason: PageExitReason.UNLOADING })

@@ -56,0 +58,0 @@ }).stop

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

import type { Configuration } from '../domain/configuration'
import { DOM_EVENT, addEventListener } from './addEventListener'
export function runOnReadyState(expectedReadyState: 'complete' | 'interactive', callback: () => void) {
export function runOnReadyState(
configuration: Configuration,
expectedReadyState: 'complete' | 'interactive',
callback: () => void
) {
if (document.readyState === expectedReadyState || document.readyState === 'complete') {

@@ -8,4 +13,4 @@ callback()

const eventName = expectedReadyState === 'complete' ? DOM_EVENT.LOAD : DOM_EVENT.DOM_CONTENT_LOADED
addEventListener(window, eventName, callback, { once: true })
addEventListener(configuration, window, eventName, callback, { once: true })
}
}

@@ -7,2 +7,3 @@ import { instrumentMethodAndCallOriginal } from '../tools/instrumentMethod'

import { shallowClone } from '../tools/utils/objectUtils'
import type { Configuration } from '../domain/configuration'
import { addEventListener } from './addEventListener'

@@ -35,5 +36,5 @@

export function initXhrObservable() {
export function initXhrObservable(configuration: Configuration) {
if (!xhrObservable) {
xhrObservable = createXhrObservable()
xhrObservable = createXhrObservable(configuration)
}

@@ -43,3 +44,3 @@ return xhrObservable

function createXhrObservable() {
function createXhrObservable(configuration: Configuration) {
const observable = new Observable<XhrContext>(() => {

@@ -52,3 +53,3 @@ const { stop: stopInstrumentingStart } = instrumentMethodAndCallOriginal(XMLHttpRequest.prototype, 'open', {

before() {
sendXhr.call(this, observable)
sendXhr.call(this, configuration, observable)
},

@@ -78,3 +79,3 @@ })

function sendXhr(this: XMLHttpRequest, observable: Observable<XhrContext>) {
function sendXhr(this: XMLHttpRequest, configuration: Configuration, observable: Observable<XhrContext>) {
const context = xhrContexts.get(this)

@@ -121,3 +122,3 @@ if (!context) {

const { stop: unsubscribeLoadEndListener } = addEventListener(this, 'loadend', onEnd)
const { stop: unsubscribeLoadEndListener } = addEventListener(configuration, this, 'loadend', onEnd)

@@ -124,0 +125,0 @@ observable.notify(startContext)

@@ -7,2 +7,3 @@ import { toStackTraceString } from '../error/error'

import { safeTruncate } from '../../tools/utils/stringUtils'
import type { Configuration } from '../configuration'
import type { ReportType, InterventionReport, DeprecationReport } from './browser.types'

@@ -25,7 +26,7 @@

export function initReportObservable(apis: RawReportType[]) {
export function initReportObservable(configuration: Configuration, apis: RawReportType[]) {
const observables: Array<Observable<RawReport>> = []
if (includes(apis, RawReportType.cspViolation)) {
observables.push(createCspViolationReportObservable())
observables.push(createCspViolationReportObservable(configuration))
}

@@ -67,5 +68,5 @@

function createCspViolationReportObservable() {
function createCspViolationReportObservable(configuration: Configuration) {
const observable = new Observable<RawReport>(() => {
const { stop } = addEventListener(document, DOM_EVENT.SECURITY_POLICY_VIOLATION, (event) => {
const { stop } = addEventListener(configuration, document, DOM_EVENT.SECURITY_POLICY_VIOLATION, (event) => {
observable.notify(buildRawReportFromCspViolation(event))

@@ -72,0 +73,0 @@ })

@@ -8,5 +8,5 @@ import type { Observable } from '../../tools/observable'

import { clearInterval, setInterval } from '../../tools/timer'
import type { Configuration } from '../configuration'
import { SESSION_TIME_OUT_DELAY } from './sessionConstants'
import { startSessionStore } from './sessionStore'
import type { SessionStoreStrategyType } from './storeStrategies/sessionStoreStrategy'

@@ -30,7 +30,8 @@ export interface SessionManager<TrackingType extends string> {

export function startSessionManager<TrackingType extends string>(
sessionStoreStrategyType: SessionStoreStrategyType,
configuration: Configuration,
productKey: string,
computeSessionState: (rawTrackingType?: string) => { trackingType: TrackingType; isTracked: boolean }
): SessionManager<TrackingType> {
const sessionStore = startSessionStore(sessionStoreStrategyType, productKey, computeSessionState)
// TODO - Improve configuration type and remove assertion
const sessionStore = startSessionStore(configuration.sessionStoreStrategyType!, productKey, computeSessionState)
stopCallbacks.push(() => sessionStore.stop())

@@ -51,4 +52,4 @@

trackActivity(() => sessionStore.expandOrRenewSession())
trackVisibility(() => sessionStore.expandSession())
trackActivity(configuration, () => sessionStore.expandOrRenewSession())
trackVisibility(configuration, () => sessionStore.expandSession())

@@ -75,4 +76,5 @@ function buildSessionContext() {

function trackActivity(expandOrRenewSession: () => void) {
function trackActivity(configuration: Configuration, expandOrRenewSession: () => void) {
const { stop } = addEventListeners(
configuration,
window,

@@ -86,3 +88,3 @@ [DOM_EVENT.CLICK, DOM_EVENT.TOUCH_START, DOM_EVENT.KEY_DOWN, DOM_EVENT.SCROLL],

function trackVisibility(expandSession: () => void) {
function trackVisibility(configuration: Configuration, expandSession: () => void) {
const expandSessionWhenVisible = () => {

@@ -94,3 +96,3 @@ if (document.visibilityState === 'visible') {

const { stop } = addEventListener(document, DOM_EVENT.VISIBILITY_CHANGE, expandSessionWhenVisible)
const { stop } = addEventListener(configuration, document, DOM_EVENT.VISIBILITY_CHANGE, expandSessionWhenVisible)
stopCallbacks.push(stop)

@@ -97,0 +99,0 @@

@@ -121,3 +121,3 @@ /* eslint-disable */

/**
* Whether a proxy configured is used
* Whether a proxy is used
*/

@@ -186,2 +186,6 @@ use_proxy?: boolean

/**
* Whether the Worker is loaded from an external URL
*/
use_worker_url?: boolean
/**
* Whether user frustrations are tracked

@@ -188,0 +192,0 @@ */

@@ -5,3 +5,3 @@ /**

export function getGlobalObject<T>(): T {
export function getGlobalObject<T = typeof globalThis>(): T {
if (typeof globalThis === 'object') {

@@ -8,0 +8,0 @@ return globalThis as unknown as T

@@ -5,18 +5,18 @@ import { getZoneJsOriginalValue } from './getZoneJsOriginalValue'

export type TimeoutId = ReturnType<typeof window.setTimeout>
export type TimeoutId = ReturnType<typeof globalThis.setTimeout>
export function setTimeout(callback: () => void, delay?: number): TimeoutId {
return getZoneJsOriginalValue(getGlobalObject<Window>(), 'setTimeout')(monitor(callback), delay)
return getZoneJsOriginalValue(getGlobalObject(), 'setTimeout')(monitor(callback), delay)
}
export function clearTimeout(timeoutId: TimeoutId | undefined) {
getZoneJsOriginalValue(getGlobalObject<Window>(), 'clearTimeout')(timeoutId)
getZoneJsOriginalValue(getGlobalObject(), 'clearTimeout')(timeoutId)
}
export function setInterval(callback: () => void, delay?: number): TimeoutId {
return getZoneJsOriginalValue(window, 'setInterval')(monitor(callback), delay)
return getZoneJsOriginalValue(getGlobalObject(), 'setInterval')(monitor(callback), delay)
}
export function clearInterval(timeoutId: TimeoutId | undefined) {
getZoneJsOriginalValue(window, 'clearInterval')(timeoutId)
getZoneJsOriginalValue(getGlobalObject(), 'clearInterval')(timeoutId)
}

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

import type { EndpointBuilder } from '../domain/configuration'
import type { EndpointBuilder, Configuration } from '../domain/configuration'
import { addTelemetryError } from '../domain/telemetry'

@@ -39,2 +39,3 @@ import type { Context } from '../tools/serialisation/context'

export function createHttpRequest(
configuration: Configuration,
endpointBuilder: EndpointBuilder,

@@ -46,3 +47,3 @@ bytesLimit: number,

const sendStrategyForRetry = (payload: Payload, onResponse: (r: HttpResponse) => void) =>
fetchKeepAliveStrategy(endpointBuilder, bytesLimit, payload, onResponse)
fetchKeepAliveStrategy(configuration, endpointBuilder, bytesLimit, payload, onResponse)

@@ -58,3 +59,3 @@ return {

sendOnExit: (payload: Payload) => {
sendBeaconStrategy(endpointBuilder, bytesLimit, payload)
sendBeaconStrategy(configuration, endpointBuilder, bytesLimit, payload)
},

@@ -65,2 +66,3 @@ }

function sendBeaconStrategy(
configuration: Configuration,
endpointBuilder: EndpointBuilder,

@@ -85,3 +87,3 @@ bytesLimit: number,

const xhrUrl = endpointBuilder.build('xhr', flushReason)
sendXHR(xhrUrl, data)
sendXHR(configuration, xhrUrl, data)
}

@@ -99,2 +101,3 @@

export function fetchKeepAliveStrategy(
configuration: Configuration,
endpointBuilder: EndpointBuilder,

@@ -113,3 +116,3 @@ bytesLimit: number,

// failed to queue the request
sendXHR(xhrUrl, data, onResponse)
sendXHR(configuration, xhrUrl, data, onResponse)
})

@@ -119,3 +122,3 @@ )

const xhrUrl = endpointBuilder.build('xhr', flushReason, retry)
sendXHR(xhrUrl, data, onResponse)
sendXHR(configuration, xhrUrl, data, onResponse)
}

@@ -133,6 +136,12 @@ }

export function sendXHR(url: string, data: Payload['data'], onResponse?: (r: HttpResponse) => void) {
export function sendXHR(
configuration: Configuration,
url: string,
data: Payload['data'],
onResponse?: (r: HttpResponse) => void
) {
const request = new XMLHttpRequest()
request.open('POST', url, true)
addEventListener(
configuration,
request,

@@ -139,0 +148,0 @@ 'loadend',

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

) {
const primaryBatch = createBatch(endpoint)
const primaryBatch = createBatch(configuration, endpoint)
let replicaBatch: Batch | undefined
if (replicaEndpoint) {
replicaBatch = createBatch(replicaEndpoint)
replicaBatch = createBatch(configuration, replicaEndpoint)
}
function createBatch(endpointBuilder: EndpointBuilder) {
function createBatch(configuration: Configuration, endpointBuilder: EndpointBuilder) {
return new Batch(
createHttpRequest(endpointBuilder, configuration.batchBytesLimit, reportError),
createHttpRequest(configuration, endpointBuilder, configuration.batchBytesLimit, reportError),
createFlushController({

@@ -29,0 +29,0 @@ messagesLimit: configuration.batchMessagesLimit,

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