Skip to content

Commit 2897297

Browse files
authored
feat(nuxt): Exclude tracing meta tags on cached pages in Nuxt 5 (#20168)
To know whether a page is SWR cached, can now be found in `event.context.routeRules.swr` (Nitro v3) instead of `event.context.cache.options.swr` (Nitro v2). closes #20169
1 parent 1cc3dd0 commit 2897297

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

dev-packages/e2e-tests/test-applications/nuxt-5/tests/tracing.cached-html.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ test.describe('Rendering Modes with Cached HTML', () => {
1414
await testChangingTracingMetaTagsOnISRPage(page, '/rendering-modes/isr-1h-cached-page', 'ISR 1h Cached Page');
1515
});
1616

17-
// TODO: Make test work with Nuxt 5
18-
test.skip('exclude tracing meta tags on SWR-cached page', async ({ page }) => {
17+
test('exclude tracing meta tags on SWR-cached page', async ({ page }) => {
1918
await testExcludeTracingMetaTagsOnCachedPage(page, '/rendering-modes/swr-cached-page', 'SWR Cached Page');
2019
});
2120

22-
// TODO: Make test work with Nuxt 5
23-
test.skip('exclude tracing meta tags on SWR 1h cached page', async ({ page }) => {
21+
test('exclude tracing meta tags on SWR 1h cached page', async ({ page }) => {
2422
await testExcludeTracingMetaTagsOnCachedPage(page, '/rendering-modes/swr-1h-cached-page', 'SWR 1h Cached Page');
2523
});
2624

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export default (nitroApp => {
2121
!!(event as any).res?.headers?.has?.('x-nitro-prerender');
2222

2323
// oxlint-disable-next-line typescript-oxlint/no-unsafe-member-access
24-
const isSWRCachedPage = event?.context?.cache?.options?.swr as boolean | undefined;
24+
const isSWRCachedPage = /* Nitro v2 */ (event?.context?.cache?.options?.swr ||
25+
// oxlint-disable-next-line typescript-oxlint/no-unsafe-member-access
26+
/* Nitro v3 */ event?.context?.routeRules?.swr) as boolean;
2527

2628
if (!isPreRenderedPage && !isSWRCachedPage) {
2729
addSentryTracingMetaTags(html.head);

0 commit comments

Comments
 (0)