Skip to content

Commit b4a31db

Browse files
committed
feat(nuxt): Log when adding HTML trace meta tags
1 parent bd7205b commit b4a31db

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/nuxt/src/runtime/plugins/sentry.server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export default defineNitroPlugin(nitroApp => {
5757

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

packages/nuxt/src/runtime/utils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ClientOptions, Context } from '@sentry/core';
2+
import { consoleSandbox } from '@sentry/core';
23
import { captureException, getClient, getTraceMetaTags } from '@sentry/core';
34
import type { VueOptions } from '@sentry/vue/src/types';
45
import type { CapturedErrorContext } from 'nitropack';
@@ -33,10 +34,16 @@ export function extractErrorContext(errorContext: CapturedErrorContext | undefin
3334
*
3435
* Exported only for testing
3536
*/
36-
export function addSentryTracingMetaTags(head: NuxtRenderHTMLContext['head']): void {
37+
export function addSentryTracingMetaTags(head: NuxtRenderHTMLContext['head'], debug?: boolean): void {
3738
const metaTags = getTraceMetaTags();
3839

3940
if (metaTags) {
41+
if (debug) {
42+
consoleSandbox(() => {
43+
// eslint-disable-next-line no-console
44+
console.log('[Sentry] Adding Sentry tracing meta tags to HTML page:', metaTags);
45+
});
46+
}
4047
head.push(metaTags);
4148
}
4249
}

0 commit comments

Comments
 (0)