You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(browser): Add afterStartPageloadSpan hook to improve spanId assignment on web vital spans (#16893)
Our standalone web vital spans need to include the span id of the
`pageload` span s.t. we can correctly assign the web vital value to the
respective pageload span in the Sentry backend.
In the previous implementation, we'd simply wait for a tick after
tracking the web vitals, get the active root span and take its spanId if
it was a pageload span. However, this relies on the assumption that the
pageload span is indeed started immediately. By default this happens but
users can always deactivate default behaviour and call
`startBrowserTracingPageloadSpan` whenever they want (for example, in a
custom `browserTracingIntegration`).
Furthermore, this "wait for a tick" logic always bugged me and was only
done because `getClient()` would not yet return the already initialized
client.
This change now makes the pageload spanId retrieval more robust by
- adding and listening to a new SDK lifecycle hook:
`afterStartPageloadSpan`. This callback fires as soon as the pageload
span is actually started and available.
- passing the `client` from the `browserTracingIntegration`'s `setup`
hook into the web vital listening function so that we can remove the
`setTimeout(_, 0)` logic.
0 commit comments