From 84a6021ab4f31be2df93e2b14603345d8245d450 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Mon, 19 Feb 2024 11:33:53 -0500 Subject: [PATCH 1/8] Adds sampling rate to inp spans --- .../src/browser/browserTracingIntegration.ts | 30 +++++-- .../src/browser/metrics/index.ts | 78 +++++++++++++++---- .../src/browser/web-vitals/types.ts | 5 +- 3 files changed, 91 insertions(+), 22 deletions(-) diff --git a/packages/tracing-internal/src/browser/browserTracingIntegration.ts b/packages/tracing-internal/src/browser/browserTracingIntegration.ts index 1bd706c49106..44870db9e7c5 100644 --- a/packages/tracing-internal/src/browser/browserTracingIntegration.ts +++ b/packages/tracing-internal/src/browser/browserTracingIntegration.ts @@ -198,9 +198,12 @@ export const browserTracingIntegration = ((_options: Partial { @@ -497,7 +503,7 @@ function registerInteractionListener( op, trimEnd: true, data: { - [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.source || 'url', + [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: latestRoute.context ? getSource(latestRoute.context) : undefined || 'url', }, }; @@ -527,7 +533,10 @@ const MAX_INTERACTIONS = 10; /** Creates a listener on interaction entries, and maps interactionIds to the origin path of the interaction */ function registerInpInteractionListener( interactionIdtoRouteNameMapping: InteractionRouteNameMapping, - latestRoute: { name: string | undefined; source: TransactionSource | undefined }, + latestRoute: { + name: string | undefined; + context: TransactionContext | undefined; + }, ): void { addPerformanceInstrumentationHandler('event', ({ entries }) => { for (const entry of entries) { @@ -545,12 +554,17 @@ function registerInpInteractionListener( if (minInteractionId === undefined || duration > interactionIdtoRouteNameMapping[minInteractionId].duration) { const interactionId = entry.interactionId; const routeName = latestRoute.name; - if (interactionId && routeName) { + 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 }; + interactionIdtoRouteNameMapping[interactionId] = { + routeName, + duration, + parentContext, + }; } } } diff --git a/packages/tracing-internal/src/browser/metrics/index.ts b/packages/tracing-internal/src/browser/metrics/index.ts index 31106260dac1..df5f757e4ce7 100644 --- a/packages/tracing-internal/src/browser/metrics/index.ts +++ b/packages/tracing-internal/src/browser/metrics/index.ts @@ -1,7 +1,15 @@ /* eslint-disable max-lines */ import type { IdleTransaction, Transaction } from '@sentry/core'; -import { SEMANTIC_ATTRIBUTE_MEASUREMENTS, Span, getActiveTransaction, getClient, setMeasurement } from '@sentry/core'; -import type { Measurements, SpanContext } from '@sentry/types'; +import { + SEMANTIC_ATTRIBUTE_MEASUREMENTS, + Span, + getActiveTransaction, + getClient, + hasTracingEnabled, + isValidSampleRate, + setMeasurement, +} from '@sentry/core'; +import type { ClientOptions, Measurements, SpanContext, TransactionContext } from '@sentry/types'; import { browserPerformanceTimeOrigin, getComponentName, htmlTreeAsString, logger, parseUrl } from '@sentry/utils'; import { spanToJSON } from '@sentry/core'; @@ -202,12 +210,14 @@ function _trackINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping) if (!entry || !client) { return; } - const { release, environment } = client.getOptions(); + const options = client.getOptions(); /** Build the INP span, create an envelope from the span, and then send the envelope */ const startTime = msToSec((browserPerformanceTimeOrigin as number) + entry.startTime); const duration = msToSec(metric.value); - const routeName = - entry.interactionId !== undefined ? interactionIdtoRouteNameMapping[entry.interactionId].routeName : undefined; + const { routeName, parentContext } = + entry.interactionId !== undefined + ? interactionIdtoRouteNameMapping[entry.interactionId] + : { routeName: undefined, parentContext: undefined }; const span = new Span({ startTimestamp: startTime, endTimestamp: startTime + duration, @@ -217,18 +227,28 @@ function _trackINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping) [SEMANTIC_ATTRIBUTE_MEASUREMENTS]: { inp: { value: metric.value, unit: 'millisecond' }, }, - release, - environment, + release: options.release, + environment: options.environment, transaction: routeName, }, exclusiveTime: metric.value, }); - 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); - }); + + /** Check to see if the span should be sampled */ + const sampleRate = getSampleRate(parentContext, options); + if (!sampleRate) { + return; + } + + if (Math.random() < (sampleRate as number | boolean)) { + 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; } }); } @@ -631,3 +651,35 @@ export function _addTtfbToMeasurements( } } } + +/** Taken from @sentry/core sampling.ts */ +function getSampleRate(transactionContext: TransactionContext | undefined, options: ClientOptions): number | boolean { + 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?.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; +} diff --git a/packages/tracing-internal/src/browser/web-vitals/types.ts b/packages/tracing-internal/src/browser/web-vitals/types.ts index fd4a31311074..1f7d344401f6 100644 --- a/packages/tracing-internal/src/browser/web-vitals/types.ts +++ b/packages/tracing-internal/src/browser/web-vitals/types.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import type { TransactionContext } from '@sentry/types'; import type { FirstInputPolyfillCallback } from './types/polyfills'; export * from './types/base'; @@ -163,4 +164,6 @@ declare global { } } -export type InteractionRouteNameMapping = { [key: string]: { routeName: string; duration: number } }; +export type InteractionRouteNameMapping = { + [key: string]: { routeName: string; duration: number; parentContext: TransactionContext }; +}; From 6bd6ff8845e1e8afc5af0351e3353ce779e422a0 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Mon, 19 Feb 2024 11:34:26 -0500 Subject: [PATCH 2/8] export isValidSampleRate --- packages/core/src/tracing/index.ts | 1 + packages/core/src/tracing/sampling.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/src/tracing/index.ts b/packages/core/src/tracing/index.ts index d1e1c7f65b44..998a73147822 100644 --- a/packages/core/src/tracing/index.ts +++ b/packages/core/src/tracing/index.ts @@ -27,3 +27,4 @@ export { } from './trace'; export { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan } from './dynamicSamplingContext'; export { setMeasurement } from './measurement'; +export { isValidSampleRate } from './sampling'; diff --git a/packages/core/src/tracing/sampling.ts b/packages/core/src/tracing/sampling.ts index 427a7076d6d0..4b1bbef47d9d 100644 --- a/packages/core/src/tracing/sampling.ts +++ b/packages/core/src/tracing/sampling.ts @@ -103,7 +103,7 @@ export function sampleTransaction( /** * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1). */ -function isValidSampleRate(rate: unknown): boolean { +export function isValidSampleRate(rate: unknown): boolean { // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck // eslint-disable-next-line @typescript-eslint/no-explicit-any if (isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) { From 0559eabb3e0448f1c6e75bb46cdb08f923917ef9 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Wed, 28 Feb 2024 10:46:54 -0500 Subject: [PATCH 3/8] Adds profile id, replay id, and user to standalone INP spans if they exist --- packages/core/src/tracing/transaction.ts | 10 ++++++++++ .../src/browser/browserTracingIntegration.ts | 15 ++++++++++++++- .../src/browser/metrics/index.ts | 17 +++++++++++++++-- .../src/browser/web-vitals/types.ts | 11 +++++++++-- packages/types/src/transaction.ts | 6 ++++++ 5 files changed, 54 insertions(+), 5 deletions(-) diff --git a/packages/core/src/tracing/transaction.ts b/packages/core/src/tracing/transaction.ts index a399137d1301..ee2b478e35a9 100644 --- a/packages/core/src/tracing/transaction.ts +++ b/packages/core/src/tracing/transaction.ts @@ -258,6 +258,16 @@ export class Transaction extends SpanClass implements TransactionInterface { this._hub = hub; } + /** + * Get the profile id of the transaction. + */ + public getProfileId(): string | undefined { + if (this._contexts !== undefined && this._contexts['profile'] !== undefined) { + return this._contexts['profile'].profile_id as string; + } + return undefined; + } + /** * Finish the transaction & prepare the event to send to Sentry. */ diff --git a/packages/tracing-internal/src/browser/browserTracingIntegration.ts b/packages/tracing-internal/src/browser/browserTracingIntegration.ts index 24644569d071..11795a15a666 100644 --- a/packages/tracing-internal/src/browser/browserTracingIntegration.ts +++ b/packages/tracing-internal/src/browser/browserTracingIntegration.ts @@ -1,6 +1,6 @@ /* eslint-disable max-lines */ import type { IdleTransaction } from '@sentry/core'; -import { getActiveSpan } from '@sentry/core'; +import { getActiveSpan, getClient, getCurrentScope } from '@sentry/core'; import { getCurrentHub } from '@sentry/core'; import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, @@ -12,6 +12,7 @@ import { } from '@sentry/core'; import type { Client, + Integration, IntegrationFn, StartSpanOptions, Transaction, @@ -539,6 +540,15 @@ function registerInpInteractionListener( }, ): void { 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?.getIntegrationByName?.('Replay') as + | (Integration & { getReplayId: () => string }) + | undefined; + // eslint-disable-next-line deprecation/deprecation + const activeTransaction = getActiveTransaction(); + const user = getCurrentScope()?.getUser(); for (const entry of entries) { if (isPerformanceEventTiming(entry)) { const duration = entry.duration; @@ -564,6 +574,9 @@ function registerInpInteractionListener( routeName, duration, parentContext, + user, + activeTransaction, + replay, }; } } diff --git a/packages/tracing-internal/src/browser/metrics/index.ts b/packages/tracing-internal/src/browser/metrics/index.ts index 5a8144e2af6d..aaf73442129e 100644 --- a/packages/tracing-internal/src/browser/metrics/index.ts +++ b/packages/tracing-internal/src/browser/metrics/index.ts @@ -214,10 +214,20 @@ function _trackINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping) /** Build the INP span, create an envelope from the span, and then send the envelope */ const startTime = msToSec((browserPerformanceTimeOrigin as number) + entry.startTime); const duration = msToSec(metric.value); - const { routeName, parentContext } = + const { routeName, parentContext, activeTransaction, user, replay } = entry.interactionId !== undefined ? interactionIdtoRouteNameMapping[entry.interactionId] - : { routeName: undefined, parentContext: undefined }; + : { + routeName: undefined, + parentContext: undefined, + activeTransaction: undefined, + user: undefined, + replay: undefined, + }; + // eslint-disable-next-line deprecation/deprecation + const userDisplay = user?.email || user?.id || user?.ip_address; + const profileId = activeTransaction?.getProfileId(); + const replayId = replay?.getReplayId(); const span = new Span({ startTimestamp: startTime, endTimestamp: startTime + duration, @@ -231,6 +241,9 @@ function _trackINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping) environment: options.environment, transaction: routeName, exclusive_time: metric.value, + ...(userDisplay !== undefined && userDisplay !== '' ? { user: userDisplay } : {}), + ...(profileId !== undefined ? { profile_id: profileId } : {}), + ...(replayId !== undefined ? { replay_id: replayId } : {}), }, }); diff --git a/packages/tracing-internal/src/browser/web-vitals/types.ts b/packages/tracing-internal/src/browser/web-vitals/types.ts index 1f7d344401f6..1e994b455f9a 100644 --- a/packages/tracing-internal/src/browser/web-vitals/types.ts +++ b/packages/tracing-internal/src/browser/web-vitals/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import type { TransactionContext } from '@sentry/types'; +import type { Integration, Transaction, TransactionContext, User } from '@sentry/types'; import type { FirstInputPolyfillCallback } from './types/polyfills'; export * from './types/base'; @@ -165,5 +165,12 @@ declare global { } export type InteractionRouteNameMapping = { - [key: string]: { routeName: string; duration: number; parentContext: TransactionContext }; + [key: string]: { + routeName: string; + duration: number; + parentContext: TransactionContext; + user?: User; + activeTransaction?: Transaction; + replay?: Integration & { getReplayId: () => string }; + }; }; diff --git a/packages/types/src/transaction.ts b/packages/types/src/transaction.ts index fbcf8b38f02d..caae6c49027d 100644 --- a/packages/types/src/transaction.ts +++ b/packages/types/src/transaction.ts @@ -152,6 +152,12 @@ export interface Transaction extends TransactionContext, Omit; + + /** + * Get the profile id from the transaction + * @deprecated Use `toJSON()` or access the fields directly instead. + */ + getProfileId(): string | undefined; } /** From bbdc8f032a64baa8be61cac87f5b8a9eb2986c9f Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Wed, 28 Feb 2024 17:39:12 -0500 Subject: [PATCH 4/8] pull profile id from attributes into top level because relay expects this --- packages/core/src/semanticAttributes.ts | 5 +++++ packages/core/src/tracing/span.ts | 2 ++ 2 files changed, 7 insertions(+) diff --git a/packages/core/src/semanticAttributes.ts b/packages/core/src/semanticAttributes.ts index 2cb2c59f473c..f595ef1aa39d 100644 --- a/packages/core/src/semanticAttributes.ts +++ b/packages/core/src/semanticAttributes.ts @@ -24,3 +24,8 @@ export const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin'; * Use this attribute to represent measurements of a span. */ export const SEMANTIC_ATTRIBUTE_MEASUREMENTS = 'measurements'; + +/** + * The id of the profile that this span occured in. + */ +export const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'profile_id'; diff --git a/packages/core/src/tracing/span.ts b/packages/core/src/tracing/span.ts index ca2c1f06cb57..2b18f38bbb18 100644 --- a/packages/core/src/tracing/span.ts +++ b/packages/core/src/tracing/span.ts @@ -20,6 +20,7 @@ import { DEBUG_BUILD } from '../debug-build'; import { getMetricSummaryJsonForSpan } from '../metrics/metric-summary'; import { SEMANTIC_ATTRIBUTE_MEASUREMENTS, + SEMANTIC_ATTRIBUTE_PROFILE_ID, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, } from '../semanticAttributes'; @@ -632,6 +633,7 @@ export class Span implements SpanInterface { origin: this._attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined, _metrics_summary: getMetricSummaryJsonForSpan(this), measurements: this._attributes[SEMANTIC_ATTRIBUTE_MEASUREMENTS] as Measurements | undefined, + profile_id: this._attributes[SEMANTIC_ATTRIBUTE_PROFILE_ID] as string | undefined, }); } From e5f21abaf06a610aeace98f2ed358360cff6c9ef Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 29 Feb 2024 14:06:36 -0500 Subject: [PATCH 5/8] refactor out some optional chaining --- .../src/browser/browserTracingIntegration.ts | 10 ++++++---- packages/tracing-internal/src/browser/metrics/index.ts | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/tracing-internal/src/browser/browserTracingIntegration.ts b/packages/tracing-internal/src/browser/browserTracingIntegration.ts index 11795a15a666..5e57e2b0243f 100644 --- a/packages/tracing-internal/src/browser/browserTracingIntegration.ts +++ b/packages/tracing-internal/src/browser/browserTracingIntegration.ts @@ -543,12 +543,14 @@ function registerInpInteractionListener( 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?.getIntegrationByName?.('Replay') as - | (Integration & { getReplayId: () => string }) - | undefined; + const replay = + client !== undefined && client.getIntegrationByName !== undefined + ? (client.getIntegrationByName('Replay') as Integration & { getReplayId: () => string }) + : undefined; // eslint-disable-next-line deprecation/deprecation const activeTransaction = getActiveTransaction(); - const user = getCurrentScope()?.getUser(); + const currentScope = getCurrentScope(); + const user = currentScope !== undefined ? currentScope.getUser() : undefined; for (const entry of entries) { if (isPerformanceEventTiming(entry)) { const duration = entry.duration; diff --git a/packages/tracing-internal/src/browser/metrics/index.ts b/packages/tracing-internal/src/browser/metrics/index.ts index aaf73442129e..de069d6baa52 100644 --- a/packages/tracing-internal/src/browser/metrics/index.ts +++ b/packages/tracing-internal/src/browser/metrics/index.ts @@ -224,10 +224,10 @@ function _trackINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping) user: undefined, replay: undefined, }; + const userDisplay = user !== undefined ? user.email || user.id || user.ip_address : undefined; // eslint-disable-next-line deprecation/deprecation - const userDisplay = user?.email || user?.id || user?.ip_address; - const profileId = activeTransaction?.getProfileId(); - const replayId = replay?.getReplayId(); + const profileId = activeTransaction !== undefined ? activeTransaction.getProfileId() : undefined; + const replayId = replay !== undefined ? replay.getReplayId() : undefined; const span = new Span({ startTimestamp: startTime, endTimestamp: startTime + duration, From d943c8def648b43d119c75f61f61bf01505c937e Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 29 Feb 2024 14:48:57 -0500 Subject: [PATCH 6/8] refactor optional check --- packages/tracing-internal/src/browser/metrics/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tracing-internal/src/browser/metrics/index.ts b/packages/tracing-internal/src/browser/metrics/index.ts index 03f5a7a0c2ff..d51a9dfbb7c4 100644 --- a/packages/tracing-internal/src/browser/metrics/index.ts +++ b/packages/tracing-internal/src/browser/metrics/index.ts @@ -669,7 +669,7 @@ function getSampleRate(transactionContext: TransactionContext | undefined, optio }, location: WINDOW.location, }); - } else if (transactionContext?.sampled !== undefined) { + } else if (transactionContext !== undefined && transactionContext.sampled !== undefined) { sampleRate = transactionContext.sampled; } else if (typeof options.tracesSampleRate !== 'undefined') { sampleRate = options.tracesSampleRate; From 65bb1acff2ebdf83ae766ad2c691bd1042176b62 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 29 Feb 2024 15:39:52 -0500 Subject: [PATCH 7/8] todo comment and update interactionIdtoRouteNameMapping replay to replayid --- packages/browser/src/profiling/utils.ts | 3 +++ .../src/browser/browserTracingIntegration.ts | 3 ++- packages/tracing-internal/src/browser/metrics/index.ts | 5 ++--- packages/tracing-internal/src/browser/web-vitals/types.ts | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/browser/src/profiling/utils.ts b/packages/browser/src/profiling/utils.ts index 9114884384b7..6ebec8511214 100644 --- a/packages/browser/src/profiling/utils.ts +++ b/packages/browser/src/profiling/utils.ts @@ -583,6 +583,9 @@ export function createProfilingEvent( return createProfilePayload(profile_id, start_timestamp, profile, event); } +// TODO (v8): We need to obtain profile ids in @sentry-internal/tracing, +// but we don't have access to this map because importing this map would +// cause a circular dependancy. We need to resolve this in v8. const PROFILE_MAP: Map = new Map(); /** * diff --git a/packages/tracing-internal/src/browser/browserTracingIntegration.ts b/packages/tracing-internal/src/browser/browserTracingIntegration.ts index 5e57e2b0243f..47bad615586d 100644 --- a/packages/tracing-internal/src/browser/browserTracingIntegration.ts +++ b/packages/tracing-internal/src/browser/browserTracingIntegration.ts @@ -547,6 +547,7 @@ function registerInpInteractionListener( client !== undefined && client.getIntegrationByName !== undefined ? (client.getIntegrationByName('Replay') as Integration & { getReplayId: () => string }) : undefined; + const replayId = replay !== undefined ? replay.getReplayId() : undefined; // eslint-disable-next-line deprecation/deprecation const activeTransaction = getActiveTransaction(); const currentScope = getCurrentScope(); @@ -578,7 +579,7 @@ function registerInpInteractionListener( parentContext, user, activeTransaction, - replay, + replayId, }; } } diff --git a/packages/tracing-internal/src/browser/metrics/index.ts b/packages/tracing-internal/src/browser/metrics/index.ts index 617405606726..b9c08f7dffaf 100644 --- a/packages/tracing-internal/src/browser/metrics/index.ts +++ b/packages/tracing-internal/src/browser/metrics/index.ts @@ -213,7 +213,7 @@ function _trackINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping) /** Build the INP span, create an envelope from the span, and then send the envelope */ const startTime = msToSec((browserPerformanceTimeOrigin as number) + entry.startTime); const duration = msToSec(metric.value); - const { routeName, parentContext, activeTransaction, user, replay } = + const { routeName, parentContext, activeTransaction, user, replayId } = entry.interactionId !== undefined ? interactionIdtoRouteNameMapping[entry.interactionId] : { @@ -221,12 +221,11 @@ function _trackINP(interactionIdtoRouteNameMapping: InteractionRouteNameMapping) parentContext: undefined, activeTransaction: undefined, user: undefined, - replay: 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 replayId = replay !== undefined ? replay.getReplayId() : undefined; const span = new Span({ startTimestamp: startTime, endTimestamp: startTime + duration, diff --git a/packages/tracing-internal/src/browser/web-vitals/types.ts b/packages/tracing-internal/src/browser/web-vitals/types.ts index 1e994b455f9a..e82296157103 100644 --- a/packages/tracing-internal/src/browser/web-vitals/types.ts +++ b/packages/tracing-internal/src/browser/web-vitals/types.ts @@ -171,6 +171,6 @@ export type InteractionRouteNameMapping = { parentContext: TransactionContext; user?: User; activeTransaction?: Transaction; - replay?: Integration & { getReplayId: () => string }; + replayId?: string; }; }; From ac749fbb1e1489f8b41ab3fb93c1e28b6c9757e4 Mon Sep 17 00:00:00 2001 From: Edward Gou Date: Thu, 29 Feb 2024 15:49:03 -0500 Subject: [PATCH 8/8] fix import --- packages/tracing-internal/src/browser/web-vitals/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tracing-internal/src/browser/web-vitals/types.ts b/packages/tracing-internal/src/browser/web-vitals/types.ts index e82296157103..adc95084bda9 100644 --- a/packages/tracing-internal/src/browser/web-vitals/types.ts +++ b/packages/tracing-internal/src/browser/web-vitals/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import type { Integration, Transaction, TransactionContext, User } from '@sentry/types'; +import type { Transaction, TransactionContext, User } from '@sentry/types'; import type { FirstInputPolyfillCallback } from './types/polyfills'; export * from './types/base';