-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
BrowserTracing id property missing in v7 #5635
-
Hi, I am trying to check if Sentry's APM is initialized with this line of code.
import * as Sentry from '@sentry/react';
import {Integrations as TracingIntegrations} from '@sentry/tracing';
Sentry.getCurrentHub()
.getClient()
?.getIntegration(TracingIntegrations.BrowserTracing)
This worked in v6, but while migrating to v7 BrowserTracing removed it's ID property and now Typescript is giving me this error:
Argument of type 'typeof BrowserTracing' is not assignable to parameter of type 'IntegrationClass<BrowserTracing>'.
Property 'id' is missing in type 'typeof BrowserTracing' but required in type 'IntegrationClass<BrowserTracing>'.
Is there fix for this typescript error? I know the static property id is removed in v7 from BrowserTracing
Beta Was this translation helpful? Give feedback.
All reactions
For now though, you can use the hasTracingEnabled util from @sentry/tracing to check if Sentry's APM is initialized. We recommend using sampleRate to decide to turn on tracing or not.
import { hasTracingEnabled } from '@sentry/tracing';
sentry-javascript/packages/tracing/src/utils.ts
Lines 18 to 29 in f563eae
Replies: 2 comments 4 replies
-
Ah this is a bug! Will fix: #5647
Beta Was this translation helpful? Give feedback.
All reactions
-
For now though, you can use the hasTracingEnabled util from @sentry/tracing to check if Sentry's APM is initialized. We recommend using sampleRate to decide to turn on tracing or not.
import { hasTracingEnabled } from '@sentry/tracing';
sentry-javascript/packages/tracing/src/utils.ts
Lines 18 to 29 in f563eae
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks, using hasTracingEnabled() looks like it works as a workaround. What do you mean by using sampleRate to decide to turn on tracing or not?
Beta Was this translation helpful? Give feedback.
All reactions
-
Ah, that if tracesSampleRate or tracesSampler is defined in init, then you enable tracing. For example:
const initSettings = { dsn: ... } if (shouldEnableTracing()) { initSettings.tracesSampleRate = 1.0 } Sentry.init(initSettings);
Beta Was this translation helpful? Give feedback.
All reactions
-
Don't you have to define either tracesSampleRate or tracesSampler in order to enable tracing? So if they are defined in init, tracing is turn on already?
Beta Was this translation helpful? Give feedback.
All reactions
-
Don't you have to define either
tracesSampleRateortracesSamplerin order to enable tracing? So if they are defined in init, tracing is turn on already?
Yup exactly. My example was more to show how you would turn off/on tracing during SDK init.
Beta Was this translation helpful? Give feedback.