Skip to content

Instantly share code, notes, and snippets.

@nadavkav
Created November 2, 2019 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadavkav/bb707fb8f9e15309cc4b549fa7519393 to your computer and use it in GitHub Desktop.
Save nadavkav/bb707fb8f9e15309cc4b549fa7519393 to your computer and use it in GitHub Desktop.
Moodle user page load PerformanceNavigationTiming
define(['jquery', 'core/config', 'core/notification'],
function($, config, notification) {
// https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming
var preftiming = performance.timing;
var params = {
contextid: config.contextid,
preftiming: JSON.stringify(preftiming),
sesskey: config.sesskey
};
$(window).on('load', function () {
$.post(config.wwwroot + '/log_user_page_pref.php', params)
.done(function(data, status) {
try {
console.log(data + status);
} catch (err) {
//notification.exception(err);
}
})
.fail(function (jqXHR, status, error) {
//notification.exception(error);
});
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment