Skip to content

feat(web-sdk): add Navigation event instrumentation #1317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

eskirk
Copy link
Collaborator

@eskirk eskirk commented Jun 12, 2025

Why

very requested feature for JS apps that do not use React/react-router instrumentations.

What

this instrumentation will track page navigation and URL changes in any instrumented applications.

Links

#485

Checklist

  • Tests added
  • Changelog updated
  • Documentation updated
@eskirk eskirk self-assigned this Jun 12, 2025
@eskirk eskirk added feature Request a new feature improvement Request a change of an existing feature labels Jun 12, 2025
@eskirk eskirk requested review from codecapitano and kpelelis June 13, 2025 00:13
@codecapitano
Copy link
Collaborator

codecapitano commented Jun 13, 2025

Hi @eskirk

Let's reconsider the purpose and function of the instrumentation.

The current method generates an event for every history event, which is excessive and doesn't provide valuable data for Real User Monitoring (RUM). This results in a high volume of events with limited insights.

Instead, let's focus on the essential insights and data users require. Primarily, this involves user navigation, specifically "route changes" or "soft navigations." The crucial data here is tracking these changes, similar to our React Router instrumentation, including for example "from" and "to" routes (it's already part of some events).

It's also important to differentiate between a soft navigation and a URL update that simply defines state on the same page. This is complex, but we can begin with a simpler approach. For instance, if only query parameters change between the new and old URLs, it's likely not a navigation. The WICG proposal on detecting soft navigations may offer some useful inspiration.

Next steps / iterations would be to update the instrumentation to track important metrics to assess the health and performance of the navigations.

private currentHash: string | null = null;

initialize() {
console.log('NavigationInstrumentation initialized', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log

});
};

window.addEventListener('popstate', (event) => {
Copy link
Collaborator

@codecapitano codecapitano Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Popstate will be triggered for history.back(), .forward() and .go().
So we always send two events.

I assume these are considered as something like sidecar events to provide more context ?
Let's not enable them by default. It's technical browser events but not really related to the trace of the user.
For example we can provide a setting to let users enable them if they really need it.

Do you have an example how they enhance the RCA flow?

@eskirk eskirk marked this pull request as draft June 13, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Request a new feature improvement Request a change of an existing feature
2 participants