Files
klz-cables.com/.pnpm-store/v10/files/3e/878da7d861e03402dc07d6be385405a708e36dff0212a193681c7da839e1e1ba338192779d5c0c3c8f1324ef07dcd433c301e7769654bd96f684da38354ab9
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

65 lines
1.6 KiB
Plaintext

/**
* The key used to store the local variables on the error object.
*/
const LOCAL_VARIABLES_KEY = '__SENTRY_ERROR_LOCAL_VARIABLES__';
/**
* Creates a rate limiter that will call the disable callback when the rate limit is reached and the enable callback
* when a timeout has occurred.
* @param maxPerSecond Maximum number of calls per second
* @param enable Callback to enable capture
* @param disable Callback to disable capture
* @returns A function to call to increment the rate limiter count
*/
function createRateLimiter(
maxPerSecond,
enable,
disable,
) {
let count = 0;
let retrySeconds = 5;
let disabledTimeout = 0;
setInterval(() => {
if (disabledTimeout === 0) {
if (count > maxPerSecond) {
retrySeconds *= 2;
disable(retrySeconds);
// Cap at one day
if (retrySeconds > 86400) {
retrySeconds = 86400;
}
disabledTimeout = retrySeconds;
}
} else {
disabledTimeout -= 1;
if (disabledTimeout === 0) {
enable();
}
}
count = 0;
}, 1000).unref();
return () => {
count += 1;
};
}
// Add types for the exception event data
/** Could this be an anonymous function? */
function isAnonymous(name) {
return name !== undefined && (name.length === 0 || name === '?' || name === '<anonymous>');
}
/** Do the function names appear to match? */
function functionNamesMatch(a, b) {
return a === b || `Object.${a}` === b || a === `Object.${b}` || (isAnonymous(a) && isAnonymous(b));
}
export { LOCAL_VARIABLES_KEY, createRateLimiter, functionNamesMatch, isAnonymous };
//# sourceMappingURL=common.js.map