/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

@ -13,7 +13,7 @@ module.exports = class ChooseLanguageModal extends ModalView
@logoutFirst = options.logoutFirst
onClickLanguageChoiceButton: (e) ->
@chosenLanguage = $(e.target).data('language')
@chosenLanguage = $(e.target).closest('.lang-choice-btn').data('language')
if @logoutFirst
@logoutUser()
else
@ -48,4 +48,5 @@ module.exports = class ChooseLanguageModal extends ModalView
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

@ -21,6 +21,8 @@ module.exports = class StudentSignInModal extends ModalView
@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) =>

View file

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