Skip to content

Commit

Permalink
add flag to enable auto-wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
lobsterkatie committed Aug 8, 2022
1 parent 560716b commit 57f6065
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions packages/nextjs/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export type UserSentryOptions = {
// 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
// up uploading too many files, which is why this defaults to `false`.
widenClientFileUpload?: boolean;

// Automatically wrap `getServerSideProps`, `getStaticProps`, and `getStaticPaths` in order to instrument them for
// tracing.
autoWrapDataFetchers?: boolean;
};

export type NextConfigFunction = (phase: string, defaults: { defaultConfig: NextConfigObject }) => NextConfigObject;
Expand Down
21 changes: 12 additions & 9 deletions packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,20 @@ export function constructWebpackConfigFunction(
},
],
},
{
test: pageRegex,
use: [
{
loader: path.resolve(__dirname, 'loaders/dataFetchersLoader.js'),
options: { projectDir },
},
],
},
],
};

if (userSentryOptions.autoWrapDataFetchers) {
newConfig.module.rules.push({
test: pageRegex,
use: [
{
loader: path.resolve(__dirname, 'loaders/dataFetchersLoader.js'),
options: { projectDir },
},
],
});
}
}

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

0 comments on commit 57f6065

Please sign in to comment.