Added config options for logging clicks and ajax calls.
This commit is contained in:
parent
dc263fb92a
commit
b745bce6ac
1 changed files with 56 additions and 53 deletions
|
@ -31,77 +31,80 @@ class _trackSingleton
|
||||||
@browser = App.Browser.detection()
|
@browser = App.Browser.detection()
|
||||||
@data = []
|
@data = []
|
||||||
# @url = 'http://localhost:3005/api/v1/ui'
|
# @url = 'http://localhost:3005/api/v1/ui'
|
||||||
@url = 'https://log.zammad.com/api/v1/ui'
|
@url = 'https://log.zammad.com/api/v1/ui'
|
||||||
|
@logClick = true
|
||||||
|
@logAjax = false
|
||||||
|
|
||||||
@forceSending = false
|
@forceSending = false
|
||||||
|
|
||||||
@log('start', 'notice', {})
|
@log('start', 'notice', {})
|
||||||
|
|
||||||
|
|
||||||
# start initial submit 30 sec. later to avoid ie10 cookie issues
|
# start initial submit 30 sec. later to avoid ie10 cookie issues
|
||||||
delay = =>
|
delay = =>
|
||||||
App.Interval.set @send, 60000
|
App.Interval.set @send, 60000
|
||||||
App.Delay.set delay, 30000
|
App.Delay.set delay, 30000
|
||||||
|
|
||||||
# log clicks
|
# log clicks
|
||||||
$(document).bind(
|
if @logClick
|
||||||
'click'
|
$(document).bind(
|
||||||
(e) =>
|
'click'
|
||||||
w = window.screen.width
|
(e) =>
|
||||||
h = window.screen.height
|
w = window.screen.width
|
||||||
aTag = $(e.target)
|
h = window.screen.height
|
||||||
if !aTag.attr('href')
|
aTag = $(e.target)
|
||||||
newTag = $(e.target).parents('a')
|
if !aTag.attr('href')
|
||||||
if newTag[0]
|
newTag = $(e.target).parents('a')
|
||||||
aTag = newTag
|
if newTag[0]
|
||||||
info =
|
aTag = newTag
|
||||||
level: 'notice'
|
info =
|
||||||
href: aTag.attr('href')
|
level: 'notice'
|
||||||
title: aTag.attr('title')
|
href: aTag.attr('href')
|
||||||
text: aTag.text()
|
title: aTag.attr('title')
|
||||||
clickX: e.pageX
|
text: aTag.text()
|
||||||
clickY: e.pageY
|
clickX: e.pageX
|
||||||
screenX: w
|
clickY: e.pageY
|
||||||
screenY: h
|
screenX: w
|
||||||
@log('click', 'notice', info)
|
screenY: h
|
||||||
)
|
@log('click', 'notice', info)
|
||||||
|
)
|
||||||
|
|
||||||
# log ajax calls
|
# log ajax calls
|
||||||
### disabled, only needed for debugging
|
if @logAjax
|
||||||
$(document).bind( 'ajaxComplete', ( e, request, settings ) =>
|
$(document).bind( 'ajaxComplete', ( e, request, settings ) =>
|
||||||
|
|
||||||
# do not log ui requests
|
# do not log ui requests
|
||||||
if settings.url && settings.url.substr(settings.url.length-3,3) isnt '/ui'
|
if settings.url && settings.url.substr(settings.url.length-3,3) isnt '/ui'
|
||||||
level = 'notice'
|
level = 'notice'
|
||||||
responseText = ''
|
responseText = ''
|
||||||
if request.status >= 400
|
if request.status >= 400
|
||||||
level = 'error'
|
level = 'error'
|
||||||
responseText = request.responseText
|
responseText = request.responseText
|
||||||
|
|
||||||
if settings.data
|
if settings.data
|
||||||
|
|
||||||
# add length limitation
|
# add length limitation
|
||||||
if settings.data.length > 3000
|
if settings.data.length > 3000
|
||||||
settings.data = settings.data.substr(0,3000)
|
settings.data = settings.data.substr(0,3000)
|
||||||
|
|
||||||
# delete passwords form data
|
# delete passwords form data
|
||||||
if typeof settings.data is 'string'
|
if typeof settings.data is 'string'
|
||||||
settings.data = settings.data.replace(/"password":".+?"/gi, '"password":"xxx"')
|
settings.data = settings.data.replace(/"password":".+?"/gi, '"password":"xxx"')
|
||||||
|
|
||||||
@log(
|
@log(
|
||||||
'ajax.send',
|
'ajax.send',
|
||||||
level,
|
level,
|
||||||
{
|
{
|
||||||
type: settings.type
|
type: settings.type
|
||||||
dataType: settings.dataType
|
dataType: settings.dataType
|
||||||
async: settings.async
|
async: settings.async
|
||||||
url: settings.url
|
url: settings.url
|
||||||
data: settings.data
|
data: settings.data
|
||||||
status: request.status
|
status: request.status
|
||||||
responseText: responseText
|
responseText: responseText
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
###
|
|
||||||
|
|
||||||
$(window).bind(
|
$(window).bind(
|
||||||
'beforeunload'
|
'beforeunload'
|
||||||
|
|
Loading…
Reference in a new issue