History

Add wentToEntry step to tutorial

Ryan Huffman committed 10 years ago

Commit dd4e06e1 parent e3ee7a22 files · +36 −6Browse files

Showing the changes to tutorial/tutorial.js (1 of 2 files). Show all

Unified · Split

tutorial/tutorial.js+27−5
@@ -972,12 +972,17 @@ TutorialManager = function() { · 971 unmodified lines
972972 var startedTutorialAt = 0;
973973 var startedLastStepAt = 0;
974974
975+ var WENT_TO_ENTRY_STEP_NUM = 20;
976+ var VERSION = 1;
977+ var tutorialID;
978+
975979 var self = this;
976980
977981 this.startTutorial = function() {
978982 currentStepNum = -1;
979983 currentStep = null;
980984 startedTutorialAt = Date.now();
985+ tutorialID = Script.generateUUID();
981986 STEPS = [
982987 new stepStart("start"),
983988 new stepOrient("orient"),
@@ -999,10 +1004,7 @@ TutorialManager = function() { · 15 unmodified lines
9991004 this.onFinish = function() {
10001005 debug("onFinish", currentStepNum);
10011006 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);
10061008 }
10071009
10081010 self.startNextStep();
@@ -1015,6 +1017,12 @@ TutorialManager = function() { · 6 unmodified lines
10151017
10161018 ++currentStepNum;
10171019
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+
10181026 if (currentStepNum >= STEPS.length) {
10191027 // Done
10201028 info("DONE WITH TUTORIAL");
@@ -1024,7 +1032,6 @@ TutorialManager = function() { · 3 unmodified lines
10241032 } else {
10251033 info("Starting step", currentStepNum);
10261034 currentStep = STEPS[currentStepNum];
1027− startedLastStepAt = Date.now();
10281035 currentStep.start(this.onFinish);
10291036 return true;
10301037 }
@@ -1046,6 +1053,21 @@ TutorialManager = function() { · 15 unmodified lines
10461053 currentStepNum = -1;
10471054 currentStep = null;
10481055 }
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+ }
10491071 }
10501072
10511073 // To run the tutorial: