/hoc analytics

This commit is contained in:
Matt Lott 2015-12-04 11:31:49 -08:00
parent 9d36d33051
commit 4778cf5535
5 changed files with 27 additions and 14 deletions

View file

@ -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:

View file

@ -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()

View file

@ -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($('<img src="https://code.org/api/hour/begin_codecombat.png" style="visibility: hidden;">'))
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()

View file

@ -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
_.delay (=> @$('input:visible:first').focus()), 500

View file

@ -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