strictly respect do not track

This commit is contained in:
Cadey Ratio 2019-08-19 16:53:28 +00:00
parent e4768b4073
commit 815638b2ed
2 changed files with 26 additions and 16 deletions

View File

@ -22,6 +22,11 @@ func init() {
}
func handlePageViewTimer(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("DNT") == "1" {
http.NotFound(w, r)
return
}
data, err := ioutil.ReadAll(r.Body)
if err != nil {
ln.Error(r.Context(), err, ln.Info("while reading data"))

View File

@ -10,6 +10,12 @@
be ineffectual.
*/
(function() {
let dnt = navigator.doNotTrack;
if (dnt == "1") {
return;
}
let startTime = new Date();
function logTime() {
@ -22,9 +28,8 @@ function logTime() {
}
);
if (!window.navigator.sendBeacon("/api/pageview-timer", message)) {
alert("wtf");
}
window.navigator.sendBeacon("/api/pageview-timer", message);
}
window.addEventListener("pagehide", logTime, false);
})();