Skip to content

Commit

Permalink
- Add view tag to view_load tracker.
Browse files Browse the repository at this point in the history
  • Loading branch information
basicer committed Jan 28, 2017
1 parent 3ece953 commit 637dc66
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
8 changes: 6 additions & 2 deletions app/core/ViewLoadTimer.coffee
Expand Up @@ -55,7 +55,8 @@ class ViewLoadTimer
totalTime = performance.now() - @t0
return console.warn("Unknown view at: #{document.location.href}, could not record perf.") if not @view.id
return console.warn("Got invalid time result for view #{@view.id}: #{totalTime}, could not record perf.") if not _.isNumber(totalTime)
m = "Loaded #{@view.id} in: #{totalTime}ms"
tag = @view.getLoadTrackingTag?()
m = "Loaded #{@view.id}/#{tag} in: #{totalTime}ms"

if @firstLoad
entries = performance.getEntriesByType('resource').filter((r) => _.string.startsWith(r.name, location.origin))
Expand All @@ -66,9 +67,12 @@ class ViewLoadTimer
resourceInfo = { totalEncodedBodySize, totalTransferSize, cachedResources, totalResources }
else
resourceInfo = {}

props = _.assign({networkTime, totalTime, viewId: @view.id, @firstLoad }, resourceInfo)
props.tag = tag if tag
console.log m if VIEW_LOAD_LOG
noty({text:m, type:'information', timeout: 1000, layout:'topCenter'}) if SHOW_NOTY
window.tracker?.trackEvent 'View Load', _.assign({ networkTime, totalTime, viewId: @view.id, @firstLoad }, resourceInfo)
window.tracker?.trackEvent 'View Load', props
.then =>
console.groupEnd() if VIEW_LOAD_LOG

Expand Down
5 changes: 3 additions & 2 deletions app/schemas/events/view_load.json
Expand Up @@ -4,7 +4,7 @@
"vendor": "com.codecombat",
"name": "view_load",
"format": "jsonschema",
"version": "1-0-1"
"version": "1-0-2"
},
"type": "object",
"properties": {
Expand All @@ -16,7 +16,8 @@
"totalTime": {"type": "number"},
"networkTime": {"type": "number"},
"viewId": {"type": "string"},
"firstLoad": {"type": "boolean"}
"firstLoad": {"type": "boolean"},
"tag": {"type": "string", "maxLength": 64}
},
"required": ["user"],
"additionalProperties": false
Expand Down
3 changes: 3 additions & 0 deletions app/views/play/CampaignView.coffee
Expand Up @@ -880,3 +880,6 @@ module.exports = class CampaignView extends RootView
$pollButton = @$el.find 'button.poll'
pollModal.on 'vote-updated', ->
$pollButton.removeClass('highlighted').tooltip 'hide'

getLoadTrackingTag: () ->
@campaign?.get?('slug') or 'overworld'
3 changes: 3 additions & 0 deletions app/views/play/level/PlayLevelView.coffee
Expand Up @@ -772,3 +772,6 @@ module.exports = class PlayLevelView extends RootView
@setupManager?.destroy()
@setupManager = new LevelSetupManager({supermodel: @supermodel, level: @level, levelID: @levelID, parent: @, session: @session, hadEverChosenHero: true})
@setupManager.open()

getLoadTrackingTag: () ->
@level.get 'slug'

0 comments on commit 637dc66

Please sign in to comment.