From 8ed378618c1a9ebf1b14f5fa729926f6c3bc7fad Mon Sep 17 00:00:00 2001 From: Adriaan <1079135+adriaandotcom@users.noreply.github.com> Date: Fri, 13 Jun 2025 16:10:23 +0200 Subject: [PATCH] test: add metadata collector attr test --- dist/latest/auto-events.js | 2 +- dist/latest/latest.dev.js | 5 ++--- test/unit/metadata-attr.test.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 test/unit/metadata-attr.test.js diff --git a/dist/latest/auto-events.js b/dist/latest/auto-events.js index 7575a1e..df8e3ec 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-06-04; 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=%2Fattr/.test(r.url) + ); + expect(req, "pageview request").to.exist; + const url = new URL(req.url); + const meta = JSON.parse( + decodeURIComponent(url.searchParams.get("metadata")) + ); + expect(meta).to.include({ fromAttr: true }); + done(); + }, 10); + }); +});