getsentry / getsentry/sentry-javascript

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

Open
#18,998 1 comment 0 reactions 0 assignees View on GitHub
Browser Feature
Dominant language
TypeScript
Stars
8.7k
Forks
1.8k
Avg merge
1d 17h
Merged PRs (30d)
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.