Repository navigation
Analytics updates - #260
Conversation
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.
There was a problem hiding this comment.
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.
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
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)".
1d3f99c to
9748299
Compare
suyangw-g
left a comment
There was a problem hiding this comment.
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.
- 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.
Description
Tweaks to how we handle Google Analytics updates:
Pre-launch Checklist