@@ -120,7 +120,7 @@ export async function record(event: GAEvent): Promise<void> {
120120
121121/** Displays a notification that analytics are in use. */
122122export async function notifyAnalyticsIfFirstRun ( ) : Promise < void > {
123- if ( ! isAnalyticsEnabled ( ) ) return ;
123+ if ( isAnalyticsOptedOut ( ) ) return ;
124124
125125 if ( configstore . get ( NOTIFICATION_ACKED ) ) {
126126 return ;
@@ -132,7 +132,7 @@ export async function notifyAnalyticsIfFirstRun(): Promise<void> {
132132 input : process . stdin ,
133133 output : process . stdout ,
134134 } ) ;
135- await readline . question ( 'Press "Enter" to continue' ) ;
135+ await readline . question ( 'Press "Enter" to acknowledge and continue' ) ;
136136 readline . close ( ) ;
137137
138138 configstore . set ( NOTIFICATION_ACKED , true ) ;
@@ -169,7 +169,12 @@ const ANALYTICS_NOTIFICATION =
169169 'Genkit CLI and Developer UI use cookies and ' +
170170 'similar technologies from Google\nto deliver and enhance the quality of its ' +
171171 'services and to analyze usage.\n' +
172- 'Learn more at https://policies.google.com/technologies/cookies' ;
172+ 'Learn more at https://policies.google.com/technologies/cookies\n' +
173+ '\n' +
174+ 'If running in non-interactive environments set --non-interactive flag. Ex:\n' +
175+ ' genkit start --non-interactive -- <cmd>\n' +
176+ 'To opt out of analytics run:\n' +
177+ ' genkit config set analyticsOptOut true\n' ;
173178const NOTIFICATION_ACKED = 'analytics_notification' ;
174179const CONFIGSTORE_CLIENT_KEY = 'genkit-tools-ga-id' ;
175180
@@ -217,14 +222,16 @@ function isValidateOnly(): boolean {
217222 return ! ! process . env [ 'GENKIT_GA_VALIDATE' ] ;
218223}
219224
220- // For now, this is default false unless GENKIT_GA_DEBUG or GENKIT_GA_VALIDATE
221- // are set. Once we have opt-out and we're ready for public preview this will
222- // get updated.
225+ function isAnalyticsAcknowledged ( ) : boolean {
226+ return configstore . get ( NOTIFICATION_ACKED ) === true ;
227+ }
228+
229+ function isAnalyticsOptedOut ( ) : boolean {
230+ return getUserSettings ( ) [ ANALYTICS_OPT_OUT_CONFIG_TAG ] === true ;
231+ }
232+
223233function isAnalyticsEnabled ( ) : boolean {
224- return (
225- ! process . argv . includes ( '--non-interactive' ) &&
226- ! getUserSettings ( ) [ ANALYTICS_OPT_OUT_CONFIG_TAG ]
227- ) ;
234+ return isAnalyticsAcknowledged ( ) && ! isAnalyticsOptedOut ( ) ;
228235}
229236
230237async function recordInternal (
0 commit comments