-
-
Couldn't load subscription status.
- Fork 1.7k
feat(browser): Add beforeStartNavigationSpan lifecycle hook
#16863
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
+69
−18
Conversation
This file contains hidden or 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
size-limit report 📦
|
mydea
approved these changes
Jul 10, 2025
|
no strong feelings, but imho this can also be |
s1gr1d
approved these changes
Jul 10, 2025
beforeStartNavigationSpan lifecycle hookbeforeStartNavigationSpan lifecycle hook
768d7ce to
ed3c762
Compare
Lms24
added a commit
that referenced
this pull request
Jul 10, 2025
…eload span (#16864) Fix a bug in standalone web vital spans where, if they were sent because of a navigation, they would incorrectly be added to the `navigation` span's trace instead of the initial `pageload` span's trace. This surfaced while dogfooding these spans on sentry and inspecting them in the EAP traceview. To fix this, I added a lifecycle hook in #16863 that triggers right before we start preparing the navigation span and hence, right before we recycle the propagation context to the new traceId. This patch now makes use of the new hook for CLS and LCP spans and it also makes the integration tests stricter to check for the correct trace ids.
This was referenced Sep 29, 2025
This was referenced Oct 7, 2025
This was referenced Oct 15, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Also affects:
@sentry/coreThis PR adds a new
beforeStartNavigationSpanlifecycle hook that gets triggered directly before thestartNavigationSpanhook by thestartBrowserTracingNavigationSpanhelper function. The reason we need this is because we have logic for standalone CLS and LCP spans that needs to run before we start preparing any work that's executed at thestartNavigationSpanhook:beforeStartNavigationSpan: send standalone span with the pageload trace id (i.e. the currently still active trace id on the propagation contextstartNavigationSpan: first recycles the propagation context, then starts the new spanIn a follow-up PR, I'll switch LCP and CLS standalone span sending over to this event rather than
startNavigationSpanwhich previously caused these spans to be added to the new navigation trace id rather than to the pageload trace id.