OpenZeppelin / OpenZeppelin/openzeppelin-ui
AnalyticsService: page_view double-counted when apps also call trackPageView
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7
- Forks
- 3
- Avg merge
- 20h 20m
- Merged PRs (30d)
- 26
Description
Problem
AnalyticsService.initializeGtag (packages/utils/src/AnalyticsService.ts, line ~175) calls gtag('config', tagId) without send_page_view: false, so gtag emits its automatic page_view on load. Apps that also track route changes via trackPageView (Role Manager and RWA Wizard both mount a TrackedRoute component) therefore send two page_view events on first landing — inflating page-view counts in GA4 by one per session. UI Builder is unaffected because it never calls trackPageView.
Surfaced while wiring GA4 custom dimensions for the analytics pipeline (OpenZeppelin/rwa-wizard#63).
Suggested fix
Either:
- Add a
sendPageViewoption (defaulttrueto preserve current behaviour) toAnalyticsService.initialize/AnalyticsProvider, passed through asgtag('config', tagId, { send_page_view }), so apps with route tracking can opt out; or - Flip the default to
send_page_view: falseand document that apps must calltrackPageView(breaking for apps relying on the automatic hit).
Consumers to update after release: role-manager and rwa-wizard TrackedRoute usages.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/utils/src/AnalyticsService.ts at AnalyticsService.initializeGtag around line 175, then trace initialize, AnalyticsProvider, and trackPageView. Inspect the TrackedRoute usages in Role Manager and RWA Wizard, while noting that UI Builder does not call trackPageView. Done means the chosen behavior is supported and those route-tracking apps no longer send a duplicate first-landing page_view without breaking existing automatic tracking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- analytics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100