Showing the changes to tutorial/tutorial.js (1 of 2 files). Show all
Unified · Split
| @@ -972,12 +972,17 @@ TutorialManager = function() { · 971 unmodified lines | ||
| 972 | 972 | var startedTutorialAt = 0; |
| 973 | 973 | var startedLastStepAt = 0; |
| 974 | 974 | |
| 975 | + var WENT_TO_ENTRY_STEP_NUM = 20; | |
| 976 | + var VERSION = 1; | |
| 977 | + var tutorialID; | |
| 978 | + | |
| 975 | 979 | var self = this; |
| 976 | 980 | |
| 977 | 981 | this.startTutorial = function() { |
| 978 | 982 | currentStepNum = -1; |
| 979 | 983 | currentStep = null; |
| 980 | 984 | startedTutorialAt = Date.now(); |
| 985 | + tutorialID = Script.generateUUID(); | |
| 981 | 986 | STEPS = [ |
| 982 | 987 | new stepStart("start"), |
| 983 | 988 | new stepOrient("orient"), |
| @@ -999,10 +1004,7 @@ TutorialManager = function() { · 15 unmodified lines | ||
| 999 | 1004 | this.onFinish = function() { |
| 1000 | 1005 | debug("onFinish", currentStepNum); |
| 1001 | 1006 | if (currentStep && currentStep.shouldLog !== false) { |
| 1002 | − var timeToFinishStep = (Date.now() - startedLastStepAt) / 1000; | |
| 1003 | − var tutorialTimeElapsed = (Date.now() - startedTutorialAt) / 1000; | |
| 1004 | − UserActivityLogger.tutorialProgress( | |
| 1005 | − currentStep.tag, currentStepNum, timeToFinishStep, tutorialTimeElapsed); | |
| 1007 | + self.trackStep(currentStep.tag, currentStepNum); | |
| 1006 | 1008 | } |
| 1007 | 1009 | |
| 1008 | 1010 | self.startNextStep(); |
| @@ -1015,6 +1017,12 @@ TutorialManager = function() { · 6 unmodified lines | ||
| 1015 | 1017 | |
| 1016 | 1018 | ++currentStepNum; |
| 1017 | 1019 | |
| 1020 | + // This always needs to be set because we use this value when | |
| 1021 | + // tracking that the user has gone through the entry portal. When the | |
| 1022 | + // tutorial finishes, there is a last "pseudo" step that the user | |
| 1023 | + // finishes when stepping into the portal. | |
| 1024 | + startedLastStepAt = Date.now(); | |
| 1025 | + | |
| 1018 | 1026 | if (currentStepNum >= STEPS.length) { |
| 1019 | 1027 | // Done |
| 1020 | 1028 | info("DONE WITH TUTORIAL"); |
| @@ -1024,7 +1032,6 @@ TutorialManager = function() { · 3 unmodified lines | ||
| 1024 | 1032 | } else { |
| 1025 | 1033 | info("Starting step", currentStepNum); |
| 1026 | 1034 | currentStep = STEPS[currentStepNum]; |
| 1027 | − startedLastStepAt = Date.now(); | |
| 1028 | 1035 | currentStep.start(this.onFinish); |
| 1029 | 1036 | return true; |
| 1030 | 1037 | } |
| @@ -1046,6 +1053,21 @@ TutorialManager = function() { · 15 unmodified lines | ||
| 1046 | 1053 | currentStepNum = -1; |
| 1047 | 1054 | currentStep = null; |
| 1048 | 1055 | } |
| 1056 | + | |
| 1057 | + this.trackStep = function(name, stepNum) { | |
| 1058 | + var timeToFinishStep = (Date.now() - startedLastStepAt) / 1000; | |
| 1059 | + var tutorialTimeElapsed = (Date.now() - startedTutorialAt) / 1000; | |
| 1060 | + UserActivityLogger.tutorialProgress( | |
| 1061 | + name, stepNum, timeToFinishStep, tutorialTimeElapsed, | |
| 1062 | + tutorialID, VERSION); | |
| 1063 | + } | |
| 1064 | + | |
| 1065 | + // This is a message sent from the "entry" portal in the courtyard, | |
| 1066 | + // after the tutorial has finished. | |
| 1067 | + this.enteredEntryPortal = function() { | |
| 1068 | + info("Got enteredEntryPortal, tracking"); | |
| 1069 | + this.trackStep("wentToEntry", WENT_TO_ENTRY_STEP_NUM); | |
| 1070 | + } | |
| 1049 | 1071 | } |
| 1050 | 1072 | |
| 1051 | 1073 | // To run the tutorial: |