@@ -5,9 +5,10 @@ import { loadWatchers, resetWatchers } from './utils/watchers'
55import  openFiles  from  './utils/openFiles' 
66import  runCommands  from  './utils/runCommands' 
77import  runVSCodeCommands  from  './utils/runVSCodeCommands' 
8- import  {   onError   as  telemetryOnError   }  from  '../telemetry' 
8+ import  *   as  telemetry  from  '../telemetry' 
99import  {  runTest  }  from  '../../actions/onTest' 
1010import  logger  from  '../logger' 
11+ import  {  VERSION  }  from  '../../environment' 
1112
1213// run at the end of when a tutorial is configured 
1314export  const  onInit  =  async  ( actions : TT . StepActions ) : Promise < void >  =>  { 
@@ -50,21 +51,35 @@ export const onReset = async (actions: TT.StepActions): Promise<void> => {
5051
5152// run when an uncaught exception is thrown 
5253export  const  onError  =  async  ( error : Error ) : Promise < void >  =>  { 
53-   telemetryOnError ( error ) 
54+   telemetry . onError ( error ) 
5455} 
5556
5657// run when a step task passes 
57- export  const  onStepComplete  =  async  ( {  levelId,  stepId } : {  levelId : string ;  stepId : string  } ) : Promise < void >  =>  { 
58+ export  const  onStepComplete  =  async  ( { 
59+   tutorialId, 
60+   levelId, 
61+   stepId, 
62+ } : { 
63+   tutorialId : string 
64+   levelId : string 
65+   stepId : string 
66+ } ) : Promise < void >  =>  { 
5867  git . saveCommit ( `Save progress: ${ stepId }  ) 
59-   logger ( `ON STEP COMPLETE:  ${ JSON . stringify ( {  levelId,  stepId  } ) } ` ) 
68+   telemetry . onEvent ( 'step_complete' ,   {  tutorialId ,  stepId ,  levelId,  version :  VERSION   } ) 
6069} 
6170
6271// run when a level is complete (all tasks pass or no tasks) 
63- export  const  onLevelComplete  =  async  ( {  levelId } : {  levelId : string  } ) : Promise < void >  =>  { 
64-   logger ( `ON LEVEL COMPLETE: ${ JSON . stringify ( levelId ) }  ) 
72+ export  const  onLevelComplete  =  async  ( { 
73+   tutorialId, 
74+   levelId, 
75+ } : { 
76+   tutorialId : string 
77+   levelId : string 
78+ } ) : Promise < void >  =>  { 
79+   telemetry . onEvent ( 'level_complete' ,  {  tutorialId,  levelId,  version : VERSION  } ) 
6580} 
6681
6782// run when all levels are complete 
6883export  const  onTutorialComplete  =  async  ( {  tutorialId } : {  tutorialId : string  } ) : Promise < void >  =>  { 
69-   logger ( `ON TUTORIAL COMPLETE:  ${ JSON . stringify ( tutorialId ) } ` ) 
84+   telemetry . onEvent ( 'tutorial_complete' ,   {  tutorialId ,   version :  VERSION   } ) 
7085} 
0 commit comments