mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-29 14:19:48 -04:00
Target specific levels with InspectletJS
Currently targeting cupboards-of-kithgard.
This commit is contained in:
parent
74b2c5abdb
commit
da6cf60381
3 changed files with 39 additions and 18 deletions
app
|
@ -46,20 +46,6 @@
|
|||
(window,document,"script","51a79585ee207206390002a2");
|
||||
</script>
|
||||
|
||||
<!-- Inspectlet -->
|
||||
<script type="text/javascript" id="inspectletjs">
|
||||
window.__insp = window.__insp || [];
|
||||
__insp.push(['wid', 2102699786]);
|
||||
(function() {
|
||||
function __ldinsp(){var insp = document.createElement('script'); insp.type = 'text/javascript'; insp.async = true; insp.id = "inspsync"; insp.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://cdn.inspectlet.com/inspectlet.js'; var x = document.getElementsByTagName('script')[0]; x.parentNode.insertBefore(insp, x); }
|
||||
if (window.attachEvent){
|
||||
window.attachEvent('onload', __ldinsp);
|
||||
}else{
|
||||
window.addEventListener('load', __ldinsp, false);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script src="https://checkout.stripe.com/checkout.js"></script>
|
||||
|
||||
<!-- IE9 doesn't support defer attribute: https://github.com/h5bp/lazyweb-requests/issues/42 -->
|
||||
|
|
|
@ -3,6 +3,7 @@ SuperModel = require 'models/SuperModel'
|
|||
utils = require 'core/utils'
|
||||
|
||||
debugAnalytics = false
|
||||
targetInspectJSLevelSlugs = ['cupboards-of-kithgard']
|
||||
|
||||
module.exports = class Tracker
|
||||
constructor: ->
|
||||
|
@ -14,6 +15,41 @@ module.exports = class Tracker
|
|||
@identify()
|
||||
@supermodel = new SuperModel()
|
||||
|
||||
enableInspectletJS: (levelSlug) ->
|
||||
# InspectletJS loading is delayed and targeting specific levels for more focused investigations
|
||||
return @disableInspectletJS() unless levelSlug in targetInspectJSLevelSlugs
|
||||
|
||||
# Start embed code
|
||||
window.__insp = window.__insp or []
|
||||
__insp.push [
|
||||
'wid'
|
||||
2102699786
|
||||
]
|
||||
do ->
|
||||
__ldinsp = ->
|
||||
insp = document.createElement('script')
|
||||
insp.type = 'text/javascript'
|
||||
insp.async = true
|
||||
insp.id = 'inspsync'
|
||||
insp.src = (if 'https:' == document.location.protocol then 'https' else 'http') + '://cdn.inspectlet.com/inspectlet.js'
|
||||
x = document.getElementsByTagName('script')[0]
|
||||
x.parentNode.insertBefore insp, x
|
||||
return
|
||||
|
||||
if window.attachEvent
|
||||
window.attachEvent 'onload', __ldinsp
|
||||
else
|
||||
window.addEventListener 'load', __ldinsp, false
|
||||
# End embed code
|
||||
|
||||
# Identify and track pageview here, because inspectlet is loaded too late for standard Tracker calls
|
||||
@identify()
|
||||
# http://www.inspectlet.com/docs#virtual_pageviews
|
||||
__insp?.push ['virtualPage']
|
||||
|
||||
disableInspectletJS: ->
|
||||
delete window.__insp
|
||||
|
||||
trackReferrers: ->
|
||||
elapsed = new Date() - new Date(me.get('dateCreated'))
|
||||
return unless elapsed < 5 * 60 * 1000
|
||||
|
@ -57,10 +93,6 @@ module.exports = class Tracker
|
|||
# https://developers.google.com/analytics/devguides/collection/analyticsjs/pages
|
||||
ga? 'send', 'pageview', "/#{name}"
|
||||
|
||||
# Inspectlet
|
||||
# http://www.inspectlet.com/docs#virtual_pageviews
|
||||
__insp?.push ['virtualPage']
|
||||
|
||||
trackEvent: (action, properties={}) =>
|
||||
@trackEventInternal action, _.cloneDeep properties unless me?.isAdmin() and @isProduction
|
||||
console.log 'Tracking external analytics event:', action, properties if debugAnalytics
|
||||
|
|
|
@ -103,6 +103,8 @@ module.exports = class PlayLevelView extends RootView
|
|||
$(window).on 'resize', @onWindowResize
|
||||
@saveScreenshot = _.throttle @saveScreenshot, 30000
|
||||
|
||||
application.tracker?.enableInspectletJS(@levelID)
|
||||
|
||||
if @isEditorPreview
|
||||
@supermodel.shouldSaveBackups = (model) -> # Make sure to load possibly changed things from localStorage.
|
||||
model.constructor.className in ['Level', 'LevelComponent', 'LevelSystem', 'ThangType']
|
||||
|
@ -562,6 +564,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
delete window.nextURL
|
||||
console.profileEnd?() if PROFILE_ME
|
||||
@onRealTimeMultiplayerLevelUnloaded()
|
||||
application.tracker?.disableInspectletJS()
|
||||
super()
|
||||
|
||||
onIPadMemoryWarning: (e) ->
|
||||
|
|
Loading…
Add table
Reference in a new issue