getsentry / getsentry/sentry-javascript

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

Đang mở
#18,998 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Browser Feature
Ngôn ngữ chính
TypeScript
Star
8.7k
Fork
1.8k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
515

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.