diff --git a/src/Analytics.js b/src/Analytics.js index 4f9ce6ad7d..c079011db7 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -19,8 +19,10 @@ import MatrixClientPeg from './MatrixClientPeg'; import PlatformPeg from './PlatformPeg'; import SdkConfig from './SdkConfig'; -function redact(str) { - return str.replace(/#\/(room|user)\/(.+)/, "#/$1/"); +function getRedactedUrl() { + const base = window.location.pathname.split('/').slice(-2).join('/'); + const redactedHash = window.location.hash.replace(/#\/(room|user)\/(.+)/, "#/$1/"); + return base + redactedHash; } const customVariables = { @@ -108,7 +110,7 @@ class Analytics { this.firstPage = false; return; } - this._paq.push(['setCustomUrl', redact(window.location.href)]); + this._paq.push(['setCustomUrl', getRedactedUrl()]); this._paq.push(['trackPageView']); }