This is an automated email from the ASF dual-hosted git repository.

hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 295dfbfce fix: report the new page title to Matomo after navigation
295dfbfce is described below

commit 295dfbfce0acbe7fac19d0b5013ac9b5968cd418
Author: Yang Luo <[email protected]>
AuthorDate: Mon Oct 12 00:39:26 2026 +0800

    fix: report the new page title to Matomo after navigation
---
 src/clientModules/matomo.js | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/clientModules/matomo.js b/src/clientModules/matomo.js
index d330166a6..017da2123 100644
--- a/src/clientModules/matomo.js
+++ b/src/clientModules/matomo.js
@@ -8,10 +8,18 @@ export function onRouteDidUpdate({location, 
previousLocation}) {
     return;
   }
   const referrer = window.location.origin + previousLocation.pathname + 
previousLocation.search;
-  setTimeout(() => {
+  const oldTitle = document.title;
+  let tries = 0;
+  // The page title is updated shortly after the route change.
+  const track = () => {
+    if (document.title === oldTitle && tries++ < 20) {
+      setTimeout(track, 50);
+      return;
+    }
     paq.push(["setReferrerUrl", referrer]);
     paq.push(["setCustomUrl", window.location.href]);
     paq.push(["setDocumentTitle", document.title]);
     paq.push(["trackPageView"]);
-  }, 0);
+  };
+  setTimeout(track, 0);
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to