mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Recording referrer information. Updating parent email prompt to also show after Signs and Portents if that's the fourth level.
This commit is contained in:
parent
d0908f694c
commit
2d18bcf9f0
6 changed files with 28 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
{me} = require 'core/auth'
|
||||
SuperModel = require 'models/SuperModel'
|
||||
utils = require 'core/utils'
|
||||
|
||||
debugAnalytics = false
|
||||
|
||||
|
@ -9,9 +10,19 @@ module.exports = class Tracker
|
|||
console.error 'Overwrote our Tracker!', window.tracker
|
||||
window.tracker = @
|
||||
@isProduction = document.location.href.search('codecombat.com') isnt -1
|
||||
@trackReferrers()
|
||||
@identify()
|
||||
@supermodel = new SuperModel()
|
||||
|
||||
trackReferrers: ->
|
||||
elapsed = new Date() - new Date(me.get('dateCreated'))
|
||||
return unless elapsed < 5 * 60 * 1000
|
||||
return if me.get('siteref') or me.get('referrer')
|
||||
if siteref = utils.getQueryVariable '_r'
|
||||
me.set 'siteref', siteref
|
||||
if referrer = document.referrer
|
||||
me.set 'referrer', referrer
|
||||
|
||||
identify: (traits={}) ->
|
||||
return unless me
|
||||
|
||||
|
@ -19,7 +30,7 @@ module.exports = class Tracker
|
|||
@explicitTraits ?= {}
|
||||
@explicitTraits[key] = value for key, value of traits
|
||||
|
||||
for userTrait in ['email', 'anonymous', 'dateCreated', 'name', 'wizardColor1', 'testGroupNumber', 'gender', 'lastLevel']
|
||||
for userTrait in ['email', 'anonymous', 'dateCreated', 'name', 'testGroupNumber', 'gender', 'lastLevel', 'siteref']
|
||||
traits[userTrait] ?= me.get(userTrait)
|
||||
console.log 'Would identify', traits if debugAnalytics
|
||||
return unless @isProduction and not me.isAdmin()
|
||||
|
|
|
@ -177,3 +177,10 @@ if document?.createElement
|
|||
wrap.appendChild temp.children[1]
|
||||
return
|
||||
)(document)
|
||||
|
||||
module.exports.getQueryVariable = getQueryVariable = (param, defaultValue) ->
|
||||
query = document.location.search.substring 1
|
||||
pairs = (pair.split('=') for pair in query.split '&')
|
||||
for pair in pairs when pair[0] is param
|
||||
return {'true': true, 'false': false}[pair[1]] ? decodeURIComponent(pair[1])
|
||||
defaultValue
|
||||
|
|
|
@ -530,11 +530,11 @@
|
|||
press_paragraph_1_link: "press packet"
|
||||
press_paragraph_1_suffix: ". All logos and images may be used without contacting us directly."
|
||||
team: "Team"
|
||||
george_title: "Cofounder"
|
||||
george_title: "Cofounder" # {change}
|
||||
george_blurb: "Businesser"
|
||||
scott_title: "Cofounder"
|
||||
scott_title: "Cofounder" # {change}
|
||||
scott_blurb: "Reasonable One"
|
||||
nick_title: "Cofounder"
|
||||
nick_title: "Cofounder" # {change}
|
||||
nick_blurb: "Motivation Guru"
|
||||
michael_title: "Programmer"
|
||||
michael_blurb: "Sys Admin"
|
||||
|
@ -564,7 +564,7 @@
|
|||
age_recommended_title: "What age is it recommended at?"
|
||||
age_recommended_1: "The recommended minimum age is 9, however children as young as 7 can play the first stages with the assistance of an adult."
|
||||
what_cover_title: "What do we cover?"
|
||||
what_cover_1: "There are 27 levels in the first stage of CodeCombat that teach and reinforce 6 specific computer science concepts:"
|
||||
what_cover_1: "There are 27 levels in the first stage of CodeCombat that teach and reinforce 6 specific computer science concepts:" # {change}
|
||||
what_cover_notation_1: "Formal notation"
|
||||
what_cover_notation_2: "- builds an understanding of the importance of syntax in programming."
|
||||
what_cover_methods_1: "Calling methods"
|
||||
|
|
|
@ -290,6 +290,9 @@ _.extend UserSchema.properties,
|
|||
free: { type: ['boolean', 'string'], format: 'date-time' }
|
||||
}
|
||||
|
||||
siteref: { type: 'string' }
|
||||
referrer: { type: 'string' }
|
||||
|
||||
c.extendBasicProperties UserSchema, 'user'
|
||||
|
||||
UserSchema.definitions =
|
||||
|
|
|
@ -397,12 +397,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
# Utilities
|
||||
|
||||
getQueryVariable: (param, defaultValue) -> CocoView.getQueryVariable(param, defaultValue)
|
||||
@getQueryVariable: (param, defaultValue) ->
|
||||
query = document.location.search.substring 1
|
||||
pairs = (pair.split('=') for pair in query.split '&')
|
||||
for pair in pairs when pair[0] is param
|
||||
return {'true': true, 'false': false}[pair[1]] ? decodeURIComponent(pair[1])
|
||||
defaultValue
|
||||
@getQueryVariable: (param, defaultValue) -> utils.getQueryVariable(param, defaultValue) # Moved to utils; TODO finish migrating
|
||||
|
||||
getRootView: ->
|
||||
view = @
|
||||
|
|
|
@ -143,7 +143,7 @@ module.exports = class CampaignView extends RootView
|
|||
@render()
|
||||
@preloadTopHeroes() unless me.get('heroConfig')?.thangType
|
||||
@$el.find('#campaign-status').delay(4000).animate({top: "-=58"}, 1000) unless @terrain is 'dungeon'
|
||||
if @terrain and me.get('name') and me.get('lastLevel') is 'forgetful-gemsmith'
|
||||
if @terrain and me.get('name') and me.get('lastLevel') in ['forgetful-gemsmith', 'signs-and-portents']
|
||||
@openModalView new ShareProgressModal()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue