From 7dd240bc8df62d106b24300279bc275867459c71 Mon Sep 17 00:00:00 2001 From: Zwyx <29386932+Zwyx@users.noreply.github.com> Date: Sun, 17 Mar 2024 21:56:48 +0800 Subject: [PATCH 1/2] Redact search params and fragment from referrer In the referrer URL, the search parameters (following the `?`) and the fragment (following the `#`) might contain personal/sensitive information. They are already dropped by Plausible server, but I think we could even make them never leave the user's device. It could be quite frightening for a user observing network requests in their browser's dev tools, to see that sensitive information is sent to Plausible, a third party service they might have never heard of. Observing that the search params and fragment are not being sent would be reassuring. --- tracker/src/plausible.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracker/src/plausible.js b/tracker/src/plausible.js index 68c85a840160..8a66cfbb45bd 100644 --- a/tracker/src/plausible.js +++ b/tracker/src/plausible.js @@ -74,7 +74,7 @@ payload.u = location.href {{/if}} payload.d = scriptEl.getAttribute('data-domain') - payload.r = document.referrer || null + payload.r = document.referrer?.split("?")[0].split("#")[0] || null if (options && options.meta) { payload.m = JSON.stringify(options.meta) } From 15dd4e5abbb64eed07c06eb41c7dc87236eee8b8 Mon Sep 17 00:00:00 2001 From: Zwyx <29386932+Zwyx@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:09:08 +0800 Subject: [PATCH 2/2] Remove optional chaining as referrer is always a string --- tracker/src/plausible.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tracker/src/plausible.js b/tracker/src/plausible.js index 8a66cfbb45bd..42271556b05c 100644 --- a/tracker/src/plausible.js +++ b/tracker/src/plausible.js @@ -74,7 +74,7 @@ payload.u = location.href {{/if}} payload.d = scriptEl.getAttribute('data-domain') - payload.r = document.referrer?.split("?")[0].split("#")[0] || null + payload.r = document.referrer.split("?")[0].split("#")[0] || null if (options && options.meta) { payload.m = JSON.stringify(options.meta) }