Respect doNotTrack setting
parent
1a644dda11
commit
8301c20c7b
|
@ -191,6 +191,29 @@ H5P.XAPIEvent.prototype.setContext = function (instance) {
|
|||
* Set the actor. Email and name will be added automatically.
|
||||
*/
|
||||
H5P.XAPIEvent.prototype.setActor = function () {
|
||||
|
||||
/*
|
||||
* Check for doNotTrack setting by user. Could be placed in h5p.js.
|
||||
* @param {boolean} [strict=true] If True, will assume "do no track" if unset.
|
||||
* @return {boolean} True, if user should not be tracked.
|
||||
*/
|
||||
const isDoNotTrackSet = function (strict) {
|
||||
strict = (typeof strict === 'boolean') ? strict : true;
|
||||
|
||||
// User explicitly does not want to be tracked
|
||||
if (window.doNotTrack === '1' || navigator.doNotTrack === 'yes' || navigator.doNotTrack === '1') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Strict and user/browser did not specify doNotTrack setting
|
||||
if (strict && !(window.doNotTrack || navigator.doNotTrack)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Not strict or user explicitly allowed tracking
|
||||
return false;
|
||||
}
|
||||
|
||||
if (H5PIntegration.user !== undefined) {
|
||||
this.data.statement.actor = {
|
||||
'name': H5PIntegration.user.name,
|
||||
|
@ -200,6 +223,11 @@ H5P.XAPIEvent.prototype.setActor = function () {
|
|||
}
|
||||
else {
|
||||
var uuid;
|
||||
|
||||
if (isDoNotTrackSet()) {
|
||||
uuid = 'not-trackable-' + H5P.createUUID();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
if (localStorage.H5PUserUUID) {
|
||||
uuid = localStorage.H5PUserUUID;
|
||||
|
@ -213,6 +241,8 @@ H5P.XAPIEvent.prototype.setActor = function () {
|
|||
// LocalStorage and Cookies are probably disabled. Do not track the user.
|
||||
uuid = 'not-trackable-' + H5P.createUUID();
|
||||
}
|
||||
}
|
||||
|
||||
this.data.statement.actor = {
|
||||
'account': {
|
||||
'name': uuid,
|
||||
|
|
Loading…
Reference in New Issue