Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send deltas between sequential navigation.timing events #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions bucky.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ exportDef = ->
tagOptions[key] = true
else if tagOptions[key]?.toString().toLowerCase is 'false'
tagOptions[key] = null

options = extend {}, defaults, tagOptions

TYPE_MAP =
'timer': 'ms'
'gauge': 'g'
Expand All @@ -96,6 +96,11 @@ exportDef = ->

HISTORY = []

EVENTS = ['navigationStart', 'redirectStart', 'redirectEnd', 'fetchStart', 'domainLookupStart', 'domainLookupEnd', \
'connectStart', 'connectEnd', 'secureConnectionStart', 'requestStart', 'responseStart', 'responseEnd', \
'domLoading', 'domInteractive', 'domContentLoadedEventStart', 'domContentLoadedEventEnd', \
'domComplete', 'loadEventStart', 'loadEventEnd']

setOptions = (opts) ->
extend options, opts

Expand Down Expand Up @@ -171,11 +176,11 @@ exportDef = ->
sameOrigin = false
else
# Relative URL

sameOrigin = true

sendStart = now()

body = ''
for name, val of data
body += "#{ name }:#{ val }\n"
Expand Down Expand Up @@ -384,9 +389,15 @@ exportDef = ->
sentPerformanceData = true

start = window.performance.timing.navigationStart
for key, time of window.performance.timing when typeof time is 'number'
for key, time of window.performance.timing when typeof time is 'number' and key != 'navigationStart'
timer.send "#{ path }.#{ key }", (time - start)

for event in EVENTS
if typeof window.performance.timing[event] is 'number' and window.performance.timing[event] > 0
if typeof lastEvent != 'undefined'
timer.send "#{ path }.#{ event }.delta", (window.performance.timing[event] - window.performance.timing[lastEvent])
lastEvent = event

return true

requests = {
Expand Down
16 changes: 13 additions & 3 deletions bucky.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading