(nuxtApp)
| 35 | name: 'sentry-client-integrations', |
| 36 | dependsOn: ['sentry-client-config'], |
| 37 | async setup(nuxtApp) { |
| 38 | // This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false", in which case everything inside |
| 39 | // will get tree-shaken away |
| 40 | if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) { |
| 41 | const sentryClient = getClient(); |
| 42 | |
| 43 | if (sentryClient && '$router' in nuxtApp) { |
| 44 | sentryClient.addIntegration( |
| 45 | browserTracingIntegration({ router: nuxtApp.$router as VueRouter, routeLabel: 'path' }), |
| 46 | ); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | nuxtApp.hook('app:created', vueApp => { |
| 51 | const sentryClient = getClient(); |
| 52 | |
| 53 | if (sentryClient) { |
| 54 | // Adding the Vue integration without the Vue error handler |
| 55 | // Nuxt is registering their own error handler, which is unset after hydration: https://github.com/nuxt/nuxt/blob/d3fdbcaac6cf66d21e25d259390d7824696f1a87/packages/nuxt/src/app/entry.ts#L64-L73 |
| 56 | // We don't want to wrap the existing error handler, as it leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515 |
| 57 | sentryClient.addIntegration( |
| 58 | vueIntegration({ |
| 59 | // We pick up the options from the "fake" vueIntegration exported by the SDK. |
| 60 | ...(GLOBAL_OBJ as GlobalObjWithIntegrationOptions)._sentryNuxtVueIntegrationOptions, |
| 61 | app: vueApp, |
| 62 | attachErrorHandler: false, |
| 63 | }), |
| 64 | ); |
| 65 | } |
| 66 | }); |
| 67 | |
| 68 | nuxtApp.hook('app:error', error => { |
| 69 | if (isNuxtError(error)) { |
| 70 | // Do not report if status code is 3xx or 4xx |
| 71 | if (error?.statusCode && error.statusCode >= 300 && error.statusCode < 500) { |
| 72 | return; |
| 73 | } |
| 74 | } |
| 75 | reportNuxtError({ error }); |
| 76 | }); |
| 77 | |
| 78 | nuxtApp.hook('vue:error', (error, instance, info) => { |
| 79 | reportNuxtError({ error, instance, info }); |
| 80 | }); |
| 81 | }, |
| 82 | }); |
nothing calls this directly
no test coverage detected