Don't duplicate reports of page visits
This commit is contained in:
@@ -33,6 +33,7 @@ Event.load.succeeded = 'load:succeeded' # controller, book
|
||||
Event.load.failed = 'load:failed' # controller, error message
|
||||
Event.load.finished = 'load:finished' # controller
|
||||
Event.remove = 'remove' # collection, item...
|
||||
Event.route = 'route'
|
||||
|
||||
exports.Url = Url = {}
|
||||
Url.itemIcon = _.template "/data/<%= modSlug %>/images/<%= itemSlug %>.png"
|
||||
|
||||
@@ -6,6 +6,7 @@ All rights reserved.
|
||||
###
|
||||
|
||||
{Duration} = require './constants'
|
||||
{Event} = require './constants'
|
||||
ItemPageController = require './controllers/item_page_controller'
|
||||
{Opacity} = require './constants'
|
||||
UrlParams = require './url_params'
|
||||
@@ -17,12 +18,15 @@ module.exports = class CraftingGuideRouter extends Backbone.Router
|
||||
constructor: (options={})->
|
||||
@_page = null
|
||||
@_pageControllers = {}
|
||||
@_lastReportedHref = null
|
||||
super options
|
||||
|
||||
@on Event.route, => @_recordPageView()
|
||||
|
||||
# Backbone.Router Overrides ####################################################################
|
||||
|
||||
navigate: ->
|
||||
super
|
||||
@_recordPageView()
|
||||
|
||||
routes:
|
||||
'': 'root'
|
||||
'item(/:name)': 'item'
|
||||
@@ -41,6 +45,9 @@ module.exports = class CraftingGuideRouter extends Backbone.Router
|
||||
# Private Methods ##############################################################################
|
||||
|
||||
_recordPageView: ->
|
||||
return if @_lastReportedHref is window.location.href
|
||||
@_lastReportedHref = window.location.href
|
||||
|
||||
if global.env is 'production'
|
||||
logger.info "Recording GA page view: #{window.location.href}"
|
||||
ga('send', 'pageview')
|
||||
|
||||
Reference in New Issue
Block a user