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 5.18.0 to 5.19.0

2

cjs/boot/init.js

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

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

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPageExitReason = exports.createPageExitObservable = exports.PageExitReason = void 0;
var experimentalFeatures_1 = require("../tools/experimentalFeatures");
var observable_1 = require("../tools/observable");
var polyfills_1 = require("../tools/utils/polyfills");
var functionUtils_1 = require("../tools/utils/functionUtils");
var addEventListener_1 = require("./addEventListener");

@@ -17,12 +15,5 @@ exports.PageExitReason = {

return new observable_1.Observable(function (observable) {
var pagehideEnabled = (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.PAGEHIDE);
var stopListeners = (0, addEventListener_1.addEventListeners)(configuration, window, [addEventListener_1.DOM_EVENT.VISIBILITY_CHANGE, addEventListener_1.DOM_EVENT.FREEZE, addEventListener_1.DOM_EVENT.PAGE_HIDE], function (event) {
if (event.type === addEventListener_1.DOM_EVENT.PAGE_HIDE && pagehideEnabled) {
var stopListeners = (0, addEventListener_1.addEventListeners)(configuration, window, [addEventListener_1.DOM_EVENT.VISIBILITY_CHANGE, addEventListener_1.DOM_EVENT.FREEZE], function (event) {
if (event.type === addEventListener_1.DOM_EVENT.VISIBILITY_CHANGE && document.visibilityState === 'hidden') {
/**
* Only event that detect page unload events while being compatible with the back/forward cache (bfcache)
*/
observable.notify({ reason: exports.PageExitReason.PAGEHIDE });
}
else if (event.type === addEventListener_1.DOM_EVENT.VISIBILITY_CHANGE && document.visibilityState === 'hidden') {
/**
* Only event that guarantee to fire on mobile devices when the page transitions to background state

@@ -41,8 +32,5 @@ * (e.g. when user switches to a different application, goes to homescreen, etc), or is being unloaded.

}, { capture: true }).stop;
var stopBeforeUnloadListener = functionUtils_1.noop;
if (!pagehideEnabled) {
stopBeforeUnloadListener = (0, addEventListener_1.addEventListener)(configuration, window, addEventListener_1.DOM_EVENT.BEFORE_UNLOAD, function () {
observable.notify({ reason: exports.PageExitReason.UNLOADING });
}).stop;
}
var stopBeforeUnloadListener = (0, addEventListener_1.addEventListener)(configuration, window, addEventListener_1.DOM_EVENT.BEFORE_UNLOAD, function () {
observable.notify({ reason: exports.PageExitReason.UNLOADING });
}).stop;
return function () {

@@ -49,0 +37,0 @@ stopListeners();

@@ -20,2 +20,10 @@ export interface VisualViewportEventMap {

}
export interface WeakRef<T extends object> {
readonly [Symbol.toStringTag]: 'WeakRef';
deref(): T | undefined;
}
export interface WeakRefConstructor {
readonly prototype: WeakRef<any>;
new <T extends object>(target: T): WeakRef<T>;
}
export interface CookieStore extends EventTarget {

@@ -22,0 +30,0 @@ }

@@ -29,5 +29,5 @@ import type { Duration } from '../../tools/utils/timeUtils';

site?: string | undefined;
service?: string | undefined;
env?: string | undefined;
version?: string | undefined;
service?: string | undefined | null;
env?: string | undefined | null;
version?: string | undefined | null;
/**

@@ -34,0 +34,0 @@ * @deprecated use usePartitionedCrossSiteSessionCookie instead

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

function checkIfString(tag, tagName) {
if (tag !== undefined && typeof tag !== 'string') {
if (tag !== undefined && tag !== null && typeof tag !== 'string') {
display_1.display.error("".concat(tagName, " must be defined as a string"));

@@ -91,3 +91,3 @@ return false;

telemetryUsageSampleRate: (_d = initConfiguration.telemetryUsageSampleRate) !== null && _d !== void 0 ? _d : 5,
service: initConfiguration.service,
service: initConfiguration.service || undefined,
silentMultipleInit: !!initConfiguration.silentMultipleInit,

@@ -94,0 +94,0 @@ allowUntrustedEvents: !!initConfiguration.allowUntrustedEvents,

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

var urlPolyfill_1 = require("../../tools/utils/urlPolyfill");
var experimentalFeatures_1 = require("../../tools/experimentalFeatures");
var stringUtils_1 = require("../../tools/utils/stringUtils");

@@ -61,7 +60,4 @@ var intakeSites_1 = require("./intakeSites");

var clientToken = _a.clientToken, internalAnalyticsSubdomain = _a.internalAnalyticsSubdomain;
var retry = _b.retry, flushReason = _b.flushReason, encoding = _b.encoding;
var tags = ["sdk_version:".concat("5.18.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && (0, experimentalFeatures_1.isExperimentalFeatureEnabled)(experimentalFeatures_1.ExperimentalFeature.COLLECT_FLUSH_REASON)) {
tags.push("flush_reason:".concat(flushReason));
}
var retry = _b.retry, encoding = _b.encoding;
var tags = ["sdk_version:".concat("5.19.0"), "api:".concat(api)].concat(configurationTags);
if (retry) {

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

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

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

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

export interface SessionManager<TrackingType extends string> {
findActiveSession: (startTime?: RelativeTime) => SessionContext<TrackingType> | undefined;
findSession: (startTime?: RelativeTime, options?: {
returnInactive: boolean;
}) => SessionContext<TrackingType> | undefined;
renewObservable: Observable<void>;

@@ -10,0 +12,0 @@ expireObservable: Observable<void>;

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

return {
findActiveSession: function (startTime) { return sessionContextHistory.find(startTime); },
findSession: function (startTime, options) { return sessionContextHistory.find(startTime, options); },
renewObservable: renewObservable,

@@ -59,0 +59,0 @@ expireObservable: expireObservable,

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

var _a = (0, functionUtils_1.throttle)(function () {
var isTracked;
(0, sessionStoreOperations_1.processSessionStoreOperations)({

@@ -56,7 +55,7 @@ process: function (sessionState) {

var synchronizedSession = synchronizeSession(sessionState);
isTracked = expandOrRenewSessionState(synchronizedSession);
expandOrRenewSessionState(synchronizedSession);
return synchronizedSession;
},
after: function (sessionState) {
if (isTracked && !hasSessionInCache()) {
if ((0, sessionState_1.isSessionStarted)(sessionState) && !hasSessionInCache()) {
renewSessionInCache(sessionState);

@@ -121,3 +120,2 @@ }

}
return isTracked;
}

@@ -124,0 +122,0 @@ function hasSessionInCache() {

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

tracer_api_version?: string | undefined;
send_logs_after_session_expiration?: boolean | undefined;
};

@@ -146,0 +147,0 @@ }) | ({

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

service: telemetryService,
version: "5.18.0",
version: "5.19.0",
source: 'browser',

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

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

tracer_api_version?: string;
/**
* Whether logs are sent after the session expiration
*/
send_logs_after_session_expiration?: boolean;
[k: string]: unknown;

@@ -348,0 +352,0 @@ };

@@ -33,3 +33,3 @@ export { Configuration, InitConfiguration, validateAndBuildConfiguration, DefaultPrivacyLevel, TraceContextInjection, EndpointBuilder, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration';

export { areCookiesAuthorized, getCookie, getInitCookie, setCookie, deleteCookie, resetInitCookies, } from './browser/cookie';
export { CookieStore } from './browser/types';
export { CookieStore, WeakRef, WeakRefConstructor } from './browser/types';
export { initXhrObservable, XhrCompleteContext, XhrStartContext } from './browser/xhrObservable';

@@ -36,0 +36,0 @@ export { initFetchObservable, FetchResolveContext, FetchStartContext, FetchContext } from './browser/fetchObservable';

@@ -11,7 +11,2 @@ /**

export declare enum ExperimentalFeature {
PAGEHIDE = "pagehide",
RESOURCE_PAGE_STATES = "resource_page_states",
COLLECT_FLUSH_REASON = "collect_flush_reason",
ZERO_LCP_TELEMETRY = "zero_lcp_telemetry",
DISABLE_REPLAY_INLINE_CSS = "disable_replay_inline_css",
WRITABLE_RESOURCE_GRAPHQL = "writable_resource_graphql",

@@ -18,0 +13,0 @@ CUSTOM_VITALS = "custom_vitals",

@@ -18,7 +18,2 @@ "use strict";

(function (ExperimentalFeature) {
ExperimentalFeature["PAGEHIDE"] = "pagehide";
ExperimentalFeature["RESOURCE_PAGE_STATES"] = "resource_page_states";
ExperimentalFeature["COLLECT_FLUSH_REASON"] = "collect_flush_reason";
ExperimentalFeature["ZERO_LCP_TELEMETRY"] = "zero_lcp_telemetry";
ExperimentalFeature["DISABLE_REPLAY_INLINE_CSS"] = "disable_replay_inline_css";
ExperimentalFeature["WRITABLE_RESOURCE_GRAPHQL"] = "writable_resource_graphql";

@@ -25,0 +20,0 @@ ExperimentalFeature["CUSTOM_VITALS"] = "custom_vitals";

@@ -28,4 +28,8 @@ import type { Duration, RelativeTime } from './utils/timeUtils';

* if no `startTime` is provided. This method assumes that entries are not overlapping.
*
* If `option.returnInactive` is true, returns the value at `startTime` (active or not).
*/
find(startTime?: RelativeTime): Value | undefined;
find(startTime?: RelativeTime, options?: {
returnInactive: boolean;
}): Value | undefined;
/**

@@ -32,0 +36,0 @@ * Helper function to close the currently active value, if any. This method assumes that entries

@@ -47,9 +47,12 @@ "use strict";

* if no `startTime` is provided. This method assumes that entries are not overlapping.
*
* If `option.returnInactive` is true, returns the value at `startTime` (active or not).
*/
ValueHistory.prototype.find = function (startTime) {
ValueHistory.prototype.find = function (startTime, options) {
if (startTime === void 0) { startTime = END_OF_TIMES; }
if (options === void 0) { options = { returnInactive: false }; }
for (var _i = 0, _a = this.entries; _i < _a.length; _i++) {
var entry = _a[_i];
if (entry.startTime <= startTime) {
if (startTime <= entry.endTime) {
if (options.returnInactive || startTime <= entry.endTime) {
return entry.value;

@@ -56,0 +59,0 @@ }

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

if (encoderResult.outputBytesCount) {
send(formatPayloadFromEncoder(encoderResult, event));
send(formatPayloadFromEncoder(encoderResult));
}

@@ -51,3 +51,2 @@ // Send messages that are not yet encoded at this point

bytesCount: (0, byteUtils_1.computeBytesCount)(pendingMessages),
flushReason: event.reason,
});

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

this.encoder.finish(function (encoderResult) {
send(formatPayloadFromEncoder(encoderResult, event));
send(formatPayloadFromEncoder(encoderResult));
});

@@ -103,3 +102,3 @@ }

exports.Batch = Batch;
function formatPayloadFromEncoder(encoderResult, flushEvent) {
function formatPayloadFromEncoder(encoderResult) {
var data;

@@ -124,5 +123,4 @@ if (typeof encoderResult.output === 'string') {

encoding: encoderResult.encoding,
flushReason: flushEvent.reason,
};
}
//# sourceMappingURL=batch.js.map
import type { EndpointBuilder, Configuration } from '../domain/configuration';
import type { Context } from '../tools/serialisation/context';
import type { RawError } from '../domain/error/error.types';
import type { FlushReason } from './flushController';
/**

@@ -22,3 +21,2 @@ * Use POST request without content type to:

retry?: RetryInfo;
flushReason?: FlushReason;
encoding?: 'deflate';

@@ -25,0 +23,0 @@ }

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

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

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

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

import { isExperimentalFeatureEnabled, ExperimentalFeature } from '../tools/experimentalFeatures';
import { Observable } from '../tools/observable';
import { objectValues, includes } from '../tools/utils/polyfills';
import { noop } from '../tools/utils/functionUtils';
import { addEventListeners, addEventListener, DOM_EVENT } from './addEventListener';

@@ -14,12 +12,5 @@ export var PageExitReason = {

return new Observable(function (observable) {
var pagehideEnabled = isExperimentalFeatureEnabled(ExperimentalFeature.PAGEHIDE);
var stopListeners = addEventListeners(configuration, window, [DOM_EVENT.VISIBILITY_CHANGE, DOM_EVENT.FREEZE, DOM_EVENT.PAGE_HIDE], function (event) {
if (event.type === DOM_EVENT.PAGE_HIDE && pagehideEnabled) {
var stopListeners = addEventListeners(configuration, window, [DOM_EVENT.VISIBILITY_CHANGE, DOM_EVENT.FREEZE], function (event) {
if (event.type === DOM_EVENT.VISIBILITY_CHANGE && document.visibilityState === 'hidden') {
/**
* Only event that detect page unload events while being compatible with the back/forward cache (bfcache)
*/
observable.notify({ reason: PageExitReason.PAGEHIDE });
}
else if (event.type === DOM_EVENT.VISIBILITY_CHANGE && document.visibilityState === 'hidden') {
/**
* Only event that guarantee to fire on mobile devices when the page transitions to background state

@@ -38,8 +29,5 @@ * (e.g. when user switches to a different application, goes to homescreen, etc), or is being unloaded.

}, { capture: true }).stop;
var stopBeforeUnloadListener = noop;
if (!pagehideEnabled) {
stopBeforeUnloadListener = addEventListener(configuration, window, DOM_EVENT.BEFORE_UNLOAD, function () {
observable.notify({ reason: PageExitReason.UNLOADING });
}).stop;
}
var stopBeforeUnloadListener = addEventListener(configuration, window, DOM_EVENT.BEFORE_UNLOAD, function () {
observable.notify({ reason: PageExitReason.UNLOADING });
}).stop;
return function () {

@@ -46,0 +34,0 @@ stopListeners();

@@ -20,2 +20,10 @@ export interface VisualViewportEventMap {

}
export interface WeakRef<T extends object> {
readonly [Symbol.toStringTag]: 'WeakRef';
deref(): T | undefined;
}
export interface WeakRefConstructor {
readonly prototype: WeakRef<any>;
new <T extends object>(target: T): WeakRef<T>;
}
export interface CookieStore extends EventTarget {

@@ -22,0 +30,0 @@ }

@@ -29,5 +29,5 @@ import type { Duration } from '../../tools/utils/timeUtils';

site?: string | undefined;
service?: string | undefined;
env?: string | undefined;
version?: string | undefined;
service?: string | undefined | null;
env?: string | undefined | null;
version?: string | undefined | null;
/**

@@ -34,0 +34,0 @@ * @deprecated use usePartitionedCrossSiteSessionCookie instead

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

function checkIfString(tag, tagName) {
if (tag !== undefined && typeof tag !== 'string') {
if (tag !== undefined && tag !== null && typeof tag !== 'string') {
display.error("".concat(tagName, " must be defined as a string"));

@@ -88,3 +88,3 @@ return false;

telemetryUsageSampleRate: (_d = initConfiguration.telemetryUsageSampleRate) !== null && _d !== void 0 ? _d : 5,
service: initConfiguration.service,
service: initConfiguration.service || undefined,
silentMultipleInit: !!initConfiguration.silentMultipleInit,

@@ -91,0 +91,0 @@ allowUntrustedEvents: !!initConfiguration.allowUntrustedEvents,

import { timeStampNow } from '../../tools/utils/timeUtils';
import { normalizeUrl } from '../../tools/utils/urlPolyfill';
import { ExperimentalFeature, isExperimentalFeatureEnabled } from '../../tools/experimentalFeatures';
import { generateUUID } from '../../tools/utils/stringUtils';

@@ -56,7 +55,4 @@ import { INTAKE_SITE_US1, INTAKE_SITE_FED_STAGING, PCI_INTAKE_HOST_US1 } from './intakeSites';

var clientToken = _a.clientToken, internalAnalyticsSubdomain = _a.internalAnalyticsSubdomain;
var retry = _b.retry, flushReason = _b.flushReason, encoding = _b.encoding;
var tags = ["sdk_version:".concat("5.18.0"), "api:".concat(api)].concat(configurationTags);
if (flushReason && isExperimentalFeatureEnabled(ExperimentalFeature.COLLECT_FLUSH_REASON)) {
tags.push("flush_reason:".concat(flushReason));
}
var retry = _b.retry, encoding = _b.encoding;
var tags = ["sdk_version:".concat("5.19.0"), "api:".concat(api)].concat(configurationTags);
if (retry) {

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

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

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

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

export interface SessionManager<TrackingType extends string> {
findActiveSession: (startTime?: RelativeTime) => SessionContext<TrackingType> | undefined;
findSession: (startTime?: RelativeTime, options?: {
returnInactive: boolean;
}) => SessionContext<TrackingType> | undefined;
renewObservable: Observable<void>;

@@ -10,0 +12,0 @@ expireObservable: Observable<void>;

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

return {
findActiveSession: function (startTime) { return sessionContextHistory.find(startTime); },
findSession: function (startTime, options) { return sessionContextHistory.find(startTime, options); },
renewObservable: renewObservable,

@@ -56,0 +56,0 @@ expireObservable: expireObservable,

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

import { selectCookieStrategy, initCookieStrategy } from './storeStrategies/sessionInCookie';
import { getExpiredSessionState, isSessionInExpiredState, isSessionInNotStartedState } from './sessionState';
import { getExpiredSessionState, isSessionInExpiredState, isSessionInNotStartedState, isSessionStarted, } from './sessionState';
import { initLocalStorageStrategy, selectLocalStorageStrategy } from './storeStrategies/sessionInLocalStorage';

@@ -45,3 +45,2 @@ import { processSessionStoreOperations } from './sessionStoreOperations';

var _a = throttle(function () {
var isTracked;
processSessionStoreOperations({

@@ -53,7 +52,7 @@ process: function (sessionState) {

var synchronizedSession = synchronizeSession(sessionState);
isTracked = expandOrRenewSessionState(synchronizedSession);
expandOrRenewSessionState(synchronizedSession);
return synchronizedSession;
},
after: function (sessionState) {
if (isTracked && !hasSessionInCache()) {
if (isSessionStarted(sessionState) && !hasSessionInCache()) {
renewSessionInCache(sessionState);

@@ -118,3 +117,2 @@ }

}
return isTracked;
}

@@ -121,0 +119,0 @@ function hasSessionInCache() {

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

tracer_api_version?: string | undefined;
send_logs_after_session_expiration?: boolean | undefined;
};

@@ -146,0 +147,0 @@ }) | ({

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

service: telemetryService,
version: "5.18.0",
version: "5.19.0",
source: 'browser',

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

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

tracer_api_version?: string;
/**
* Whether logs are sent after the session expiration
*/
send_logs_after_session_expiration?: boolean;
[k: string]: unknown;

@@ -348,0 +352,0 @@ };

@@ -33,3 +33,3 @@ export { Configuration, InitConfiguration, validateAndBuildConfiguration, DefaultPrivacyLevel, TraceContextInjection, EndpointBuilder, serializeConfiguration, INTAKE_SITE_STAGING, INTAKE_SITE_US1, INTAKE_SITE_US1_FED, INTAKE_SITE_EU1, } from './domain/configuration';

export { areCookiesAuthorized, getCookie, getInitCookie, setCookie, deleteCookie, resetInitCookies, } from './browser/cookie';
export { CookieStore } from './browser/types';
export { CookieStore, WeakRef, WeakRefConstructor } from './browser/types';
export { initXhrObservable, XhrCompleteContext, XhrStartContext } from './browser/xhrObservable';

@@ -36,0 +36,0 @@ export { initFetchObservable, FetchResolveContext, FetchStartContext, FetchContext } from './browser/fetchObservable';

@@ -11,7 +11,2 @@ /**

export declare enum ExperimentalFeature {
PAGEHIDE = "pagehide",
RESOURCE_PAGE_STATES = "resource_page_states",
COLLECT_FLUSH_REASON = "collect_flush_reason",
ZERO_LCP_TELEMETRY = "zero_lcp_telemetry",
DISABLE_REPLAY_INLINE_CSS = "disable_replay_inline_css",
WRITABLE_RESOURCE_GRAPHQL = "writable_resource_graphql",

@@ -18,0 +13,0 @@ CUSTOM_VITALS = "custom_vitals",

@@ -15,7 +15,2 @@ /**

(function (ExperimentalFeature) {
ExperimentalFeature["PAGEHIDE"] = "pagehide";
ExperimentalFeature["RESOURCE_PAGE_STATES"] = "resource_page_states";
ExperimentalFeature["COLLECT_FLUSH_REASON"] = "collect_flush_reason";
ExperimentalFeature["ZERO_LCP_TELEMETRY"] = "zero_lcp_telemetry";
ExperimentalFeature["DISABLE_REPLAY_INLINE_CSS"] = "disable_replay_inline_css";
ExperimentalFeature["WRITABLE_RESOURCE_GRAPHQL"] = "writable_resource_graphql";

@@ -22,0 +17,0 @@ ExperimentalFeature["CUSTOM_VITALS"] = "custom_vitals";

@@ -28,4 +28,8 @@ import type { Duration, RelativeTime } from './utils/timeUtils';

* if no `startTime` is provided. This method assumes that entries are not overlapping.
*
* If `option.returnInactive` is true, returns the value at `startTime` (active or not).
*/
find(startTime?: RelativeTime): Value | undefined;
find(startTime?: RelativeTime, options?: {
returnInactive: boolean;
}): Value | undefined;
/**

@@ -32,0 +36,0 @@ * Helper function to close the currently active value, if any. This method assumes that entries

@@ -44,9 +44,12 @@ import { setInterval, clearInterval } from './timer';

* if no `startTime` is provided. This method assumes that entries are not overlapping.
*
* If `option.returnInactive` is true, returns the value at `startTime` (active or not).
*/
ValueHistory.prototype.find = function (startTime) {
ValueHistory.prototype.find = function (startTime, options) {
if (startTime === void 0) { startTime = END_OF_TIMES; }
if (options === void 0) { options = { returnInactive: false }; }
for (var _i = 0, _a = this.entries; _i < _a.length; _i++) {
var entry = _a[_i];
if (entry.startTime <= startTime) {
if (startTime <= entry.endTime) {
if (options.returnInactive || startTime <= entry.endTime) {
return entry.value;

@@ -53,0 +56,0 @@ }

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

if (encoderResult.outputBytesCount) {
send(formatPayloadFromEncoder(encoderResult, event));
send(formatPayloadFromEncoder(encoderResult));
}

@@ -48,3 +48,2 @@ // Send messages that are not yet encoded at this point

bytesCount: computeBytesCount(pendingMessages),
flushReason: event.reason,
});

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

this.encoder.finish(function (encoderResult) {
send(formatPayloadFromEncoder(encoderResult, event));
send(formatPayloadFromEncoder(encoderResult));
});

@@ -100,3 +99,3 @@ }

export { Batch };
function formatPayloadFromEncoder(encoderResult, flushEvent) {
function formatPayloadFromEncoder(encoderResult) {
var data;

@@ -121,5 +120,4 @@ if (typeof encoderResult.output === 'string') {

encoding: encoderResult.encoding,
flushReason: flushEvent.reason,
};
}
//# sourceMappingURL=batch.js.map
import type { EndpointBuilder, Configuration } from '../domain/configuration';
import type { Context } from '../tools/serialisation/context';
import type { RawError } from '../domain/error/error.types';
import type { FlushReason } from './flushController';
/**

@@ -22,3 +21,2 @@ * Use POST request without content type to:

retry?: RetryInfo;
flushReason?: FlushReason;
encoding?: 'deflate';

@@ -25,0 +23,0 @@ }

{
"name": "@datadog/browser-core",
"version": "5.18.0",
"version": "5.19.0",
"license": "Apache-2.0",

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

},
"gitHead": "933517cf9fc2d33f561ac54a07a1f5e8bbab154e"
"gitHead": "ce92533465ebb3c3d0142f0c7d83af471572a818"
}

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

import { isExperimentalFeatureEnabled, ExperimentalFeature } from '../tools/experimentalFeatures'
import { Observable } from '../tools/observable'
import { objectValues, includes } from '../tools/utils/polyfills'
import { noop } from '../tools/utils/functionUtils'
import type { Configuration } from '../domain/configuration'

@@ -23,15 +21,9 @@ import { addEventListeners, addEventListener, DOM_EVENT } from './addEventListener'

return new Observable<PageExitEvent>((observable) => {
const pagehideEnabled = isExperimentalFeatureEnabled(ExperimentalFeature.PAGEHIDE)
const { stop: stopListeners } = addEventListeners(
configuration,
window,
[DOM_EVENT.VISIBILITY_CHANGE, DOM_EVENT.FREEZE, DOM_EVENT.PAGE_HIDE],
[DOM_EVENT.VISIBILITY_CHANGE, DOM_EVENT.FREEZE],
(event) => {
if (event.type === DOM_EVENT.PAGE_HIDE && pagehideEnabled) {
if (event.type === DOM_EVENT.VISIBILITY_CHANGE && document.visibilityState === 'hidden') {
/**
* Only event that detect page unload events while being compatible with the back/forward cache (bfcache)
*/
observable.notify({ reason: PageExitReason.PAGEHIDE })
} else if (event.type === DOM_EVENT.VISIBILITY_CHANGE && document.visibilityState === 'hidden') {
/**
* Only event that guarantee to fire on mobile devices when the page transitions to background state

@@ -52,8 +44,5 @@ * (e.g. when user switches to a different application, goes to homescreen, etc), or is being unloaded.

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

@@ -60,0 +49,0 @@ return () => {

@@ -42,2 +42,14 @@ // Those types come from the official TypeScript DOM library, but are not included in our minimal

export interface WeakRef<T extends object> {
readonly [Symbol.toStringTag]: 'WeakRef'
deref(): T | undefined
}
export interface WeakRefConstructor {
readonly prototype: WeakRef<any>
new <T extends object>(target: T): WeakRef<T>
}
// Those are native API types that are not official supported by TypeScript yet

@@ -44,0 +56,0 @@

@@ -49,5 +49,5 @@ import { catchUserErrors } from '../../tools/catchUserErrors'

// tag and context options
service?: string | undefined
env?: string | undefined
version?: string | undefined
service?: string | undefined | null
env?: string | undefined | null
version?: string | undefined | null

@@ -113,4 +113,4 @@ // cookie options

function checkIfString(tag: unknown, tagName: string) {
if (tag !== undefined && typeof tag !== 'string') {
function checkIfString(tag: unknown, tagName: string): tag is string | undefined | null {
if (tag !== undefined && tag !== null && typeof tag !== 'string') {
display.error(`${tagName} must be defined as a string`)

@@ -201,3 +201,3 @@ return false

telemetryUsageSampleRate: initConfiguration.telemetryUsageSampleRate ?? 5,
service: initConfiguration.service,
service: initConfiguration.service || undefined,
silentMultipleInit: !!initConfiguration.silentMultipleInit,

@@ -204,0 +204,0 @@ allowUntrustedEvents: !!initConfiguration.allowUntrustedEvents,

import type { Payload } from '../../transport'
import { timeStampNow } from '../../tools/utils/timeUtils'
import { normalizeUrl } from '../../tools/utils/urlPolyfill'
import { ExperimentalFeature, isExperimentalFeatureEnabled } from '../../tools/experimentalFeatures'
import { generateUUID } from '../../tools/utils/stringUtils'

@@ -91,8 +90,5 @@ import type { InitConfiguration } from './configuration'

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

@@ -99,0 +95,0 @@ tags.push(`retry_count:${retry.count}`, `retry_after:${retry.lastFailureStatus}`)

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

export interface SessionManager<TrackingType extends string> {
findActiveSession: (startTime?: RelativeTime) => SessionContext<TrackingType> | undefined
findSession: (
startTime?: RelativeTime,
options?: { returnInactive: boolean }
) => SessionContext<TrackingType> | undefined
renewObservable: Observable<void>

@@ -84,3 +87,3 @@ expireObservable: Observable<void>

return {
findActiveSession: (startTime) => sessionContextHistory.find(startTime),
findSession: (startTime, options) => sessionContextHistory.find(startTime, options),
renewObservable,

@@ -87,0 +90,0 @@ expireObservable,

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

import type { SessionStoreStrategyType } from './storeStrategies/sessionStoreStrategy'
import { getExpiredSessionState, isSessionInExpiredState, isSessionInNotStartedState } from './sessionState'
import {
getExpiredSessionState,
isSessionInExpiredState,
isSessionInNotStartedState,
isSessionStarted,
} from './sessionState'
import type { SessionState } from './sessionState'

@@ -73,3 +78,2 @@ import { initLocalStorageStrategy, selectLocalStorageStrategy } from './storeStrategies/sessionInLocalStorage'

const { throttled: throttledExpandOrRenewSession, cancel: cancelExpandOrRenewSession } = throttle(() => {
let isTracked: boolean
processSessionStoreOperations(

@@ -83,7 +87,7 @@ {

const synchronizedSession = synchronizeSession(sessionState)
isTracked = expandOrRenewSessionState(synchronizedSession)
expandOrRenewSessionState(synchronizedSession)
return synchronizedSession
},
after: (sessionState) => {
if (isTracked && !hasSessionInCache()) {
if (isSessionStarted(sessionState) && !hasSessionInCache()) {
renewSessionInCache(sessionState)

@@ -164,3 +168,2 @@ }

}
return isTracked
}

@@ -167,0 +170,0 @@

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

tracer_api_version?: string
/**
* Whether logs are sent after the session expiration
*/
send_logs_after_session_expiration?: boolean
[k: string]: unknown

@@ -358,0 +362,0 @@ }

@@ -95,3 +95,3 @@ export {

} from './browser/cookie'
export { CookieStore } from './browser/types'
export { CookieStore, WeakRef, WeakRefConstructor } from './browser/types'
export { initXhrObservable, XhrCompleteContext, XhrStartContext } from './browser/xhrObservable'

@@ -98,0 +98,0 @@ export { initFetchObservable, FetchResolveContext, FetchStartContext, FetchContext } from './browser/fetchObservable'

@@ -14,7 +14,2 @@ /**

export enum ExperimentalFeature {
PAGEHIDE = 'pagehide',
RESOURCE_PAGE_STATES = 'resource_page_states',
COLLECT_FLUSH_REASON = 'collect_flush_reason',
ZERO_LCP_TELEMETRY = 'zero_lcp_telemetry',
DISABLE_REPLAY_INLINE_CSS = 'disable_replay_inline_css',
WRITABLE_RESOURCE_GRAPHQL = 'writable_resource_graphql',

@@ -21,0 +16,0 @@ CUSTOM_VITALS = 'custom_vitals',

@@ -63,7 +63,12 @@ import { setInterval, clearInterval } from './timer'

* if no `startTime` is provided. This method assumes that entries are not overlapping.
*
* If `option.returnInactive` is true, returns the value at `startTime` (active or not).
*/
find(startTime: RelativeTime = END_OF_TIMES): Value | undefined {
find(
startTime: RelativeTime = END_OF_TIMES,
options: { returnInactive: boolean } = { returnInactive: false }
): Value | undefined {
for (const entry of this.entries) {
if (entry.startTime <= startTime) {
if (startTime <= entry.endTime) {
if (options.returnInactive || startTime <= entry.endTime) {
return entry.value

@@ -70,0 +75,0 @@ }

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

if (encoderResult.outputBytesCount) {
send(formatPayloadFromEncoder(encoderResult, event))
send(formatPayloadFromEncoder(encoderResult))
}

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

bytesCount: computeBytesCount(pendingMessages),
flushReason: event.reason,
})

@@ -75,3 +74,3 @@ }

this.encoder.finish((encoderResult) => {
send(formatPayloadFromEncoder(encoderResult, event))
send(formatPayloadFromEncoder(encoderResult))
})

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

function formatPayloadFromEncoder(encoderResult: EncoderResult, flushEvent: FlushEvent): Payload {
function formatPayloadFromEncoder(encoderResult: EncoderResult): Payload {
let data: string | Blob

@@ -149,4 +148,3 @@ if (typeof encoderResult.output === 'string') {

encoding: encoderResult.encoding,
flushReason: flushEvent.reason,
}
}

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

import { newRetryState, sendWithRetryStrategy } from './sendWithRetryStrategy'
import type { FlushReason } from './flushController'

@@ -31,3 +30,2 @@ /**

retry?: RetryInfo
flushReason?: FlushReason
encoding?: 'deflate'

@@ -34,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

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