mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-23 01:30:05 +01:00
Refactor do not track code.
This commit is contained in:
parent
fd0c22c09d
commit
0ba7676e97
35
lib/web.js
35
lib/web.js
@ -48,26 +48,17 @@ export const hook = (_this, method, callback) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const doNotTrack = () => {
|
export const doNotTrack = () => {
|
||||||
if (
|
const { doNotTrack, navigator, external } = window;
|
||||||
window.doNotTrack ||
|
|
||||||
navigator.doNotTrack ||
|
const msTracking = () => {
|
||||||
navigator.msDoNotTrack ||
|
return (
|
||||||
(window.external && 'msTrackingProtectionEnabled' in window.external)
|
external &&
|
||||||
) {
|
typeof external.msTrackingProtectionEnabled === 'function' &&
|
||||||
if (
|
external.msTrackingProtectionEnabled()
|
||||||
window.doNotTrack == '1' ||
|
);
|
||||||
navigator.doNotTrack == 'yes' ||
|
};
|
||||||
navigator.doNotTrack == '1' ||
|
|
||||||
navigator.msDoNotTrack == '1' ||
|
const dnt = doNotTrack || navigator.doNotTrack || navigator.msDoNotTrack || msTracking();
|
||||||
(window.external &&
|
|
||||||
window.external.msTrackingProtectionEnabled &&
|
return dnt === true || dnt === 1 || dnt === 'yes' || dnt === '1';
|
||||||
window.external.msTrackingProtectionEnabled())
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
import buble from '@rollup/plugin-buble';
|
import buble from '@rollup/plugin-buble';
|
||||||
|
import replace from '@rollup/plugin-replace';
|
||||||
import resolve from '@rollup/plugin-node-resolve';
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
import { terser } from 'rollup-plugin-terser';
|
import { terser } from 'rollup-plugin-terser';
|
||||||
|
|
||||||
@ -9,5 +10,10 @@ export default {
|
|||||||
file: 'public/umami.js',
|
file: 'public/umami.js',
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
},
|
},
|
||||||
plugins: [resolve(), buble(), terser({ compress: { evaluate: false } })],
|
plugins: [
|
||||||
|
replace({ __DNT__: !!process.env.ENABLE_DNT }),
|
||||||
|
resolve(),
|
||||||
|
buble(),
|
||||||
|
terser({ compress: { evaluate: false } }),
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
@ -13,7 +13,7 @@ import { post, hook, doNotTrack } from '../lib/web';
|
|||||||
|
|
||||||
const script = document.querySelector('script[data-website-id]');
|
const script = document.querySelector('script[data-website-id]');
|
||||||
|
|
||||||
if (!script || doNotTrack()) return;
|
if (!script || (__DNT__ && doNotTrack())) return;
|
||||||
|
|
||||||
const website = script.getAttribute('data-website-id');
|
const website = script.getAttribute('data-website-id');
|
||||||
const hostUrl = new URL(script.src).origin;
|
const hostUrl = new URL(script.src).origin;
|
||||||
|
Loading…
Reference in New Issue
Block a user