diff --git a/app/templates/courses/hour-of-code-view.jade b/app/templates/courses/hour-of-code-view.jade index 0bdeb07e8..1ed8bcfef 100644 --- a/app/templates/courses/hour-of-code-view.jade +++ b/app/templates/courses/hour-of-code-view.jade @@ -34,7 +34,7 @@ block content p strong Hi adventurer, welcome back! p - a#continue-playing-btn.btn.btn-success.btn-lg(href=view.continuePlayingLink()) Continue Playing + button#continue-playing-btn.btn.btn-success.btn-lg Continue Playing p em.spr span.spr Last Played: diff --git a/app/views/courses/ChooseLanguageModal.coffee b/app/views/courses/ChooseLanguageModal.coffee index 7d8fe3f26..549582105 100644 --- a/app/views/courses/ChooseLanguageModal.coffee +++ b/app/views/courses/ChooseLanguageModal.coffee @@ -4,21 +4,21 @@ template = require 'templates/courses/choose-language-modal' module.exports = class ChooseLanguageModal extends ModalView id: 'choose-language-modal' template: template - + events: 'click .lang-choice-btn': 'onClickLanguageChoiceButton' - + initialize: (options) -> options ?= {} @logoutFirst = options.logoutFirst onClickLanguageChoiceButton: (e) -> - @chosenLanguage = $(e.target).data('language') + @chosenLanguage = $(e.target).closest('.lang-choice-btn').data('language') if @logoutFirst @logoutUser() else @saveLanguageSetting() - + logoutUser: -> $.ajax({ method: 'POST' @@ -45,7 +45,8 @@ module.exports = class ChooseLanguageModal extends ModalView @listenToOnce me, 'sync', @onLanguageSettingSaved else @onLanguageSettingSaved() - + onLanguageSettingSaved: -> @trigger('set-language') + window.tracker?.trackEvent 'Chose language', category: 'Courses', label: @chosenLanguage @hide() diff --git a/app/views/courses/HourOfCodeView.coffee b/app/views/courses/HourOfCodeView.coffee index cbff1a060..5cd213da4 100644 --- a/app/views/courses/HourOfCodeView.coffee +++ b/app/views/courses/HourOfCodeView.coffee @@ -18,7 +18,7 @@ module.exports = class HourOfCodeView extends RootView template: template events: - 'click #student-btn': 'onClickStudentButton' + 'click #continue-playing-btn': 'onClickContinuePlayingButton' 'click #start-new-game-btn': 'onClickStartNewGameButton' 'click #log-in-btn': 'onClickLogInButton' 'click #log-out-link': 'onClickLogOutLink' @@ -60,19 +60,25 @@ module.exports = class HourOfCodeView extends RootView me.set('hourOfCode', true) me.patch() $('body').append($('')) - application.tracker?.trackEvent 'Hour of Code Begin' + window.tracker?.trackEvent 'Hour of Code Begin' + + onClickContinuePlayingButton: -> + url = @continuePlayingLink() + window.tracker?.trackEvent 'HoC continue playing ', category: 'HoC', label: url + app.router.navigate(url, { trigger: true }) afterRender: -> super() @onClickStartNewGameButton() if @getQueryVariable('go') and not @lastLevel onClickStartNewGameButton: -> - # user without hour of code course instance, creates one, starts playing + # User without hour of code course instance, creates one, starts playing modal = new ChooseLanguageModal({ logoutFirst: @hourOfCodeCourseInstance? }) @openModalView(modal) @listenToOnce modal, 'set-language', @startHourOfCodePlay + window.tracker?.trackEvent 'Start New Game', category: 'HoC', label: 'HoC Start New Game' continuePlayingLink: -> ci = @hourOfCodeCourseInstance @@ -91,10 +97,13 @@ module.exports = class HourOfCodeView extends RootView modal = new StudentLogInModal() @openModalView(modal) modal.on 'want-to-create-account', @onWantToCreateAccount, @ + window.tracker?.trackEvent 'Started Login', category: 'HoC', label: 'HoC Login' onWantToCreateAccount: -> modal = new StudentSignUpModal() @openModalView(modal) + window.tracker?.trackEvent 'Started Signup', category: 'HoC', label: 'HoC Sign Up' onClickLogOutLink: -> + window.tracker?.trackEvent 'Log Out', category: 'HoC', label: 'HoC Log Out' auth.logoutUser() diff --git a/app/views/courses/StudentLogInModal.coffee b/app/views/courses/StudentLogInModal.coffee index 5baf986f6..ffebbab8e 100644 --- a/app/views/courses/StudentLogInModal.coffee +++ b/app/views/courses/StudentLogInModal.coffee @@ -7,7 +7,7 @@ User = require 'models/User' module.exports = class StudentSignInModal extends ModalView id: 'student-log-in-modal' template: template - + events: 'click #log-in-btn': 'onClickLogInButton' 'submit form': 'onSubmitForm' @@ -16,11 +16,13 @@ module.exports = class StudentSignInModal extends ModalView onSubmitForm: (e) -> e.preventDefault() @login() - + onClickLogInButton: -> @login() login: -> + # TODO: doesn't track failed login + window.tracker?.trackEvent 'Finished Login', category: 'Courses', label: 'Courses Student Login' data = forms.formToObject @$el @enableModalInProgress(@$el) auth.loginUser data, (jqxhr) => @@ -39,4 +41,4 @@ module.exports = class StudentSignInModal extends ModalView afterInsert: -> super() - _.delay (=> @$('input:visible:first').focus()), 500 \ No newline at end of file + _.delay (=> @$('input:visible:first').focus()), 500 diff --git a/app/views/courses/StudentSignUpModal.coffee b/app/views/courses/StudentSignUpModal.coffee index 0c25cb030..5e4ec404c 100644 --- a/app/views/courses/StudentSignUpModal.coffee +++ b/app/views/courses/StudentSignUpModal.coffee @@ -23,7 +23,7 @@ module.exports = class StudentSignUpModal extends ModalView afterInsert: -> super() _.delay (=> @$('input:visible:first').focus()), 500 - + onClickSkipLink: -> @trigger 'click-skip-link' # defer to view that opened this modal @hide?() @@ -71,7 +71,8 @@ module.exports = class StudentSignUpModal extends ModalView data.emails ?= {} data.emails.generalNews ?= {} data.emails.generalNews.enabled = false - window.tracker?.trackEvent 'Finished Student Signup', label: 'CodeCombat' + # TODO: Doesn't handle failed user creation. Double posts when placed in onCreateUserSuccess. + window.tracker?.trackEvent 'Finished Student Signup', category: 'Courses', label: 'Courses Student Signup' @enableModalInProgress(@$el) user = new User(data) user.notyErrors = false