Skip to content
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

Merged
merged 5 commits into from
Jul 26, 2024
Merged

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jul 25, 2024

Adding the Vue BrowserTracing instrumentation to get parametrized routes.

closes #13067

@s1gr1d s1gr1d requested review from Lms24 and mydea July 25, 2024 14:47
Copy link
Member Author

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();
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

@@ -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
Copy link
Member

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.

Suggested change
* 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

Comment on lines 32 to 36
if (sentryClient && '$router' in nuxtApp) {
sentryClient.addIntegration(
browserTracingIntegration({ router: nuxtApp.$router as VueRouter, routeLabel: 'path' }),
);
}
Copy link
Member

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.

@s1gr1d s1gr1d requested a review from Lms24 July 26, 2024 07:05
Copy link
Member

@Lms24 Lms24 left a 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!

@s1gr1d s1gr1d merged commit e38f89d into develop Jul 26, 2024
96 checks passed
@s1gr1d s1gr1d deleted the sig/nuxt-parametrized-routes branch July 26, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nuxt: Route Parametrization
3 participants