From 3dcfa2cc8a82dba94115678777c3d53cfdc6ef68 Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Fri, 2 Sep 2016 15:33:16 -0700 Subject: [PATCH] A/b test default language in home product --- app/models/User.coffee | 10 +++++++++ app/views/play/modal/PlayHeroesModal.coffee | 23 ++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/models/User.coffee b/app/models/User.coffee index 1e63b65b5..167f4dd11 100644 --- a/app/models/User.coffee +++ b/app/models/User.coffee @@ -197,6 +197,16 @@ module.exports = class User extends CocoModel application.tracker.identify hintsGroup: @hintsGroup unless me.isAdmin() @hintsGroup + getDefaultLanguageGroup: -> + # A/B test default programming language in home version + return @defaultLanguageGroup if @defaultLanguageGroup + group = me.get('testGroupNumber') % 2 + @defaultLanguageGroup = switch group + when 0 then 'javascript' + when 1 then 'python' + application.tracker.identify defaultLanguageGroup: @defaultLanguageGroup unless me.isAdmin() + @defaultLanguageGroup + getVideoTutorialStylesIndex: (numVideos=0)-> # A/B Testing video tutorial styles # Not a constant number of videos available (e.g. could be 0, 1, 3, or 4 currently) diff --git a/app/views/play/modal/PlayHeroesModal.coffee b/app/views/play/modal/PlayHeroesModal.coffee index 3114834d2..731a9f514 100644 --- a/app/views/play/modal/PlayHeroesModal.coffee +++ b/app/views/play/modal/PlayHeroesModal.coffee @@ -107,12 +107,21 @@ module.exports = class PlayHeroesModal extends ModalView {id: 'javascript', name: 'JavaScript'} ] else - @codeLanguageList = [ - {id: 'python', name: "Python (#{$.i18n.t('choose_hero.default')})"} - {id: 'javascript', name: 'JavaScript'} - {id: 'coffeescript', name: "CoffeeScript (#{$.i18n.t('choose_hero.experimental')})"} - {id: 'lua', name: 'Lua'} - ] + @codeLanguageList = switch me.getDefaultLanguageGroup() + when 'javascript' + [ + {id: 'javascript', name: "JavaScript (#{$.i18n.t('choose_hero.default')})"} + {id: 'python', name: "Python"} + {id: 'coffeescript', name: "CoffeeScript (#{$.i18n.t('choose_hero.experimental')})"} + {id: 'lua', name: 'Lua'} + ] + else + [ + {id: 'python', name: "Python (#{$.i18n.t('choose_hero.default')})"} + {id: 'javascript', name: 'JavaScript'} + {id: 'coffeescript', name: "CoffeeScript (#{$.i18n.t('choose_hero.experimental')})"} + {id: 'lua', name: 'Lua'} + ] if me.isAdmin() or not application.isProduction() @codeLanguageList.push {id: 'java', name: "Java (#{$.i18n.t('choose_hero.experimental')})"} @@ -226,7 +235,7 @@ module.exports = class PlayHeroesModal extends ModalView onCodeLanguageChanged: (e) -> @codeLanguage = @$el.find('#option-code-language').val() @codeLanguageChanged = true - + window.tracker?.trackEvent 'Campaign changed code language', category: 'Campaign Hero Select', codeLanguage: @codeLanguage, levelSlug: @options.level?.get('slug') #- Purchasing the hero