@@ -500,12 +500,12 @@ function shouldAddSentryToEntryPoint(
500
500
excludeServerRoutes : Array < string | RegExp > = [ ] ,
501
501
isDev : boolean ,
502
502
) : boolean {
503
- if ( entryPointName === 'middleware' ) {
504
- return true ;
505
- }
506
-
507
503
// On the server side, by default we inject the `Sentry.init()` code into every page (with a few exceptions).
508
504
if ( isServer ) {
505
+ if ( entryPointName === 'middleware' ) {
506
+ return true ;
507
+ }
508
+
509
509
const entryPointRoute = entryPointName . replace ( / ^ p a g e s / , '' ) ;
510
510
511
511
// User-specified pages to skip. (Note: For ease of use, `excludeServerRoutes` is specified in terms of routes,
@@ -527,23 +527,18 @@ function shouldAddSentryToEntryPoint(
527
527
// versions.)
528
528
entryPointRoute === '/_app' ||
529
529
entryPointRoute === '/_document' ||
530
- // Newer versions of nextjs are starting to introduce things outside the `pages/` folder (middleware, an `app/`
531
- // directory, etc), but until those features are stable and we know how we want to support them, the safest bet is
532
- // not to inject anywhere but inside `pages/`.
533
530
! entryPointName . startsWith ( 'pages/' )
534
531
) {
535
532
return false ;
536
533
}
537
534
538
535
// We want to inject Sentry into all other pages
539
536
return true ;
540
- }
541
-
542
- // On the client side, we only want to inject into `_app`, because that guarantees there'll be only one copy of the
543
- // SDK in the eventual bundle. Since `_app` is the (effectively) the root component for every nextjs app, inclusing
544
- // Sentry there means it will be available for every front end page.
545
- else {
546
- return entryPointName === 'pages/_app' ;
537
+ } else {
538
+ return (
539
+ entryPointName === 'pages/_app' || // entrypoint for `/pages` pages
540
+ entryPointName === 'main-app' // entrypoint for `/app` pages
541
+ ) ;
547
542
}
548
543
}
549
544
0 commit comments