MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / reportNuxtError

Function reportNuxtError

packages/nuxt/src/runtime/utils.ts:57–88  ·  view source on GitHub ↗
(options: {
  error: unknown;
  instance?: ComponentPublicInstance | null;
  info?: string;
})

Source from the content-addressed store, hash-verified

55 * We don't want to use the error handling from `@sentry/vue` as it wraps the existing error handler, which leads to a 500 error: https://github.com/getsentry/sentry-javascript/issues/12515
56 */
57export function reportNuxtError(options: {
58 error: unknown;
59 instance?: ComponentPublicInstance | null;
60 info?: string;
61}): void {
62 const { error, instance, info } = options;
63
64 const metadata: Record<string, unknown> = {
65 info,
66 // todo: add component name and trace (like in the vue integration)
67 };
68
69 if (instance?.$props) {
70 const sentryClient = getClient();
71 // `attachProps` is defined in the Vue integration options, but the type is not exported from @sentry/vue, as it's only used internally.
72 const sentryOptions = sentryClient ? (sentryClient.getOptions() as ClientOptions & { attachProps: boolean }) : null;
73
74 // `attachProps` is enabled by default and props should only not be attached if explicitly disabled (see DEFAULT_CONFIG in `vueIntegration`).
75 // oxlint-disable-next-line typescript/no-unsafe-member-access
76 if (sentryOptions?.attachProps && instance.$props !== false) {
77 metadata.propsData = instance.$props;
78 }
79 }
80
81 // Capture exception in the next event loop, to make sure that all breadcrumbs are recorded in time.
82 setTimeout(() => {
83 captureException(error, {
84 captureContext: { contexts: { nuxt: metadata } },
85 mechanism: { handled: false, type: `auto.function.nuxt.${instance ? 'vue' : 'app'}-error` },
86 });
87 });
88}

Callers 2

utils.test.tsFile · 0.90
setupFunction · 0.90

Calls 4

getClientFunction · 0.90
captureExceptionFunction · 0.90
setTimeoutFunction · 0.85
getOptionsMethod · 0.65

Tested by

no test coverage detected