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

feat: add the elapsed time to events for debugging #5868

Merged
merged 2 commits into from
Nov 2, 2020
Merged
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
3 changes: 2 additions & 1 deletion src/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ module.exports = (function () {
eventsFired.push({
eventType: eventString,
args: eventPayload,
id: key
id: key,
elapsedTime: utils.getPerformanceNow(),
});

/** Push each specific callback to the `callbacks` array.
Expand Down
8 changes: 8 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,14 @@ export function timestamp() {
return new Date().getTime();
}

/**
* The returned value represents the time elapsed since the time origin. @see https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
* @returns {number}
*/
export function getPerformanceNow() {
return (window.performance && window.performance.now && window.performance.now()) || 0;
}

/**
* When the deviceAccess flag config option is false, no cookies should be read or set
* @returns {boolean}
Expand Down