@@ -19,8 +19,16 @@ class GoogleAnalytics {
1919 // 2. Navigate to Admin > Data Streams > Select your stream
2020 // 3. Measurement ID is shown at the top (format: G-XXXXXXXXXX)
2121 // 4. For API Secret: Scroll down to "Measurement Protocol API secrets" > "Create" to generate a new secret
22- protected static measurementID = "G-XXXXXXXXXX" ; // TODO: Replace with actual GA4 Measurement ID
23- protected static apiSecret = "XXXXXXXXXXXXXXXXXXXXXXXX" ; // TODO: Replace with actual GA4 API Secret
22+ //
23+ // These can be overridden via environment variables:
24+ // - IGNITEUI_CLI_GA4_MEASUREMENT_ID
25+ // - IGNITEUI_CLI_GA4_API_SECRET
26+ protected static measurementID = process . env . IGNITEUI_CLI_GA4_MEASUREMENT_ID || "G-XXXXXXXXXX" ; // TODO: Replace default with actual GA4 Measurement ID
27+ protected static apiSecret = process . env . IGNITEUI_CLI_GA4_API_SECRET || "XXXXXXXXXXXXXXXXXXXXXXXX" ; // TODO: Replace default with actual GA4 API Secret
28+
29+ // GA4 requires engagement_time_msec to be set for events to be processed
30+ // Using a minimal value to satisfy the requirement
31+ protected static readonly GA4_MIN_ENGAGEMENT_TIME = "100" ;
2432
2533 /**
2634 * Generates http post request with provided parameters and sends it to GA4
@@ -51,7 +59,7 @@ class GoogleAnalytics {
5159 const eventParams : any = {
5260 app_name : App . appName ,
5361 app_version : parameters . av || this . appVersion ,
54- engagement_time_msec : "100" // Required for events
62+ engagement_time_msec : this . GA4_MIN_ENGAGEMENT_TIME
5563 } ;
5664
5765 // Map custom dimensions to event parameters
@@ -106,7 +114,9 @@ class GoogleAnalytics {
106114 const https = require ( "https" ) ;
107115 const req = https . request ( options ) ;
108116 req . on ( "error" , e => {
109- // TODO: save all the logs and send them later
117+ // Silently fail analytics errors to avoid disrupting CLI functionality
118+ // In the future, this could log to a file or queue for retry
119+ // Error details: e.message, e.code
110120 } ) ;
111121 req . write ( payloadString ) ;
112122 req . end ( ) ;
0 commit comments