@sentry-internal/tracing
Advanced tools
Comparing version 7.103.0 to 7.104.0
@@ -7,2 +7,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
const backgroundtab = require('./backgroundtab.js'); | ||
const instrument = require('./instrument.js'); | ||
const index = require('./metrics/index.js'); | ||
@@ -22,2 +23,3 @@ const request = require('./request.js'); | ||
enableLongTask: true, | ||
enableInp: false, | ||
_experiments: {}, | ||
@@ -62,2 +64,8 @@ ...request.defaultRequestInstrumentationOptions, | ||
/** Stores a mapping of interactionIds from PerformanceEventTimings to the origin interaction path */ | ||
const interactionIdtoRouteNameMapping = {}; | ||
if (options.enableInp) { | ||
index.startTrackingINP(interactionIdtoRouteNameMapping); | ||
} | ||
if (options.enableLongTask) { | ||
@@ -70,5 +78,7 @@ index.startTrackingLongTasks(); | ||
const latestRoute = { | ||
const latestRoute | ||
= { | ||
name: undefined, | ||
source: undefined, | ||
context: undefined, | ||
}; | ||
@@ -121,3 +131,3 @@ | ||
latestRoute.name = finalContext.name; | ||
latestRoute.source = getSource(finalContext); | ||
latestRoute.context = finalContext; | ||
@@ -273,2 +283,6 @@ if (finalContext.sampled === false) { | ||
if (options.enableInp) { | ||
registerInpInteractionListener(interactionIdtoRouteNameMapping, latestRoute); | ||
} | ||
request.instrumentOutgoingRequests({ | ||
@@ -333,3 +347,5 @@ traceFetch, | ||
options, | ||
latestRoute, | ||
latestRoute | ||
, | ||
) { | ||
@@ -369,3 +385,3 @@ let inflightInteractionTransaction; | ||
data: { | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.source || 'url', | ||
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.context ? getSource(latestRoute.context) : 'url', | ||
}, | ||
@@ -391,2 +407,65 @@ }; | ||
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) { | ||
@@ -393,0 +472,0 @@ const sourceFromAttributes = context.attributes && context.attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]; |
@@ -7,2 +7,3 @@ 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'); | ||
@@ -17,2 +18,3 @@ const observe = require('./web-vitals/lib/observe.js'); | ||
let _previousLcp; | ||
let _previousInp; | ||
@@ -56,2 +58,12 @@ /** | ||
/** | ||
* 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, | ||
@@ -123,2 +135,11 @@ * and receives the entries of the observer. | ||
function instrumentInp() { | ||
return getINP.onINP(metric => { | ||
triggerHandlers('inp', { | ||
metric, | ||
}); | ||
_previousInp = metric; | ||
}); | ||
} | ||
function addMetricObserver( | ||
@@ -195,4 +216,5 @@ type, | ||
exports.addFidInstrumentationHandler = addFidInstrumentationHandler; | ||
exports.addInpInstrumentationHandler = addInpInstrumentationHandler; | ||
exports.addLcpInstrumentationHandler = addLcpInstrumentationHandler; | ||
exports.addPerformanceInstrumentationHandler = addPerformanceInstrumentationHandler; | ||
//# sourceMappingURL=instrument.js.map |
@@ -121,2 +121,18 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/** | ||
* 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. */ | ||
@@ -166,2 +182,65 @@ 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 */ | ||
@@ -557,2 +636,34 @@ function addPerformanceEntries(transaction) { | ||
/** 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; | ||
@@ -562,2 +673,3 @@ exports._addResourceSpans = _addResourceSpans; | ||
exports.addPerformanceEntries = addPerformanceEntries; | ||
exports.startTrackingINP = startTrackingINP; | ||
exports.startTrackingInteractions = startTrackingInteractions; | ||
@@ -564,0 +676,0 @@ exports.startTrackingLongTasks = startTrackingLongTasks; |
@@ -1,6 +0,7 @@ | ||
import { TRACING_DEFAULTS, addTracingExtensions, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getActiveSpan, getCurrentHub, startIdleTransaction, getActiveTransaction } from '@sentry/core'; | ||
import { TRACING_DEFAULTS, addTracingExtensions, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getActiveSpan, getCurrentHub, startIdleTransaction, getActiveTransaction, getClient, getCurrentScope } 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 { startTrackingWebVitals, startTrackingLongTasks, startTrackingInteractions, addPerformanceEntries } from './metrics/index.js'; | ||
import { addPerformanceInstrumentationHandler } from './instrument.js'; | ||
import { startTrackingWebVitals, startTrackingINP, startTrackingLongTasks, startTrackingInteractions, addPerformanceEntries } from './metrics/index.js'; | ||
import { defaultRequestInstrumentationOptions, instrumentOutgoingRequests } from './request.js'; | ||
@@ -19,2 +20,3 @@ import { WINDOW } from './types.js'; | ||
enableLongTask: true, | ||
enableInp: false, | ||
_experiments: {}, | ||
@@ -59,2 +61,8 @@ ...defaultRequestInstrumentationOptions, | ||
/** Stores a mapping of interactionIds from PerformanceEventTimings to the origin interaction path */ | ||
const interactionIdtoRouteNameMapping = {}; | ||
if (options.enableInp) { | ||
startTrackingINP(interactionIdtoRouteNameMapping); | ||
} | ||
if (options.enableLongTask) { | ||
@@ -67,5 +75,7 @@ startTrackingLongTasks(); | ||
const latestRoute = { | ||
const latestRoute | ||
= { | ||
name: undefined, | ||
source: undefined, | ||
context: undefined, | ||
}; | ||
@@ -118,3 +128,3 @@ | ||
latestRoute.name = finalContext.name; | ||
latestRoute.source = getSource(finalContext); | ||
latestRoute.context = finalContext; | ||
@@ -270,2 +280,6 @@ if (finalContext.sampled === false) { | ||
if (options.enableInp) { | ||
registerInpInteractionListener(interactionIdtoRouteNameMapping, latestRoute); | ||
} | ||
instrumentOutgoingRequests({ | ||
@@ -330,3 +344,5 @@ traceFetch, | ||
options, | ||
latestRoute, | ||
latestRoute | ||
, | ||
) { | ||
@@ -366,3 +382,3 @@ let inflightInteractionTransaction; | ||
data: { | ||
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.source || 'url', | ||
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.context ? getSource(latestRoute.context) : 'url', | ||
}, | ||
@@ -388,2 +404,65 @@ }; | ||
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) { | ||
@@ -390,0 +469,0 @@ const sourceFromAttributes = context.attributes && context.attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]; |
@@ -5,2 +5,3 @@ 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'; | ||
@@ -15,2 +16,3 @@ import { observe } from './web-vitals/lib/observe.js'; | ||
let _previousLcp; | ||
let _previousInp; | ||
@@ -54,2 +56,12 @@ /** | ||
/** | ||
* 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, | ||
@@ -121,2 +133,11 @@ * and receives the entries of the observer. | ||
function instrumentInp() { | ||
return onINP(metric => { | ||
triggerHandlers('inp', { | ||
metric, | ||
}); | ||
_previousInp = metric; | ||
}); | ||
} | ||
function addMetricObserver( | ||
@@ -191,3 +212,3 @@ type, | ||
export { addClsInstrumentationHandler, addFidInstrumentationHandler, addLcpInstrumentationHandler, addPerformanceInstrumentationHandler }; | ||
export { addClsInstrumentationHandler, addFidInstrumentationHandler, addInpInstrumentationHandler, addLcpInstrumentationHandler, addPerformanceInstrumentationHandler }; | ||
//# sourceMappingURL=instrument.js.map |
@@ -1,5 +0,5 @@ | ||
import { getActiveTransaction, spanToJSON, setMeasurement } from '@sentry/core'; | ||
import { getActiveTransaction, spanToJSON, setMeasurement, getClient, Span, createSpanEnvelope, hasTracingEnabled, isValidSampleRate } 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 } from '../instrument.js'; | ||
import { addPerformanceInstrumentationHandler, addClsInstrumentationHandler, addLcpInstrumentationHandler, addFidInstrumentationHandler, addInpInstrumentationHandler } from '../instrument.js'; | ||
import { WINDOW } from '../types.js'; | ||
@@ -119,2 +119,18 @@ import { getVisibilityWatcher } from '../web-vitals/lib/getVisibilityWatcher.js'; | ||
/** | ||
* 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. */ | ||
@@ -164,2 +180,65 @@ 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 */ | ||
@@ -555,3 +634,35 @@ function addPerformanceEntries(transaction) { | ||
export { _addMeasureSpans, _addResourceSpans, _addTtfbToMeasurements, addPerformanceEntries, startTrackingInteractions, startTrackingLongTasks, startTrackingWebVitals }; | ||
/** 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 }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@sentry-internal/tracing", | ||
"version": "7.103.0", | ||
"version": "7.104.0", | ||
"description": "Sentry Internal Tracing Package", | ||
@@ -32,5 +32,5 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/core": "7.103.0", | ||
"@sentry/types": "7.103.0", | ||
"@sentry/utils": "7.103.0" | ||
"@sentry/core": "7.104.0", | ||
"@sentry/types": "7.104.0", | ||
"@sentry/utils": "7.104.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
@@ -61,2 +61,8 @@ import { Client, StartSpanOptions } from '@sentry/types'; | ||
/** | ||
* If true, Sentry will capture INP web vitals as standalone spans . | ||
* | ||
* Default: false | ||
*/ | ||
enableInp: boolean; | ||
/** | ||
* _metricOptions allows the user to send options to change how metrics are collected. | ||
@@ -112,2 +118,3 @@ * | ||
enableLongTask: boolean; | ||
enableInp: boolean; | ||
_metricOptions?: Partial<{ | ||
@@ -114,0 +121,0 @@ /** |
@@ -9,2 +9,10 @@ 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 { | ||
@@ -82,6 +90,15 @@ /** | ||
}) => 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; | ||
@@ -88,0 +105,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'; | ||
/** | ||
@@ -18,2 +19,6 @@ * 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 */ | ||
@@ -20,0 +25,0 @@ export declare function addPerformanceEntries(transaction: Transaction): void; |
@@ -0,1 +1,2 @@ | ||
import { Transaction, TransactionContext, User } from '@sentry/types'; | ||
import { FirstInputPolyfillCallback } from './types/polyfills'; | ||
@@ -88,2 +89,12 @@ 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 |
@@ -61,2 +61,8 @@ import type { Client, StartSpanOptions } from '@sentry/types'; | ||
/** | ||
* If true, Sentry will capture INP web vitals as standalone spans . | ||
* | ||
* Default: false | ||
*/ | ||
enableInp: boolean; | ||
/** | ||
* _metricOptions allows the user to send options to change how metrics are collected. | ||
@@ -112,2 +118,3 @@ * | ||
enableLongTask: boolean; | ||
enableInp: boolean; | ||
_metricOptions?: Partial<{ | ||
@@ -114,0 +121,0 @@ /** |
@@ -9,2 +9,10 @@ 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 { | ||
@@ -82,6 +90,15 @@ /** | ||
}) => 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; | ||
@@ -88,0 +105,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'; | ||
/** | ||
@@ -18,2 +19,6 @@ * 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 */ | ||
@@ -20,0 +25,0 @@ export declare function addPerformanceEntries(transaction: Transaction): void; |
@@ -0,1 +1,2 @@ | ||
import type { Transaction, TransactionContext, User } from '@sentry/types'; | ||
import type { FirstInputPolyfillCallback } from './types/polyfills'; | ||
@@ -88,2 +89,12 @@ 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 |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
1304959
281
11152
19
+ Added@sentry/core@7.104.0(transitive)
+ Added@sentry/types@7.104.0(transitive)
+ Added@sentry/utils@7.104.0(transitive)
- Removed@sentry/core@7.103.0(transitive)
- Removed@sentry/types@7.103.0(transitive)
- Removed@sentry/utils@7.103.0(transitive)
Updated@sentry/core@7.104.0
Updated@sentry/types@7.104.0
Updated@sentry/utils@7.104.0