From 7dc389fcc15aec8b1d9db8afc5aff85e48fb2827 Mon Sep 17 00:00:00 2001 From: Adriaan <1079135+adriaandotcom@users.noreply.github.com> Date: Fri, 30 May 2025 17:29:24 +0200 Subject: [PATCH] Add callback support to sa_pageview --- dist/latest/auto-events.js | 2 +- dist/latest/latest.dev.js | 38 ++++++++++++++++-------- src/default.js | 46 ++++++++++++++++++----------- test/unit/pageview-callback.test.js | 34 +++++++++++++++++++++ 4 files changed, 89 insertions(+), 31 deletions(-) create mode 100644 test/unit/pageview-callback.test.js diff --git a/dist/latest/auto-events.js b/dist/latest/auto-events.js index 7575a1e..c8ac687 100644 --- a/dist/latest/auto-events.js +++ b/dist/latest/auto-events.js @@ -1,4 +1,4 @@ -/* Simple Analytics - Privacy-first analytics (docs.simpleanalytics.com/script; 2025-05-29; 7048; v12) */ +/* Simple Analytics - Privacy-first analytics (docs.simpleanalytics.com/script; 2025-05-30; 7048; v12) */ function r(t,e){var a,n;t.hasAttribute("data-simple-event")||(a=!1,h.downloads&&/^https?:\/\//i.test(t.href)&&new RegExp("\\.("+(h.downloadsExtensions||[]).join("|")+")$","i").test(t.pathname)?a="download":h.outbound&&/^https?:\/\//i.test(t.href)&&t.hostname!==m.location.hostname?a="outbound":h.emails&&/^mailto:/i.test(t.href)&&(a="email"),a&&(e?(n="saAutomatedLink(this, '"+a+"');",t.hasAttribute("target")&&"_self"!==t.getAttribute("target")||(n+=" return false;"),t.setAttribute("onclick",n)):t.addEventListener("click",function(){g(t,a)})))}function e(){try{for(var t=document.getElementsByTagName("a"),e=0;e { + const req = dom.sent.find( + (r) => r.type === "image" && /path=%2Fcallback/.test(r.url) + ); + expect(req, "pageview request").to.exist; + expect(called, "callback called").to.be.true; + done(); + }, 10); + }); +});