-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nuxt): Add vue-router instrumentation #13054
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not related - just a restructuring of the type
export default defineNuxtPlugin(nuxtApp => { | ||
nuxtApp.hook('app:created', vueApp => { | ||
const sentryClient = getClient(); | ||
const sentryClient = getClient(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: We can early return if client is not defined to remove the if (sentryClient)
checks below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather leave the checks as I'm also accessing the client in a Nuxt lifecycle hook and I cannot be sure that the early return would hinder the lifecycle hook to be called if there is no client. Does this make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. I think then we need a new call to getClient
inside the hook so we ensure that we always have an up-to-date reference.
packages/nuxt/src/common/types.ts
Outdated
@@ -5,93 +5,93 @@ export type SentryNuxtOptions = Omit<Parameters<typeof init>[0] & object, 'app'> | |||
|
|||
type SourceMapsOptions = { | |||
/** | |||
* Options for the Sentry Vite plugin to customize the source maps upload process. | |||
* If this flag is `true`, and an auth token is detected, the Sentry integration will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l (sorry for the bike shedding): Just was wondering if "integration" is a good term here? IIUC users interact with our nuxt module here, correct? So I'd go with module or just SDK.
* If this flag is `true`, and an auth token is detected, the Sentry integration will | |
* If this flag is `true`, and an auth token is detected, the Sentry integration will |
if (sentryClient && '$router' in nuxtApp) { | ||
sentryClient.addIntegration( | ||
browserTracingIntegration({ router: nuxtApp.$router as VueRouter, routeLabel: 'path' }), | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: This is runtime code, right? If so, I think we need to add the __SENTRY_TRACING__
guard here to enable tree shaking of browserTracingIntegration
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing my review! LGTM!
Adding the Vue BrowserTracing instrumentation to get parametrized routes.
closes #13067