mirror of
https://github.com/MarSeventh/CloudFlare-ImgBed.git
synced 2026-04-27 23:55:01 +00:00
init
This commit is contained in:
54
node_modules/@sentry/utils/esm/instrument/_handlers.js
generated
vendored
Normal file
54
node_modules/@sentry/utils/esm/instrument/_handlers.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import { DEBUG_BUILD } from '../debug-build.js';
|
||||
import { logger } from '../logger.js';
|
||||
import { getFunctionName } from '../stacktrace.js';
|
||||
|
||||
// We keep the handlers globally
|
||||
const handlers = {};
|
||||
const instrumented = {};
|
||||
|
||||
/** Add a handler function. */
|
||||
function addHandler(type, handler) {
|
||||
handlers[type] = handlers[type] || [];
|
||||
(handlers[type] ).push(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all instrumentation handlers.
|
||||
* This can be used by tests to ensure we have a clean slate of instrumentation handlers.
|
||||
*/
|
||||
function resetInstrumentationHandlers() {
|
||||
Object.keys(handlers).forEach(key => {
|
||||
handlers[key ] = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
/** Maybe run an instrumentation function, unless it was already called. */
|
||||
function maybeInstrument(type, instrumentFn) {
|
||||
if (!instrumented[type]) {
|
||||
instrumentFn();
|
||||
instrumented[type] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Trigger handlers for a given instrumentation type. */
|
||||
function triggerHandlers(type, data) {
|
||||
const typeHandlers = type && handlers[type];
|
||||
if (!typeHandlers) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const handler of typeHandlers) {
|
||||
try {
|
||||
handler(data);
|
||||
} catch (e) {
|
||||
DEBUG_BUILD &&
|
||||
logger.error(
|
||||
`Error while triggering instrumentation handler.\nType: ${type}\nName: ${getFunctionName(handler)}\nError:`,
|
||||
e,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { addHandler, maybeInstrument, resetInstrumentationHandlers, triggerHandlers };
|
||||
//# sourceMappingURL=_handlers.js.map
|
||||
Reference in New Issue
Block a user