Skip to content

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

@JPeer264

Description

@JPeer264

Description

follow up to #18921 (comment)

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:

startBrowserTracingNavigationSpan(client, {
name,
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'navigation',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: `auto.navigation.react.${instrumentationName}`,
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
},
});

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):
    if (from !== undefined && from !== to) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions