@@ -500,12 +500,12 @@ function shouldAddSentryToEntryPoint(
500500 excludeServerRoutes : Array < string | RegExp > = [ ] ,
501501 isDev : boolean ,
502502) : boolean {
503- if ( entryPointName === 'middleware' ) {
504- return true ;
505- }
506-
507503 // On the server side, by default we inject the `Sentry.init()` code into every page (with a few exceptions).
508504 if ( isServer ) {
505+ if ( entryPointName === 'middleware' ) {
506+ return true ;
507+ }
508+
509509 const entryPointRoute = entryPointName . replace ( / ^ p a g e s / , '' ) ;
510510
511511 // User-specified pages to skip. (Note: For ease of use, `excludeServerRoutes` is specified in terms of routes,
@@ -527,23 +527,18 @@ function shouldAddSentryToEntryPoint(
527527 // versions.)
528528 entryPointRoute === '/_app' ||
529529 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/`.
533530 ! entryPointName . startsWith ( 'pages/' )
534531 ) {
535532 return false ;
536533 }
537534
538535 // We want to inject Sentry into all other pages
539536 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+ ) ;
547542 }
548543}
549544
0 commit comments