Repository navigation
Respect the configured namespace for manual pageviews - #110
Conversation
Requested in item 3: keep namespaced trackers from replacing another tracker manual pageview function. Reuse existing namespace and pageview text variables to reduce minified bytes. Refs #107
Claude review checkpointReviewed commit |
|
SDLC label: |
Address review of item 3: older namespaced installations still call sa_pageview. Keep that alias when free, without overwriting another tracker, and cover both function names in the regression test. Refs #107
Documentation update
|
|
In response to #110 (comment): Prepared a patch against current docs/master describing the legacy sa_pageview alias when free and explicit ba_pageview routing with a second tracker. Verified both behaviors in the current implementation. The patch applies cleanly. There is no matching open docs PR to update. I have requested owner approval for a supporting docs PR because this automation is authorized to push to existing PR branches. Publication of these instructions must follow the relevant script PR and the v12 release; the patch remains local pending that approval. |
Requested: merge current v12 into PR #110. Preserve the namespaced manual pageview and legacy alias behavior, and rebuild conflicting distributions.
Summary
Closes #107
Manual page views were always exposed as
window.sa_pageview, ignoringdata-namespace. On a page with two trackers the second script overwrote the first script's manual function, so manual page views were sent to the other tracker's hostname.src/default.jsnow assigns the manual page view function towindow[namespace + "_pageview"], so a namespaced install getsba_pageviewand a second tracker can no longer take over the first one's function. The legacysa_pageviewglobal is kept as an alias, but only when it is still free when the script loads, so existing namespaced manual installations that callsa_pageviewkeep working while a default-namespace script on the same page always ownssa_pageviewregardless of load order.Rebuilt
dist/is included, as required for this repository. Currentv12was merged into this branch; the merge touched only generated distributions, which were rebuilt from source.Changes:
Security implications
Has security impact - described as: manual page views from a namespaced tracker could previously be routed to another tracker's configured hostname when several trackers coexisted on one page, which sent visitor page view data to the wrong destination.
Testing
Run by Claude on the merge commit
492f671, with Node.js 24.21.0 and pnpm 11.17.0 as declared inpackage.json:pnpm install --frozen-lockfile— succeeded.pnpm run build— succeeded, andgit statusis clean afterwards, so every committed file underdist/reproduces exactly from the current source.pnpm run test:unit— 41 passing, 0 failing, includingexposes the pageview function under its configured namespaceandkeeps a default manual tracker separate from an automatic namespaced tracker.dist/v12/app.jsemitsm[ct+"_"+b]=Yt; var Zt="sa_"+b; m[Zt]||(m[Zt]=Yt), so the namespaced global is always assigned and thesa_pageviewalias is only taken when free.compile.jssets the build-time default namespace tosafor every target, including the custom and Cloudflare builds.BrowserStack was not run locally; the full matrix is left to CI.
Checklist