Skip to content

Commit 7e7824c

Browse files
committed
filter static assets
1 parent d11620e commit 7e7824c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/nextjs/src/server/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,13 @@ export function init(options: NodeOptions): void {
115115

116116
const filterLowQualityTransactions: EventProcessor = event => {
117117
if (event.type === 'transaction') {
118-
// TODO:
119-
// - Next.js automatically creates spans for ALL resources. This can be noisy but we let the noise live for now. We may want to filter the transactions for certain resources, like static assets, in the future.
120-
// - When, and if we should decide to filter these transactions, good consideration needs to be put into how to filter them. The path for static assets depends on the `basePath` and `assetPrefix` options.
121-
// if (event.transaction?.match(/GET \/.*\/static\/.*.js/)) {
122-
// return null;
123-
// }
118+
/** This function filters transactions for requests to the Next.js static assets as those requests lead to a lot of noise in the Sentry dashboard.
119+
* By setting the next.config.js options `basePath` and `assetPrefix`, the path to the static assets might be changed.
120+
* This regex matches the default path to the static assets (`_next/static`) and could potentially filter out too many transactions.
121+
*/
122+
if (event.transaction?.match(/GET \/_next\/static\/.*/)) {
123+
return null;
124+
}
124125

125126
if (
126127
globalWithInjectedValues.__sentryRewritesTunnelPath__ &&

0 commit comments

Comments
 (0)