-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(nextjs): Mark clientside prefetch request spans with http.request.prefetch: true
attribute
#15980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(nextjs): Mark clientside prefetch request spans with http.request.prefetch: true
attribute
#15980
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
303369c
feat(browser): Add `onRequestSpanStart` hook to browser tracing integ…
lforst 0cdb568
feat(nextjs): Mark clientside prefetch request spans with `http.clien…
lforst 9c357f5
Update packages/browser/src/tracing/browserTracingIntegration.ts
lforst e11d453
optional
lforst 62eba88
size check
lforst 3eea48c
test
lforst 5ac833a
Merge branch 'lforst-request-span-hook' into lforst-nextjs-client-pre…
lforst 94588fd
test
lforst d23e282
soy un idiota
lforst 3f782ca
Merge branch 'develop' into lforst-request-span-hook
lforst 618efe7
Merge branch 'lforst-request-span-hook' into lforst-nextjs-client-pre…
lforst f57e14c
fix test
lforst c26c793
Merge branch 'lforst-request-span-hook' into lforst-nextjs-client-pre…
lforst 8addc76
.
lforst cf111cc
.
lforst 1530703
.
lforst 0aeb77e
Merge branch 'develop' into lforst-nextjs-client-prefetch-op
lforst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
dev-packages/e2e-tests/test-applications/nextjs-15/app/prefetching/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Link from 'next/link'; | ||
|
||
export default function Page() { | ||
return ( | ||
<Link id="prefetch-link" href="/prefetching/to-be-prefetched"> | ||
link | ||
</Link> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
dev-packages/e2e-tests/test-applications/nextjs-15/app/prefetching/to-be-prefetched/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const dynamic = 'force-dynamic'; | ||
|
||
export default function Page() { | ||
return <p>Hello</p>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
dev-packages/e2e-tests/test-applications/nextjs-15/tests/prefetch-spans.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { waitForTransaction } from '@sentry-internal/test-utils'; | ||
|
||
test('Prefetch client spans should have a http.request.prefetch attribute', async ({ page }) => { | ||
test.skip(process.env.TEST_ENV === 'development', "Prefetch requests don't have the prefetch header in dev mode"); | ||
|
||
const pageloadTransactionPromise = waitForTransaction('nextjs-15', async transactionEvent => { | ||
return transactionEvent?.transaction === '/prefetching'; | ||
}); | ||
|
||
await page.goto(`/prefetching`); | ||
|
||
// Make it more likely that nextjs prefetches | ||
await page.hover('#prefetch-link'); | ||
|
||
expect((await pageloadTransactionPromise).spans).toContainEqual( | ||
expect.objectContaining({ | ||
op: 'http.client', | ||
data: expect.objectContaining({ | ||
'http.request.prefetch': true, | ||
}), | ||
}), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: do we care about cases where users register their own
browserTracingIntegration()
? As in should we merge a possible custom implementation with our logic? Not sure what our general approach to this is so feel free to declare undefined behaviour :DThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think user's would be always importing this
browserTracingIntegration
(the Next.js one) so the behavior should already be merged (see line 23). Unless I am misunderstanding.