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

add disable finger print options #18599

Merged
merged 20 commits into from
Jan 17, 2022
2 changes: 2 additions & 0 deletions .eslintignore
Expand Up @@ -4,3 +4,5 @@ plugins/*/javascripts/
plugins/*/angularjs/
plugins/*/tests/UI/
plugins/*/vue/dist/**/*.js
js/*.js
piwik.js
30 changes: 21 additions & 9 deletions js/piwik.js
Expand Up @@ -112,7 +112,7 @@
"", "\b", "\t", "\n", "\f", "\r", "\"", "\\", apply, call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, lastIndex, length, parse, prototype, push, replace,
sort, slice, stringify, test, toJSON, toString, valueOf, objectToJSON, addTracker, removeAllAsyncTrackersButFirst,
optUserOut, forgetUserOptOut, isUserOptedOut, withCredentials, visibilityState
optUserOut, forgetUserOptOut, isUserOptedOut, withCredentials, visibilityState, disableBrowserFeatureDetection
*/
/*global _paq:true */
/*members push */
Expand Down Expand Up @@ -2439,7 +2439,9 @@ if (typeof window.Matomo !== 'object') {
uniqueTrackerId = trackerIdCounter++,

// whether a tracking request has been sent yet during this page view
hasSentTrackingRequestYet = false;
hasSentTrackingRequestYet = false,

configBrowserFeatureDetectionEnable = true;

// Document title
try {
Expand Down Expand Up @@ -3128,6 +3130,11 @@ if (typeof window.Matomo !== 'object') {
* Browser features (plugins, resolution, cookies)
*/
function detectBrowserFeatures() {

// Browser Feature is disabled return empty object
if (!configBrowserFeatureDetectionEnable) {
return {};
}
if (isDefined(browserFeatures.res)) {
return browserFeatures;
}
Expand Down Expand Up @@ -3749,13 +3756,13 @@ if (typeof window.Matomo !== 'object') {
(charSet ? '&cs=' + encodeWrapper(charSet) : '') +
'&send_image=0';

var browserFeatures = detectBrowserFeatures();
// browser features
for (i in browserFeatures) {
if (Object.prototype.hasOwnProperty.call(browserFeatures, i)) {
request += '&' + i + '=' + browserFeatures[i];
var browserFeatures = detectBrowserFeatures();
peterhashair marked this conversation as resolved.
Show resolved Hide resolved
// browser features
for (i in browserFeatures) {
if (Object.prototype.hasOwnProperty.call(browserFeatures, i)) {
request += '&' + i + '=' + browserFeatures[i];
}
}
}

var customDimensionIdsAlreadyHandled = [];
if (customData) {
Expand Down Expand Up @@ -4960,6 +4967,10 @@ if (typeof window.Matomo !== 'object') {
linkTrackingInstalled = false;
linkTrackingEnabled = false;
};
this.disableBrowserFeatureDetection = function ()
peterhashair marked this conversation as resolved.
Show resolved Hide resolved
{
configBrowserFeatureDetectionEnable = false;
};
this.getConfigVisitorCookieTimeout = function () {
return configVisitorCookieTimeout;
};
Expand Down Expand Up @@ -6018,6 +6029,7 @@ if (typeof window.Matomo !== 'object') {
this.setCookieConsentGiven = function () {
if (configCookiesDisabled && !configDoNotTrack) {
configCookiesDisabled = false;
configBrowserFeatureDetectionEnable = true;
if (configTrackerSiteId && hasSentTrackingRequestYet) {
setVisitorIdCookie();

Expand Down Expand Up @@ -6947,7 +6959,7 @@ if (typeof window.Matomo !== 'object') {
*/
this.setConsentGiven = function (setCookieConsent) {
configHasConsent = true;

configBrowserFeatureDetectionEnable = true;
deleteCookie(CONSENT_REMOVED_COOKIE_NAME, configCookiePath, configCookieDomain);

var i, requestType;
Expand Down