Repository navigation
v12 - #40
v12#40adriaandotcom wants to merge 78 commits into
Conversation
It seems Solana from Phantom has this namespace for their browser extension. I added a check for prevent them being detected as bots.
Fix problem with solana extension
…ith-jsdom-and-mocha Add unit tests using jsdom
Save local changes v12-b
…le [no ci] Add AGENTS instructions
…trategy-with-abstractions Add modular tests and helper utilities
…egex-case-insensitive Fix allowParams case sensitivity
Resolve PR #40 conflicts while retaining the v12 dist artifacts. Keep main's BrowserStack workflow and nested-link click handling, and combine the test scripts from both branches.
* Document tracker compatibility and size priorities for agents * Update AGENTS.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Simple Analytics Codex <codex@simpleanalytics.invalid> Co-authored-by: Adriaan <1079135+adriaandotcom@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Support inline event attributes in the main v12 tracker Requested: integrate documented inline events without overengineering, keep the script small and website behavior intact, and open a separate PR based on and targeting v12. Use delegated click/submit handlers and keepalive GETs with the existing image fallback. Preserve installed inline helpers and make confirmed 404 detection opt-in. Add focused tests and patch the vulnerable Handlebars build dependency. * Simplify inline events after review Requested: remove compatibility checks for the beta helper, measure repeated attribute strings, clarify the DOM alias, and shorten submit-button metadata extraction. Keep literals because sharing them increases gzip size. Prefer trimmed, capped submitter labels and scan title/body text for 404s. Address the related bot feedback by running the complete unit suite in CI. * Normalize inline submit button label whitespace Requested: address scripts PR #106 review comment 4282258759 so formatting a button across multiple lines does not fragment button_text metadata. Collapse whitespace before trimming and applying the existing 200-character limit. Add a regression for equivalent compact and indented button markup, and regenerate the affected tracker bundles. Verification: regression fails on the previous compiled tracker; all 33 unit tests pass after the fix. Build, formatting, and diff checks pass. --------- Co-authored-by: Simple Analytics Codex <codex@simpleanalytics.invalid>
|
|
||
| var getQueryParams = function (ignoreSource, overwriteSearch) { | ||
| /** if ignoremetrics **/ | ||
| k = !ignoreSource && collectMetricByString("q") ? "" : falseVar; |
There was a problem hiding this comment.
k is gated only on querykeys, so it bypasses the existing query opt-outs: with data-ignore-metrics="utm" and ?utm_source=news&token=abc the pageview now sends k=utm_source,token even though query is empty (verified against dist/latest/latest.dev.js). A site that explicitly turned off UTM collection starts sending those parameter names without changing its embed. Gate the name collection on collectMetricByString("ut") as well, or reuse the same filter result so ignored params are excluded from k.
| callbackRaw | ||
| ) { | ||
| if (!callbackRaw && isFunction(metadata)) callbackRaw = metadata; | ||
| var callback = isFunction(callbackRaw) ? callbackRaw : function () {}; |
There was a problem hiding this comment.
The callback is dropped whenever pageview returns early at if (!path || lastSendPath == path) return; (line 848) — i.e. for a repeated path or an ignored page. sa_pageview("/same", cb1); sa_pageview("/same", cb2) only fires cb1, so a caller that continues navigation from the callback hangs forever. Call callback() before that early return.
| @@ -837,7 +914,10 @@ | |||
|
|
|||
| /** if uniques **/ | |||
| // We set unique variable based on pushstate or back navigation, if no match we check the referrer | |||
| page.unique = isPushState || userNavigated ? falseVar : !sameSite; | |||
| page.unique = | |||
| /__cf_/.test(getReferrer()) || isPushState || userNavigated | |||
There was a problem hiding this comment.
getReferrer() strips the query string (([^?#]+)(.*) → $4), so __cf_* params can never reach this test and the Cloudflare under-attack handling is dead code — a visit with referrer https://external.com/page?__cf_chl_tk=abc still reports unique=true (verified against the built latest.dev.js). Test the raw referrer instead:
| /__cf_/.test(getReferrer()) || isPushState || userNavigated | |
| /__cf_/.test(doc.referrer) || isPushState || userNavigated |
| @@ -37,6 +37,7 @@ | |||
| "outbound", | |||
| "emails", | |||
| "downloads", | |||
| "phones", | |||
There was a problem hiding this comment.
Adding phones to the default collect list changes behaviour for every existing auto-events installation: tel: clicks start producing new phone_* events with a phone metadata field, which shifts event lists and datapoint counts without the customer changing their embed. Consider shipping it opt-in (data-collect="outbound,emails,downloads,phones") unless the default change is deliberate.
| "phones", |
| @@ -175,6 +186,10 @@ | |||
| // Collect email clicks | |||
| } else if (optionsLink.emails && /^mailto:/i.test(link.href)) { | |||
| collect = "email"; | |||
|
|
|||
| // Collect telephone clicks | |||
| } else if (optionsLink.phones && /^tel:/i.test(link.href)) { | |||
There was a problem hiding this comment.
tel: links take the addEventListener branch, and for phone the callback runs synchronously and sets document.location = href without checking whether the click was cancelled — so a site that calls preventDefault() on tel: links (custom dialer modal, confirmation step) now gets forced into the tel: navigation anyway (reproduced in jsdom). Skip the forced navigation when event.defaultPrevented is set, and let the browser own the navigation.
Documentation update
|
Summary
Fixes #97
Prepare public script v12:
Before merging, update beta.js as well or inform customer team 13489e0b-295c-476b-b955-46389fe10895.
Security implications
Has security impact - described as: Query parameter values are never collected by this addition. Name collection is limited to parameters with non-empty values and can be disabled.
Testing
Checklist