File tree 6 files changed +50
-2
lines changed
dev-packages/e2e-tests/test-applications/nextjs-15
packages/nextjs/src/client
6 files changed +50
-2
lines changed Original file line number Diff line number Diff line change
1
+ import Link from 'next/link' ;
2
+
3
+ export default function Page ( ) {
4
+ return (
5
+ < Link id = "prefetch-link" href = "/prefetching/to-be-prefetched" >
6
+ link
7
+ </ Link >
8
+ ) ;
9
+ }
Original file line number Diff line number Diff line change
1
+ export const dynamic = 'force-dynamic' ;
2
+
3
+ export default function Page ( ) {
4
+ return < p > Hello</ p > ;
5
+ }
Original file line number Diff line number Diff line change 2
2
/// <reference types="next/image-types/global" />
3
3
4
4
// NOTE: This file should not be edited
5
- // see https://nextjs.org/docs/app/building-your-application/configuring /typescript for more information.
5
+ // see https://nextjs.org/docs/app/api-reference/config /typescript for more information.
Original file line number Diff line number Diff line change 18
18
"@types/node" : " ^18.19.1" ,
19
19
"@types/react" : " 18.0.26" ,
20
20
"@types/react-dom" : " 18.0.9" ,
21
- "next" : " 15.0 .0-canary.182 " ,
21
+ "next" : " 15.3 .0-canary.33 " ,
22
22
"react" : " beta" ,
23
23
"react-dom" : " beta" ,
24
24
"typescript" : " ~5.0.0"
Original file line number Diff line number Diff line change
1
+ import { expect , test } from '@playwright/test' ;
2
+ import { waitForTransaction } from '@sentry-internal/test-utils' ;
3
+
4
+ test ( 'Prefetch client spans should have a http.request.prefetch attribute' , async ( { page } ) => {
5
+ test . skip ( process . env . TEST_ENV === 'development' , "Prefetch requests don't have the prefetch header in dev mode" ) ;
6
+
7
+ const pageloadTransactionPromise = waitForTransaction ( 'nextjs-15' , async transactionEvent => {
8
+ return transactionEvent ?. transaction === '/prefetching' ;
9
+ } ) ;
10
+
11
+ await page . goto ( `/prefetching` ) ;
12
+
13
+ // Make it more likely that nextjs prefetches
14
+ await page . hover ( '#prefetch-link' ) ;
15
+
16
+ expect ( ( await pageloadTransactionPromise ) . spans ) . toContainEqual (
17
+ expect . objectContaining ( {
18
+ op : 'http.client' ,
19
+ data : expect . objectContaining ( {
20
+ 'http.request.prefetch' : true ,
21
+ } ) ,
22
+ } ) ,
23
+ ) ;
24
+ } ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,16 @@ export function browserTracingIntegration(
12
12
...options ,
13
13
instrumentNavigation : false ,
14
14
instrumentPageLoad : false ,
15
+ onRequestSpanStart ( ...args ) {
16
+ const [ span , { headers } ] = args ;
17
+
18
+ // Next.js prefetch requests have a `next-router-prefetch` header
19
+ if ( headers ?. get ( 'next-router-prefetch' ) ) {
20
+ span ?. setAttribute ( 'http.request.prefetch' , true ) ;
21
+ }
22
+
23
+ return options . onRequestSpanStart ?.( ...args ) ;
24
+ } ,
15
25
} ) ;
16
26
17
27
const { instrumentPageLoad = true , instrumentNavigation = true } = options ;
You can’t perform that action at this time.
0 commit comments