getsentry / getsentry/sentry-javascript
Use `client.on('startNavigationSpan')` in the BrowserSession integration
- Langage dominant
- TypeScript
- Étoiles
- 8.7k
- Forks
- 1.8k
- Merge moyen
- 1 j 17 h
- PR mergées (30 j)
- 515
Description
### Description
follow up to https://github.com/getsentry/sentry-javascript/issues/18921#issuecomment-3790620627
Right now we make use of `addHistoryInstrumentationHandler`, which listens on the `popstate` event listener. This works fine, but when tracing is enabled `client.on('startNavigationSpan')` is more granular for specific libraries, such as reactrouter: https://github.com/getsentry/sentry-javascript/blob/c45eae4648179c8d565439ec07d0ec386babf9d6/packages/react/src/reactrouter.tsx#L174-L181
With the `client.on` approach, there _might be 2 problems_:
1. There won't be any `from` anymore. So in case we would implement a function to exclude certain routes, we would only have the `to` parameter in a slightly different format
2. If my research is correct, we might have receive 1 more session, as we don't skip the first transaction (as there is a `from !== undefined`, which would be the first navigation): https://github.com/getsentry/sentry-javascript/blob/c45eae4648179c8d565439ec07d0ec386babf9d6/packages/browser/src/integrations/browsersession.ts#L50
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.