Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/nuxt/src/runtime/plugins/sentry.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export default defineNitroPlugin(nitroApp => {

// @ts-expect-error - 'render:html' is a valid hook name in the Nuxt context
nitroApp.hooks.hook('render:html', (html: NuxtRenderHTMLContext) => {
addSentryTracingMetaTags(html.head);
const sentryClient = SentryNode.getClient();
addSentryTracingMetaTags(html.head, sentryClient?.getOptions().debug);
});
});

Expand Down
6 changes: 5 additions & 1 deletion packages/nuxt/src/runtime/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ClientOptions, Context } from '@sentry/core';
import { logger } from '@sentry/core';
import { captureException, getClient, getTraceMetaTags } from '@sentry/core';
import type { VueOptions } from '@sentry/vue/src/types';
import type { CapturedErrorContext } from 'nitropack';
Expand Down Expand Up @@ -33,10 +34,13 @@ export function extractErrorContext(errorContext: CapturedErrorContext | undefin
*
* Exported only for testing
*/
export function addSentryTracingMetaTags(head: NuxtRenderHTMLContext['head']): void {
export function addSentryTracingMetaTags(head: NuxtRenderHTMLContext['head'], debug?: boolean): void {
const metaTags = getTraceMetaTags();

if (metaTags) {
if (debug) {
logger.log('Adding Sentry tracing meta tags to HTML page:', metaTags);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: I think I caused this confusion in our offline convo: We don't even need the debug flag check here because the logger won't emit anything unless people init the SDK with debug: true.

head.push(metaTags);
}
}
Expand Down