@sentry/google-cloud-serverless
Version:
Official Sentry SDK for Google Cloud Functions
36 lines (33 loc) • 998 B
JavaScript
import { withIsolationScope, addExceptionMechanism } from '@sentry/core';
function domainify(fn) {
return (...args) => withIsolationScope(() => fn(...args));
}
function proxyFunction(source, wrap, overrides) {
const wrapper = wrap(source);
const handler = {
apply: (_target, thisArg, args) => {
return wrapper.apply(thisArg, args);
}
};
if (overrides) {
handler.get = (target, prop) => {
if (Object.prototype.hasOwnProperty.call(overrides, prop)) {
return overrides[prop];
}
return target[prop];
};
}
return new Proxy(source, handler);
}
function markEventUnhandled(scope, type) {
scope.addEventProcessor((event) => {
addExceptionMechanism(event, { handled: false, type });
return event;
});
return scope;
}
function getFunctionName() {
return process.env.FUNCTION_TARGET || process.env.K_SERVICE || void 0;
}
export { domainify, getFunctionName, markEventUnhandled, proxyFunction };
//# sourceMappingURL=utils.js.map