New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sentry-internal/browser-utils

Package Overview
Dependencies
Maintainers
9
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry-internal/browser-utils - npm Package Compare versions

Comparing version 8.50.0 to 9.0.0-alpha.0

2

build/cjs/debug-build.js

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ /**

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -47,3 +47,3 @@ const core = require('@sentry/core');

const contentWindow = sandbox.contentWindow;
if (contentWindow && contentWindow[name]) {
if (contentWindow?.[name]) {
impl = contentWindow[name] ;

@@ -50,0 +50,0 @@ }

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const instrument = require('./metrics/instrument.js');

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -45,7 +45,6 @@ const core = require('@sentry/core');

const globalObject = types.WINDOW ;
const targetObj = globalObject[target];
const proto = targetObj && targetObj.prototype;
const proto = globalObject[target]?.prototype;
// eslint-disable-next-line no-prototype-builtins
if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
if (!proto?.hasOwnProperty?.('addEventListener')) {
return;

@@ -152,3 +151,3 @@ }

if (!target || !target.tagName) {
if (!target?.tagName) {
return true;

@@ -155,0 +154,0 @@ }

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -23,8 +23,5 @@ const core = require('@sentry/core');

function instrumentHistory() {
if (!core.supportsHistory()) {
return;
}
const oldOnPopState = types.WINDOW.onpopstate;
types.WINDOW.onpopstate = function ( ...args) {
// The `popstate` event may also be triggered on `pushState`, but it may not always reliably be emitted by the browser
// Which is why we also monkey-patch methods below, in addition to this
types.WINDOW.addEventListener('popstate', () => {
const to = types.WINDOW.location.href;

@@ -34,16 +31,16 @@ // keep track of the current URL state, as we always receive only the updated state

lastHref = to;
const handlerData = { from, to };
core.triggerHandlers('history', handlerData);
if (oldOnPopState) {
// Apparently this can throw in Firefox when incorrectly implemented plugin is installed.
// https://github.com/getsentry/sentry-javascript/issues/3344
// https://github.com/bugsnag/bugsnag-js/issues/469
try {
return oldOnPopState.apply(this, args);
} catch (_oO) {
// no-empty
}
if (from === to) {
return;
}
};
const handlerData = { from, to } ;
core.triggerHandlers('history', handlerData);
});
// Just guard against this not being available, in weird environments
if (!core.supportsHistory()) {
return;
}
function historyReplacementFunction(originalHistoryFunction) {

@@ -58,3 +55,8 @@ return function ( ...args) {

lastHref = to;
const handlerData = { from, to };
if (from === to) {
return;
}
const handlerData = { from, to } ;
core.triggerHandlers('history', handlerData);

@@ -61,0 +63,0 @@ }

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -160,3 +160,3 @@ const core = require('@sentry/core');

return (url ).toString();
} catch (e2) {} // eslint-disable-line no-empty
} catch {} // eslint-disable-line no-empty

@@ -163,0 +163,0 @@ return undefined;

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -28,3 +28,3 @@ const core = require('@sentry/core');

const performance = utils.getBrowserPerformanceAPI();
if (performance && core.browserPerformanceTimeOrigin) {
if (performance && core.browserPerformanceTimeOrigin()) {
// @ts-expect-error we want to make sure all of these are available, even if TS is sure they are

@@ -43,3 +43,3 @@ if (performance.mark) {

ttfbCleanupCallback();
clsCleanupCallback && clsCleanupCallback();
clsCleanupCallback?.();
};

@@ -64,3 +64,3 @@ }

for (const entry of entries) {
const startTime = utils.msToSec((core.browserPerformanceTimeOrigin ) + entry.startTime);
const startTime = utils.msToSec((core.browserPerformanceTimeOrigin() ) + entry.startTime);
const duration = utils.msToSec(entry.duration);

@@ -104,3 +104,3 @@

const startTime = utils.msToSec((core.browserPerformanceTimeOrigin ) + entry.startTime);
const startTime = utils.msToSec((core.browserPerformanceTimeOrigin() ) + entry.startTime);

@@ -116,3 +116,2 @@ const { start_timestamp: parentStartTimestamp, op: parentOp } = core.spanToJSON(parent);

}
const duration = utils.msToSec(entry.duration);

@@ -160,3 +159,3 @@

if (entry.name === 'click') {
const startTime = utils.msToSec((core.browserPerformanceTimeOrigin ) + entry.startTime);
const startTime = utils.msToSec((core.browserPerformanceTimeOrigin() ) + entry.startTime);
const duration = utils.msToSec(entry.duration);

@@ -220,3 +219,3 @@

const timeOrigin = utils.msToSec(core.browserPerformanceTimeOrigin );
const timeOrigin = utils.msToSec(core.browserPerformanceTimeOrigin() );
const startTime = utils.msToSec(entry.startTime);

@@ -242,3 +241,4 @@ _measurements['fid'] = { value: metric.value, unit: 'millisecond' };

const performance = utils.getBrowserPerformanceAPI();
if (!performance || !performance.getEntries || !core.browserPerformanceTimeOrigin) {
const origin = core.browserPerformanceTimeOrigin();
if (!performance?.getEntries || !origin) {
// Gatekeeper if performance API not available

@@ -248,3 +248,3 @@ return;

const timeOrigin = utils.msToSec(core.browserPerformanceTimeOrigin);
const timeOrigin = utils.msToSec(origin);

@@ -598,3 +598,3 @@ const performanceEntries = performance.getEntries();

// See: https://developer.mozilla.org/en-US/docs/Web/API/LayoutShift
if (_clsEntry && _clsEntry.sources) {
if (_clsEntry?.sources) {
_clsEntry.sources.forEach((source, index) =>

@@ -601,0 +601,0 @@ span.setAttribute(`cls.source.${index + 1}`, core.htmlTreeAsString(source.node)),

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -65,10 +65,12 @@ const core = require('@sentry/core');

_collectClsOnce();
unsubscribeStartNavigation && unsubscribeStartNavigation();
unsubscribeStartNavigation?.();
});
const activeSpan = core.getActiveSpan();
const rootSpan = activeSpan && core.getRootSpan(activeSpan);
const spanJSON = rootSpan && core.spanToJSON(rootSpan);
if (spanJSON && spanJSON.op === 'pageload') {
pageloadSpanId = rootSpan.spanContext().spanId;
if (activeSpan) {
const rootSpan = core.getRootSpan(activeSpan);
const spanJSON = core.spanToJSON(rootSpan);
if (spanJSON.op === 'pageload') {
pageloadSpanId = rootSpan.spanContext().spanId;
}
}

@@ -81,6 +83,6 @@ }, 0);

const startTime = utils.msToSec((core.browserPerformanceTimeOrigin || 0) + ((entry && entry.startTime) || 0));
const startTime = utils.msToSec((core.browserPerformanceTimeOrigin() || 0) + (entry?.startTime || 0));
const routeName = core.getCurrentScope().getScopeData().transactionName;
const name = entry ? core.htmlTreeAsString(entry.sources[0] && entry.sources[0].node) : 'Layout shift';
const name = entry ? core.htmlTreeAsString(entry.sources[0]?.node) : 'Layout shift';

@@ -90,3 +92,3 @@ const attributes = core.dropUndefinedKeys({

[core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.webvital.cls',
[core.SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: (entry && entry.duration) || 0,
[core.SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: entry?.duration || 0,
// attach the pageload span id to the CLS span so that we can link them in the UI

@@ -118,3 +120,3 @@ 'sentry.pageload.span_id': pageloadSpanId,

return PerformanceObserver.supportedEntryTypes.includes('layout-shift');
} catch (e) {
} catch {
return false;

@@ -121,0 +123,0 @@ }

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -15,3 +15,3 @@ const core = require('@sentry/core');

const performance = utils.getBrowserPerformanceAPI();
if (performance && core.browserPerformanceTimeOrigin) {
if (performance && core.browserPerformanceTimeOrigin()) {
const inpCallback = _trackINP();

@@ -73,3 +73,3 @@

/** Build the INP span, create an envelope from the span, and then send the envelope */
const startTime = utils.msToSec((core.browserPerformanceTimeOrigin ) + entry.startTime);
const startTime = utils.msToSec((core.browserPerformanceTimeOrigin() ) + entry.startTime);
const duration = utils.msToSec(metric.value);

