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

@sentry-internal/tracing

Package Overview
Dependencies
Maintainers
9
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry-internal/tracing - npm Package Compare versions

Comparing version 7.105.0 to 8.0.0-alpha.1

33

cjs/browser/backgroundtab.js

@@ -15,20 +15,29 @@ Object.defineProperty(exports, '__esModule', { value: true });

types.WINDOW.document.addEventListener('visibilitychange', () => {
// eslint-disable-next-line deprecation/deprecation
const activeTransaction = core.getActiveTransaction() ;
if (types.WINDOW.document.hidden && activeTransaction) {
const statusType = 'cancelled';
const activeSpan = core.getActiveSpan();
if (!activeSpan) {
return;
}
const { op, status } = core.spanToJSON(activeTransaction);
const rootSpan = core.getRootSpan(activeSpan);
if (!rootSpan) {
return;
}
debugBuild.DEBUG_BUILD &&
utils.logger.log(`[Tracing] Transaction: ${statusType} -> since tab moved to the background, op: ${op}`);
if (types.WINDOW.document.hidden && rootSpan) {
const cancelledStatus = 'cancelled';
const { op, status } = core.spanToJSON(rootSpan);
if (debugBuild.DEBUG_BUILD) {
utils.logger.log(`[Tracing] Transaction: ${cancelledStatus} -> since tab moved to the background, op: ${op}`);
}
// We should not set status if it is already set, this prevent important statuses like
// error or data loss from being overwritten on transaction.
if (!status) {
activeTransaction.setStatus(statusType);
rootSpan.setStatus(cancelledStatus);
}
// TODO: Can we rewrite this to an attribute?
// eslint-disable-next-line deprecation/deprecation
activeTransaction.setTag('visibilitychange', 'document.hidden');
activeTransaction.end();
rootSpan.setAttribute('sentry.cancellation_reason', 'document.hidden');
rootSpan.end();
}

@@ -35,0 +44,0 @@ });

Object.defineProperty(exports, '__esModule', { value: true });
const core = require('@sentry/core');
const utils = require('@sentry/utils');
const debugBuild = require('../common/debug-build.js');
const backgroundtab = require('./backgroundtab.js');
const index = require('./metrics/index.js');
require('@sentry/utils');
require('../common/debug-build.js');
const request = require('./request.js');
const router = require('./router.js');
const types = require('./types.js');

@@ -16,3 +13,3 @@ const BROWSER_TRACING_INTEGRATION_ID = 'BrowserTracing';

const DEFAULT_BROWSER_TRACING_OPTIONS = {
({
...core.TRACING_DEFAULTS,

@@ -26,320 +23,5 @@ markBackgroundTransactions: true,

...request.defaultRequestInstrumentationOptions,
};
});
/**
* The Browser Tracing integration automatically instruments browser pageload/navigation
* actions as transactions, and captures requests, metrics and errors as spans.
*
* The integration can be configured with a variety of options, and can be extended to use
* any routing library. This integration uses {@see IdleTransaction} to create transactions.
*
* @deprecated Use `browserTracingIntegration()` instead.
*/
class BrowserTracing {
// This class currently doesn't have a static `id` field like the other integration classes, because it prevented
// @sentry/tracing from being treeshaken. Tree shakers do not like static fields, because they behave like side effects.
// TODO: Come up with a better plan, than using static fields on integration classes, and use that plan on all
// integrations.
/** Browser Tracing integration options */
/**
* @inheritDoc
*/
constructor(_options) {
this.name = BROWSER_TRACING_INTEGRATION_ID;
this._hasSetTracePropagationTargets = false;
core.addTracingExtensions();
if (debugBuild.DEBUG_BUILD) {
this._hasSetTracePropagationTargets = !!(
_options &&
// eslint-disable-next-line deprecation/deprecation
(_options.tracePropagationTargets || _options.tracingOrigins)
);
}
this.options = {
...DEFAULT_BROWSER_TRACING_OPTIONS,
..._options,
};
// Special case: enableLongTask can be set in _experiments
// TODO (v8): Remove this in v8
if (this.options._experiments.enableLongTask !== undefined) {
this.options.enableLongTask = this.options._experiments.enableLongTask;
}
// TODO (v8): remove this block after tracingOrigins is removed
// Set tracePropagationTargets to tracingOrigins if specified by the user
// In case both are specified, tracePropagationTargets takes precedence
// eslint-disable-next-line deprecation/deprecation
if (_options && !_options.tracePropagationTargets && _options.tracingOrigins) {
// eslint-disable-next-line deprecation/deprecation
this.options.tracePropagationTargets = _options.tracingOrigins;
}
this._collectWebVitals = index.startTrackingWebVitals();
if (this.options.enableLongTask) {
index.startTrackingLongTasks();
}
if (this.options._experiments.enableInteractions) {
index.startTrackingInteractions();
}
}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
this._getCurrentHub = getCurrentHub;
const hub = getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const client = hub.getClient();
const clientOptions = client && client.getOptions();
const {
routingInstrumentation: instrumentRouting,
startTransactionOnLocationChange,
startTransactionOnPageLoad,
markBackgroundTransactions,
traceFetch,
traceXHR,
shouldCreateSpanForRequest,
enableHTTPTimings,
_experiments,
} = this.options;
const clientOptionsTracePropagationTargets = clientOptions && clientOptions.tracePropagationTargets;
// There are three ways to configure tracePropagationTargets:
// 1. via top level client option `tracePropagationTargets`
// 2. via BrowserTracing option `tracePropagationTargets`
// 3. via BrowserTracing option `tracingOrigins` (deprecated)
//
// To avoid confusion, favour top level client option `tracePropagationTargets`, and fallback to
// BrowserTracing option `tracePropagationTargets` and then `tracingOrigins` (deprecated).
// This is done as it minimizes bundle size (we don't have to have undefined checks).
//
// If both 1 and either one of 2 or 3 are set (from above), we log out a warning.
// eslint-disable-next-line deprecation/deprecation
const tracePropagationTargets = clientOptionsTracePropagationTargets || this.options.tracePropagationTargets;
if (debugBuild.DEBUG_BUILD && this._hasSetTracePropagationTargets && clientOptionsTracePropagationTargets) {
utils.logger.warn(
'[Tracing] The `tracePropagationTargets` option was set in the BrowserTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used.',
);
}
instrumentRouting(
(context) => {
const transaction = this._createRouteTransaction(context);
this.options._experiments.onStartRouteTransaction &&
this.options._experiments.onStartRouteTransaction(transaction, context, getCurrentHub);
return transaction;
},
startTransactionOnPageLoad,
startTransactionOnLocationChange,
);
if (markBackgroundTransactions) {
backgroundtab.registerBackgroundTabDetection();
}
if (_experiments.enableInteractions) {
this._registerInteractionListener();
}
request.instrumentOutgoingRequests({
traceFetch,
traceXHR,
tracePropagationTargets,
shouldCreateSpanForRequest,
enableHTTPTimings,
});
}
/** Create routing idle transaction. */
_createRouteTransaction(context) {
if (!this._getCurrentHub) {
debugBuild.DEBUG_BUILD &&
utils.logger.warn(`[Tracing] Did not create ${context.op} transaction because _getCurrentHub is invalid.`);
return undefined;
}
const hub = this._getCurrentHub();
const { beforeNavigate, idleTimeout, finalTimeout, heartbeatInterval } = this.options;
const isPageloadTransaction = context.op === 'pageload';
let expandedContext;
if (isPageloadTransaction) {
const sentryTrace = isPageloadTransaction ? getMetaContent('sentry-trace') : '';
const baggage = isPageloadTransaction ? getMetaContent('baggage') : undefined;
const { traceId, dsc, parentSpanId, sampled } = utils.propagationContextFromHeaders(sentryTrace, baggage);
expandedContext = {
traceId,
parentSpanId,
parentSampled: sampled,
...context,
metadata: {
// eslint-disable-next-line deprecation/deprecation
...context.metadata,
dynamicSamplingContext: dsc,
},
trimEnd: true,
};
} else {
expandedContext = {
trimEnd: true,
...context,
};
}
const modifiedContext = typeof beforeNavigate === 'function' ? beforeNavigate(expandedContext) : expandedContext;
// For backwards compatibility reasons, beforeNavigate can return undefined to "drop" the transaction (prevent it
// from being sent to Sentry).
const finalContext = modifiedContext === undefined ? { ...expandedContext, sampled: false } : modifiedContext;
// If `beforeNavigate` set a custom name, record that fact
// eslint-disable-next-line deprecation/deprecation
finalContext.metadata =
finalContext.name !== expandedContext.name
? // eslint-disable-next-line deprecation/deprecation
{ ...finalContext.metadata, source: 'custom' }
: // eslint-disable-next-line deprecation/deprecation
finalContext.metadata;
this._latestRouteName = finalContext.name;
this._latestRouteSource = getSource(finalContext);
// eslint-disable-next-line deprecation/deprecation
if (finalContext.sampled === false) {
debugBuild.DEBUG_BUILD && utils.logger.log(`[Tracing] Will not send ${finalContext.op} transaction because of beforeNavigate.`);
}
debugBuild.DEBUG_BUILD && utils.logger.log(`[Tracing] Starting ${finalContext.op} transaction on scope`);
const { location } = types.WINDOW;
const idleTransaction = core.startIdleTransaction(
hub,
finalContext,
idleTimeout,
finalTimeout,
true,
{ location }, // for use in the tracesSampler
heartbeatInterval,
isPageloadTransaction, // should wait for finish signal if it's a pageload transaction
);
if (isPageloadTransaction) {
types.WINDOW.document.addEventListener('readystatechange', () => {
if (['interactive', 'complete'].includes(types.WINDOW.document.readyState)) {
idleTransaction.sendAutoFinishSignal();
}
});
if (['interactive', 'complete'].includes(types.WINDOW.document.readyState)) {
idleTransaction.sendAutoFinishSignal();
}
}
idleTransaction.registerBeforeFinishCallback(transaction => {
this._collectWebVitals();
index.addPerformanceEntries(transaction);
});
return idleTransaction ;
}
/** Start listener for interaction transactions */
_registerInteractionListener() {
let inflightInteractionTransaction;
const registerInteractionTransaction = () => {
const { idleTimeout, finalTimeout, heartbeatInterval } = this.options;
const op = 'ui.action.click';
// eslint-disable-next-line deprecation/deprecation
const currentTransaction = core.getActiveTransaction();
if (currentTransaction && currentTransaction.op && ['navigation', 'pageload'].includes(currentTransaction.op)) {
debugBuild.DEBUG_BUILD &&
utils.logger.warn(
`[Tracing] Did not create ${op} transaction because a pageload or navigation transaction is in progress.`,
);
return undefined;
}
if (inflightInteractionTransaction) {
inflightInteractionTransaction.setFinishReason('interactionInterrupted');
inflightInteractionTransaction.end();
inflightInteractionTransaction = undefined;
}
if (!this._getCurrentHub) {
debugBuild.DEBUG_BUILD && utils.logger.warn(`[Tracing] Did not create ${op} transaction because _getCurrentHub is invalid.`);
return undefined;
}
if (!this._latestRouteName) {
debugBuild.DEBUG_BUILD && utils.logger.warn(`[Tracing] Did not create ${op} transaction because _latestRouteName is missing.`);
return undefined;
}
const hub = this._getCurrentHub();
const { location } = types.WINDOW;
const context = {
name: this._latestRouteName,
op,
trimEnd: true,
data: {
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: this._latestRouteSource || 'url',
},
};
inflightInteractionTransaction = core.startIdleTransaction(
hub,
context,
idleTimeout,
finalTimeout,
true,
{ location }, // for use in the tracesSampler
heartbeatInterval,
);
};
['click'].forEach(type => {
addEventListener(type, registerInteractionTransaction, { once: false, capture: true });
});
}
}
/** Returns the value of a meta tag */
function getMetaContent(metaName) {
// Can't specify generic to `getDomElement` because tracing can be used
// in a variety of environments, have to disable `no-unsafe-member-access`
// as a result.
const metaTag = utils.getDomElement(`meta[name=${metaName}]`);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return metaTag ? metaTag.getAttribute('content') : undefined;
}
function getSource(context) {
const sourceFromAttributes = context.attributes && context.attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// eslint-disable-next-line deprecation/deprecation
const sourceFromData = context.data && context.data[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// eslint-disable-next-line deprecation/deprecation
const sourceFromMetadata = context.metadata && context.metadata.source;
return sourceFromAttributes || sourceFromData || sourceFromMetadata;
}
exports.BROWSER_TRACING_INTEGRATION_ID = BROWSER_TRACING_INTEGRATION_ID;
exports.BrowserTracing = BrowserTracing;
exports.getMetaContent = getMetaContent;
//# sourceMappingURL=browsertracing.js.map

@@ -7,3 +7,2 @@ Object.defineProperty(exports, '__esModule', { value: true });

const backgroundtab = require('./backgroundtab.js');
const instrument = require('./instrument.js');
const index = require('./metrics/index.js');

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

enableLongTask: true,
enableInp: false,
_experiments: {},

@@ -39,20 +37,4 @@ ...request.defaultRequestInstrumentationOptions,

const browserTracingIntegration = ((_options = {}) => {
const _hasSetTracePropagationTargets = debugBuild.DEBUG_BUILD
? !!(
// eslint-disable-next-line deprecation/deprecation
(_options.tracePropagationTargets || _options.tracingOrigins)
)
: false;
core.addTracingExtensions();
// TODO (v8): remove this block after tracingOrigins is removed
// Set tracePropagationTargets to tracingOrigins if specified by the user
// In case both are specified, tracePropagationTargets takes precedence
// eslint-disable-next-line deprecation/deprecation
if (!_options.tracePropagationTargets && _options.tracingOrigins) {
// eslint-disable-next-line deprecation/deprecation
_options.tracePropagationTargets = _options.tracingOrigins;
}
const options = {

@@ -65,8 +47,2 @@ ...DEFAULT_BROWSER_TRACING_OPTIONS,

/** Stores a mapping of interactionIds from PerformanceEventTimings to the origin interaction path */
const interactionIdtoRouteNameMapping = {};
if (options.enableInp) {
index.startTrackingINP(interactionIdtoRouteNameMapping);
}
if (options.enableLongTask) {

@@ -79,9 +55,5 @@ index.startTrackingLongTasks();

const latestRoute
let latestRouteName;
let latestRouteSource;
= {
name: undefined,
context: undefined,
};
/** Create routing idle transaction. */

@@ -123,12 +95,11 @@ function _createRouteTransaction(context) {

// If `beforeStartSpan` set a custom name, record that fact
// eslint-disable-next-line deprecation/deprecation
finalContext.metadata =
finalContext.attributes =
finalContext.name !== expandedContext.name
? // eslint-disable-next-line deprecation/deprecation
{ ...finalContext.metadata, source: 'custom' }
: // eslint-disable-next-line deprecation/deprecation
finalContext.metadata;
? { ...finalContext.attributes, [core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom' }
: finalContext.attributes;
latestRoute.name = finalContext.name;
latestRoute.context = finalContext;
latestRouteName = finalContext.name;
if (finalContext.attributes) {
latestRouteSource = finalContext.attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
}

@@ -179,56 +150,33 @@ if (finalContext.sampled === false) {

afterAllSetup(client) {
const clientOptions = client.getOptions();
const { markBackgroundSpan, traceFetch, traceXHR, shouldCreateSpanForRequest, enableHTTPTimings, _experiments } =
options;
const clientOptionsTracePropagationTargets = clientOptions && clientOptions.tracePropagationTargets;
// There are three ways to configure tracePropagationTargets:
// 1. via top level client option `tracePropagationTargets`
// 2. via BrowserTracing option `tracePropagationTargets`
// 3. via BrowserTracing option `tracingOrigins` (deprecated)
//
// To avoid confusion, favour top level client option `tracePropagationTargets`, and fallback to
// BrowserTracing option `tracePropagationTargets` and then `tracingOrigins` (deprecated).
// This is done as it minimizes bundle size (we don't have to have undefined checks).
//
// If both 1 and either one of 2 or 3 are set (from above), we log out a warning.
// eslint-disable-next-line deprecation/deprecation
const tracePropagationTargets = clientOptionsTracePropagationTargets || options.tracePropagationTargets;
if (debugBuild.DEBUG_BUILD && _hasSetTracePropagationTargets && clientOptionsTracePropagationTargets) {
utils.logger.warn(
'[Tracing] The `tracePropagationTargets` option was set in the BrowserTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used.',
);
}
let activeSpan;
let startingUrl = types.WINDOW.location && types.WINDOW.location.href;
if (client.on) {
client.on('startNavigationSpan', (context) => {
if (activeSpan) {
debugBuild.DEBUG_BUILD && utils.logger.log(`[Tracing] Finishing current transaction with op: ${core.spanToJSON(activeSpan).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeSpan.end();
}
activeSpan = _createRouteTransaction({
op: 'navigation',
...context,
});
client.on('startNavigationSpan', (context) => {
if (activeSpan) {
debugBuild.DEBUG_BUILD && utils.logger.log(`[Tracing] Finishing current transaction with op: ${core.spanToJSON(activeSpan).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeSpan.end();
}
activeSpan = _createRouteTransaction({
op: 'navigation',
...context,
});
});
client.on('startPageLoadSpan', (context) => {
if (activeSpan) {
debugBuild.DEBUG_BUILD && utils.logger.log(`[Tracing] Finishing current transaction with op: ${core.spanToJSON(activeSpan).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeSpan.end();
}
activeSpan = _createRouteTransaction({
op: 'pageload',
...context,
});
client.on('startPageLoadSpan', (context) => {
if (activeSpan) {
debugBuild.DEBUG_BUILD && utils.logger.log(`[Tracing] Finishing current transaction with op: ${core.spanToJSON(activeSpan).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeSpan.end();
}
activeSpan = _createRouteTransaction({
op: 'pageload',
...context,
});
}
});
if (options.instrumentPageLoad && client.emit && types.WINDOW.location) {
if (options.instrumentPageLoad && types.WINDOW.location) {
const context = {

@@ -246,3 +194,3 @@ name: types.WINDOW.location.pathname,

if (options.instrumentNavigation && client.emit && types.WINDOW.location) {
if (options.instrumentNavigation && types.WINDOW.location) {
utils.addHistoryInstrumentationHandler(({ to, from }) => {

@@ -283,13 +231,9 @@ /**

if (_experiments.enableInteractions) {
registerInteractionListener(options, latestRoute);
registerInteractionListener(options, latestRouteName, latestRouteSource);
}
if (options.enableInp) {
registerInpInteractionListener(interactionIdtoRouteNameMapping, latestRoute);
}
request.instrumentOutgoingRequests({
traceFetch,
traceXHR,
tracePropagationTargets,
tracePropagationTargets: client.getOptions().tracePropagationTargets,
shouldCreateSpanForRequest,

@@ -299,5 +243,2 @@ enableHTTPTimings,

},
// TODO v8: Remove this again
// This is private API that we use to fix converted BrowserTracing integrations in Next.js & SvelteKit
options,
};

@@ -308,9 +249,5 @@ }) ;

* Manually start a page load span.
* This will only do something if the BrowserTracing integration has been setup.
* This will only do something if a browser tracing integration integration has been setup.
*/
function startBrowserTracingPageLoadSpan(client, spanOptions) {
if (!client.emit) {
return;
}
client.emit('startPageLoadSpan', spanOptions);

@@ -325,9 +262,5 @@

* Manually start a navigation span.
* This will only do something if the BrowserTracing integration has been setup.
* This will only do something if a browser tracing integration has been setup.
*/
function startBrowserTracingNavigationSpan(client, spanOptions) {
if (!client.emit) {
return;
}
client.emit('startNavigationSpan', spanOptions);

@@ -353,5 +286,4 @@

options,
latestRoute
,
latestRouteName,
latestRouteSource,
) {

@@ -365,8 +297,11 @@ let inflightInteractionTransaction;

const currentTransaction = core.getActiveTransaction();
if (currentTransaction && currentTransaction.op && ['navigation', 'pageload'].includes(currentTransaction.op)) {
debugBuild.DEBUG_BUILD &&
utils.logger.warn(
`[Tracing] Did not create ${op} transaction because a pageload or navigation transaction is in progress.`,
);
return undefined;
if (currentTransaction) {
const currentTransactionOp = core.spanToJSON(currentTransaction).op;
if (currentTransactionOp && ['navigation', 'pageload'].includes(currentTransactionOp)) {
debugBuild.DEBUG_BUILD &&
utils.logger.warn(
`[Tracing] Did not create ${op} transaction because a pageload or navigation transaction is in progress.`,
);
return undefined;
}
}

@@ -380,3 +315,3 @@

if (!latestRoute.name) {
if (!latestRouteName) {
debugBuild.DEBUG_BUILD && utils.logger.warn(`[Tracing] Did not create ${op} transaction because _latestRouteName is missing.`);

@@ -389,7 +324,7 @@ return undefined;

const context = {
name: latestRoute.name,
name: latestRouteName,
op,
trimEnd: true,
data: {
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.context ? getSource(latestRoute.context) : 'url',
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRouteSource || 'url',
},

@@ -415,75 +350,2 @@ };

function isPerformanceEventTiming(entry) {
return 'duration' in entry;
}
/** We store up to 10 interaction candidates max to cap memory usage. This is the same cap as getINP from web-vitals */
const MAX_INTERACTIONS = 10;
/** Creates a listener on interaction entries, and maps interactionIds to the origin path of the interaction */
function registerInpInteractionListener(
interactionIdtoRouteNameMapping,
latestRoute
,
) {
instrument.addPerformanceInstrumentationHandler('event', ({ entries }) => {
const client = core.getClient();
// 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 !== undefined && client.getIntegrationByName !== undefined
? (client.getIntegrationByName('Replay') )
: undefined;
const replayId = replay !== undefined ? replay.getReplayId() : undefined;
// eslint-disable-next-line deprecation/deprecation
const activeTransaction = core.getActiveTransaction();
const currentScope = core.getCurrentScope();
const user = currentScope !== undefined ? currentScope.getUser() : undefined;
for (const entry of entries) {
if (isPerformanceEventTiming(entry)) {
const duration = entry.duration;
const keys = Object.keys(interactionIdtoRouteNameMapping);
const minInteractionId =
keys.length > 0
? keys.reduce((a, b) => {
return interactionIdtoRouteNameMapping[a].duration < interactionIdtoRouteNameMapping[b].duration
? a
: b;
})
: undefined;
if (minInteractionId === undefined || duration > interactionIdtoRouteNameMapping[minInteractionId].duration) {
const interactionId = entry.interactionId;
const routeName = latestRoute.name;
const parentContext = latestRoute.context;
if (interactionId && routeName && parentContext) {
if (minInteractionId && Object.keys(interactionIdtoRouteNameMapping).length >= MAX_INTERACTIONS) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete interactionIdtoRouteNameMapping[minInteractionId];
}
interactionIdtoRouteNameMapping[interactionId] = {
routeName,
duration,
parentContext,
user,
activeTransaction,
replayId,
};
}
}
}
}
});
}
function getSource(context) {
const sourceFromAttributes = context.attributes && context.attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// eslint-disable-next-line deprecation/deprecation
const sourceFromData = context.data && context.data[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// eslint-disable-next-line deprecation/deprecation
const sourceFromMetadata = context.metadata && context.metadata.source;
return sourceFromAttributes || sourceFromData || sourceFromMetadata;
}
exports.BROWSER_TRACING_INTEGRATION_ID = BROWSER_TRACING_INTEGRATION_ID;

@@ -490,0 +352,0 @@ exports.browserTracingIntegration = browserTracingIntegration;

@@ -7,3 +7,2 @@ Object.defineProperty(exports, '__esModule', { value: true });

const getFID = require('./web-vitals/getFID.js');
const getINP = require('./web-vitals/getINP.js');
const getLCP = require('./web-vitals/getLCP.js');

@@ -18,3 +17,2 @@ const observe = require('./web-vitals/lib/observe.js');

let _previousLcp;
let _previousInp;

@@ -58,12 +56,2 @@ /**

/**
* Add a callback that will be triggered when a INP metric is available.
* Returns a cleanup callback which can be called to remove the instrumentation handler.
*/
function addInpInstrumentationHandler(
callback,
) {
return addMetricObserver('inp', callback, instrumentInp, _previousInp);
}
/**
* Add a callback that will be triggered when a performance observer is triggered,

@@ -135,11 +123,2 @@ * and receives the entries of the observer.

function instrumentInp() {
return getINP.onINP(metric => {
triggerHandlers('inp', {
metric,
});
_previousInp = metric;
});
}
function addMetricObserver(

@@ -216,5 +195,4 @@ type,

exports.addFidInstrumentationHandler = addFidInstrumentationHandler;
exports.addInpInstrumentationHandler = addInpInstrumentationHandler;
exports.addLcpInstrumentationHandler = addLcpInstrumentationHandler;
exports.addPerformanceInstrumentationHandler = addPerformanceInstrumentationHandler;
//# sourceMappingURL=instrument.js.map

@@ -75,3 +75,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

transaction.startChild({
description: 'Main UI thread blocked',
name: 'Main UI thread blocked',
op: 'ui.long-task',

@@ -103,3 +103,3 @@ origin: 'auto.ui.browser.metrics',

const span = {
description: utils.htmlTreeAsString(entry.target),
name: utils.htmlTreeAsString(entry.target),
op: `ui.interaction.${entry.name}`,

@@ -123,18 +123,2 @@ origin: 'auto.ui.browser.metrics',

/**
* Start tracking INP webvital events.
*/
function startTrackingINP(interactionIdtoRouteNameMapping) {
const performance = getBrowserPerformanceAPI();
if (performance && utils.browserPerformanceTimeOrigin) {
const inpCallback = _trackINP(interactionIdtoRouteNameMapping);
return () => {
inpCallback();
};
}
return () => undefined;
}
/** Starts tracking the Cumulative Layout Shift on the current page. */

@@ -184,65 +168,2 @@ function _trackCLS() {

/** Starts tracking the Interaction to Next Paint on the current page. */
function _trackINP(interactionIdtoRouteNameMapping) {
return instrument.addInpInstrumentationHandler(({ metric }) => {
const entry = metric.entries.find(e => e.name === 'click');
const client = core.getClient();
if (!entry || !client) {
return;
}
const options = client.getOptions();
/** Build the INP span, create an envelope from the span, and then send the envelope */
const startTime = msToSec((utils.browserPerformanceTimeOrigin ) + entry.startTime);
const duration = msToSec(metric.value);
const { routeName, parentContext, activeTransaction, user, replayId } =
entry.interactionId !== undefined
? interactionIdtoRouteNameMapping[entry.interactionId]
: {
routeName: undefined,
parentContext: undefined,
activeTransaction: undefined,
user: undefined,
replayId: undefined,
};
const userDisplay = user !== undefined ? user.email || user.id || user.ip_address : undefined;
// eslint-disable-next-line deprecation/deprecation
const profileId = activeTransaction !== undefined ? activeTransaction.getProfileId() : undefined;
const span = new core.Span({
startTimestamp: startTime,
endTimestamp: startTime + duration,
op: 'ui.interaction.click',
name: utils.htmlTreeAsString(entry.target),
attributes: {
release: options.release,
environment: options.environment,
transaction: routeName,
...(userDisplay !== undefined && userDisplay !== '' ? { user: userDisplay } : {}),
...(profileId !== undefined ? { profile_id: profileId } : {}),
...(replayId !== undefined ? { replay_id: replayId } : {}),
},
exclusiveTime: metric.value,
measurements: {
inp: { value: metric.value, unit: 'millisecond' },
},
});
/** Check to see if the span should be sampled */
const sampleRate = getSampleRate(parentContext, options);
if (!sampleRate) {
return;
}
if (Math.random() < (sampleRate )) {
const envelope = span ? core.createSpanEnvelope([span]) : undefined;
const transport = client && client.getTransport();
if (transport && envelope) {
transport.send(envelope).then(null, reason => {
debugBuild.DEBUG_BUILD && utils.logger.error('Error while sending interaction:', reason);
});
}
return;
}
});
}
/** Add performance related spans to a transaction */

@@ -271,4 +192,3 @@ function addPerformanceEntries(transaction) {

// eslint-disable-next-line deprecation/deprecation
if (transaction.op === 'navigation' && transactionStartTime && timeOrigin + startTime < transactionStartTime) {
if (op === 'navigation' && transactionStartTime && timeOrigin + startTime < transactionStartTime) {
return;

@@ -342,3 +262,3 @@ }

utils$1._startChild(transaction, {
description: 'first input delay',
name: 'first input delay',
endTimestamp: fidMark.value + msToSec(_measurements['fid'].value),

@@ -385,3 +305,3 @@ op: 'ui.action',

utils$1._startChild(transaction, {
description: entry.name ,
name: entry.name ,
endTimestamp: measureEndTimestamp,

@@ -415,3 +335,3 @@ op: entry.entryType ,

timeOrigin,
description,
name,
eventEnd,

@@ -427,3 +347,3 @@ ) {

origin: 'auto.browser.browser.metrics',
description: description || event,
name: name || event,
startTimestamp: timeOrigin + msToSec(start),

@@ -445,3 +365,3 @@ endTimestamp: timeOrigin + msToSec(end),

origin: 'auto.browser.browser.metrics',
description: 'request',
name: 'request',
startTimestamp: timeOrigin + msToSec(entry.requestStart ),

@@ -454,3 +374,3 @@ endTimestamp: timeOrigin + msToSec(entry.responseEnd ),

origin: 'auto.browser.browser.metrics',
description: 'response',
name: 'response',
startTimestamp: timeOrigin + msToSec(entry.responseStart ),

@@ -502,3 +422,3 @@ endTimestamp: timeOrigin + msToSec(entry.responseEnd ),

utils$1._startChild(transaction, {
description: resourceUrl.replace(types.WINDOW.location.origin, ''),
name: resourceUrl.replace(types.WINDOW.location.origin, ''),
endTimestamp,

@@ -646,34 +566,2 @@ op: entry.initiatorType ? `resource.${entry.initiatorType}` : 'resource.other',

/** Taken from @sentry/core sampling.ts */
function getSampleRate(transactionContext, options) {
if (!core.hasTracingEnabled(options)) {
return false;
}
let sampleRate;
if (transactionContext !== undefined && typeof options.tracesSampler === 'function') {
sampleRate = options.tracesSampler({
transactionContext,
name: transactionContext.name,
parentSampled: transactionContext.parentSampled,
attributes: {
// eslint-disable-next-line deprecation/deprecation
...transactionContext.data,
...transactionContext.attributes,
},
location: types.WINDOW.location,
});
} else if (transactionContext !== undefined && transactionContext.sampled !== undefined) {
sampleRate = transactionContext.sampled;
} else if (typeof options.tracesSampleRate !== 'undefined') {
sampleRate = options.tracesSampleRate;
} else {
sampleRate = 1;
}
if (!core.isValidSampleRate(sampleRate)) {
debugBuild.DEBUG_BUILD && utils.logger.warn('[Tracing] Discarding transaction because of invalid sample rate.');
return false;
}
return sampleRate;
}
exports._addMeasureSpans = _addMeasureSpans;

@@ -683,3 +571,2 @@ exports._addResourceSpans = _addResourceSpans;

exports.addPerformanceEntries = addPerformanceEntries;
exports.startTrackingINP = startTrackingINP;
exports.startTrackingInteractions = startTrackingInteractions;

@@ -686,0 +573,0 @@ exports.startTrackingLongTasks = startTrackingLongTasks;

@@ -7,7 +7,4 @@ Object.defineProperty(exports, '__esModule', { value: true });

const instrument = require('./instrument.js');
const types = require('./types.js');
/* eslint-disable max-lines */
const DEFAULT_TRACE_PROPAGATION_TARGETS = ['localhost', /^\/(?!\/)/];
/** Options for Request Instrumentation */

@@ -19,5 +16,2 @@

enableHTTPTimings: true,
// TODO (v8): Remove this property
tracingOrigins: DEFAULT_TRACE_PROPAGATION_TARGETS,
tracePropagationTargets: DEFAULT_TRACE_PROPAGATION_TARGETS,
};

@@ -27,12 +21,3 @@

function instrumentOutgoingRequests(_options) {
const {
traceFetch,
traceXHR,
// eslint-disable-next-line deprecation/deprecation
tracePropagationTargets,
// eslint-disable-next-line deprecation/deprecation
tracingOrigins,
shouldCreateSpanForRequest,
enableHTTPTimings,
} = {
const { traceFetch, traceXHR, shouldCreateSpanForRequest, enableHTTPTimings, tracePropagationTargets } = {
traceFetch: defaultRequestInstrumentationOptions.traceFetch,

@@ -46,7 +31,3 @@ traceXHR: defaultRequestInstrumentationOptions.traceXHR,

// TODO(v8) Remove tracingOrigins here
// The only reason we're passing it in here is because this instrumentOutgoingRequests function is publicly exported
// and we don't want to break the API. We can remove it in v8.
const shouldAttachHeadersWithTargets = (url) =>
shouldAttachHeaders(url, tracePropagationTargets || tracingOrigins);
const shouldAttachHeadersWithTargets = (url) => shouldAttachHeaders(url, tracePropagationTargets);

@@ -171,7 +152,44 @@ const spans = {};

* A function that determines whether to attach tracing headers to a request.
* This was extracted from `instrumentOutgoingRequests` to make it easier to test shouldAttachHeaders.
* We only export this fuction for testing purposes.
* We only export this function for testing purposes.
*/
function shouldAttachHeaders(url, tracePropagationTargets) {
return utils.stringMatchesSomePattern(url, tracePropagationTargets || DEFAULT_TRACE_PROPAGATION_TARGETS);
function shouldAttachHeaders(
targetUrl,
tracePropagationTargets,
) {
// window.location.href not being defined is an edge case in the browser but we need to handle it.
// Potentially dangerous situations where it may not be defined: Browser Extensions, Web Workers, patching of the location obj
const href = types.WINDOW.location && types.WINDOW.location.href;
if (!href) {
// If there is no window.location.origin, we default to only attaching tracing headers to relative requests, i.e. ones that start with `/`
// BIG DISCLAIMER: Users can call URLs with a double slash (fetch("//example.com/api")), this is a shorthand for "send to the same protocol",
// so we need a to exclude those requests, because they might be cross origin.
const isRelativeSameOriginRequest = !!targetUrl.match(/^\/(?!\/)/);
if (!tracePropagationTargets) {
return isRelativeSameOriginRequest;
} else {
return utils.stringMatchesSomePattern(targetUrl, tracePropagationTargets);
}
} else {
let resolvedUrl;
let currentOrigin;
// URL parsing may fail, we default to not attaching trace headers in that case.
try {
resolvedUrl = new URL(targetUrl, href);
currentOrigin = new URL(href).origin;
} catch (e) {
return false;
}
const isSameOriginRequest = resolvedUrl.origin === currentOrigin;
if (!tracePropagationTargets) {
return isSameOriginRequest;
} else {
return (
utils.stringMatchesSomePattern(resolvedUrl.toString(), tracePropagationTargets) ||
(isSameOriginRequest && utils.stringMatchesSomePattern(resolvedUrl.pathname, tracePropagationTargets))
);
}
}
}

@@ -184,3 +202,2 @@

*/
// eslint-disable-next-line complexity
function xhrCallback(

@@ -250,4 +267,3 @@ handlerData,

const sentryBaggageHeader = utils.dynamicSamplingContextToSentryBaggageHeader(
dsc ||
(span ? core.getDynamicSamplingContextFromSpan(span) : core.getDynamicSamplingContextFromClient(traceId, client, scope)),
dsc || (span ? core.getDynamicSamplingContextFromSpan(span) : core.getDynamicSamplingContextFromClient(traceId, client)),
);

@@ -281,3 +297,2 @@

exports.DEFAULT_TRACE_PROPAGATION_TARGETS = DEFAULT_TRACE_PROPAGATION_TARGETS;
exports.defaultRequestInstrumentationOptions = defaultRequestInstrumentationOptions;

@@ -284,0 +299,0 @@ exports.extractNetworkProtocol = extractNetworkProtocol;

Object.defineProperty(exports, '__esModule', { value: true });
const core = require('@sentry/core');
const utils = require('@sentry/utils');

@@ -30,3 +31,5 @@ const debugBuild = require('../common/debug-build.js');

origin: 'auto.pageload.browser',
metadata: { source: 'url' },
attributes: {
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
},
});

@@ -54,3 +57,4 @@ }

if (activeTransaction) {
debugBuild.DEBUG_BUILD && utils.logger.log(`[Tracing] Finishing current transaction with op: ${activeTransaction.op}`);
debugBuild.DEBUG_BUILD &&
utils.logger.log(`[Tracing] Finishing current transaction with op: ${core.spanToJSON(activeTransaction).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.

@@ -63,3 +67,5 @@ activeTransaction.end();

origin: 'auto.navigation.browser',
metadata: { source: 'url' },
attributes: {
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
},
});

@@ -66,0 +72,0 @@ }

@@ -7,3 +7,3 @@ Object.defineProperty(exports, '__esModule', { value: true });

/**
* Create and track fetch request spans for usage in combination with `addInstrumentationHandler`.
* Create and track fetch request spans for usage in combination with `addFetchInstrumentationHandler`.
*

@@ -119,4 +119,3 @@ * @returns Span if a span was created, otherwise void.

const sentryBaggageHeader = utils.dynamicSamplingContextToSentryBaggageHeader(
dsc ||
(span ? core.getDynamicSamplingContextFromSpan(span) : core.getDynamicSamplingContextFromClient(traceId, client, scope)),
dsc || (span ? core.getDynamicSamplingContextFromSpan(span) : core.getDynamicSamplingContextFromClient(traceId, client)),
);

@@ -123,0 +122,0 @@

@@ -18,3 +18,2 @@ Object.defineProperty(exports, '__esModule', { value: true });

const fetch = require('./common/fetch.js');
const extensions = require('./extensions.js');

@@ -24,9 +23,6 @@

exports.IdleTransaction = core.IdleTransaction;
exports.Span = core.Span;
exports.SpanStatus = core.SpanStatus;
exports.Transaction = core.Transaction;
exports.extractTraceparentData = core.extractTraceparentData;
exports.getActiveTransaction = core.getActiveTransaction;
exports.hasTracingEnabled = core.hasTracingEnabled;
exports.spanStatusfromHttpCode = core.spanStatusfromHttpCode;
exports.startIdleTransaction = core.startIdleTransaction;

@@ -44,3 +40,2 @@ exports.TRACEPARENT_REGEXP = utils.TRACEPARENT_REGEXP;

exports.BROWSER_TRACING_INTEGRATION_ID = browsertracing.BROWSER_TRACING_INTEGRATION_ID;
exports.BrowserTracing = browsertracing.BrowserTracing;
exports.browserTracingIntegration = browserTracingIntegration.browserTracingIntegration;

@@ -57,3 +52,2 @@ exports.startBrowserTracingNavigationSpan = browserTracingIntegration.startBrowserTracingNavigationSpan;

exports.instrumentFetchRequest = fetch.instrumentFetchRequest;
exports.addExtensionMethods = extensions.addExtensionMethods;
//# sourceMappingURL=index.js.map

@@ -9,3 +9,2 @@ var {

const debugBuild = require('../../common/debug-build.js');
const nodeUtils = require('./utils/node-utils.js');

@@ -50,7 +49,2 @@ /** Tracing integration for Apollo */

setupOnce(_, getCurrentHub) {
if (nodeUtils.shouldDisableAutoInstrumentation(getCurrentHub)) {
debugBuild.DEBUG_BUILD && utils.logger.log('Apollo Integration is skipped because of instrumenter configuration.');
return;
}
if (this._useNest) {

@@ -165,6 +159,6 @@ const pkg = this.loadDependency();

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;
// eslint-disable-next-line deprecation/deprecation
const span = _optionalChain([parentSpan, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({
description: `${resolverGroupName}.${resolverName}`,
name: `${resolverGroupName}.${resolverName}`,
op: 'graphql.resolve',

@@ -171,0 +165,0 @@ origin: 'auto.graphql.apollo',

@@ -10,6 +10,3 @@ var {

const debugBuild = require('../../common/debug-build.js');
const nodeUtils = require('./utils/node-utils.js');
/* eslint-disable max-lines */
/**

@@ -46,3 +43,3 @@ * Express integration

*/
setupOnce(_, getCurrentHub) {
setupOnce(_) {
if (!this._router) {

@@ -53,7 +50,2 @@ debugBuild.DEBUG_BUILD && utils.logger.error('ExpressIntegration is missing an Express instance');

if (nodeUtils.shouldDisableAutoInstrumentation(getCurrentHub)) {
debugBuild.DEBUG_BUILD && utils.logger.log('Express Integration is skipped because of instrumenter configuration.');
return;
}
instrumentMiddlewares(this._router, this._methods);

@@ -89,3 +81,3 @@ instrumentRouter(this._router );

const span = transaction.startChild({
description: fn.name,
name: fn.name,
op: `middleware.express.${method}`,

@@ -111,3 +103,3 @@ origin: 'auto.middleware.express',

const span = _optionalChain([transaction, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({
description: fn.name,
name: fn.name,
op: `middleware.express.${method}`,

@@ -133,3 +125,3 @@ origin: 'auto.middleware.express',

const span = _optionalChain([transaction, 'optionalAccess', _6 => _6.startChild, 'call', _7 => _7({
description: fn.name,
name: fn.name,
op: `middleware.express.${method}`,

@@ -308,3 +300,3 @@ origin: 'auto.middleware.express',

const attributes = (transaction && core.spanToJSON(transaction).data) || {};
if (transaction && attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] !== 'custom') {
if (transaction && attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] === 'url') {
// If the request URL is '/' or empty, the reconstructed route will be empty.

@@ -311,0 +303,0 @@ // Therefore, we fall back to setting the final route to '/' in this case.

@@ -9,3 +9,2 @@ var {

const debugBuild = require('../../common/debug-build.js');
const nodeUtils = require('./utils/node-utils.js');

@@ -36,7 +35,2 @@ /** Tracing integration for graphql package */

setupOnce(_, getCurrentHub) {
if (nodeUtils.shouldDisableAutoInstrumentation(getCurrentHub)) {
debugBuild.DEBUG_BUILD && utils.logger.log('GraphQL Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = this.loadDependency();

@@ -54,7 +48,7 @@

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;
// eslint-disable-next-line deprecation/deprecation
const span = _optionalChain([parentSpan, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({
description: 'execute',
name: 'execute',
op: 'graphql.execute',

@@ -61,0 +55,0 @@ origin: 'auto.graphql.graphql',

@@ -9,3 +9,2 @@ var {

const debugBuild = require('../../common/debug-build.js');
const nodeUtils = require('./utils/node-utils.js');

@@ -118,7 +117,2 @@ // This allows us to use the same array for both defaults options and the type itself.

setupOnce(_, getCurrentHub) {
if (nodeUtils.shouldDisableAutoInstrumentation(getCurrentHub)) {
debugBuild.DEBUG_BUILD && utils.logger.log('Mongo Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = this.loadDependency();

@@ -153,3 +147,2 @@

const lastArg = args[args.length - 1];
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();

@@ -161,3 +154,3 @@ // eslint-disable-next-line deprecation/deprecation

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;

@@ -231,3 +224,3 @@ const sendDefaultPii = _optionalChain([client, 'optionalAccess', _2 => _2.getOptions, 'call', _3 => _3(), 'access', _4 => _4.sendDefaultPii]);

origin: 'auto.db.mongo',
description: operation,
name: operation,
data,

@@ -234,0 +227,0 @@ };

@@ -9,3 +9,2 @@ var {

const debugBuild = require('../../common/debug-build.js');
const nodeUtils = require('./utils/node-utils.js');

@@ -36,7 +35,2 @@ /** Tracing integration for node-mysql package */

setupOnce(_, getCurrentHub) {
if (nodeUtils.shouldDisableAutoInstrumentation(getCurrentHub)) {
debugBuild.DEBUG_BUILD && utils.logger.log('Mysql Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = this.loadDependency();

@@ -97,7 +91,7 @@

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;
// eslint-disable-next-line deprecation/deprecation
const span = _optionalChain([parentSpan, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({
description: typeof options === 'string' ? options : (options ).sql,
name: typeof options === 'string' ? options : (options ).sql,
op: 'db',

@@ -104,0 +98,0 @@ origin: 'auto.db.mysql',

@@ -9,3 +9,2 @@ var {

const debugBuild = require('../../common/debug-build.js');
const nodeUtils = require('./utils/node-utils.js');

@@ -38,7 +37,2 @@ /** Tracing integration for node-postgres package */

setupOnce(_, getCurrentHub) {
if (nodeUtils.shouldDisableAutoInstrumentation(getCurrentHub)) {
debugBuild.DEBUG_BUILD && utils.logger.log('Postgres Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = this.loadDependency();

@@ -70,3 +64,3 @@

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;

@@ -96,3 +90,3 @@ const data = {

const span = _optionalChain([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({
description: typeof config === 'string' ? config : (config ).text,
name: typeof config === 'string' ? config : (config ).text,
op: 'db',

@@ -99,0 +93,0 @@ origin: 'auto.db.postgres',

@@ -6,3 +6,2 @@ Object.defineProperty(exports, '__esModule', { value: true });

const debugBuild = require('../../common/debug-build.js');
const nodeUtils = require('./utils/node-utils.js');

@@ -56,7 +55,2 @@ function isValidPrismaClient(possibleClient) {

options.client.$use((params, next) => {
// eslint-disable-next-line deprecation/deprecation
if (nodeUtils.shouldDisableAutoInstrumentation(core.getCurrentHub)) {
return next(params);
}
const action = params.action;

@@ -63,0 +57,0 @@ const model = params.model;

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

import { getActiveTransaction, spanToJSON } from '@sentry/core';
import { getActiveSpan, getRootSpan, spanToJSON } from '@sentry/core';
import { logger } from '@sentry/utils';

@@ -13,20 +13,29 @@ import { DEBUG_BUILD } from '../common/debug-build.js';

WINDOW.document.addEventListener('visibilitychange', () => {
// eslint-disable-next-line deprecation/deprecation
const activeTransaction = getActiveTransaction() ;
if (WINDOW.document.hidden && activeTransaction) {
const statusType = 'cancelled';
const activeSpan = getActiveSpan();
if (!activeSpan) {
return;
}
const { op, status } = spanToJSON(activeTransaction);
const rootSpan = getRootSpan(activeSpan);
if (!rootSpan) {
return;
}
DEBUG_BUILD &&
logger.log(`[Tracing] Transaction: ${statusType} -> since tab moved to the background, op: ${op}`);
if (WINDOW.document.hidden && rootSpan) {
const cancelledStatus = 'cancelled';
const { op, status } = spanToJSON(rootSpan);
if (DEBUG_BUILD) {
logger.log(`[Tracing] Transaction: ${cancelledStatus} -> since tab moved to the background, op: ${op}`);
}
// We should not set status if it is already set, this prevent important statuses like
// error or data loss from being overwritten on transaction.
if (!status) {
activeTransaction.setStatus(statusType);
rootSpan.setStatus(cancelledStatus);
}
// TODO: Can we rewrite this to an attribute?
// eslint-disable-next-line deprecation/deprecation
activeTransaction.setTag('visibilitychange', 'document.hidden');
activeTransaction.end();
rootSpan.setAttribute('sentry.cancellation_reason', 'document.hidden');
rootSpan.end();
}

@@ -33,0 +42,0 @@ });

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

import { TRACING_DEFAULTS, addTracingExtensions, startIdleTransaction, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getActiveTransaction } from '@sentry/core';
import { logger, propagationContextFromHeaders, getDomElement } from '@sentry/utils';
import { DEBUG_BUILD } from '../common/debug-build.js';
import { registerBackgroundTabDetection } from './backgroundtab.js';
import { startTrackingWebVitals, startTrackingLongTasks, startTrackingInteractions, addPerformanceEntries } from './metrics/index.js';
import { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from './request.js';
import { TRACING_DEFAULTS } from '@sentry/core';
import '@sentry/utils';
import '../common/debug-build.js';
import { defaultRequestInstrumentationOptions } from './request.js';
import { instrumentRoutingWithDefaults } from './router.js';
import { WINDOW } from './types.js';

@@ -14,3 +11,3 @@ const BROWSER_TRACING_INTEGRATION_ID = 'BrowserTracing';

const DEFAULT_BROWSER_TRACING_OPTIONS = {
({
...TRACING_DEFAULTS,

@@ -24,318 +21,5 @@ markBackgroundTransactions: true,

...defaultRequestInstrumentationOptions,
};
});
/**
* The Browser Tracing integration automatically instruments browser pageload/navigation
* actions as transactions, and captures requests, metrics and errors as spans.
*
* The integration can be configured with a variety of options, and can be extended to use
* any routing library. This integration uses {@see IdleTransaction} to create transactions.
*
* @deprecated Use `browserTracingIntegration()` instead.
*/
class BrowserTracing {
// This class currently doesn't have a static `id` field like the other integration classes, because it prevented
// @sentry/tracing from being treeshaken. Tree shakers do not like static fields, because they behave like side effects.
// TODO: Come up with a better plan, than using static fields on integration classes, and use that plan on all
// integrations.
/** Browser Tracing integration options */
/**
* @inheritDoc
*/
constructor(_options) {
this.name = BROWSER_TRACING_INTEGRATION_ID;
this._hasSetTracePropagationTargets = false;
addTracingExtensions();
if (DEBUG_BUILD) {
this._hasSetTracePropagationTargets = !!(
_options &&
// eslint-disable-next-line deprecation/deprecation
(_options.tracePropagationTargets || _options.tracingOrigins)
);
}
this.options = {
...DEFAULT_BROWSER_TRACING_OPTIONS,
..._options,
};
// Special case: enableLongTask can be set in _experiments
// TODO (v8): Remove this in v8
if (this.options._experiments.enableLongTask !== undefined) {
this.options.enableLongTask = this.options._experiments.enableLongTask;
}
// TODO (v8): remove this block after tracingOrigins is removed
// Set tracePropagationTargets to tracingOrigins if specified by the user
// In case both are specified, tracePropagationTargets takes precedence
// eslint-disable-next-line deprecation/deprecation
if (_options && !_options.tracePropagationTargets && _options.tracingOrigins) {
// eslint-disable-next-line deprecation/deprecation
this.options.tracePropagationTargets = _options.tracingOrigins;
}
this._collectWebVitals = startTrackingWebVitals();
if (this.options.enableLongTask) {
startTrackingLongTasks();
}
if (this.options._experiments.enableInteractions) {
startTrackingInteractions();
}
}
/**
* @inheritDoc
*/
setupOnce(_, getCurrentHub) {
this._getCurrentHub = getCurrentHub;
const hub = getCurrentHub();
// eslint-disable-next-line deprecation/deprecation
const client = hub.getClient();
const clientOptions = client && client.getOptions();
const {
routingInstrumentation: instrumentRouting,
startTransactionOnLocationChange,
startTransactionOnPageLoad,
markBackgroundTransactions,
traceFetch,
traceXHR,
shouldCreateSpanForRequest,
enableHTTPTimings,
_experiments,
} = this.options;
const clientOptionsTracePropagationTargets = clientOptions && clientOptions.tracePropagationTargets;
// There are three ways to configure tracePropagationTargets:
// 1. via top level client option `tracePropagationTargets`
// 2. via BrowserTracing option `tracePropagationTargets`
// 3. via BrowserTracing option `tracingOrigins` (deprecated)
//
// To avoid confusion, favour top level client option `tracePropagationTargets`, and fallback to
// BrowserTracing option `tracePropagationTargets` and then `tracingOrigins` (deprecated).
// This is done as it minimizes bundle size (we don't have to have undefined checks).
//
// If both 1 and either one of 2 or 3 are set (from above), we log out a warning.
// eslint-disable-next-line deprecation/deprecation
const tracePropagationTargets = clientOptionsTracePropagationTargets || this.options.tracePropagationTargets;
if (DEBUG_BUILD && this._hasSetTracePropagationTargets && clientOptionsTracePropagationTargets) {
logger.warn(
'[Tracing] The `tracePropagationTargets` option was set in the BrowserTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used.',
);
}
instrumentRouting(
(context) => {
const transaction = this._createRouteTransaction(context);
this.options._experiments.onStartRouteTransaction &&
this.options._experiments.onStartRouteTransaction(transaction, context, getCurrentHub);
return transaction;
},
startTransactionOnPageLoad,
startTransactionOnLocationChange,
);
if (markBackgroundTransactions) {
registerBackgroundTabDetection();
}
if (_experiments.enableInteractions) {
this._registerInteractionListener();
}
instrumentOutgoingRequests({
traceFetch,
traceXHR,
tracePropagationTargets,
shouldCreateSpanForRequest,
enableHTTPTimings,
});
}
/** Create routing idle transaction. */
_createRouteTransaction(context) {
if (!this._getCurrentHub) {
DEBUG_BUILD &&
logger.warn(`[Tracing] Did not create ${context.op} transaction because _getCurrentHub is invalid.`);
return undefined;
}
const hub = this._getCurrentHub();
const { beforeNavigate, idleTimeout, finalTimeout, heartbeatInterval } = this.options;
const isPageloadTransaction = context.op === 'pageload';
let expandedContext;
if (isPageloadTransaction) {
const sentryTrace = isPageloadTransaction ? getMetaContent('sentry-trace') : '';
const baggage = isPageloadTransaction ? getMetaContent('baggage') : undefined;
const { traceId, dsc, parentSpanId, sampled } = propagationContextFromHeaders(sentryTrace, baggage);
expandedContext = {
traceId,
parentSpanId,
parentSampled: sampled,
...context,
metadata: {
// eslint-disable-next-line deprecation/deprecation
...context.metadata,
dynamicSamplingContext: dsc,
},
trimEnd: true,
};
} else {
expandedContext = {
trimEnd: true,
...context,
};
}
const modifiedContext = typeof beforeNavigate === 'function' ? beforeNavigate(expandedContext) : expandedContext;
// For backwards compatibility reasons, beforeNavigate can return undefined to "drop" the transaction (prevent it
// from being sent to Sentry).
const finalContext = modifiedContext === undefined ? { ...expandedContext, sampled: false } : modifiedContext;
// If `beforeNavigate` set a custom name, record that fact
// eslint-disable-next-line deprecation/deprecation
finalContext.metadata =
finalContext.name !== expandedContext.name
? // eslint-disable-next-line deprecation/deprecation
{ ...finalContext.metadata, source: 'custom' }
: // eslint-disable-next-line deprecation/deprecation
finalContext.metadata;
this._latestRouteName = finalContext.name;
this._latestRouteSource = getSource(finalContext);
// eslint-disable-next-line deprecation/deprecation
if (finalContext.sampled === false) {
DEBUG_BUILD && logger.log(`[Tracing] Will not send ${finalContext.op} transaction because of beforeNavigate.`);
}
DEBUG_BUILD && logger.log(`[Tracing] Starting ${finalContext.op} transaction on scope`);
const { location } = WINDOW;
const idleTransaction = startIdleTransaction(
hub,
finalContext,
idleTimeout,
finalTimeout,
true,
{ location }, // for use in the tracesSampler
heartbeatInterval,
isPageloadTransaction, // should wait for finish signal if it's a pageload transaction
);
if (isPageloadTransaction) {
WINDOW.document.addEventListener('readystatechange', () => {
if (['interactive', 'complete'].includes(WINDOW.document.readyState)) {
idleTransaction.sendAutoFinishSignal();
}
});
if (['interactive', 'complete'].includes(WINDOW.document.readyState)) {
idleTransaction.sendAutoFinishSignal();
}
}
idleTransaction.registerBeforeFinishCallback(transaction => {
this._collectWebVitals();
addPerformanceEntries(transaction);
});
return idleTransaction ;
}
/** Start listener for interaction transactions */
_registerInteractionListener() {
let inflightInteractionTransaction;
const registerInteractionTransaction = () => {
const { idleTimeout, finalTimeout, heartbeatInterval } = this.options;
const op = 'ui.action.click';
// eslint-disable-next-line deprecation/deprecation
const currentTransaction = getActiveTransaction();
if (currentTransaction && currentTransaction.op && ['navigation', 'pageload'].includes(currentTransaction.op)) {
DEBUG_BUILD &&
logger.warn(
`[Tracing] Did not create ${op} transaction because a pageload or navigation transaction is in progress.`,
);
return undefined;
}
if (inflightInteractionTransaction) {
inflightInteractionTransaction.setFinishReason('interactionInterrupted');
inflightInteractionTransaction.end();
inflightInteractionTransaction = undefined;
}
if (!this._getCurrentHub) {
DEBUG_BUILD && logger.warn(`[Tracing] Did not create ${op} transaction because _getCurrentHub is invalid.`);
return undefined;
}
if (!this._latestRouteName) {
DEBUG_BUILD && logger.warn(`[Tracing] Did not create ${op} transaction because _latestRouteName is missing.`);
return undefined;
}
const hub = this._getCurrentHub();
const { location } = WINDOW;
const context = {
name: this._latestRouteName,
op,
trimEnd: true,
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: this._latestRouteSource || 'url',
},
};
inflightInteractionTransaction = startIdleTransaction(
hub,
context,
idleTimeout,
finalTimeout,
true,
{ location }, // for use in the tracesSampler
heartbeatInterval,
);
};
['click'].forEach(type => {
addEventListener(type, registerInteractionTransaction, { once: false, capture: true });
});
}
}
/** Returns the value of a meta tag */
function getMetaContent(metaName) {
// Can't specify generic to `getDomElement` because tracing can be used
// in a variety of environments, have to disable `no-unsafe-member-access`
// as a result.
const metaTag = getDomElement(`meta[name=${metaName}]`);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return metaTag ? metaTag.getAttribute('content') : undefined;
}
function getSource(context) {
const sourceFromAttributes = context.attributes && context.attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// eslint-disable-next-line deprecation/deprecation
const sourceFromData = context.data && context.data[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// eslint-disable-next-line deprecation/deprecation
const sourceFromMetadata = context.metadata && context.metadata.source;
return sourceFromAttributes || sourceFromData || sourceFromMetadata;
}
export { BROWSER_TRACING_INTEGRATION_ID, BrowserTracing, getMetaContent };
export { BROWSER_TRACING_INTEGRATION_ID };
//# sourceMappingURL=browsertracing.js.map

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

import { TRACING_DEFAULTS, addTracingExtensions, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getActiveSpan, getCurrentHub, startIdleTransaction, getActiveTransaction, getClient, getCurrentScope } from '@sentry/core';
import { TRACING_DEFAULTS, addTracingExtensions, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getActiveSpan, getCurrentHub, startIdleTransaction, getActiveTransaction } from '@sentry/core';
import { logger, browserPerformanceTimeOrigin, addHistoryInstrumentationHandler, propagationContextFromHeaders, getDomElement } from '@sentry/utils';
import { DEBUG_BUILD } from '../common/debug-build.js';
import { registerBackgroundTabDetection } from './backgroundtab.js';
import { addPerformanceInstrumentationHandler } from './instrument.js';
import { startTrackingWebVitals, startTrackingINP, startTrackingLongTasks, startTrackingInteractions, addPerformanceEntries } from './metrics/index.js';
import { startTrackingWebVitals, startTrackingLongTasks, startTrackingInteractions, addPerformanceEntries } from './metrics/index.js';
import { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from './request.js';

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

enableLongTask: true,
enableInp: false,
_experiments: {},

@@ -36,20 +34,4 @@ ...defaultRequestInstrumentationOptions,

const browserTracingIntegration = ((_options = {}) => {
const _hasSetTracePropagationTargets = DEBUG_BUILD
? !!(
// eslint-disable-next-line deprecation/deprecation
(_options.tracePropagationTargets || _options.tracingOrigins)
)
: false;
addTracingExtensions();
// TODO (v8): remove this block after tracingOrigins is removed
// Set tracePropagationTargets to tracingOrigins if specified by the user
// In case both are specified, tracePropagationTargets takes precedence
// eslint-disable-next-line deprecation/deprecation
if (!_options.tracePropagationTargets && _options.tracingOrigins) {
// eslint-disable-next-line deprecation/deprecation
_options.tracePropagationTargets = _options.tracingOrigins;
}
const options = {

@@ -62,8 +44,2 @@ ...DEFAULT_BROWSER_TRACING_OPTIONS,

/** Stores a mapping of interactionIds from PerformanceEventTimings to the origin interaction path */
const interactionIdtoRouteNameMapping = {};
if (options.enableInp) {
startTrackingINP(interactionIdtoRouteNameMapping);
}
if (options.enableLongTask) {

@@ -76,9 +52,5 @@ startTrackingLongTasks();

const latestRoute
let latestRouteName;
let latestRouteSource;
= {
name: undefined,
context: undefined,
};
/** Create routing idle transaction. */

@@ -120,12 +92,11 @@ function _createRouteTransaction(context) {

// If `beforeStartSpan` set a custom name, record that fact
// eslint-disable-next-line deprecation/deprecation
finalContext.metadata =
finalContext.attributes =
finalContext.name !== expandedContext.name
? // eslint-disable-next-line deprecation/deprecation
{ ...finalContext.metadata, source: 'custom' }
: // eslint-disable-next-line deprecation/deprecation
finalContext.metadata;
? { ...finalContext.attributes, [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'custom' }
: finalContext.attributes;
latestRoute.name = finalContext.name;
latestRoute.context = finalContext;
latestRouteName = finalContext.name;
if (finalContext.attributes) {
latestRouteSource = finalContext.attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
}

@@ -176,56 +147,33 @@ if (finalContext.sampled === false) {

afterAllSetup(client) {
const clientOptions = client.getOptions();
const { markBackgroundSpan, traceFetch, traceXHR, shouldCreateSpanForRequest, enableHTTPTimings, _experiments } =
options;
const clientOptionsTracePropagationTargets = clientOptions && clientOptions.tracePropagationTargets;
// There are three ways to configure tracePropagationTargets:
// 1. via top level client option `tracePropagationTargets`
// 2. via BrowserTracing option `tracePropagationTargets`
// 3. via BrowserTracing option `tracingOrigins` (deprecated)
//
// To avoid confusion, favour top level client option `tracePropagationTargets`, and fallback to
// BrowserTracing option `tracePropagationTargets` and then `tracingOrigins` (deprecated).
// This is done as it minimizes bundle size (we don't have to have undefined checks).
//
// If both 1 and either one of 2 or 3 are set (from above), we log out a warning.
// eslint-disable-next-line deprecation/deprecation
const tracePropagationTargets = clientOptionsTracePropagationTargets || options.tracePropagationTargets;
if (DEBUG_BUILD && _hasSetTracePropagationTargets && clientOptionsTracePropagationTargets) {
logger.warn(
'[Tracing] The `tracePropagationTargets` option was set in the BrowserTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used.',
);
}
let activeSpan;
let startingUrl = WINDOW.location && WINDOW.location.href;
if (client.on) {
client.on('startNavigationSpan', (context) => {
if (activeSpan) {
DEBUG_BUILD && logger.log(`[Tracing] Finishing current transaction with op: ${spanToJSON(activeSpan).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeSpan.end();
}
activeSpan = _createRouteTransaction({
op: 'navigation',
...context,
});
client.on('startNavigationSpan', (context) => {
if (activeSpan) {
DEBUG_BUILD && logger.log(`[Tracing] Finishing current transaction with op: ${spanToJSON(activeSpan).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeSpan.end();
}
activeSpan = _createRouteTransaction({
op: 'navigation',
...context,
});
});
client.on('startPageLoadSpan', (context) => {
if (activeSpan) {
DEBUG_BUILD && logger.log(`[Tracing] Finishing current transaction with op: ${spanToJSON(activeSpan).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeSpan.end();
}
activeSpan = _createRouteTransaction({
op: 'pageload',
...context,
});
client.on('startPageLoadSpan', (context) => {
if (activeSpan) {
DEBUG_BUILD && logger.log(`[Tracing] Finishing current transaction with op: ${spanToJSON(activeSpan).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.
activeSpan.end();
}
activeSpan = _createRouteTransaction({
op: 'pageload',
...context,
});
}
});
if (options.instrumentPageLoad && client.emit && WINDOW.location) {
if (options.instrumentPageLoad && WINDOW.location) {
const context = {

@@ -243,3 +191,3 @@ name: WINDOW.location.pathname,

if (options.instrumentNavigation && client.emit && WINDOW.location) {
if (options.instrumentNavigation && WINDOW.location) {
addHistoryInstrumentationHandler(({ to, from }) => {

@@ -280,13 +228,9 @@ /**

if (_experiments.enableInteractions) {
registerInteractionListener(options, latestRoute);
registerInteractionListener(options, latestRouteName, latestRouteSource);
}
if (options.enableInp) {
registerInpInteractionListener(interactionIdtoRouteNameMapping, latestRoute);
}
instrumentOutgoingRequests({
traceFetch,
traceXHR,
tracePropagationTargets,
tracePropagationTargets: client.getOptions().tracePropagationTargets,
shouldCreateSpanForRequest,

@@ -296,5 +240,2 @@ enableHTTPTimings,

},
// TODO v8: Remove this again
// This is private API that we use to fix converted BrowserTracing integrations in Next.js & SvelteKit
options,
};

@@ -305,9 +246,5 @@ }) ;

* Manually start a page load span.
* This will only do something if the BrowserTracing integration has been setup.
* This will only do something if a browser tracing integration integration has been setup.
*/
function startBrowserTracingPageLoadSpan(client, spanOptions) {
if (!client.emit) {
return;
}
client.emit('startPageLoadSpan', spanOptions);

@@ -322,9 +259,5 @@

* Manually start a navigation span.
* This will only do something if the BrowserTracing integration has been setup.
* This will only do something if a browser tracing integration has been setup.
*/
function startBrowserTracingNavigationSpan(client, spanOptions) {
if (!client.emit) {
return;
}
client.emit('startNavigationSpan', spanOptions);

@@ -350,5 +283,4 @@

options,
latestRoute
,
latestRouteName,
latestRouteSource,
) {

@@ -362,8 +294,11 @@ let inflightInteractionTransaction;

const currentTransaction = getActiveTransaction();
if (currentTransaction && currentTransaction.op && ['navigation', 'pageload'].includes(currentTransaction.op)) {
DEBUG_BUILD &&
logger.warn(
`[Tracing] Did not create ${op} transaction because a pageload or navigation transaction is in progress.`,
);
return undefined;
if (currentTransaction) {
const currentTransactionOp = spanToJSON(currentTransaction).op;
if (currentTransactionOp && ['navigation', 'pageload'].includes(currentTransactionOp)) {
DEBUG_BUILD &&
logger.warn(
`[Tracing] Did not create ${op} transaction because a pageload or navigation transaction is in progress.`,
);
return undefined;
}
}

@@ -377,3 +312,3 @@

if (!latestRoute.name) {
if (!latestRouteName) {
DEBUG_BUILD && logger.warn(`[Tracing] Did not create ${op} transaction because _latestRouteName is missing.`);

@@ -386,7 +321,7 @@ return undefined;

const context = {
name: latestRoute.name,
name: latestRouteName,
op,
trimEnd: true,
data: {
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.context ? getSource(latestRoute.context) : 'url',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRouteSource || 'url',
},

@@ -412,76 +347,3 @@ };

function isPerformanceEventTiming(entry) {
return 'duration' in entry;
}
/** We store up to 10 interaction candidates max to cap memory usage. This is the same cap as getINP from web-vitals */
const MAX_INTERACTIONS = 10;
/** Creates a listener on interaction entries, and maps interactionIds to the origin path of the interaction */
function registerInpInteractionListener(
interactionIdtoRouteNameMapping,
latestRoute
,
) {
addPerformanceInstrumentationHandler('event', ({ entries }) => {
const client = getClient();
// 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 !== undefined && client.getIntegrationByName !== undefined
? (client.getIntegrationByName('Replay') )
: undefined;
const replayId = replay !== undefined ? replay.getReplayId() : undefined;
// eslint-disable-next-line deprecation/deprecation
const activeTransaction = getActiveTransaction();
const currentScope = getCurrentScope();
const user = currentScope !== undefined ? currentScope.getUser() : undefined;
for (const entry of entries) {
if (isPerformanceEventTiming(entry)) {
const duration = entry.duration;
const keys = Object.keys(interactionIdtoRouteNameMapping);
const minInteractionId =
keys.length > 0
? keys.reduce((a, b) => {
return interactionIdtoRouteNameMapping[a].duration < interactionIdtoRouteNameMapping[b].duration
? a
: b;
})
: undefined;
if (minInteractionId === undefined || duration > interactionIdtoRouteNameMapping[minInteractionId].duration) {
const interactionId = entry.interactionId;
const routeName = latestRoute.name;
const parentContext = latestRoute.context;
if (interactionId && routeName && parentContext) {
if (minInteractionId && Object.keys(interactionIdtoRouteNameMapping).length >= MAX_INTERACTIONS) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete interactionIdtoRouteNameMapping[minInteractionId];
}
interactionIdtoRouteNameMapping[interactionId] = {
routeName,
duration,
parentContext,
user,
activeTransaction,
replayId,
};
}
}
}
}
});
}
function getSource(context) {
const sourceFromAttributes = context.attributes && context.attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// eslint-disable-next-line deprecation/deprecation
const sourceFromData = context.data && context.data[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
// eslint-disable-next-line deprecation/deprecation
const sourceFromMetadata = context.metadata && context.metadata.source;
return sourceFromAttributes || sourceFromData || sourceFromMetadata;
}
export { BROWSER_TRACING_INTEGRATION_ID, browserTracingIntegration, getMetaContent, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan };
//# sourceMappingURL=browserTracingIntegration.js.map

@@ -5,3 +5,2 @@ import { logger, getFunctionName } from '@sentry/utils';

import { onFID } from './web-vitals/getFID.js';
import { onINP } from './web-vitals/getINP.js';
import { onLCP } from './web-vitals/getLCP.js';

@@ -16,3 +15,2 @@ import { observe } from './web-vitals/lib/observe.js';

let _previousLcp;
let _previousInp;

@@ -56,12 +54,2 @@ /**

/**
* Add a callback that will be triggered when a INP metric is available.
* Returns a cleanup callback which can be called to remove the instrumentation handler.
*/
function addInpInstrumentationHandler(
callback,
) {
return addMetricObserver('inp', callback, instrumentInp, _previousInp);
}
/**
* Add a callback that will be triggered when a performance observer is triggered,

@@ -133,11 +121,2 @@ * and receives the entries of the observer.

function instrumentInp() {
return onINP(metric => {
triggerHandlers('inp', {
metric,
});
_previousInp = metric;
});
}
function addMetricObserver(

@@ -212,3 +191,3 @@ type,

export { addClsInstrumentationHandler, addFidInstrumentationHandler, addInpInstrumentationHandler, addLcpInstrumentationHandler, addPerformanceInstrumentationHandler };
export { addClsInstrumentationHandler, addFidInstrumentationHandler, addLcpInstrumentationHandler, addPerformanceInstrumentationHandler };
//# sourceMappingURL=instrument.js.map

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

import { getActiveTransaction, spanToJSON, setMeasurement, getClient, Span, createSpanEnvelope, hasTracingEnabled, isValidSampleRate } from '@sentry/core';
import { getActiveTransaction, spanToJSON, setMeasurement } from '@sentry/core';
import { browserPerformanceTimeOrigin, htmlTreeAsString, getComponentName, logger, parseUrl } from '@sentry/utils';
import { DEBUG_BUILD } from '../../common/debug-build.js';
import { addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addLcpInstrumentationHandler, addFidInstrumentationHandler, addInpInstrumentationHandler } from '../instrument.js';
import { addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addLcpInstrumentationHandler, addFidInstrumentationHandler } from '../instrument.js';
import { WINDOW } from '../types.js';

@@ -73,3 +73,3 @@ import { getVisibilityWatcher } from '../web-vitals/lib/getVisibilityWatcher.js';

transaction.startChild({
description: 'Main UI thread blocked',
name: 'Main UI thread blocked',
op: 'ui.long-task',

@@ -101,3 +101,3 @@ origin: 'auto.ui.browser.metrics',

const span = {
description: htmlTreeAsString(entry.target),
name: htmlTreeAsString(entry.target),
op: `ui.interaction.${entry.name}`,

@@ -121,18 +121,2 @@ origin: 'auto.ui.browser.metrics',

/**
* Start tracking INP webvital events.
*/
function startTrackingINP(interactionIdtoRouteNameMapping) {
const performance = getBrowserPerformanceAPI();
if (performance && browserPerformanceTimeOrigin) {
const inpCallback = _trackINP(interactionIdtoRouteNameMapping);
return () => {
inpCallback();
};
}
return () => undefined;
}
/** Starts tracking the Cumulative Layout Shift on the current page. */

@@ -182,65 +166,2 @@ function _trackCLS() {

/** Starts tracking the Interaction to Next Paint on the current page. */
function _trackINP(interactionIdtoRouteNameMapping) {
return addInpInstrumentationHandler(({ metric }) => {
const entry = metric.entries.find(e => e.name === 'click');
const client = getClient();
if (!entry || !client) {
return;
}
const options = client.getOptions();
/** Build the INP span, create an envelope from the span, and then send the envelope */
const startTime = msToSec((browserPerformanceTimeOrigin ) + entry.startTime);
const duration = msToSec(metric.value);
const { routeName, parentContext, activeTransaction, user, replayId } =
entry.interactionId !== undefined
? interactionIdtoRouteNameMapping[entry.interactionId]
: {
routeName: undefined,
parentContext: undefined,
activeTransaction: undefined,
user: undefined,
replayId: undefined,
};
const userDisplay = user !== undefined ? user.email || user.id || user.ip_address : undefined;
// eslint-disable-next-line deprecation/deprecation
const profileId = activeTransaction !== undefined ? activeTransaction.getProfileId() : undefined;
const span = new Span({
startTimestamp: startTime,
endTimestamp: startTime + duration,
op: 'ui.interaction.click',
name: htmlTreeAsString(entry.target),
attributes: {
release: options.release,
environment: options.environment,
transaction: routeName,
...(userDisplay !== undefined && userDisplay !== '' ? { user: userDisplay } : {}),
...(profileId !== undefined ? { profile_id: profileId } : {}),
...(replayId !== undefined ? { replay_id: replayId } : {}),
},
exclusiveTime: metric.value,
measurements: {
inp: { value: metric.value, unit: 'millisecond' },
},
});
/** Check to see if the span should be sampled */
const sampleRate = getSampleRate(parentContext, options);
if (!sampleRate) {
return;
}
if (Math.random() < (sampleRate )) {
const envelope = span ? createSpanEnvelope([span]) : undefined;
const transport = client && client.getTransport();
if (transport && envelope) {
transport.send(envelope).then(null, reason => {
DEBUG_BUILD && logger.error('Error while sending interaction:', reason);
});
}
return;
}
});
}
/** Add performance related spans to a transaction */

@@ -269,4 +190,3 @@ function addPerformanceEntries(transaction) {

// eslint-disable-next-line deprecation/deprecation
if (transaction.op === 'navigation' && transactionStartTime && timeOrigin + startTime < transactionStartTime) {
if (op === 'navigation' && transactionStartTime && timeOrigin + startTime < transactionStartTime) {
return;

@@ -340,3 +260,3 @@ }

_startChild(transaction, {
description: 'first input delay',
name: 'first input delay',
endTimestamp: fidMark.value + msToSec(_measurements['fid'].value),

@@ -383,3 +303,3 @@ op: 'ui.action',

_startChild(transaction, {
description: entry.name ,
name: entry.name ,
endTimestamp: measureEndTimestamp,

@@ -413,3 +333,3 @@ op: entry.entryType ,

timeOrigin,
description,
name,
eventEnd,

@@ -425,3 +345,3 @@ ) {

origin: 'auto.browser.browser.metrics',
description: description || event,
name: name || event,
startTimestamp: timeOrigin + msToSec(start),

@@ -443,3 +363,3 @@ endTimestamp: timeOrigin + msToSec(end),

origin: 'auto.browser.browser.metrics',
description: 'request',
name: 'request',
startTimestamp: timeOrigin + msToSec(entry.requestStart ),

@@ -452,3 +372,3 @@ endTimestamp: timeOrigin + msToSec(entry.responseEnd ),

origin: 'auto.browser.browser.metrics',
description: 'response',
name: 'response',
startTimestamp: timeOrigin + msToSec(entry.responseStart ),

@@ -500,3 +420,3 @@ endTimestamp: timeOrigin + msToSec(entry.responseEnd ),

_startChild(transaction, {
description: resourceUrl.replace(WINDOW.location.origin, ''),
name: resourceUrl.replace(WINDOW.location.origin, ''),
endTimestamp,

@@ -644,35 +564,3 @@ op: entry.initiatorType ? `resource.${entry.initiatorType}` : 'resource.other',

/** Taken from @sentry/core sampling.ts */
function getSampleRate(transactionContext, options) {
if (!hasTracingEnabled(options)) {
return false;
}
let sampleRate;
if (transactionContext !== undefined && typeof options.tracesSampler === 'function') {
sampleRate = options.tracesSampler({
transactionContext,
name: transactionContext.name,
parentSampled: transactionContext.parentSampled,
attributes: {
// eslint-disable-next-line deprecation/deprecation
...transactionContext.data,
...transactionContext.attributes,
},
location: WINDOW.location,
});
} else if (transactionContext !== undefined && transactionContext.sampled !== undefined) {
sampleRate = transactionContext.sampled;
} else if (typeof options.tracesSampleRate !== 'undefined') {
sampleRate = options.tracesSampleRate;
} else {
sampleRate = 1;
}
if (!isValidSampleRate(sampleRate)) {
DEBUG_BUILD && logger.warn('[Tracing] Discarding transaction because of invalid sample rate.');
return false;
}
return sampleRate;
}
export { _addMeasureSpans, _addResourceSpans, _addTtfbToMeasurements, addPerformanceEntries, startTrackingINP, startTrackingInteractions, startTrackingLongTasks, startTrackingWebVitals };
export { _addMeasureSpans, _addResourceSpans, _addTtfbToMeasurements, addPerformanceEntries, startTrackingInteractions, startTrackingLongTasks, startTrackingWebVitals };
//# sourceMappingURL=index.js.map

@@ -5,7 +5,4 @@ import { spanToJSON, hasTracingEnabled, setHttpStatus, getCurrentScope, getIsolationScope, startInactiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getClient, spanToTraceHeader, getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromClient } from '@sentry/core';

import { addPerformanceInstrumentationHandler } from './instrument.js';
import { WINDOW } from './types.js';
/* eslint-disable max-lines */
const DEFAULT_TRACE_PROPAGATION_TARGETS = ['localhost', /^\/(?!\/)/];
/** Options for Request Instrumentation */

@@ -17,5 +14,2 @@

enableHTTPTimings: true,
// TODO (v8): Remove this property
tracingOrigins: DEFAULT_TRACE_PROPAGATION_TARGETS,
tracePropagationTargets: DEFAULT_TRACE_PROPAGATION_TARGETS,
};

@@ -25,12 +19,3 @@

function instrumentOutgoingRequests(_options) {
const {
traceFetch,
traceXHR,
// eslint-disable-next-line deprecation/deprecation
tracePropagationTargets,
// eslint-disable-next-line deprecation/deprecation
tracingOrigins,
shouldCreateSpanForRequest,
enableHTTPTimings,
} = {
const { traceFetch, traceXHR, shouldCreateSpanForRequest, enableHTTPTimings, tracePropagationTargets } = {
traceFetch: defaultRequestInstrumentationOptions.traceFetch,

@@ -44,7 +29,3 @@ traceXHR: defaultRequestInstrumentationOptions.traceXHR,

// TODO(v8) Remove tracingOrigins here
// The only reason we're passing it in here is because this instrumentOutgoingRequests function is publicly exported
// and we don't want to break the API. We can remove it in v8.
const shouldAttachHeadersWithTargets = (url) =>
shouldAttachHeaders(url, tracePropagationTargets || tracingOrigins);
const shouldAttachHeadersWithTargets = (url) => shouldAttachHeaders(url, tracePropagationTargets);

@@ -169,7 +150,44 @@ const spans = {};

* A function that determines whether to attach tracing headers to a request.
* This was extracted from `instrumentOutgoingRequests` to make it easier to test shouldAttachHeaders.
* We only export this fuction for testing purposes.
* We only export this function for testing purposes.
*/
function shouldAttachHeaders(url, tracePropagationTargets) {
return stringMatchesSomePattern(url, tracePropagationTargets || DEFAULT_TRACE_PROPAGATION_TARGETS);
function shouldAttachHeaders(
targetUrl,
tracePropagationTargets,
) {
// window.location.href not being defined is an edge case in the browser but we need to handle it.
// Potentially dangerous situations where it may not be defined: Browser Extensions, Web Workers, patching of the location obj
const href = WINDOW.location && WINDOW.location.href;
if (!href) {
// If there is no window.location.origin, we default to only attaching tracing headers to relative requests, i.e. ones that start with `/`
// BIG DISCLAIMER: Users can call URLs with a double slash (fetch("//example.com/api")), this is a shorthand for "send to the same protocol",
// so we need a to exclude those requests, because they might be cross origin.
const isRelativeSameOriginRequest = !!targetUrl.match(/^\/(?!\/)/);
if (!tracePropagationTargets) {
return isRelativeSameOriginRequest;
} else {
return stringMatchesSomePattern(targetUrl, tracePropagationTargets);
}
} else {
let resolvedUrl;
let currentOrigin;
// URL parsing may fail, we default to not attaching trace headers in that case.
try {
resolvedUrl = new URL(targetUrl, href);
currentOrigin = new URL(href).origin;
} catch (e) {
return false;
}
const isSameOriginRequest = resolvedUrl.origin === currentOrigin;
if (!tracePropagationTargets) {
return isSameOriginRequest;
} else {
return (
stringMatchesSomePattern(resolvedUrl.toString(), tracePropagationTargets) ||
(isSameOriginRequest && stringMatchesSomePattern(resolvedUrl.pathname, tracePropagationTargets))
);
}
}
}

@@ -182,3 +200,2 @@

*/
// eslint-disable-next-line complexity
function xhrCallback(

@@ -248,4 +265,3 @@ handlerData,

const sentryBaggageHeader = dynamicSamplingContextToSentryBaggageHeader(
dsc ||
(span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromClient(traceId, client, scope)),
dsc || (span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromClient(traceId, client)),
);

@@ -279,3 +295,3 @@

export { DEFAULT_TRACE_PROPAGATION_TARGETS, defaultRequestInstrumentationOptions, extractNetworkProtocol, instrumentOutgoingRequests, shouldAttachHeaders, xhrCallback };
export { defaultRequestInstrumentationOptions, extractNetworkProtocol, instrumentOutgoingRequests, shouldAttachHeaders, xhrCallback };
//# sourceMappingURL=request.js.map

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

import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, spanToJSON } from '@sentry/core';
import { logger, browserPerformanceTimeOrigin, addHistoryInstrumentationHandler } from '@sentry/utils';

@@ -28,3 +29,5 @@ import { DEBUG_BUILD } from '../common/debug-build.js';

origin: 'auto.pageload.browser',
metadata: { source: 'url' },
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
},
});

@@ -52,3 +55,4 @@ }

if (activeTransaction) {
DEBUG_BUILD && logger.log(`[Tracing] Finishing current transaction with op: ${activeTransaction.op}`);
DEBUG_BUILD &&
logger.log(`[Tracing] Finishing current transaction with op: ${spanToJSON(activeTransaction).op}`);
// If there's an open transaction on the scope, we need to finish it before creating an new one.

@@ -61,3 +65,5 @@ activeTransaction.end();

origin: 'auto.navigation.browser',
metadata: { source: 'url' },
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
},
});

@@ -64,0 +70,0 @@ }

@@ -5,3 +5,3 @@ import { hasTracingEnabled, setHttpStatus, getCurrentScope, getClient, startInactiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getIsolationScope, spanToTraceHeader, getDynamicSamplingContextFromSpan, getDynamicSamplingContextFromClient } from '@sentry/core';

/**
* Create and track fetch request spans for usage in combination with `addInstrumentationHandler`.
* Create and track fetch request spans for usage in combination with `addFetchInstrumentationHandler`.
*

@@ -117,4 +117,3 @@ * @returns Span if a span was created, otherwise void.

const sentryBaggageHeader = dynamicSamplingContextToSentryBaggageHeader(
dsc ||
(span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromClient(traceId, client, scope)),
dsc || (span ? getDynamicSamplingContextFromSpan(span) : getDynamicSamplingContextFromClient(traceId, client)),
);

@@ -121,0 +120,0 @@

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

export { IdleTransaction, Span, SpanStatus, Transaction, extractTraceparentData, getActiveTransaction, hasTracingEnabled, spanStatusfromHttpCode, startIdleTransaction } from '@sentry/core';
export { IdleTransaction, SpanStatus, Transaction, getActiveTransaction, hasTracingEnabled, startIdleTransaction } from '@sentry/core';
export { TRACEPARENT_REGEXP, stripUrlQueryAndFragment } from '@sentry/utils';

@@ -11,3 +11,3 @@ export { Express } from './node/integrations/express.js';

export { lazyLoadedNodePerformanceMonitoringIntegrations } from './node/integrations/lazy.js';
export { BROWSER_TRACING_INTEGRATION_ID, BrowserTracing } from './browser/browsertracing.js';
export { BROWSER_TRACING_INTEGRATION_ID } from './browser/browsertracing.js';
export { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan } from './browser/browserTracingIntegration.js';

@@ -17,3 +17,2 @@ export { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from './browser/request.js';

export { addTracingHeadersToFetchRequest, instrumentFetchRequest } from './common/fetch.js';
export { addExtensionMethods } from './extensions.js';
//# sourceMappingURL=index.js.map
import { _optionalChain } from '@sentry/utils';
import { loadModule, logger, fill, arrayify, isThenable } from '@sentry/utils';
import { DEBUG_BUILD } from '../../common/debug-build.js';
import { shouldDisableAutoInstrumentation } from './utils/node-utils.js';

@@ -44,7 +43,2 @@ /** Tracing integration for Apollo */

setupOnce(_, getCurrentHub) {
if (shouldDisableAutoInstrumentation(getCurrentHub)) {
DEBUG_BUILD && logger.log('Apollo Integration is skipped because of instrumenter configuration.');
return;
}
if (this._useNest) {

@@ -159,6 +153,6 @@ const pkg = this.loadDependency();

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;
// eslint-disable-next-line deprecation/deprecation
const span = _optionalChain([parentSpan, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({
description: `${resolverGroupName}.${resolverName}`,
name: `${resolverGroupName}.${resolverName}`,
op: 'graphql.resolve',

@@ -165,0 +159,0 @@ origin: 'auto.graphql.apollo',

@@ -5,6 +5,3 @@ import { _optionalChain } from '@sentry/utils';

import { DEBUG_BUILD } from '../../common/debug-build.js';
import { shouldDisableAutoInstrumentation } from './utils/node-utils.js';
/* eslint-disable max-lines */
/**

@@ -41,3 +38,3 @@ * Express integration

*/
setupOnce(_, getCurrentHub) {
setupOnce(_) {
if (!this._router) {

@@ -48,7 +45,2 @@ DEBUG_BUILD && logger.error('ExpressIntegration is missing an Express instance');

if (shouldDisableAutoInstrumentation(getCurrentHub)) {
DEBUG_BUILD && logger.log('Express Integration is skipped because of instrumenter configuration.');
return;
}
instrumentMiddlewares(this._router, this._methods);

@@ -84,3 +76,3 @@ instrumentRouter(this._router );

const span = transaction.startChild({
description: fn.name,
name: fn.name,
op: `middleware.express.${method}`,

@@ -106,3 +98,3 @@ origin: 'auto.middleware.express',

const span = _optionalChain([transaction, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({
description: fn.name,
name: fn.name,
op: `middleware.express.${method}`,

@@ -128,3 +120,3 @@ origin: 'auto.middleware.express',

const span = _optionalChain([transaction, 'optionalAccess', _6 => _6.startChild, 'call', _7 => _7({
description: fn.name,
name: fn.name,
op: `middleware.express.${method}`,

@@ -303,3 +295,3 @@ origin: 'auto.middleware.express',

const attributes = (transaction && spanToJSON(transaction).data) || {};
if (transaction && attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] !== 'custom') {
if (transaction && attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] === 'url') {
// If the request URL is '/' or empty, the reconstructed route will be empty.

@@ -306,0 +298,0 @@ // Therefore, we fall back to setting the final route to '/' in this case.

import { _optionalChain } from '@sentry/utils';
import { loadModule, logger, fill, isThenable } from '@sentry/utils';
import { DEBUG_BUILD } from '../../common/debug-build.js';
import { shouldDisableAutoInstrumentation } from './utils/node-utils.js';

@@ -30,7 +29,2 @@ /** Tracing integration for graphql package */

setupOnce(_, getCurrentHub) {
if (shouldDisableAutoInstrumentation(getCurrentHub)) {
DEBUG_BUILD && logger.log('GraphQL Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = this.loadDependency();

@@ -48,7 +42,7 @@

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;
// eslint-disable-next-line deprecation/deprecation
const span = _optionalChain([parentSpan, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({
description: 'execute',
name: 'execute',
op: 'graphql.execute',

@@ -55,0 +49,0 @@ origin: 'auto.graphql.graphql',

import { _optionalChain } from '@sentry/utils';
import { loadModule, logger, fill, isThenable } from '@sentry/utils';
import { DEBUG_BUILD } from '../../common/debug-build.js';
import { shouldDisableAutoInstrumentation } from './utils/node-utils.js';

@@ -112,7 +111,2 @@ // This allows us to use the same array for both defaults options and the type itself.

setupOnce(_, getCurrentHub) {
if (shouldDisableAutoInstrumentation(getCurrentHub)) {
DEBUG_BUILD && logger.log('Mongo Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = this.loadDependency();

@@ -147,3 +141,2 @@

const lastArg = args[args.length - 1];
// eslint-disable-next-line deprecation/deprecation
const hub = getCurrentHub();

@@ -155,3 +148,3 @@ // eslint-disable-next-line deprecation/deprecation

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;

@@ -225,3 +218,3 @@ const sendDefaultPii = _optionalChain([client, 'optionalAccess', _2 => _2.getOptions, 'call', _3 => _3(), 'access', _4 => _4.sendDefaultPii]);

origin: 'auto.db.mongo',
description: operation,
name: operation,
data,

@@ -228,0 +221,0 @@ };

import { _optionalChain } from '@sentry/utils';
import { loadModule, logger, fill } from '@sentry/utils';
import { DEBUG_BUILD } from '../../common/debug-build.js';
import { shouldDisableAutoInstrumentation } from './utils/node-utils.js';

@@ -30,7 +29,2 @@ /** Tracing integration for node-mysql package */

setupOnce(_, getCurrentHub) {
if (shouldDisableAutoInstrumentation(getCurrentHub)) {
DEBUG_BUILD && logger.log('Mysql Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = this.loadDependency();

@@ -91,7 +85,7 @@

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;
// eslint-disable-next-line deprecation/deprecation
const span = _optionalChain([parentSpan, 'optionalAccess', _2 => _2.startChild, 'call', _3 => _3({
description: typeof options === 'string' ? options : (options ).sql,
name: typeof options === 'string' ? options : (options ).sql,
op: 'db',

@@ -98,0 +92,0 @@ origin: 'auto.db.mysql',

import { _optionalChain } from '@sentry/utils';
import { loadModule, logger, fill, isThenable } from '@sentry/utils';
import { DEBUG_BUILD } from '../../common/debug-build.js';
import { shouldDisableAutoInstrumentation } from './utils/node-utils.js';

@@ -32,7 +31,2 @@ /** Tracing integration for node-postgres package */

setupOnce(_, getCurrentHub) {
if (shouldDisableAutoInstrumentation(getCurrentHub)) {
DEBUG_BUILD && logger.log('Postgres Integration is skipped because of instrumenter configuration.');
return;
}
const pkg = this.loadDependency();

@@ -64,3 +58,3 @@

// eslint-disable-next-line deprecation/deprecation
const parentSpan = scope.getSpan();
const parentSpan = scope.getSpan() ;

@@ -90,3 +84,3 @@ const data = {

const span = _optionalChain([parentSpan, 'optionalAccess', _4 => _4.startChild, 'call', _5 => _5({
description: typeof config === 'string' ? config : (config ).text,
name: typeof config === 'string' ? config : (config ).text,
op: 'db',

@@ -93,0 +87,0 @@ origin: 'auto.db.postgres',

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

import { startSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getCurrentHub } from '@sentry/core';
import { startSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
import { addNonEnumerableProperty, logger } from '@sentry/utils';
import { DEBUG_BUILD } from '../../common/debug-build.js';
import { shouldDisableAutoInstrumentation } from './utils/node-utils.js';

@@ -53,7 +52,2 @@ function isValidPrismaClient(possibleClient) {

options.client.$use((params, next) => {
// eslint-disable-next-line deprecation/deprecation
if (shouldDisableAutoInstrumentation(getCurrentHub)) {
return next(params);
}
const action = params.action;

@@ -60,0 +54,0 @@ const model = params.model;

{
"name": "@sentry-internal/tracing",
"version": "7.105.0",
"version": "8.0.0-alpha.1",
"description": "Sentry Internal Tracing Package",

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

"engines": {
"node": ">=8"
"node": ">=14.8"
},

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

"dependencies": {
"@sentry/core": "7.105.0",
"@sentry/types": "7.105.0",
"@sentry/utils": "7.105.0"
"@sentry/core": "8.0.0-alpha.1",
"@sentry/types": "8.0.0-alpha.1",
"@sentry/utils": "8.0.0-alpha.1"
},

@@ -38,0 +38,0 @@ "devDependencies": {

import { Hub } from '@sentry/core';
import { EventProcessor, Integration, Transaction, TransactionContext } from '@sentry/types';
import { RequestInstrumentationOptions } from './request';
export declare const BROWSER_TRACING_INTEGRATION_ID = "BrowserTracing";
/** Options for Browser Tracing integration */
export interface BrowserTracingOptions extends RequestInstrumentationOptions {
export interface BrowserTracingOptions {
/**

@@ -61,2 +60,20 @@ * The time to wait in ms until the transaction will be finished during an idle state. An idle state is defined

/**
* Flag to disable patching all together for fetch requests.
*
* Default: true
*/
traceFetch: boolean;
/**
* Flag to disable patching all together for xhr requests.
*
* Default: true
*/
traceXHR: boolean;
/**
* If true, Sentry will capture http timings and add them to the corresponding http spans.
*
* Default: true
*/
enableHTTPTimings: boolean;
/**
* _metricOptions allows the user to send options to change how metrics are collected.

@@ -103,2 +120,9 @@ *

routingInstrumentation<T extends Transaction>(this: void, customStartTransaction: (context: TransactionContext) => T | undefined, startTransactionOnPageLoad?: boolean, startTransactionOnLocationChange?: boolean): void;
/**
* This function will be called before creating a span for a request with the given url.
* Return false if you don't want a span for the given url.
*
* Default: (url: string) => true
*/
shouldCreateSpanForRequest?(this: void, url: string): boolean;
}

@@ -125,3 +149,2 @@ /**

private _collectWebVitals;
private _hasSetTracePropagationTargets;
constructor(_options?: Partial<BrowserTracingOptions>);

@@ -128,0 +151,0 @@ /**

import { Client, StartSpanOptions } from '@sentry/types';
import { Span } from '@sentry/types';
import { RequestInstrumentationOptions } from './request';
export declare const BROWSER_TRACING_INTEGRATION_ID = "BrowserTracing";
/** Options for Browser Tracing integration */
export interface BrowserTracingOptions extends RequestInstrumentationOptions {
export interface BrowserTracingOptions {
/**

@@ -61,8 +60,20 @@ * The time to wait in ms until the transaction will be finished during an idle state. An idle state is defined

/**
* If true, Sentry will capture INP web vitals as standalone spans .
* Flag to disable patching all together for fetch requests.
*
* Default: false
* Default: true
*/
enableInp: boolean;
traceFetch: boolean;
/**
* Flag to disable patching all together for xhr requests.
*
* Default: true
*/
traceXHR: boolean;
/**
* If true, Sentry will capture http timings and add them to the corresponding http spans.
*
* Default: true
*/
enableHTTPTimings: boolean;
/**
* _metricOptions allows the user to send options to change how metrics are collected.

@@ -82,6 +93,3 @@ *

* _experiments allows the user to send options to define how this integration works.
* Note that the `enableLongTask` options is deprecated in favor of the option at the top level, and will be removed in v8.
*
* TODO (v8): Remove enableLongTask
*
* Default: undefined

@@ -97,2 +105,9 @@ */

beforeStartSpan?: (options: StartSpanOptions) => StartSpanOptions;
/**
* This function will be called before creating a span for a request with the given url.
* Return false if you don't want a span for the given url.
*
* Default: (url: string) => true
*/
shouldCreateSpanForRequest?(this: void, url: string): boolean;
}

@@ -112,32 +127,6 @@ /**

afterAllSetup(client: Client<import("@sentry/types").ClientOptions<import("@sentry/types").BaseTransportOptions>>): void;
options: {
idleTimeout: number;
finalTimeout: number;
heartbeatInterval: number;
instrumentPageLoad: boolean;
instrumentNavigation: boolean;
markBackgroundSpan: boolean;
enableLongTask: boolean;
enableInp: boolean;
_metricOptions?: Partial<{
/**
* @deprecated This property no longer has any effect and will be removed in v8.
*/
_reportAllChanges: boolean;
}> | undefined;
_experiments: Partial<{
enableInteractions: boolean;
}>;
beforeStartSpan?: ((options: StartSpanOptions) => StartSpanOptions) | undefined;
tracingOrigins: (string | RegExp)[];
tracePropagationTargets: (string | RegExp)[];
traceFetch: boolean;
traceXHR: boolean;
enableHTTPTimings: boolean;
shouldCreateSpanForRequest?: ((this: void, url: string) => boolean) | undefined;
};
};
/**
* Manually start a page load span.
* This will only do something if the BrowserTracing integration has been setup.
* This will only do something if a browser tracing integration integration has been setup.
*/

@@ -147,3 +136,3 @@ export declare function startBrowserTracingPageLoadSpan(client: Client, spanOptions: StartSpanOptions): Span | undefined;

* Manually start a navigation span.
* This will only do something if the BrowserTracing integration has been setup.
* This will only do something if a browser tracing integration has been setup.
*/

@@ -150,0 +139,0 @@ export declare function startBrowserTracingNavigationSpan(client: Client, spanOptions: StartSpanOptions): Span | undefined;

export * from '../exports';
export { RequestInstrumentationOptions } from './request';
export { BrowserTracing, BROWSER_TRACING_INTEGRATION_ID, } from './browsertracing';
export { BROWSER_TRACING_INTEGRATION_ID } from './browsertracing';
export { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan, } from './browserTracingIntegration';

@@ -5,0 +5,0 @@ export { instrumentOutgoingRequests, defaultRequestInstrumentationOptions } from './request';

@@ -9,10 +9,2 @@ type InstrumentHandlerTypePerformanceObserver = 'longtask' | 'event' | 'navigation' | 'paint' | 'resource';

}
interface PerformanceEventTiming extends PerformanceEntry {
processingStart: number;
processingEnd: number;
duration: number;
cancelable?: boolean;
target?: unknown | null;
interactionId?: number;
}
interface Metric {

@@ -90,15 +82,6 @@ /**

}) => void): CleanupHandlerCallback;
/**
* Add a callback that will be triggered when a INP metric is available.
* Returns a cleanup callback which can be called to remove the instrumentation handler.
*/
export declare function addInpInstrumentationHandler(callback: (data: {
metric: Pick<Metric, Exclude<keyof Metric, 'entries'>> & {
entries: PerformanceEventTiming[];
};
}) => void): CleanupHandlerCallback;
export declare function addPerformanceInstrumentationHandler(type: 'event', callback: (data: {
entries: ((PerformanceEntry & {
entries: (PerformanceEntry & {
target?: unknown | null;
}) | PerformanceEventTiming)[];
})[];
}) => void): CleanupHandlerCallback;

@@ -105,0 +88,0 @@ export declare function addPerformanceInstrumentationHandler(type: InstrumentHandlerTypePerformanceObserver, callback: (data: {

import { Transaction } from '@sentry/core';
import { Measurements } from '@sentry/types';
import { InteractionRouteNameMapping } from '../web-vitals/types';
/**

@@ -19,6 +18,2 @@ * Start tracking web vitals.

export declare function startTrackingInteractions(): void;
/**
* Start tracking INP webvital events.
*/
export declare function startTrackingINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping): () => void;
/** Add performance related spans to a transaction */

@@ -25,0 +20,0 @@ export declare function addPerformanceEntries(transaction: Transaction): void;

import { HandlerDataXhr, Span } from '@sentry/types';
export declare const DEFAULT_TRACE_PROPAGATION_TARGETS: (string | RegExp)[];
/** Options for Request Instrumentation */
export interface RequestInstrumentationOptions {
/**
* @deprecated Will be removed in v8.
* Use `shouldCreateSpanForRequest` to control span creation and `tracePropagationTargets` to control
* trace header attachment.
*/
tracingOrigins: Array<string | RegExp>;
/**
* List of strings and/or regexes used to determine which outgoing requests will have `sentry-trace` and `baggage`
* List of strings and/or Regular Expressions used to determine which outgoing requests will have `sentry-trace` and `baggage`
* headers attached.
*
* @deprecated Use the top-level `tracePropagationTargets` option in `Sentry.init` instead.
* This option will be removed in v8.
* **Default:** If this option is not provided, tracing headers will be attached to all outgoing requests.
* If you are using a browser SDK, by default, tracing headers will only be attached to outgoing requests to the same origin.
*
* Default: ['localhost', /^\//] @see {DEFAULT_TRACE_PROPAGATION_TARGETS}
* **Disclaimer:** Carelessly setting this option in browser environments may result into CORS errors!
* Only attach tracing headers to requests to the same origin, or to requests to services you can control CORS headers of.
* Cross-origin requests, meaning requests to a different domain, for example a request to `https://api.example.com/` while you're on `https://example.com/`, take special care.
* If you are attaching headers to cross-origin requests, make sure the backend handling the request returns a `"Access-Control-Allow-Headers: sentry-trace, baggage"` header to ensure your requests aren't blocked.
*
* If you provide a `tracePropagationTargets` array, the entries you provide will be matched against the entire URL of the outgoing request.
* If you are using a browser SDK, the entries will also be matched against the pathname of the outgoing requests.
* This is so you can have matchers for relative requests, for example, `/^\/api/` if you want to trace requests to your `/api` routes on the same domain.
*
* If any of the two match any of the provided values, tracing headers will be attached to the outgoing request.
* Both, the string values, and the RegExes you provide in the array will match if they partially match the URL or pathname.
*
* Examples:
* - `tracePropagationTargets: [/^\/api/]` and request to `https://same-origin.com/api/posts`:
* - Tracing headers will be attached because the request is sent to the same origin and the regex matches the pathname "/api/posts".
* - `tracePropagationTargets: [/^\/api/]` and request to `https://different-origin.com/api/posts`:
* - Tracing headers will not be attached because the pathname will only be compared when the request target lives on the same origin.
* - `tracePropagationTargets: [/^\/api/, 'https://external-api.com']` and request to `https://external-api.com/v1/data`:
* - Tracing headers will be attached because the request URL matches the string `'https://external-api.com'`.
*/
tracePropagationTargets: Array<string | RegExp>;
tracePropagationTargets?: Array<string | RegExp>;
/**

@@ -62,6 +73,5 @@ * Flag to disable patching all together for fetch requests.

* A function that determines whether to attach tracing headers to a request.
* This was extracted from `instrumentOutgoingRequests` to make it easier to test shouldAttachHeaders.
* We only export this fuction for testing purposes.
* We only export this function for testing purposes.
*/
export declare function shouldAttachHeaders(url: string, tracePropagationTargets: (string | RegExp)[] | undefined): boolean;
export declare function shouldAttachHeaders(targetUrl: string, tracePropagationTargets: (string | RegExp)[] | undefined): boolean;
/**

@@ -68,0 +78,0 @@ * Create and track xhr request spans

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

import { Transaction, TransactionContext, User } from '@sentry/types';
import { FirstInputPolyfillCallback } from './types/polyfills';

@@ -89,12 +88,2 @@ export * from './types/base';

}
export type InteractionRouteNameMapping = {
[key: string]: {
routeName: string;
duration: number;
parentContext: TransactionContext;
user?: User;
activeTransaction?: Transaction;
replayId?: string;
};
};
//# sourceMappingURL=types.d.ts.map

@@ -11,3 +11,3 @@ import { Client, HandlerDataFetch, Scope, Span, SpanOrigin } from '@sentry/types';

/**
* Create and track fetch request spans for usage in combination with `addInstrumentationHandler`.
* Create and track fetch request spans for usage in combination with `addFetchInstrumentationHandler`.
*

@@ -14,0 +14,0 @@ * @returns Span if a span was created, otherwise void.

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

export { extractTraceparentData, getActiveTransaction, hasTracingEnabled, IdleTransaction, Span, SpanStatus, spanStatusfromHttpCode, startIdleTransaction, Transaction, } from '@sentry/core';
export { getActiveTransaction, hasTracingEnabled, IdleTransaction, SpanStatus, startIdleTransaction, Transaction, } from '@sentry/core';
export { SpanStatusType } from '@sentry/core';
export { stripUrlQueryAndFragment, TRACEPARENT_REGEXP } from '@sentry/utils';
//# sourceMappingURL=index.d.ts.map
export * from './exports';
export { Apollo, Express, GraphQL, Mongo, Mysql, Postgres, Prisma, lazyLoadedNodePerformanceMonitoringIntegrations, } from './node';
export { LazyLoadedIntegration } from './node';
export { BrowserTracing, browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan, BROWSER_TRACING_INTEGRATION_ID, instrumentOutgoingRequests, defaultRequestInstrumentationOptions, addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addFidInstrumentationHandler, addLcpInstrumentationHandler, } from './browser';
export { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan, BROWSER_TRACING_INTEGRATION_ID, instrumentOutgoingRequests, defaultRequestInstrumentationOptions, addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addFidInstrumentationHandler, addLcpInstrumentationHandler, } from './browser';
export { addTracingHeadersToFetchRequest, instrumentFetchRequest } from './common/fetch';
export { RequestInstrumentationOptions } from './browser';
export { addExtensionMethods } from './extensions';
//# sourceMappingURL=index.d.ts.map

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

import { Hub, Integration, PolymorphicRequest } from '@sentry/types';
import { Integration, PolymorphicRequest } from '@sentry/types';
type Method = 'all' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head' | 'checkout' | 'copy' | 'lock' | 'merge' | 'mkactivity' | 'mkcol' | 'move' | 'm-search' | 'notify' | 'purge' | 'report' | 'search' | 'subscribe' | 'trace' | 'unlock' | 'unsubscribe' | 'use';

@@ -58,3 +58,3 @@ type Router = {

*/
setupOnce(_: unknown, getCurrentHub: () => Hub): void;
setupOnce(_: unknown): void;
}

@@ -61,0 +61,0 @@ /**

import type { Hub } from '@sentry/core';
import type { EventProcessor, Integration, Transaction, TransactionContext } from '@sentry/types';
import type { RequestInstrumentationOptions } from './request';
export declare const BROWSER_TRACING_INTEGRATION_ID = "BrowserTracing";
/** Options for Browser Tracing integration */
export interface BrowserTracingOptions extends RequestInstrumentationOptions {
export interface BrowserTracingOptions {
/**

@@ -61,2 +60,20 @@ * The time to wait in ms until the transaction will be finished during an idle state. An idle state is defined

/**
* Flag to disable patching all together for fetch requests.
*
* Default: true
*/
traceFetch: boolean;
/**
* Flag to disable patching all together for xhr requests.
*
* Default: true
*/
traceXHR: boolean;
/**
* If true, Sentry will capture http timings and add them to the corresponding http spans.
*
* Default: true
*/
enableHTTPTimings: boolean;
/**
* _metricOptions allows the user to send options to change how metrics are collected.

@@ -103,2 +120,9 @@ *

routingInstrumentation<T extends Transaction>(this: void, customStartTransaction: (context: TransactionContext) => T | undefined, startTransactionOnPageLoad?: boolean, startTransactionOnLocationChange?: boolean): void;
/**
* This function will be called before creating a span for a request with the given url.
* Return false if you don't want a span for the given url.
*
* Default: (url: string) => true
*/
shouldCreateSpanForRequest?(this: void, url: string): boolean;
}

@@ -125,3 +149,2 @@ /**

private _collectWebVitals;
private _hasSetTracePropagationTargets;
constructor(_options?: Partial<BrowserTracingOptions>);

@@ -128,0 +151,0 @@ /**

import type { Client, StartSpanOptions } from '@sentry/types';
import type { Span } from '@sentry/types';
import type { RequestInstrumentationOptions } from './request';
export declare const BROWSER_TRACING_INTEGRATION_ID = "BrowserTracing";
/** Options for Browser Tracing integration */
export interface BrowserTracingOptions extends RequestInstrumentationOptions {
export interface BrowserTracingOptions {
/**

@@ -61,8 +60,20 @@ * The time to wait in ms until the transaction will be finished during an idle state. An idle state is defined

/**
* If true, Sentry will capture INP web vitals as standalone spans .
* Flag to disable patching all together for fetch requests.
*
* Default: false
* Default: true
*/
enableInp: boolean;
traceFetch: boolean;
/**
* Flag to disable patching all together for xhr requests.
*
* Default: true
*/
traceXHR: boolean;
/**
* If true, Sentry will capture http timings and add them to the corresponding http spans.
*
* Default: true
*/
enableHTTPTimings: boolean;
/**
* _metricOptions allows the user to send options to change how metrics are collected.

@@ -82,6 +93,3 @@ *

* _experiments allows the user to send options to define how this integration works.
* Note that the `enableLongTask` options is deprecated in favor of the option at the top level, and will be removed in v8.
*
* TODO (v8): Remove enableLongTask
*
* Default: undefined

@@ -97,2 +105,9 @@ */

beforeStartSpan?: (options: StartSpanOptions) => StartSpanOptions;
/**
* This function will be called before creating a span for a request with the given url.
* Return false if you don't want a span for the given url.
*
* Default: (url: string) => true
*/
shouldCreateSpanForRequest?(this: void, url: string): boolean;
}

@@ -112,32 +127,6 @@ /**

afterAllSetup(client: Client<import("@sentry/types").ClientOptions<import("@sentry/types").BaseTransportOptions>>): void;
options: {
idleTimeout: number;
finalTimeout: number;
heartbeatInterval: number;
instrumentPageLoad: boolean;
instrumentNavigation: boolean;
markBackgroundSpan: boolean;
enableLongTask: boolean;
enableInp: boolean;
_metricOptions?: Partial<{
/**
* @deprecated This property no longer has any effect and will be removed in v8.
*/
_reportAllChanges: boolean;
}> | undefined;
_experiments: Partial<{
enableInteractions: boolean;
}>;
beforeStartSpan?: ((options: StartSpanOptions) => StartSpanOptions) | undefined;
tracingOrigins: (string | RegExp)[];
tracePropagationTargets: (string | RegExp)[];
traceFetch: boolean;
traceXHR: boolean;
enableHTTPTimings: boolean;
shouldCreateSpanForRequest?: ((this: void, url: string) => boolean) | undefined;
};
};
/**
* Manually start a page load span.
* This will only do something if the BrowserTracing integration has been setup.
* This will only do something if a browser tracing integration integration has been setup.
*/

@@ -147,3 +136,3 @@ export declare function startBrowserTracingPageLoadSpan(client: Client, spanOptions: StartSpanOptions): Span | undefined;

* Manually start a navigation span.
* This will only do something if the BrowserTracing integration has been setup.
* This will only do something if a browser tracing integration has been setup.
*/

@@ -150,0 +139,0 @@ export declare function startBrowserTracingNavigationSpan(client: Client, spanOptions: StartSpanOptions): Span | undefined;

export * from '../exports';
export type { RequestInstrumentationOptions } from './request';
export { BrowserTracing, BROWSER_TRACING_INTEGRATION_ID, } from './browsertracing';
export { BROWSER_TRACING_INTEGRATION_ID } from './browsertracing';
export { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan, } from './browserTracingIntegration';

@@ -5,0 +5,0 @@ export { instrumentOutgoingRequests, defaultRequestInstrumentationOptions } from './request';

@@ -9,10 +9,2 @@ type InstrumentHandlerTypePerformanceObserver = 'longtask' | 'event' | 'navigation' | 'paint' | 'resource';

}
interface PerformanceEventTiming extends PerformanceEntry {
processingStart: number;
processingEnd: number;
duration: number;
cancelable?: boolean;
target?: unknown | null;
interactionId?: number;
}
interface Metric {

@@ -90,15 +82,6 @@ /**

}) => void): CleanupHandlerCallback;
/**
* Add a callback that will be triggered when a INP metric is available.
* Returns a cleanup callback which can be called to remove the instrumentation handler.
*/
export declare function addInpInstrumentationHandler(callback: (data: {
metric: Omit<Metric, 'entries'> & {
entries: PerformanceEventTiming[];
};
}) => void): CleanupHandlerCallback;
export declare function addPerformanceInstrumentationHandler(type: 'event', callback: (data: {
entries: ((PerformanceEntry & {
entries: (PerformanceEntry & {
target?: unknown | null;
}) | PerformanceEventTiming)[];
})[];
}) => void): CleanupHandlerCallback;

@@ -105,0 +88,0 @@ export declare function addPerformanceInstrumentationHandler(type: InstrumentHandlerTypePerformanceObserver, callback: (data: {

import type { Transaction } from '@sentry/core';
import type { Measurements } from '@sentry/types';
import type { InteractionRouteNameMapping } from '../web-vitals/types';
/**

@@ -19,6 +18,2 @@ * Start tracking web vitals.

export declare function startTrackingInteractions(): void;
/**
* Start tracking INP webvital events.
*/
export declare function startTrackingINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping): () => void;
/** Add performance related spans to a transaction */

@@ -25,0 +20,0 @@ export declare function addPerformanceEntries(transaction: Transaction): void;

import type { HandlerDataXhr, Span } from '@sentry/types';
export declare const DEFAULT_TRACE_PROPAGATION_TARGETS: (string | RegExp)[];
/** Options for Request Instrumentation */
export interface RequestInstrumentationOptions {
/**
* @deprecated Will be removed in v8.
* Use `shouldCreateSpanForRequest` to control span creation and `tracePropagationTargets` to control
* trace header attachment.
*/
tracingOrigins: Array<string | RegExp>;
/**
* List of strings and/or regexes used to determine which outgoing requests will have `sentry-trace` and `baggage`
* List of strings and/or Regular Expressions used to determine which outgoing requests will have `sentry-trace` and `baggage`
* headers attached.
*
* @deprecated Use the top-level `tracePropagationTargets` option in `Sentry.init` instead.
* This option will be removed in v8.
* **Default:** If this option is not provided, tracing headers will be attached to all outgoing requests.
* If you are using a browser SDK, by default, tracing headers will only be attached to outgoing requests to the same origin.
*
* Default: ['localhost', /^\//] @see {DEFAULT_TRACE_PROPAGATION_TARGETS}
* **Disclaimer:** Carelessly setting this option in browser environments may result into CORS errors!
* Only attach tracing headers to requests to the same origin, or to requests to services you can control CORS headers of.
* Cross-origin requests, meaning requests to a different domain, for example a request to `https://api.example.com/` while you're on `https://example.com/`, take special care.
* If you are attaching headers to cross-origin requests, make sure the backend handling the request returns a `"Access-Control-Allow-Headers: sentry-trace, baggage"` header to ensure your requests aren't blocked.
*
* If you provide a `tracePropagationTargets` array, the entries you provide will be matched against the entire URL of the outgoing request.
* If you are using a browser SDK, the entries will also be matched against the pathname of the outgoing requests.
* This is so you can have matchers for relative requests, for example, `/^\/api/` if you want to trace requests to your `/api` routes on the same domain.
*
* If any of the two match any of the provided values, tracing headers will be attached to the outgoing request.
* Both, the string values, and the RegExes you provide in the array will match if they partially match the URL or pathname.
*
* Examples:
* - `tracePropagationTargets: [/^\/api/]` and request to `https://same-origin.com/api/posts`:
* - Tracing headers will be attached because the request is sent to the same origin and the regex matches the pathname "/api/posts".
* - `tracePropagationTargets: [/^\/api/]` and request to `https://different-origin.com/api/posts`:
* - Tracing headers will not be attached because the pathname will only be compared when the request target lives on the same origin.
* - `tracePropagationTargets: [/^\/api/, 'https://external-api.com']` and request to `https://external-api.com/v1/data`:
* - Tracing headers will be attached because the request URL matches the string `'https://external-api.com'`.
*/
tracePropagationTargets: Array<string | RegExp>;
tracePropagationTargets?: Array<string | RegExp>;
/**

@@ -62,6 +73,5 @@ * Flag to disable patching all together for fetch requests.

* A function that determines whether to attach tracing headers to a request.
* This was extracted from `instrumentOutgoingRequests` to make it easier to test shouldAttachHeaders.
* We only export this fuction for testing purposes.
* We only export this function for testing purposes.
*/
export declare function shouldAttachHeaders(url: string, tracePropagationTargets: (string | RegExp)[] | undefined): boolean;
export declare function shouldAttachHeaders(targetUrl: string, tracePropagationTargets: (string | RegExp)[] | undefined): boolean;
/**

@@ -68,0 +78,0 @@ * Create and track xhr request spans

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

import type { Transaction, TransactionContext, User } from '@sentry/types';
import type { FirstInputPolyfillCallback } from './types/polyfills';

@@ -89,12 +88,2 @@ export * from './types/base';

}
export type InteractionRouteNameMapping = {
[key: string]: {
routeName: string;
duration: number;
parentContext: TransactionContext;
user?: User;
activeTransaction?: Transaction;
replayId?: string;
};
};
//# sourceMappingURL=types.d.ts.map

@@ -8,3 +8,3 @@ import type { Client, HandlerDataFetch, Scope, Span, SpanOrigin } from '@sentry/types';

/**
* Create and track fetch request spans for usage in combination with `addInstrumentationHandler`.
* Create and track fetch request spans for usage in combination with `addFetchInstrumentationHandler`.
*

@@ -11,0 +11,0 @@ * @returns Span if a span was created, otherwise void.

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

export { extractTraceparentData, getActiveTransaction, hasTracingEnabled, IdleTransaction, Span, SpanStatus, spanStatusfromHttpCode, startIdleTransaction, Transaction, } from '@sentry/core';
export { getActiveTransaction, hasTracingEnabled, IdleTransaction, SpanStatus, startIdleTransaction, Transaction, } from '@sentry/core';
export type { SpanStatusType } from '@sentry/core';
export { stripUrlQueryAndFragment, TRACEPARENT_REGEXP } from '@sentry/utils';
//# sourceMappingURL=index.d.ts.map
export * from './exports';
export { Apollo, Express, GraphQL, Mongo, Mysql, Postgres, Prisma, lazyLoadedNodePerformanceMonitoringIntegrations, } from './node';
export type { LazyLoadedIntegration } from './node';
export { BrowserTracing, browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan, BROWSER_TRACING_INTEGRATION_ID, instrumentOutgoingRequests, defaultRequestInstrumentationOptions, addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addFidInstrumentationHandler, addLcpInstrumentationHandler, } from './browser';
export { browserTracingIntegration, startBrowserTracingNavigationSpan, startBrowserTracingPageLoadSpan, BROWSER_TRACING_INTEGRATION_ID, instrumentOutgoingRequests, defaultRequestInstrumentationOptions, addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addFidInstrumentationHandler, addLcpInstrumentationHandler, } from './browser';
export { addTracingHeadersToFetchRequest, instrumentFetchRequest } from './common/fetch';
export type { RequestInstrumentationOptions } from './browser';
export { addExtensionMethods } from './extensions';
//# sourceMappingURL=index.d.ts.map

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

import type { Hub, Integration, PolymorphicRequest } from '@sentry/types';
import type { Integration, PolymorphicRequest } from '@sentry/types';
type Method = 'all' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head' | 'checkout' | 'copy' | 'lock' | 'merge' | 'mkactivity' | 'mkcol' | 'move' | 'm-search' | 'notify' | 'purge' | 'report' | 'search' | 'subscribe' | 'trace' | 'unlock' | 'unsubscribe' | 'use';

@@ -58,3 +58,3 @@ type Router = {

*/
setupOnce(_: unknown, getCurrentHub: () => Hub): void;
setupOnce(_: unknown): void;
}

@@ -61,0 +61,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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