@sentry/nextjs
Version:
Official Sentry SDK for Next.js
53 lines (43 loc) • 1.74 kB
JavaScript
var {
_optionalChain
} = require('@sentry/utils');
Object.defineProperty(exports, '__esModule', { value: true });
const core = require('@sentry/core');
const isBuild = require('./utils/isBuild.js');
const wrapperUtils = require('./utils/wrapperUtils.js');
/**
* Create a wrapped version of the user's exported `getStaticProps` function
*
* @param origGetStaticProps The user's `getStaticProps` function
* @param parameterizedRoute The page's parameterized route
* @returns A wrapped version of the function
*/
function wrapGetStaticPropsWithSentry(
origGetStaticPropsa,
parameterizedRoute,
) {
return new Proxy(origGetStaticPropsa, {
apply: (wrappingTarget, thisArg, args) => {
if (isBuild.isBuild()) {
return wrappingTarget.apply(thisArg, args);
}
core.addTracingExtensions();
const errorWrappedGetStaticProps = wrapperUtils.withErrorInstrumentation(wrappingTarget);
const options = _optionalChain([core.getClient, 'call', _ => _(), 'optionalAccess', _2 => _2.getOptions, 'call', _3 => _3()]);
if (_optionalChain([options, 'optionalAccess', _4 => _4.instrumenter]) === 'sentry') {
return wrapperUtils.callDataFetcherTraced(errorWrappedGetStaticProps, args, {
parameterizedRoute,
dataFetchingMethodName: 'getStaticProps',
});
}
return errorWrappedGetStaticProps.apply(thisArg, args);
},
});
}
/**
* @deprecated Use `wrapGetStaticPropsWithSentry` instead.
*/
const withSentryGetStaticProps = wrapGetStaticPropsWithSentry;
exports.withSentryGetStaticProps = withSentryGetStaticProps;
exports.wrapGetStaticPropsWithSentry = wrapGetStaticPropsWithSentry;
//# sourceMappingURL=wrapGetStaticPropsWithSentry.js.map