@@ -116,5 +116,4 @@ const activeSpan = core.getActiveSpan();

* Register a listener to cache route information for INP interactions.
* TODO(v9): `latestRoute` no longer needs to be passed in and will be removed in v9.
*/
function registerInpInteractionListener(_latestRoute) {
function registerInpInteractionListener() {
const handleEntries = ({ entries }) => {

@@ -121,0 +120,0 @@ const activeSpan = core.getActiveSpan();

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -97,3 +97,3 @@ const core = require('@sentry/core');

if (!typeHandlers || !typeHandlers.length) {
if (!typeHandlers?.length) {
return;

@@ -100,0 +100,0 @@ }

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -71,7 +71,7 @@ const core = require('@sentry/core');

const { release, environment } = client.getOptions();
const { release, environment, sendDefaultPii } = client.getOptions();
// We need to get the replay, user, and activeTransaction from the current scope
// so that we can associate replay id, profile id, and a user display to the span
const replay = client.getIntegrationByName('Replay');
const replayId = replay && replay.getReplayId();
const replayId = replay?.getReplayId();

@@ -87,3 +87,3 @@ const scope = core.getCurrentScope();

profileId = scope.getScopeData().contexts.profile.profile_id;
} catch (e) {
} catch {
// do nothing

@@ -105,4 +105,7 @@ }

// For example: Chrome vs. Chrome Mobile
'user_agent.original': types.WINDOW.navigator && types.WINDOW.navigator.userAgent,
'user_agent.original': types.WINDOW.navigator?.userAgent,
// This tells Sentry to infer the IP address from the request
'client.address': sendDefaultPii ? '{{auto}}' : undefined,
...passedAttributes,

@@ -124,3 +127,3 @@ };

// @ts-expect-error we want to make sure all of these are available, even if TS is sure they are
return types.WINDOW && types.WINDOW.addEventListener && types.WINDOW.performance;
return types.WINDOW.addEventListener && types.WINDOW.performance;
}

@@ -127,0 +130,0 @@

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const bindReporter = require('./lib/bindReporter.js');

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const bindReporter = require('./lib/bindReporter.js');

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const types = require('../../types.js');

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const types = require('../../types.js');

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const getRating = (value, thresholds) => {

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ /*

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -24,3 +24,3 @@ const getNavigationEntry = require('./getNavigationEntry.js');

const navEntry = getNavigationEntry.getNavigationEntry();
return (navEntry && navEntry.activationStart) || 0;
return navEntry?.activationStart || 0;
};

@@ -27,0 +27,0 @@

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -25,4 +25,3 @@ const types = require('../../../types.js');

const getNavigationEntry = (checkResponseStart = true) => {
const navigationEntry =
types.WINDOW.performance && types.WINDOW.performance.getEntriesByType && types.WINDOW.performance.getEntriesByType('navigation')[0];
const navigationEntry = types.WINDOW.performance?.getEntriesByType?.('navigation')[0];
// Check to ensure the `responseStart` property is present and valid.

@@ -29,0 +28,0 @@ // In some cases no value is reported by the browser (for

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const types = require('../../../types.js');

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -30,5 +30,5 @@ const types = require('../../../types.js');

if (navEntry) {
if ((types.WINDOW.document && types.WINDOW.document.prerendering) || getActivationStart.getActivationStart() > 0) {
if (types.WINDOW.document?.prerendering || getActivationStart.getActivationStart() > 0) {
navigationType = 'prerender';
} else if (types.WINDOW.document && types.WINDOW.document.wasDiscarded) {
} else if (types.WINDOW.document?.wasDiscarded) {
navigationType = 'restore';

@@ -35,0 +35,0 @@ } else if (navEntry.type) {

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -103,3 +103,3 @@ const interactionCountPolyfill = require('./polyfills/interactionCountPolyfill.js');

entry.duration === existingInteraction.latency &&
entry.startTime === (existingInteraction.entries[0] && existingInteraction.entries[0].startTime)
entry.startTime === existingInteraction.entries[0]?.startTime
) {

@@ -106,0 +106,0 @@ existingInteraction.entries.push(entry);

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ /*

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -34,3 +34,3 @@ const types = require('../../../types.js');

const onHiddenOrPageHide = (event) => {
if (event.type === 'pagehide' || (types.WINDOW.document && types.WINDOW.document.visibilityState === 'hidden')) {
if (event.type === 'pagehide' || types.WINDOW.document?.visibilityState === 'hidden') {
cb(event);

@@ -37,0 +37,0 @@ }

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const observe = require('../observe.js');

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ /*

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -23,3 +23,3 @@ const types = require('../../../types.js');

const whenActivated = (callback) => {
if (types.WINDOW.document && types.WINDOW.document.prerendering) {
if (types.WINDOW.document?.prerendering) {
addEventListener('prerenderingchange', () => callback(), true);

@@ -26,0 +26,0 @@ } else {

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -36,3 +36,3 @@ const types = require('../../../types.js');

// race an idle callback with the next `visibilitychange` event.
if (types.WINDOW.document && types.WINDOW.document.visibilityState === 'hidden') {
if (types.WINDOW.document?.visibilityState === 'hidden') {
cb();

@@ -39,0 +39,0 @@ } else {

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const bindReporter = require('./lib/bindReporter.js');

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -35,5 +35,5 @@ const types = require('../../types.js');

const whenReady = (callback) => {
if (types.WINDOW.document && types.WINDOW.document.prerendering) {
if (types.WINDOW.document?.prerendering) {
whenActivated.whenActivated(() => whenReady(callback));
} else if (types.WINDOW.document && types.WINDOW.document.readyState !== 'complete') {
} else if (types.WINDOW.document?.readyState !== 'complete') {
addEventListener('load', () => whenReady(callback), true);

@@ -40,0 +40,0 @@ } else {

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

Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });

@@ -3,0 +3,0 @@ const core = require('@sentry/core');

@@ -45,3 +45,3 @@ import { isNativeFunction, logger } from '@sentry/core';

const contentWindow = sandbox.contentWindow;
if (contentWindow && contentWindow[name]) {
if (contentWindow?.[name]) {
impl = contentWindow[name] ;

@@ -48,0 +48,0 @@ }

@@ -43,7 +43,6 @@ import { addHandler, maybeInstrument, triggerHandlers, fill, addNonEnumerableProperty, uuid4 } from '@sentry/core';

const globalObject = WINDOW ;
const targetObj = globalObject[target];
const proto = targetObj && targetObj.prototype;
const proto = globalObject[target]?.prototype;
// eslint-disable-next-line no-prototype-builtins
if (!proto || !proto.hasOwnProperty || !proto.hasOwnProperty('addEventListener')) {
if (!proto?.hasOwnProperty?.('addEventListener')) {
return;

@@ -150,3 +149,3 @@ }

if (!target || !target.tagName) {
if (!target?.tagName) {
return true;

@@ -153,0 +152,0 @@ }

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

import { addHandler, maybeInstrument, supportsHistory, triggerHandlers, fill } from '@sentry/core';
import { addHandler, maybeInstrument, triggerHandlers, supportsHistory, fill } from '@sentry/core';
import { WINDOW } from '../types.js';

@@ -21,8 +21,5 @@

function instrumentHistory() {
if (!supportsHistory()) {
return;
}
const oldOnPopState = WINDOW.onpopstate;
WINDOW.onpopstate = function ( ...args) {
// The `popstate` event may also be triggered on `pushState`, but it may not always reliably be emitted by the browser
// Which is why we also monkey-patch methods below, in addition to this
WINDOW.addEventListener('popstate', () => {
const to = WINDOW.location.href;

@@ -32,16 +29,16 @@ // keep track of the current URL state, as we always receive only the updated state

lastHref = to;
const handlerData = { from, to };
triggerHandlers('history', handlerData);
if (oldOnPopState) {
// Apparently this can throw in Firefox when incorrectly implemented plugin is installed.
// https://github.com/getsentry/sentry-javascript/issues/3344
// https://github.com/bugsnag/bugsnag-js/issues/469
try {
return oldOnPopState.apply(this, args);
} catch (_oO) {
// no-empty
}
if (from === to) {
return;
}
};
const handlerData = { from, to } ;
triggerHandlers('history', handlerData);
});
// Just guard against this not being available, in weird environments
if (!supportsHistory()) {
return;
}
function historyReplacementFunction(originalHistoryFunction) {

@@ -56,3 +53,8 @@ return function ( ...args) {

lastHref = to;
const handlerData = { from, to };
if (from === to) {
return;
}
const handlerData = { from, to } ;
triggerHandlers('history', handlerData);

@@ -59,0 +61,0 @@ }

@@ -158,3 +158,3 @@ import { addHandler, maybeInstrument, timestampInSeconds, isString, triggerHandlers } from '@sentry/core';

return (url ).toString();
} catch (e2) {} // eslint-disable-line no-empty
} catch {} // eslint-disable-line no-empty

@@ -161,0 +161,0 @@ return undefined;

@@ -26,3 +26,3 @@ import { browserPerformanceTimeOrigin, getActiveSpan, spanToJSON, setMeasurement, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, parseUrl, htmlTreeAsString, getComponentName } from '@sentry/core';

const performance = getBrowserPerformanceAPI();
if (performance && browserPerformanceTimeOrigin) {
if (performance && browserPerformanceTimeOrigin()) {
// @ts-expect-error we want to make sure all of these are available, even if TS is sure they are

@@ -41,3 +41,3 @@ if (performance.mark) {

ttfbCleanupCallback();
clsCleanupCallback && clsCleanupCallback();
clsCleanupCallback?.();
};

@@ -62,3 +62,3 @@ }

for (const entry of entries) {
const startTime = msToSec((browserPerformanceTimeOrigin ) + entry.startTime);
const startTime = msToSec((browserPerformanceTimeOrigin() ) + entry.startTime);
const duration = msToSec(entry.duration);

@@ -102,3 +102,3 @@

const startTime = msToSec((browserPerformanceTimeOrigin ) + entry.startTime);
const startTime = msToSec((browserPerformanceTimeOrigin() ) + entry.startTime);

@@ -114,3 +114,2 @@ const { start_timestamp: parentStartTimestamp, op: parentOp } = spanToJSON(parent);

}
const duration = msToSec(entry.duration);

@@ -158,3 +157,3 @@

if (entry.name === 'click') {
const startTime = msToSec((browserPerformanceTimeOrigin ) + entry.startTime);
const startTime = msToSec((browserPerformanceTimeOrigin() ) + entry.startTime);
const duration = msToSec(entry.duration);

@@ -218,3 +217,3 @@

const timeOrigin = msToSec(browserPerformanceTimeOrigin );
const timeOrigin = msToSec(browserPerformanceTimeOrigin() );
const startTime = msToSec(entry.startTime);

@@ -240,3 +239,4 @@ _measurements['fid'] = { value: metric.value, unit: 'millisecond' };

const performance = getBrowserPerformanceAPI();
if (!performance || !performance.getEntries || !browserPerformanceTimeOrigin) {
const origin = browserPerformanceTimeOrigin();
if (!performance?.getEntries || !origin) {
// Gatekeeper if performance API not available

@@ -246,3 +246,3 @@ return;

const timeOrigin = msToSec(browserPerformanceTimeOrigin);
const timeOrigin = msToSec(origin);

@@ -596,3 +596,3 @@ const performanceEntries = performance.getEntries();

// See: https://developer.mozilla.org/en-US/docs/Web/API/LayoutShift
if (_clsEntry && _clsEntry.sources) {
if (_clsEntry?.sources) {
_clsEntry.sources.forEach((source, index) =>

@@ -599,0 +599,0 @@ span.setAttribute(`cls.source.${index + 1}`, htmlTreeAsString(source.node)),

@@ -63,10 +63,12 @@ import { getClient, getActiveSpan, getRootSpan, spanToJSON, logger, browserPerformanceTimeOrigin, getCurrentScope, htmlTreeAsString, dropUndefinedKeys, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE } from '@sentry/core';

_collectClsOnce();
unsubscribeStartNavigation && unsubscribeStartNavigation();
unsubscribeStartNavigation?.();
});
const activeSpan = getActiveSpan();
const rootSpan = activeSpan && getRootSpan(activeSpan);
const spanJSON = rootSpan && spanToJSON(rootSpan);
if (spanJSON && spanJSON.op === 'pageload') {
pageloadSpanId = rootSpan.spanContext().spanId;
if (activeSpan) {
const rootSpan = getRootSpan(activeSpan);
const spanJSON = spanToJSON(rootSpan);
if (spanJSON.op === 'pageload') {
pageloadSpanId = rootSpan.spanContext().spanId;
}
}

@@ -79,6 +81,6 @@ }, 0);

const startTime = msToSec((browserPerformanceTimeOrigin || 0) + ((entry && entry.startTime) || 0));
const startTime = msToSec((browserPerformanceTimeOrigin() || 0) + (entry?.startTime || 0));
const routeName = getCurrentScope().getScopeData().transactionName;
const name = entry ? htmlTreeAsString(entry.sources[0] && entry.sources[0].node) : 'Layout shift';
const name = entry ? htmlTreeAsString(entry.sources[0]?.node) : 'Layout shift';

@@ -88,3 +90,3 @@ const attributes = dropUndefinedKeys({

[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.webvital.cls',
[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: (entry && entry.duration) || 0,
[SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME]: entry?.duration || 0,
// attach the pageload span id to the CLS span so that we can link them in the UI

@@ -116,3 +118,3 @@ 'sentry.pageload.span_id': pageloadSpanId,

return PerformanceObserver.supportedEntryTypes.includes('layout-shift');
} catch (e) {
} catch {
return false;

@@ -119,0 +121,0 @@ }

@@ -13,3 +13,3 @@ import { browserPerformanceTimeOrigin, getActiveSpan, getRootSpan, spanToJSON, getCurrentScope, htmlTreeAsString, dropUndefinedKeys, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT, SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE } from '@sentry/core';

const performance = getBrowserPerformanceAPI();
if (performance && browserPerformanceTimeOrigin) {
if (performance && browserPerformanceTimeOrigin()) {
const inpCallback = _trackINP();

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

/** Build the INP span, create an envelope from the span, and then send the envelope */
const startTime = msToSec((browserPerformanceTimeOrigin ) + entry.startTime);
const startTime = msToSec((browserPerformanceTimeOrigin() ) + entry.startTime);
const duration = msToSec(metric.value);

@@ -114,5 +114,4 @@ const activeSpan = getActiveSpan();

* Register a listener to cache route information for INP interactions.
* TODO(v9): `latestRoute` no longer needs to be passed in and will be removed in v9.
*/
function registerInpInteractionListener(_latestRoute) {
function registerInpInteractionListener() {
const handleEntries = ({ entries }) => {

@@ -119,0 +118,0 @@ const activeSpan = getActiveSpan();

@@ -95,3 +95,3 @@ import { logger, getFunctionName } from '@sentry/core';

if (!typeHandlers || !typeHandlers.length) {
if (!typeHandlers?.length) {
return;

@@ -98,0 +98,0 @@ }

@@ -69,7 +69,7 @@ import { spanToJSON, withActiveSpan, startInactiveSpan, getClient, getCurrentScope } from '@sentry/core';

const { release, environment } = client.getOptions();
const { release, environment, sendDefaultPii } = client.getOptions();
// We need to get the replay, user, and activeTransaction from the current scope
// so that we can associate replay id, profile id, and a user display to the span
const replay = client.getIntegrationByName('Replay');
const replayId = replay && replay.getReplayId();
const replayId = replay?.getReplayId();

@@ -85,3 +85,3 @@ const scope = getCurrentScope();

profileId = scope.getScopeData().contexts.profile.profile_id;
} catch (e) {
} catch {
// do nothing

@@ -103,4 +103,7 @@ }

// For example: Chrome vs. Chrome Mobile
'user_agent.original': WINDOW.navigator && WINDOW.navigator.userAgent,
'user_agent.original': WINDOW.navigator?.userAgent,
// This tells Sentry to infer the IP address from the request
'client.address': sendDefaultPii ? '{{auto}}' : undefined,
...passedAttributes,

@@ -122,3 +125,3 @@ };

// @ts-expect-error we want to make sure all of these are available, even if TS is sure they are
return WINDOW && WINDOW.addEventListener && WINDOW.performance;
return WINDOW.addEventListener && WINDOW.performance;
}

@@ -125,0 +128,0 @@

@@ -22,3 +22,3 @@ import { getNavigationEntry } from './getNavigationEntry.js';

const navEntry = getNavigationEntry();
return (navEntry && navEntry.activationStart) || 0;
return navEntry?.activationStart || 0;
};

@@ -25,0 +25,0 @@

@@ -23,4 +23,3 @@ import { WINDOW } from '../../../types.js';

const getNavigationEntry = (checkResponseStart = true) => {
const navigationEntry =
WINDOW.performance && WINDOW.performance.getEntriesByType && WINDOW.performance.getEntriesByType('navigation')[0];
const navigationEntry = WINDOW.performance?.getEntriesByType?.('navigation')[0];
// Check to ensure the `responseStart` property is present and valid.

@@ -27,0 +26,0 @@ // In some cases no value is reported by the browser (for

@@ -28,5 +28,5 @@ import { WINDOW } from '../../../types.js';

if (navEntry) {
if ((WINDOW.document && WINDOW.document.prerendering) || getActivationStart() > 0) {
if (WINDOW.document?.prerendering || getActivationStart() > 0) {
navigationType = 'prerender';
} else if (WINDOW.document && WINDOW.document.wasDiscarded) {
} else if (WINDOW.document?.wasDiscarded) {
navigationType = 'restore';

@@ -33,0 +33,0 @@ } else if (navEntry.type) {

@@ -101,3 +101,3 @@ import { getInteractionCount } from './polyfills/interactionCountPolyfill.js';

entry.duration === existingInteraction.latency &&
entry.startTime === (existingInteraction.entries[0] && existingInteraction.entries[0].startTime)
entry.startTime === existingInteraction.entries[0]?.startTime
) {

@@ -104,0 +104,0 @@ existingInteraction.entries.push(entry);

@@ -32,3 +32,3 @@ import { WINDOW } from '../../../types.js';

const onHiddenOrPageHide = (event) => {
if (event.type === 'pagehide' || (WINDOW.document && WINDOW.document.visibilityState === 'hidden')) {
if (event.type === 'pagehide' || WINDOW.document?.visibilityState === 'hidden') {
cb(event);

@@ -35,0 +35,0 @@ }

@@ -21,3 +21,3 @@ import { WINDOW } from '../../../types.js';

const whenActivated = (callback) => {
if (WINDOW.document && WINDOW.document.prerendering) {
if (WINDOW.document?.prerendering) {
addEventListener('prerenderingchange', () => callback(), true);

@@ -24,0 +24,0 @@ } else {

@@ -34,3 +34,3 @@ import { WINDOW } from '../../../types.js';

// race an idle callback with the next `visibilitychange` event.
if (WINDOW.document && WINDOW.document.visibilityState === 'hidden') {
if (WINDOW.document?.visibilityState === 'hidden') {
cb();

@@ -37,0 +37,0 @@ } else {

@@ -33,5 +33,5 @@ import { WINDOW } from '../../types.js';

const whenReady = (callback) => {
if (WINDOW.document && WINDOW.document.prerendering) {
if (WINDOW.document?.prerendering) {
whenActivated(() => whenReady(callback));
} else if (WINDOW.document && WINDOW.document.readyState !== 'complete') {
} else if (WINDOW.document?.readyState !== 'complete') {
addEventListener('load', () => whenReady(callback), true);

@@ -38,0 +38,0 @@ } else {

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

{"type":"module","version":"8.50.0","sideEffects":false}
{"type":"module","version":"9.0.0-alpha.0","sideEffects":false}

@@ -7,5 +7,4 @@ /**

* Register a listener to cache route information for INP interactions.
* TODO(v9): `latestRoute` no longer needs to be passed in and will be removed in v9.
*/
export declare function registerInpInteractionListener(_latestRoute?: unknown): void;
export declare function registerInpInteractionListener(): void;
//# sourceMappingURL=inp.d.ts.map

@@ -77,10 +77,2 @@ import { CLSMetric, CLSMetricWithAttribution } from './cls';

];
/**
* @deprecated Use metric-specific function types instead, such as:
* `(metric: LCPMetric) => void`. If a single callback type is needed for
* multiple metrics, use `(metric: MetricType) => void`.
*/
export interface ReportCallback {
(metric: MetricType): void;
}
export interface ReportOpts {

@@ -87,0 +79,0 @@ reportAllChanges?: boolean;

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

export declare const WINDOW: import("@sentry/core").InternalGlobal & Pick<Window, Exclude<keyof Window, "document">> & Partial<Pick<Window, "document">>;
export declare const WINDOW: {
navigator?: {
userAgent?: string | undefined;
maxTouchPoints?: number | undefined;
} | undefined;
console: Console;
PerformanceObserver?: any;
Sentry?: any;
onerror?: {
(event: string | object, source?: string | undefined, lineno?: number | undefined, colno?: number | undefined, error?: Error | undefined): any;
__SENTRY_INSTRUMENTED__?: true | undefined;
} | undefined;
onunhandledrejection?: {
(event: unknown): boolean;
__SENTRY_INSTRUMENTED__?: true | undefined;
} | undefined;
SENTRY_ENVIRONMENT?: string | undefined;
SENTRY_DSN?: string | undefined;
SENTRY_RELEASE?: {
id?: string | undefined;
} | undefined;
SENTRY_SDK_SOURCE?: import("@sentry/core").SdkSource | undefined;
_sentryDebugIds?: Record<string, string> | undefined;
_sentryModuleMetadata?: Record<string, any> | undefined;
_sentryEsmLoaderHookRegistered?: boolean | undefined;
} & import("@sentry/core").Carrier & Pick<Window, Exclude<keyof Window, "document">> & Partial<Pick<Window, "document">>;
//# sourceMappingURL=types.d.ts.map

@@ -7,5 +7,4 @@ /**

* Register a listener to cache route information for INP interactions.
* TODO(v9): `latestRoute` no longer needs to be passed in and will be removed in v9.
*/
export declare function registerInpInteractionListener(_latestRoute?: unknown): void;
export declare function registerInpInteractionListener(): void;
//# sourceMappingURL=inp.d.ts.map

@@ -74,10 +74,2 @@ import type { CLSMetric, CLSMetricWithAttribution } from './cls';

export type MetricRatingThresholds = [number, number];
/**
* @deprecated Use metric-specific function types instead, such as:
* `(metric: LCPMetric) => void`. If a single callback type is needed for
* multiple metrics, use `(metric: MetricType) => void`.
*/
export interface ReportCallback {
(metric: MetricType): void;
}
export interface ReportOpts {

@@ -84,0 +76,0 @@ reportAllChanges?: boolean;

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

export declare const WINDOW: import("@sentry/core").InternalGlobal & Omit<Window, "document"> & Partial<Pick<Window, "document">>;
export declare const WINDOW: {
navigator?: {
userAgent?: string | undefined;
maxTouchPoints?: number | undefined;
} | undefined;
console: Console;
PerformanceObserver?: any;
Sentry?: any;
onerror?: {
(event: string | object, source?: string | undefined, lineno?: number | undefined, colno?: number | undefined, error?: Error | undefined): any;
__SENTRY_INSTRUMENTED__?: true | undefined;
} | undefined;
onunhandledrejection?: {
(event: unknown): boolean;
__SENTRY_INSTRUMENTED__?: true | undefined;
} | undefined;
SENTRY_ENVIRONMENT?: string | undefined;
SENTRY_DSN?: string | undefined;
SENTRY_RELEASE?: {
id?: string | undefined;
} | undefined;
SENTRY_SDK_SOURCE?: import("@sentry/core").SdkSource | undefined;
_sentryDebugIds?: Record<string, string> | undefined;
_sentryModuleMetadata?: Record<string, any> | undefined;
_sentryEsmLoaderHookRegistered?: boolean | undefined;
} & import("@sentry/core").Carrier & Omit<Window, "document"> & Partial<Pick<Window, "document">>;
//# sourceMappingURL=types.d.ts.map
{
"name": "@sentry-internal/browser-utils",
"version": "8.50.0",
"version": "9.0.0-alpha.0",
"description": "Browser Utilities for all Sentry JavaScript SDKs",

@@ -10,3 +10,3 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"engines": {
"node": ">=14.18"
"node": ">=18"
},

@@ -33,3 +33,3 @@ "files": [

"typesVersions": {
"<4.9": {
"<5.0": {
"build/types/index.d.ts": [

@@ -44,3 +44,3 @@ "build/types-ts3.8/index.d.ts"

"dependencies": {
"@sentry/core": "8.50.0"
"@sentry/core": "9.0.0-alpha.0"
},

@@ -47,0 +47,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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