@@ -93,7 +93,7 @@ export function withSentryConfig<C>(nextConfig?: C, sentryBuildOptions: SentryBu
9393
9494/**
9595 * Checks if the user has a middleware/proxy file with a matcher that might exclude the tunnel route.
96- * Warns the user if they have a matcher but are not using withSentryMiddlewareConfig or withSentryProxyConfig .
96+ * Warns the user if their matcher might interfere with the tunnel route .
9797 */
9898function checkMiddlewareMatcherForTunnelRoute ( tunnelPath : string ) : void {
9999 if ( showedMiddlewareMatcherWarning ) {
@@ -108,29 +108,20 @@ function checkMiddlewareMatcherForTunnelRoute(tunnelPath: string): void {
108108 return ;
109109 }
110110
111- // Check if they're already using Sentry middleware/proxy config helpers
112- if (
113- middlewareFile . contents . includes ( 'withSentryMiddlewareConfig' ) ||
114- middlewareFile . contents . includes ( 'withSentryProxyConfig' )
115- ) {
116- return ;
117- }
118-
119111 // Look for config.matcher export
120112 const isProxy = middlewareFile . path . includes ( 'proxy' ) ;
121113 const hasConfigMatcher = / e x p o r t \s + c o n s t \s + c o n f i g \s * = \s * { [ ^ } ] * m a t c h e r \s * : / s. test ( middlewareFile . contents ) ;
122114
123115 if ( hasConfigMatcher ) {
124- const helperName = isProxy ? 'withSentryProxyConfig' : 'withSentryMiddlewareConfig' ;
125116 // eslint-disable-next-line no-console
126117 console . warn (
127118 `[@sentry/nextjs] WARNING: You have a ${ isProxy ? 'proxy' : 'middleware' } file (${ path . basename ( middlewareFile . path ) } ) with a \`config.matcher\`. ` +
128- `If your matcher does not include the Sentry tunnel route (${ tunnelPath } ), tunnel requests may be blocked . ` +
129- `To ensure your matcher doesn't interfere with Sentry event delivery, wrap your config with \` ${ helperName } \` :\n\n` +
130- ` import { ${ helperName } } from '@sentry/nextjs';\n` +
131- ` export const config = ${ helperName } ({\n` +
132- " matcher: ['/your/routes'] ,\n" +
133- ' }) ;\n' ,
119+ `If your matcher runs on the Sentry tunnel route (${ tunnelPath } ), it may interfere with event delivery . ` +
120+ 'Please ensure your matcher excludes the tunnel route. For example :\n\n' +
121+ ' export const config = {\n' +
122+ ' // Use a negative lookahead to exclude the Sentry tunnel route\n' +
123+ ` matcher: '/((?! ${ tunnelPath . replace ( / ^ \/ / , '' ) } |_next/static|_next/image|favicon.ico).*)' ,\n` +
124+ ' };\n' ,
134125 ) ;
135126 showedMiddlewareMatcherWarning = true ;
136127 }
0 commit comments