Skip to content

Commit 29ee43f

Browse files
author
Luca Forstner
committed
Add isBuildCheck to getStaticProps
1 parent 59bb0d8 commit 29ee43f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/nextjs/src/config/wrappers/withSentryGetStaticProps.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GetStaticProps } from 'next';
22

3-
import { callDataFetcherTraced } from './wrapperUtils';
3+
import { isBuild } from '../../utils/isBuild';
4+
import { callDataFetcherTraced, withErrorInstrumentation } from './wrapperUtils';
45

56
type Props = { [key: string]: unknown };
67

@@ -18,7 +19,13 @@ export function withSentryGetStaticProps(
1819
return async function (
1920
...getStaticPropsArguments: Parameters<GetStaticProps<Props>>
2021
): ReturnType<GetStaticProps<Props>> {
21-
return callDataFetcherTraced(origGetStaticProps, getStaticPropsArguments, {
22+
if (isBuild()) {
23+
return origGetStaticProps(...getStaticPropsArguments);
24+
}
25+
26+
const errorWrappedGetStaticProps = withErrorInstrumentation(origGetStaticProps);
27+
28+
return callDataFetcherTraced(errorWrappedGetStaticProps, getStaticPropsArguments, {
2229
parameterizedRoute,
2330
dataFetchingMethodName: 'getStaticProps',
2431
});

0 commit comments

Comments
 (0)