Files
klz-cables.com/.pnpm-store/v10/files/25/1f28abc8102c0b1e0bb6aa1ce464736af2437590e6794901363d357640b7bd49371b8f9ad2a5c9404528832e4d8afb14698d5f4d99eeea59030872b469de61
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

118 lines
3.4 KiB
Plaintext

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const stacktrace = require('./stacktrace.js');
const worldwide = require('./worldwide.js');
let parsedStackResults;
let lastSentryKeysCount;
let lastNativeKeysCount;
let cachedFilenameDebugIds;
/**
* Returns a map of filenames to debug identifiers.
* Supports both proprietary _sentryDebugIds and native _debugIds (e.g., from Vercel) formats.
*/
function getFilenameToDebugIdMap(stackParser) {
const sentryDebugIdMap = worldwide.GLOBAL_OBJ._sentryDebugIds;
const nativeDebugIdMap = worldwide.GLOBAL_OBJ._debugIds;
if (!sentryDebugIdMap && !nativeDebugIdMap) {
return {};
}
const sentryDebugIdKeys = sentryDebugIdMap ? Object.keys(sentryDebugIdMap) : [];
const nativeDebugIdKeys = nativeDebugIdMap ? Object.keys(nativeDebugIdMap) : [];
// If the count of registered globals hasn't changed since the last call, we
// can just return the cached result.
if (
cachedFilenameDebugIds &&
sentryDebugIdKeys.length === lastSentryKeysCount &&
nativeDebugIdKeys.length === lastNativeKeysCount
) {
return cachedFilenameDebugIds;
}
lastSentryKeysCount = sentryDebugIdKeys.length;
lastNativeKeysCount = nativeDebugIdKeys.length;
// Build a map of filename -> debug_id from both sources
cachedFilenameDebugIds = {};
if (!parsedStackResults) {
parsedStackResults = {};
}
const processDebugIds = (debugIdKeys, debugIdMap) => {
for (const key of debugIdKeys) {
const debugId = debugIdMap[key];
const result = parsedStackResults?.[key];
if (result && cachedFilenameDebugIds && debugId) {
// Use cached filename but update with current debug ID
cachedFilenameDebugIds[result[0]] = debugId;
// Update cached result with new debug ID
if (parsedStackResults) {
parsedStackResults[key] = [result[0], debugId];
}
} else if (debugId) {
const parsedStack = stackParser(key);
for (let i = parsedStack.length - 1; i >= 0; i--) {
const stackFrame = parsedStack[i];
const filename = stackFrame?.filename;
if (filename && cachedFilenameDebugIds && parsedStackResults) {
cachedFilenameDebugIds[filename] = debugId;
parsedStackResults[key] = [filename, debugId];
break;
}
}
}
}
};
if (sentryDebugIdMap) {
processDebugIds(sentryDebugIdKeys, sentryDebugIdMap);
}
// Native _debugIds will override _sentryDebugIds if same file
if (nativeDebugIdMap) {
processDebugIds(nativeDebugIdKeys, nativeDebugIdMap);
}
return cachedFilenameDebugIds;
}
/**
* Returns a list of debug images for the given resources.
*/
function getDebugImagesForResources(
stackParser,
resource_paths,
) {
const filenameDebugIdMap = getFilenameToDebugIdMap(stackParser);
if (!filenameDebugIdMap) {
return [];
}
const images = [];
for (const path of resource_paths) {
const normalizedPath = stacktrace.normalizeStackTracePath(path);
if (normalizedPath && filenameDebugIdMap[normalizedPath]) {
images.push({
type: 'sourcemap',
code_file: path,
debug_id: filenameDebugIdMap[normalizedPath],
});
}
}
return images;
}
exports.getDebugImagesForResources = getDebugImagesForResources;
exports.getFilenameToDebugIdMap = getFilenameToDebugIdMap;
//# sourceMappingURL=debug-ids.js.map