@sentry/google-cloud-serverless
Version:
Official Sentry SDK for Google Cloud Functions
41 lines (37 loc) • 1.13 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const core = require('@sentry/core');
function domainify(fn) {
return (...args) => core.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) => {
core.addExceptionMechanism(event, { handled: false, type });
return event;
});
return scope;
}
function getFunctionName() {
return process.env.FUNCTION_TARGET || process.env.K_SERVICE || void 0;
}
exports.domainify = domainify;
exports.getFunctionName = getFunctionName;
exports.markEventUnhandled = markEventUnhandled;
exports.proxyFunction = proxyFunction;
//# sourceMappingURL=utils.js.map