Skip to content

Commit 2148ad7

Browse files
committed
feat: add capture_pageleave 'on_navigation' option
Add new 'on_navigation' option for capture_pageleave config that captures pageleave events on every SPA navigation (pushState, replaceState, popstate) in addition to window unload. This enables the expected behavior pattern: - pageView A → (navigate) → pageLeave A + pageView B → (navigate) → pageLeave B + pageView C The implementation leverages PageViewManager.doPageLeave() to include all scroll properties and previous pageview metadata in the pageleave event. Changes: - Add 'on_navigation' as new capture_pageleave option type - Add _shouldCapturePageleaveOnNavigation() method to check if feature is enabled - Modify HistoryAutocapture to call PageViewManager.doPageLeave() before capturing pageview during navigation - Add _hasNavigated flag to prevent pageleave on first navigation - Add comprehensive test coverage for all navigation types fix: add missing _shouldCapturePageleaveOnNavigation mock to test setup The main beforeEach was missing the mock for _shouldCapturePageleaveOnNavigation, which caused the 'should track history through multiple pageviews' test to fail. This method is called during navigation to check if pageleave should be captured, so it needs to be mocked (returning false) for tests that aren't testing pageleave. refactor: remove redundant _hasNavigated flag, rely on PageViewManager state Check $prev_pageview_id from doPageLeave() to determine if there's a previous page to capture pageleave for. refactor: remove redundant _hasNavigated flag, rely on PageViewManager state Check from doPageLeave() to determine if there's a previous page to capture pageleave for. Discard changes to .vscode/settings.json Discard changes to packages/browser/src/session-props.ts wip
1 parent 98bacc0 commit 2148ad7

File tree

5 files changed

+620
-1
lines changed

5 files changed

+620
-1
lines changed

0 commit comments

Comments
 (0)