@@ -120,7 +120,7 @@ export async function record(event: GAEvent): Promise<void> {
120
120
121
121
/** Displays a notification that analytics are in use. */
122
122
export async function notifyAnalyticsIfFirstRun ( ) : Promise < void > {
123
- if ( ! isAnalyticsEnabled ( ) ) return ;
123
+ if ( isAnalyticsOptedOut ( ) ) return ;
124
124
125
125
if ( configstore . get ( NOTIFICATION_ACKED ) ) {
126
126
return ;
@@ -132,7 +132,7 @@ export async function notifyAnalyticsIfFirstRun(): Promise<void> {
132
132
input : process . stdin ,
133
133
output : process . stdout ,
134
134
} ) ;
135
- await readline . question ( 'Press "Enter" to continue' ) ;
135
+ await readline . question ( 'Press "Enter" to acknowledge and continue' ) ;
136
136
readline . close ( ) ;
137
137
138
138
configstore . set ( NOTIFICATION_ACKED , true ) ;
@@ -169,7 +169,12 @@ const ANALYTICS_NOTIFICATION =
169
169
'Genkit CLI and Developer UI use cookies and ' +
170
170
'similar technologies from Google\nto deliver and enhance the quality of its ' +
171
171
'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' ;
173
178
const NOTIFICATION_ACKED = 'analytics_notification' ;
174
179
const CONFIGSTORE_CLIENT_KEY = 'genkit-tools-ga-id' ;
175
180
@@ -217,14 +222,16 @@ function isValidateOnly(): boolean {
217
222
return ! ! process . env [ 'GENKIT_GA_VALIDATE' ] ;
218
223
}
219
224
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
+
223
233
function isAnalyticsEnabled ( ) : boolean {
224
- return (
225
- ! process . argv . includes ( '--non-interactive' ) &&
226
- ! getUserSettings ( ) [ ANALYTICS_OPT_OUT_CONFIG_TAG ]
227
- ) ;
234
+ return isAnalyticsAcknowledged ( ) && ! isAnalyticsOptedOut ( ) ;
228
235
}
229
236
230
237
async function recordInternal (
0 commit comments