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
Adding ping=1 tracker query param to allow JS tracker to update the end of visit time for more accurate visit length #8069
Conversation
7f1ef90
to
261847e
Compare
Still have to do manual tests & get JSLint test to pass, but this is ready to be reviewed. Will update the description w/ more info soon, but if you want to review now, going commit by commit will help, as I tried to make the commit messages descriptive. |
261847e
to
06cc452
Compare
*/ | ||
setHeartBeatTimer: function (minimumVisitLength, heartBeatDelay) { | ||
var now = new Date(); | ||
setHeartBeatTimer: function (heartBeatDelay) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break API? Removing the first parameter? I reckon it was not much used before? Should we mention it in changelog? Or maybe we do already? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might break code that uses it, however, it didn't actually do anything before. It was incomplete, just half the feature. It sent useless requests, probably creating new actions, no one should be using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not everyone likes it, I'd personally name it heartBeatDelayInSeconds
and also mention it in doc block that it is seconds since one is used to deal with ms
eg in setTimeout
etc.
I'll have another look tomorrow and not only have a look at the diff... so far looks like a nice, small addition |
be10196
to
c5ef759
Compare
heartBeatDown(); | ||
}); | ||
|
||
heartBeatUp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When looking at the code I found it a bit confusing that setUpHeartBeat()
does also directly sends or sets a timeout for heartBeatUp
although it's convenient. I'd maybe remove it from there and call it separately but up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand this, setUpHeartBeat()
sets up events and the first timeout, but the timeout is set via heartBeatUp()
. heartBeatUp()
is called in many places, including in heartBeatUp itself, because the timeout does not always exist even if the heart beat is enabled.
I will probably merge w/o this change, but if you want to clarify we can talk on slack.
FYI: The minified piwik.js version needs to be created |
…s misleading. Though it is initially set to the start time of a visit's last action, it is supposed to represent the visit's actual end time.
… is more performant and executes much less code on user websites. New piwik.js tests included as well as an additional utility to make writing future tests easier (use jquery to parse tracker requests that are returned from fetchTrackedRequests). However tests don't currently pass since qunit is not super helpful for testing async code.
…he piwik.js test).
…eature in the JS tracker.
…me, since we should ping N seconds after last ping also. And if tracking request is sent before heart beat timer is configured, setup heart beat when configuring heart beat timer.
…nableHeartBeatTimer, rename clearHeartBeat to disableHeartBeatTimer, make sure the timer will be set up after any tracker request, not just page view.
…elay cannot be lower than 1 second.
…doesn't appear in minified piwik.js. And set last tracker request time in makeSureThereIsAGapAfterFirstTrackingRequestToPreventMultipleVisitorCreation for increased code clarity + so it will be set when bulk requests sent.
ce5f651
to
8b4a1c7
Compare
… to ...InSeconds since its in milliseconds.
Adding ping=1 tracker query param to allow JS tracker to update the end of visit time for more accurate visit length.
Moved the interval changing code to here: #8213 |
Includes JavaScript tracker addition that sends a 'ping=1' request to Piwik every N seconds for a more accurate visit time, and the Piwik tracker code to handle those requests.
Changes to the JavaScript Tracker
Modified existing 'heart beat' code so it would be more efficient and more accurate. The system as it functions now is as follows:
setHeartBeatTimer()
method is used to configure the heart beat interval.If a window loses focus, the timeout is cleared. When the window gains focus, the timeout is reinstated.
Changes to Piwik tracking code
The change to the tracker is simple, if a ping request is sent and the visit is not new, the action is set to null and only the visit is updated.
Other Changes
wait()
function that spun (so the event queue never advanced).Manual Testing Strategy
For each browser:
TODO:
Refs #2041