feat(builder): add network context to wizard, export and sidebar analytics events - #419
Merged
Conversation
…ytics events Audit of GA4 event call sites in the UI Builder: - wizard_step, export_clicked and sidebar_interaction now carry network_id and ecosystem alongside their existing params - every string dimension is normalised to "unknown" when missing/empty so event-scoped custom dimensions are never dropped - WizardLayout takes an optional analyticsContext prop; MainActions reads the selected network from the builder store - add component tests asserting exactly one event per user action - document the full event -> params table in ANALYTICS_FEATURE_FLAG.md
Contributor
There was a problem hiding this comment.
Pull request overview
Adds network and ecosystem context to UI Builder analytics events, normalizes missing values, and expands test coverage and documentation.
Changes:
- Extended wizard, export, and sidebar analytics payloads.
- Added fallback normalization and analytics tests.
- Updated the GA4 event documentation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
apps/builder/src/hooks/useBuilderAnalytics.ts |
Adds analytics context and fallback handling. |
apps/builder/src/hooks/__tests__/useBuilderAnalytics.test.ts |
Tests context and fallback behavior. |
apps/builder/src/components/UIBuilder/index.tsx |
Supplies wizard analytics context. |
apps/builder/src/components/UIBuilder/hooks/useCompleteStepState.ts |
Adds export network context. |
apps/builder/src/components/Sidebar/AppSidebar/MainActions.tsx |
Adds sidebar network context. |
apps/builder/src/components/Sidebar/AppSidebar/__tests__/MainActions.analytics.test.tsx |
Tests sidebar analytics events. |
apps/builder/src/components/Common/WizardLayout.tsx |
Adds wizard analytics context propagation. |
apps/builder/src/components/Common/__tests__/WizardLayout.analytics.test.tsx |
Tests wizard event behavior. |
apps/builder/ANALYTICS_FEATURE_FLAG.md |
Documents the complete event parameter table. |
Suppressed comments (1)
apps/builder/src/hooks/useBuilderAnalytics.ts:62
- The normalization guarantee in the new documentation/PR contract does not cover
network_selected: this hook only overridestrackEcosystemSelection, whiletrackNetworkSelectionis still the method inherited through...analytics. If the shared hook receives an empty network ID or ecosystem, those values can still be sent without theunknownfallback. Wrap this method here (preserving the shared analytics gating) or otherwise ensure it applies the same normalization, and add a regression test for empty inputs.
trackEcosystemSelection: (ecosystem: string) => {
analytics.trackEvent('ecosystem_selected', { ecosystem: orUnknown(ecosystem) });
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Audit + gap fill of the UI Builder GA4 events ahead of registering event-scoped custom dimensions. No new event types; existing param names are unchanged.
wizard_step,export_clicked,sidebar_interactionnow includenetwork_idandecosystem."unknown"when missing/empty (centralorUnknown/networkParamshelpers inuseBuilderAnalytics.ts).WizardLayouttakes an optionalanalyticsContextprop (fed from the builder store inUIBuilder/index.tsx) so the common component stays store-agnostic;MainActionsreadsselectedNetworkConfigId/selectedEcosystemviauseUIBuilderStore.ANALYTICS_FEATURE_FLAG.mdnow carries the full event → params table.Event → params table
page_viewpage_title,page_location(GA defaults)gtag('config'); no manualtrackPageViewcallsAnalyticsProviderinApp.tsxecosystem_selectedecosystemChainSelector.tsx,useBuilderLifecycle.tsnetwork_selectednetwork_id,ecosystemChainSelector.tsx,useBuilderLifecycle.tswizard_stepstep_number,step_name,network_id✨,ecosystem✨Common/WizardLayout.tsxexport_clickedexport_type,network_id✨,ecosystem✨hooks/useCompleteStepState.tssidebar_interactionaction,network_id✨,ecosystem✨Sidebar/AppSidebar/MainActions.tsxtransaction_executednetwork_id,ecosystem,execution_methodStepFormCustomization/FormPreview.tsxcontract_ui_creatednetwork_id,ecosystem,total_recordshooks/builder/useAutoSave.tsrelayer_service_configurednetwork_id,ecosystemRelayerConfiguration/index.tsxuikit_changednetwork_id,ecosystem,uikit_nameUiKitSettings.tsxaddress_book_openednetwork_id,ecosystemAddressBook/AddressBookDialog.tsx✨ = added in this PR. Custom dimensions to register:
ecosystem,network_id,step_name,step_number,export_type,action,execution_method,uikit_name,total_records.Audit findings
trackWizardStepcalls inWizardLayout.tsxare the Next and Back handlers; each fires once per click.relayer_service_configuredandaddress_book_openedare ref-guarded;contract_ui_createdonly fires on the CREATE path;ecosystem_selectedfrom deep links is guarded by a change check.page_viewis not double-counted.gtag('config', tagId)is called withoutsend_page_view: false, so GA sends one automatic page_view, and nothing inapps/buildercallstrackPageView(the hook only passes it through). No fix needed.contract_ui_created/address_book_openedhad'unknown'fallbacks; the hook now applies them uniformly.pendingNetworkId, sidebar record load) bypassWizardLayout's Next/Back handlers and therefore do not emitwizard_step. This matches the "user clicked" semantics of the event; flagging in case a step-entered metric is wanted later.export_typeis still hard-coded toreact-vite(the only template today).Verification
pnpm lint,pnpm typecheck(builder) — cleanpnpm test(repo root) — 49 files / 335 tests builder, all other packages pass