Skip to content

Analytics updates - #260

Merged
jgindin merged 8 commits into
mainfrom
analytics-updates
Oct 9, 2026
Merged

jgindin merged 8 commits into
mainfrom
analytics-updates

Conversation

@jgindin

@jgindin jgindin commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Tweaks to how we handle Google Analytics updates:

  • Ensure GA4 events have usage_type and env_mode dimensions
  • resolve config options before defining window.gtag
  • use LocalStorageInteractions for GA4 client ID

Pre-launch Checklist

  • I signed the [CLA].
  • I read the [Contributors Guide].
  • I read the [Style Guide].
  • I have added updates to the [CHANGELOG].
  • I updated/added relevant documentation.
  • My code changes (if any) have tests.
  • If my branch is on fork, I have verified that scripts/e2e_test.sh passes.

Remove gcloud token lookup and authentication references from
scripts/create_ga4_dimensions.sh, README.md, and
Ga4UsageTrackingService JSDoc. Display the Google OAuth 2.0 Playground
instructions when no valid ACCESS_TOKEN is provided, and update the
script generation assertions in scripts/update_ga4_dimensions.test.mjs.
Add LocalStorageKey.GA4_CLIENT_ID and refactor
Ga4UsageTrackingService.getOrCreatePersistentClientId() to read and
write the persistent client ID through LocalStorageInteractions instead
of accessing localStorage directly.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors GA4 usage tracking to authenticate via the Google OAuth 2.0 Playground instead of gcloud, updates related scripts and documentation, and migrates direct localStorage access to LocalStorageInteractions. It also introduces new custom dimensions for file opening and CL creation statuses and reasons. Feedback highlights that removing the reason dimension from create_ga4_dimensions.sh will cause an existing unit test in scripts/update_ga4_dimensions.test.mjs to fail, and suggests a fix to inject the dimension during test setup.

Comment thread scripts/create_ga4_dimensions.sh Resolved
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

Your automated preview is successfully live (commit 06eb0a1):
👉 Launch PR Preview

Note: This environment will be wiped automatically when the PR is merged or closed.

Previously, we were using the "status" and "reason" dimensions for
 different cases, so they would get mixed up.
Evaluate getConfigOptions() before assigning window.gtag in
Ga4UsageTrackingService.initialize() so synchronous storage warnings
logged by LocalStorageInteractions cannot dispatch composer_error events
into dataLayer ahead of the initial gtag('config', ...) call.
Allow Ga4UsageTrackingService subclasses to override
 dispatchGtagEvent() and getOrCreatePersistentClientId()
Any event created not created by us wasn't carrying these dimensions, and
so reports show them as "(not set)".

@suyangw-g suyangw-g left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments on test coverage for the new getConfigOptions() dimensions, the initialize() ordering guard when window.gtag is pre-defined, and display name consistency in update_ga4_dimensions.mjs.

Comment thread scripts/create_ga4_dimensions.sh Resolved
- Suppress events dispatched while initialize() resolves config and
  issues gtag('js')/gtag('config') via an isInitializing flag, so
  re-entrant composer_error events cannot precede config even when
  window.gtag is pre-defined.
- Add LocalStorageInteractions.readItem() to distinguish a failed read
  from a missing key, and skip the follow-up setItem() for the GA4
  client ID when the read fails.
- Consolidate subclass dimension metadata into SUBCLASS_PARAMS in
  update_ga4_dimensions.mjs so re-discovered subclass dimensions keep
  their curated display names (e.g. "Create CL Failure Reason").
- Add tests for usage_type/env_mode in getConfigOptions(), the
  THIRD_PARTY branch, initialize() ordering, and readItem().
Gallery embeds RenderedFrame, which injects StateSync. The spec did not
mock StateSync, so the real root instance scheduled a debounced (300ms)
history sync when the active catalog was set. Tests running longer than
300ms then threw "this.chatState.chatHistory is not a function" because
MockChatState has no chatHistory.

Provide a MockStateSync exposing sessionResetNonce, matching
rendered-frame.spec.ts.
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.

3 participants