12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import { _optionalChain } from '@sentry/utils';
- import { addTracingExtensions, getClient } from '@sentry/core';
- import { isBuild } from './utils/isBuild.js';
- import { callDataFetcherTraced, withErrorInstrumentation } from './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()) {
- return wrappingTarget.apply(thisArg, args);
- }
- addTracingExtensions();
- const errorWrappedGetStaticProps = withErrorInstrumentation(wrappingTarget);
- const options = _optionalChain([getClient, 'call', _ => _(), 'optionalAccess', _2 => _2.getOptions, 'call', _3 => _3()]);
- if (_optionalChain([options, 'optionalAccess', _4 => _4.instrumenter]) === 'sentry') {
- return callDataFetcherTraced(errorWrappedGetStaticProps, args, {
- parameterizedRoute,
- dataFetchingMethodName: 'getStaticProps',
- });
- }
- return errorWrappedGetStaticProps.apply(thisArg, args);
- },
- });
- }
- /**
- * @deprecated Use `wrapGetStaticPropsWithSentry` instead.
- */
- const withSentryGetStaticProps = wrapGetStaticPropsWithSentry;
- export { withSentryGetStaticProps, wrapGetStaticPropsWithSentry };
- //# sourceMappingURL=wrapGetStaticPropsWithSentry.js.map
|