Skip to content

Commit d9e4118

Browse files
committed
add flag to enable auto-wrapping
1 parent cf0056e commit d9e4118

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

packages/nextjs/src/config/types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export type UserSentryOptions = {
4949
// uploaded. At the same time, we don't want to widen the scope if we don't have to, because we're guaranteed to end
5050
// up uploading too many files, which is why this defaults to `false`.
5151
widenClientFileUpload?: boolean;
52+
53+
// Automatically wrap `getServerSideProps`, `getStaticProps`, and `getStaticPaths` in order to instrument them for
54+
// tracing.
55+
autoWrapDataFetchers?: boolean;
5256
};
5357

5458
export type NextConfigFunction = (phase: string, defaults: { defaultConfig: NextConfigObject }) => NextConfigObject;

packages/nextjs/src/config/webpack.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,20 @@ export function constructWebpackConfigFunction(
7474
},
7575
],
7676
},
77-
{
78-
test: pageRegex,
79-
use: [
80-
{
81-
loader: path.resolve(__dirname, 'loaders/dataFetchersLoader.js'),
82-
options: { projectDir },
83-
},
84-
],
85-
},
8677
],
8778
};
79+
80+
if (userSentryOptions.autoWrapDataFetchers) {
81+
newConfig.module.rules.push({
82+
test: pageRegex,
83+
use: [
84+
{
85+
loader: path.resolve(__dirname, 'loaders/dataFetchersLoader.js'),
86+
options: { projectDir },
87+
},
88+
],
89+
});
90+
}
8891
}
8992

9093
// The SDK uses syntax (ES6 and ES6+ features like object spread) which isn't supported by older browsers. For users

0 commit comments

Comments
 (0)