Files
klz-cables.com/.pnpm-store/v10/files/84/4c58c4875404690544dbe90eec22d74ea6c8fd54d263849d0750873f47c2453304c1fb44694140d69c4f7c04da97c3ea8806d4053fcf02063cdb6b5f341308
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

45 lines
1.5 KiB
Plaintext

import { getActiveSpan, getRootSpan, spanToJSON, debug, SPAN_STATUS_ERROR } from '@sentry/core';
import { DEBUG_BUILD } from '../debug-build.js';
import { WINDOW } from '../helpers.js';
/**
* Add a listener that cancels and finishes a transaction when the global
* document is hidden.
*/
function registerBackgroundTabDetection() {
if (WINDOW.document) {
WINDOW.document.addEventListener('visibilitychange', () => {
const activeSpan = getActiveSpan();
if (!activeSpan) {
return;
}
const rootSpan = getRootSpan(activeSpan);
if (WINDOW.document.hidden && rootSpan) {
const cancelledStatus = 'cancelled';
const { op, status } = spanToJSON(rootSpan);
if (DEBUG_BUILD) {
debug.log(`[Tracing] Transaction: ${cancelledStatus} -> since tab moved to the background, op: ${op}`);
}
// We should not set status if it is already set, this prevent important statuses like
// error or data loss from being overwritten on transaction.
if (!status) {
rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message: cancelledStatus });
}
rootSpan.setAttribute('sentry.cancellation_reason', 'document.hidden');
rootSpan.end();
}
});
} else {
DEBUG_BUILD && debug.warn('[Tracing] Could not set up background tab detection due to lack of global document');
}
}
export { registerBackgroundTabDetection };
//# sourceMappingURL=backgroundtab.js.map