@@ -14,6 +14,7 @@ import { registerRegistryAddCommand, registerRegistryScaffoldCommand } from './c
1414import { registerOasServeCommand , registerRegistryServeCommand } from './commands/serve' ;
1515import { registerBuildXanoscriptRepoCommand } from './commands/generate-xanoscript-repo' ;
1616import { Caly } from '@calycode/core' ;
17+ import { InitializedPostHog } from './utils/posthog/init' ;
1718import { nodeConfigStorage } from './node-config-storage' ;
1819
1920const commandStartTimes = new WeakMap < Command , number > ( ) ;
@@ -23,11 +24,22 @@ const program = new Command();
2324const core = new Caly ( nodeConfigStorage ) ;
2425
2526// Store start time on the command object
26- program . hook ( 'preAction' , ( thisCommand ) => {
27+ program . hook ( 'preAction' , ( thisCommand , actionCommand ) => {
28+ console . log ( actionCommand . name ( ) ) ;
2729 commandStartTimes . set ( thisCommand , Date . now ( ) ) ;
30+ // [ ] Add some system information to the capture
31+ InitializedPostHog . capture ( {
32+ distinctId : 'anonymous' ,
33+ event : 'command_started' ,
34+ properties : {
35+ "command" : actionCommand . name ( )
36+ }
37+ } ) ;
38+ InitializedPostHog . shutdown ( ) ;
2839} ) ;
2940
3041program . hook ( 'postAction' , ( thisCommand , actionCommand ) => {
42+ console . log ( actionCommand . name ( ) ) ;
3143 const start = commandStartTimes . get ( thisCommand ) ;
3244 if ( ! start ) {
3345 // Could happen if preAction failed, or if there's a bug
@@ -42,6 +54,16 @@ program.hook('postAction', (thisCommand, actionCommand) => {
4254 : actionCommand . name ( ) ;
4355
4456 console . log ( `\n⏱️ Command "${ commandPath } " completed in ${ duration } s` ) ;
57+ // [ ] Add some outcome capture in a very anonymous manner
58+ InitializedPostHog . capture ( {
59+ distinctId : 'anonymous' ,
60+ event : 'command_finished' ,
61+ properties : {
62+ "command" : actionCommand . name ( ) ,
63+ duration : duration
64+ }
65+ } ) ;
66+ InitializedPostHog . shutdown ( ) ;
4567} ) ;
4668
4769program
0 commit comments