@@ -18,7 +18,7 @@ import { getBuckets } from "../utils/buckets";
1818import chalk from "chalk" ;
1919import Table from "cli-table3" ;
2020import { createDeltaProcessor } from "../utils/delta" ;
21- import trackEvent from "../utils/observability" ;
21+ import trackEvent , { UserIdentity } from "../utils/observability" ;
2222import { minimatch } from "minimatch" ;
2323import { exitGracefully } from "../utils/exit-gracefully" ;
2424
@@ -63,7 +63,7 @@ export default new Command()
6363 . action ( async function ( options ) {
6464 const ora = Ora ( ) ;
6565 const flags = parseFlags ( options ) ;
66- let email : string | null = null ;
66+ let userIdentity : UserIdentity = null ;
6767
6868 try {
6969 ora . start ( "Loading configuration..." ) ;
@@ -76,7 +76,7 @@ export default new Command()
7676 ora . start ( "Checking authentication status..." ) ;
7777 const auth = await tryAuthenticate ( settings ) ;
7878 if ( auth ) {
79- email = auth . email ;
79+ userIdentity = { email : auth . email , id : auth . id } ;
8080 ora . succeed ( `Authenticated as ${ auth . email } ` ) ;
8181 } else {
8282 ora . info (
@@ -92,7 +92,7 @@ export default new Command()
9292 ora . succeed ( "Localization configuration is valid" ) ;
9393
9494 // Track event with or without authentication
95- trackEvent ( email , "cmd.status.start" , {
95+ trackEvent ( userIdentity , "cmd.status.start" , {
9696 i18nConfig,
9797 flags,
9898 } ) ;
@@ -356,10 +356,11 @@ export default new Command()
356356 ) } (${ completeKeys . length } /${ totalKeysInFile } keys)`,
357357 ) ;
358358 } else {
359- const message = `[${ sourceLocale } -> ${ targetLocale } ] ${ parseFloat ( completionPercent ) > 50
359+ const message = `[${ sourceLocale } -> ${ targetLocale } ] ${
360+ parseFloat ( completionPercent ) > 50
360361 ? chalk . yellow ( `${ completionPercent } % complete` )
361362 : chalk . red ( `${ completionPercent } % complete` )
362- } (${ completeKeys . length } /${ totalKeysInFile } keys)`;
363+ } (${ completeKeys . length } /${ totalKeysInFile } keys)`;
363364
364365 bucketOra . succeed ( message ) ;
365366
@@ -369,7 +370,8 @@ export default new Command()
369370 ` ${ chalk . red ( `Missing:` ) } ${ missingKeys . length } keys, ~${ wordsToTranslate } words` ,
370371 ) ;
371372 console . log (
372- ` ${ chalk . red ( `Missing:` ) } ${ missingKeys . length
373+ ` ${ chalk . red ( `Missing:` ) } ${
374+ missingKeys . length
373375 } keys, ~${ wordsToTranslate } words`,
374376 ) ;
375377 console . log (
@@ -382,7 +384,8 @@ export default new Command()
382384 }
383385 if ( updatedKeys . length > 0 ) {
384386 console . log (
385- ` ${ chalk . yellow ( `Updated:` ) } ${ updatedKeys . length
387+ ` ${ chalk . yellow ( `Updated:` ) } ${
388+ updatedKeys . length
386389 } keys that changed in source`,
387390 ) ;
388391 }
@@ -536,7 +539,8 @@ export default new Command()
536539
537540 console . log ( chalk . bold ( `\n• ${ path } :` ) ) ;
538541 console . log (
539- ` ${ stats . sourceKeys
542+ ` ${
543+ stats . sourceKeys
540544 } source keys, ~${ stats . wordCount . toLocaleString ( ) } source words`,
541545 ) ;
542546
@@ -603,14 +607,16 @@ export default new Command()
603607
604608 if ( missingLanguages . length > 0 ) {
605609 console . log (
606- `• ${ chalk . yellow ( missingLanguages . join ( ", " ) ) } ${ missingLanguages . length === 1 ? "has" : "have"
610+ `• ${ chalk . yellow ( missingLanguages . join ( ", " ) ) } ${
611+ missingLanguages . length === 1 ? "has" : "have"
607612 } no translations yet`,
608613 ) ;
609614 }
610615
611616 if ( completeLanguages . length > 0 ) {
612617 console . log (
613- `• ${ chalk . green ( completeLanguages . join ( ", " ) ) } ${ completeLanguages . length === 1 ? "is" : "are"
618+ `• ${ chalk . green ( completeLanguages . join ( ", " ) ) } ${
619+ completeLanguages . length === 1 ? "is" : "are"
614620 } completely translated`,
615621 ) ;
616622 }
@@ -624,22 +630,22 @@ export default new Command()
624630 }
625631
626632 // Track successful completion
627- trackEvent ( email , "cmd.status.success" , {
633+ trackEvent ( userIdentity , "cmd.status.success" , {
628634 i18nConfig,
629635 flags,
630636 totalSourceKeyCount,
631637 languageStats,
632638 totalWordsToTranslate,
633- authenticated : ! ! email ,
639+ authenticated : ! ! userIdentity ,
634640 } ) ;
635641 await new Promise ( ( resolve ) => setTimeout ( resolve , 50 ) ) ;
636642 exitGracefully ( ) ;
637643 } catch ( error : any ) {
638644 ora . fail ( error . message ) ;
639- trackEvent ( email , "cmd.status.error" , {
645+ trackEvent ( userIdentity , "cmd.status.error" , {
640646 flags,
641647 error : error . message ,
642- authenticated : ! ! email ,
648+ authenticated : ! ! userIdentity ,
643649 } ) ;
644650 await new Promise ( ( resolve ) => setTimeout ( resolve , 50 ) ) ;
645651 process . exit ( 1 ) ;
0 commit comments