Skip to content

[NT-2598] Add React Native extended view tracking#170

Merged
Alex Freas (akfreas) merged 6 commits intomainfrom
NT-2598-add-react-native-extended-view-tracking
Mar 11, 2026
Merged

[NT-2598] Add React Native extended view tracking#170
Alex Freas (akfreas) merged 6 commits intomainfrom
NT-2598-add-react-native-extended-view-tracking

Conversation

@akfreas
Copy link
Copy Markdown
Collaborator

Upgrades useViewportTracking from a single fire-and-forget event to the Web SDK's ElementViewObserver pattern: accumulated duration tracking, periodic updates, and final events per visibility cycle.

This aligns the RN SDK with the RFC's "Batched, Duration-based ComponentViews" recommendation.

  • Rewrite useViewportTracking with a ViewCycleState machine that accumulates real visible time instead of sending the configured threshold as viewDurationMs
  • Emit periodic update events at a configurable viewDurationUpdateIntervalMs (default 5s) after the initial dwell event
  • Emit a final event when visibility ends (only if at least one event was already fired)
  • Add AppState listener to pause/resume time accumulation on app background/foreground
  • Thread new viewDurationUpdateIntervalMs prop through <Personalization> and <Analytics>
  • Stable componentViewId per visibility cycle, fresh ID on each new cycle
  • Update spec 023 with new acceptance scenarios, FRs, and success criteria
  • Add unit tests for the hook and Detox e2e tests for periodic events, duration accumulation, and scroll-away/back cycles
  • Enrich AnalyticsEventDisplay with per-component stats for e2e observability

@akfreas Alex Freas (akfreas) force-pushed the NT-2598-add-react-native-extended-view-tracking branch from d2c0be7 to d12f850 Compare March 10, 2026 14:35
@akfreas Alex Freas (akfreas) marked this pull request as ready for review March 11, 2026 13:41
@akfreas Alex Freas (akfreas) force-pushed the NT-2598-add-react-native-extended-view-tracking branch from e3bd8c4 to 13401ca Compare March 11, 2026 14:01
@akfreas Alex Freas (akfreas) marked this pull request as draft March 11, 2026 14:13
@akfreas Alex Freas (akfreas) marked this pull request as ready for review March 11, 2026 16:36
@akfreas Alex Freas (akfreas) merged commit 3be1b1e into main Mar 11, 2026
30 checks passed
@akfreas Alex Freas (akfreas) deleted the NT-2598-add-react-native-extended-view-tracking branch March 11, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants