@@ -5,9 +5,10 @@ import { loadWatchers, resetWatchers } from './utils/watchers'
5
5
import openFiles from './utils/openFiles'
6
6
import runCommands from './utils/runCommands'
7
7
import runVSCodeCommands from './utils/runVSCodeCommands'
8
- import { onError as telemetryOnError } from '../telemetry'
8
+ import * as telemetry from '../telemetry'
9
9
import { runTest } from '../../actions/onTest'
10
10
import logger from '../logger'
11
+ import { VERSION } from '../../environment'
11
12
12
13
// run at the end of when a tutorial is configured
13
14
export const onInit = async ( actions : TT . StepActions ) : Promise < void > => {
@@ -50,21 +51,35 @@ export const onReset = async (actions: TT.StepActions): Promise<void> => {
50
51
51
52
// run when an uncaught exception is thrown
52
53
export const onError = async ( error : Error ) : Promise < void > => {
53
- telemetryOnError ( error )
54
+ telemetry . onError ( error )
54
55
}
55
56
56
57
// 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 > => {
58
67
git . saveCommit ( `Save progress: ${ stepId } ` )
59
- logger ( `ON STEP COMPLETE: ${ JSON . stringify ( { levelId, stepId } ) } ` )
68
+ telemetry . onEvent ( 'step_complete' , { tutorialId , stepId , levelId, version : VERSION } )
60
69
}
61
70
62
71
// 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 } )
65
80
}
66
81
67
82
// run when all levels are complete
68
83
export const onTutorialComplete = async ( { tutorialId } : { tutorialId : string } ) : Promise < void > => {
69
- logger ( `ON TUTORIAL COMPLETE: ${ JSON . stringify ( tutorialId ) } ` )
84
+ telemetry . onEvent ( 'tutorial_complete' , { tutorialId , version : VERSION } )
70
85
}
0 commit comments