Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 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 { consoleSandbox } 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,16 @@ 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) {
consoleSandbox(() => {
// eslint-disable-next-line no-console
console.log('[Sentry] 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.

m: can we use logger instead? then we don't need to worry about the sandbox

}
head.push(metaTags);
}
}
Expand Down
Loading