Files
klz-cables.com/.pnpm-store/v10/files/e9/8803ec9182edc4db7ee2fc9879a26af55a312078bb7e3af165fe1e346449f7ceca7b0df9b92d99ab4412d1bae294acb05022c324263280ccb86f2dff362311
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

67 lines
2.0 KiB
Plaintext

import { LRUMap } from '@sentry/core';
import { WINDOW } from '@sentry/react';
import { maybeParameterizeRoute, getManifest } from './parameterization.js';
/**
* Cache for ISR/SSG route checks. Exported for testing purposes.
* @internal
*/
const IS_ISR_SSG_ROUTE_CACHE = new LRUMap(100);
/**
* Check if the current page is an ISR/SSG route by checking the route manifest.
* @internal Exported for testing purposes.
*/
function isIsrSsgRoute(pathname) {
// Early parameterization to get the cache key
const parameterizedPath = maybeParameterizeRoute(pathname);
const pathToCheck = parameterizedPath || pathname;
// Check cache using the parameterized path as the key
const cachedResult = IS_ISR_SSG_ROUTE_CACHE.get(pathToCheck);
if (cachedResult !== undefined) {
return cachedResult;
}
// Cache miss get the manifest
const manifest = getManifest();
if (!manifest?.isrRoutes || !Array.isArray(manifest.isrRoutes) || manifest.isrRoutes.length === 0) {
IS_ISR_SSG_ROUTE_CACHE.set(pathToCheck, false);
return false;
}
const isIsrSsgRoute = manifest.isrRoutes.includes(pathToCheck);
IS_ISR_SSG_ROUTE_CACHE.set(pathToCheck, isIsrSsgRoute);
return isIsrSsgRoute;
}
/**
* Remove sentry-trace and baggage meta tags from the DOM if this is an ISR/SSG page.
* This prevents the browser tracing integration from using stale/cached trace IDs.
*/
function removeIsrSsgTraceMetaTags() {
if (!WINDOW.document || !isIsrSsgRoute(WINDOW.location.pathname)) {
return;
}
// Helper function to remove a meta tag
function removeMetaTag(metaName) {
try {
const meta = WINDOW.document.querySelector(`meta[name="${metaName}"]`);
if (meta) {
meta.remove();
}
} catch {
// ignore errors when removing the meta tag
}
}
// Remove the meta tags so browserTracingIntegration won't pick them up
removeMetaTag('sentry-trace');
removeMetaTag('baggage');
}
export { IS_ISR_SSG_ROUTE_CACHE, isIsrSsgRoute, removeIsrSsgTraceMetaTags };
//# sourceMappingURL=isrRoutingTracing.js.map