Skip to content

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

Merged
wyf7107 merged 8 commits into
google:mainfrom
lkang172:telemetry-ga4-instrumentation
Jul 29, 2026
Merged

feat(web): Instrument GA4 events and user properties for telemetry tracking#470
wyf7107 merged 8 commits into
google:mainfrom
lkang172:telemetry-ga4-instrumentation

Conversation

@lkang172

@lkang172 lkang172 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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.

…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
@lkang172
lkang172 force-pushed the telemetry-ga4-instrumentation branch from f046c65 to ce55832 Compare July 29, 2026 04:59
@wyf7107
wyf7107 merged commit 8a2d44c into google:main Jul 29, 2026
8 checks passed
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