Skip to content

feat(web): Instrument GA4 events and user properties for telemetry tracking - #470

Open
lkang172 wants to merge 5 commits into
google:mainfrom
lkang172:telemetry-ga4-instrumentation
Open

feat(web): Instrument GA4 events and user properties for telemetry tracking#470
lkang172 wants to merge 5 commits into
google:mainfrom
lkang172:telemetry-ga4-instrumentation

Conversation

@lkang172

@lkang172 lkang172 commented Jul 20, 2026

Copy link
Copy Markdown

This PR instruments Google Analytics 4 (GA4) telemetry events and user properties across the Web UI, fully gated by the user's telemetry consent preference.

Changes Included

  • AnalyticsService (analytics.service.ts):
    • Manages dynamic GA4 script initialization and event dispatches.
    • Enforces strict consent gating using an Angular effect() on TelemetryService.telemetryEnabled().
    • Sets ga-disable-<MEASUREMENT_ID> = true and drops all outbound dispatches when consent is withheld (false/null).
  • Custom Telemetry Events:
    • Logs interaction events without any extra parameters upon feature usage:
      • chat_session_create: creating a new chat session in ChatComponent.
      • builder_enter_click: entering builder mode in ChatComponent.
      • builder_agent_save_click: saving an agent build in BuilderTabsComponent.
      • graph_view_click: opening the agent structure graph in ChatComponent.
      • trace_view_toggle: navigating to the Trace tab in SidePanelComponent.
      • event_view_toggle: navigating to the Event tab in SidePanelComponent.
      • eval_create_click: creating a new eval case in AddEvalSessionDialogComponent.
  • Testing:
    • Added unit test suite (analytics.service.spec.ts) covering event/property dispatches and consent enforcement.

Verification

  • Verified production bundle build via npx ng build --configuration development.
  • Verified unit test suite execution.

lkang172 added 3 commits July 17, 2026 20:52
Add TelemetryConsentDialogComponent and integrate it into ChatComponent initialization to prompt the user for consent when unset. Add a slide toggle for 'Usage Metrics' to the user settings menu, and implement optimistic updates with rollback capability on network/API failure.
…acking

- Create AnalyticsService to manage GA4 initialization, User Properties, and event dispatches gated by user consent.
- Set adk_version and adk_language User Properties via gtag when /version API resolves.
- Instrument standalone telemetry events for feature usage: chat_session_create, builder_enter_click, builder_agent_save_click, graph_view_click, trace_view_toggle, event_view_toggle, and eval_create_click.
- Add comprehensive AnalyticsService unit tests.
@lkang172 lkang172 changed the title Telemetry GA4 instrumentation feat(web): Instrument GA4 events and user properties for telemetry tracking Jul 20, 2026
lkang172 and others added 2 commits July 22, 2026 17:52
Update TelemetryService and unit tests to request /config/telemetry instead of /api/config/telemetry to match the FastAPI route registered in dev_server.py.
@lkang172
lkang172 marked this pull request as ready for review July 27, 2026 18:20
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.

1 participant