getsentry / getsentry/sentry-javascript

Use `client.on('startNavigationSpan')` in the BrowserSession integration

Abierto
#18,998 1 comentario 0 reacciones 0 asignados Ver en GitHub
Browser Feature
Lenguaje dominante
TypeScript
Estrellas
8.7k
Forks
1.8k
Merge medio
1 d 17 h
PR fusionados (30 d)
515

Descripción

### 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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.