Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
4e33371
Fix problem with solana extension
ironbrands16 May 11, 2023
38373b8
Move from _phantom to phantom
adriaandotcom May 12, 2023
ea0cd3d
Merge pull request #39 from ironbrands16/patch-1
adriaandotcom May 12, 2023
f79ba5d
Run prettier via GitHub Action
May 12, 2023
3d7ccb5
Fix bug in checking phantom.solana
adriaandotcom Jun 19, 2023
65a6c3a
Always expose sa_pageview
adriaandotcom Jun 29, 2023
a914c9a
Check for Cloudflare under attack mode param
adriaandotcom Jul 14, 2023
de31383
Run prettier via GitHub Action
Jul 14, 2023
4924174
Test for all Cloudflare params
adriaandotcom Jul 14, 2023
23e043d
Clean subdomain hostname, fix auto events for links with child elemen…
adriaandotcom Mar 7, 2024
dc1a3ef
Add acron and remove trailing comma
adriaandotcom Feb 13, 2025
6e7ce19
Run prettier via GitHub Action
adriaandotcom Feb 13, 2025
e717409
Save local changes [no ci]
adriaandotcom May 27, 2025
8845936
Add jsdom unit tests
adriaandotcom May 27, 2025
46992f6
Fix default test without Browserstack
adriaandotcom May 29, 2025
5dad1ea
Add unit test to job
adriaandotcom May 29, 2025
770470a
Make sure all node js version are the same
adriaandotcom May 29, 2025
cda1d7d
Merge pull request #63 from simpleanalytics/codex/set-up-unit-tests-w…
adriaandotcom May 29, 2025
3fb3495
Merge branch 'v12' into v12-b
adriaandotcom May 29, 2025
065dbb1
Allow overwriting referrer
adriaandotcom May 29, 2025
ae84e8d
Merge pull request #62 from simpleanalytics/v12-b
adriaandotcom May 29, 2025
e1702cf
Rename testing file
adriaandotcom May 29, 2025
779661a
Run prettier in dry mode [no ci]
adriaandotcom May 29, 2025
dc35828
Add AGENTS guidance
adriaandotcom May 29, 2025
f99b45f
Improve AGENTS.md
adriaandotcom May 29, 2025
fbdd6ee
Add .cursorrules [no ci]
adriaandotcom May 29, 2025
fb045ce
Merge pull request #64 from simpleanalytics/codex/create-agents.md-fi…
adriaandotcom May 29, 2025
6bbf49a
Add modular unit tests and helpers
adriaandotcom May 29, 2025
d16c953
Merge pull request #65 from simpleanalytics/codex/plan-unit-testing-s…
adriaandotcom May 29, 2025
6f06801
Run browserstack not every time, and add linting
adriaandotcom May 29, 2025
b721ad0
Run browserstack not every time, for real
adriaandotcom May 29, 2025
495be42
Require prettier for brwoserstack too
adriaandotcom May 29, 2025
6bb5c0d
Rename prettier to linting
adriaandotcom May 29, 2025
8bfb9ec
Merge pull request #67 from simpleanalytics/codex/create-agents.md-file
adriaandotcom May 29, 2025
0a8a5ff
chore: fix eslint errors
adriaandotcom May 30, 2025
47bda2f
Merge pull request #68 from simpleanalytics/codex/fix-eslint-errors
adriaandotcom May 30, 2025
bfd91a4
feat(auto-events): skip automation when data-simple-event present
adriaandotcom May 30, 2025
912f482
Add manual build step
adriaandotcom May 30, 2025
5ee72b9
Merge branch 'v12' into codex/skip-automated-events-for-data-simple-e…
adriaandotcom May 30, 2025
0f12612
Merge pull request #69 from simpleanalytics/codex/skip-automated-even…
adriaandotcom May 30, 2025
82fcbb4
Rename to Testing Suite
adriaandotcom May 30, 2025
e38d8f6
Merge branch 'main' into v12
adriaandotcom May 30, 2025
21ae5b7
fix metadata reload in appendMetadata
adriaandotcom May 30, 2025
c256994
Merge pull request #70 from simpleanalytics/codex/fix-sa_metadata-loa…
adriaandotcom May 30, 2025
1835428
Bind sendBeacon calls
adriaandotcom May 30, 2025
f37e4ee
Merge branch 'v12' into codex/implement-fix-for-sendbeacon-error
adriaandotcom May 30, 2025
cfdd6f6
Merge pull request #71 from simpleanalytics/codex/implement-fix-for-s…
adriaandotcom May 30, 2025
7dc389f
Add callback support to sa_pageview
adriaandotcom May 30, 2025
3ac0008
Merge branch 'v12' into codex/add-callback-to-sa_pageview
adriaandotcom May 30, 2025
76b0426
Merge pull request #72 from simpleanalytics/codex/add-callback-to-sa_…
adriaandotcom Jun 13, 2025
cba0b20
Checkout dist after test:unit
adriaandotcom Jun 13, 2025
2d165c9
Reuse query param filter for manual pageviews
adriaandotcom Jun 13, 2025
984f634
Merge branch 'v12' into codex/fix-query-param-handling-in-sa_pageview
adriaandotcom Jun 13, 2025
2bfd05c
Merge pull request #74 from simpleanalytics/codex/fix-query-param-han…
adriaandotcom Jun 13, 2025
8ed3786
test: add metadata collector attr test
adriaandotcom Jun 13, 2025
28bf151
Merge branch 'v12' into codex/add-test-for-data-metadata-collector
adriaandotcom Jun 13, 2025
e1b021e
Merge pull request #75 from simpleanalytics/codex/add-test-for-data-m…
adriaandotcom Jun 13, 2025
571b372
Run npm run build
adriaandotcom Jun 13, 2025
c938f2f
Add tel link tracking to auto events
adriaandotcom Jun 13, 2025
67edab1
Add unit tests for auto-events
adriaandotcom Jun 13, 2025
defc6a0
Warn when metadata collector function is not found
adriaandotcom Jun 24, 2025
a216bda
Run npm run build
adriaandotcom Jun 24, 2025
aa513da
Merge pull request #77 from simpleanalytics/codex/add-unit-tests-for-…
adriaandotcom Jun 24, 2025
78bc66d
Fix delayed phone link events
adriaandotcom Jun 24, 2025
dc116ae
Merge pull request #76 from simpleanalytics/codex/add-tel--clicks-to-…
adriaandotcom Jul 29, 2025
9294410
fix allowParams regex to be case insensitive
adriaandotcom Jul 29, 2025
c869bb0
Merge pull request #81 from simpleanalytics/codex/make-allow-params-r…
adriaandotcom Jul 29, 2025
443ee6b
Merge main into v12
Aug 11, 2026
52d297e
Fix merged BrowserStack test setup
Aug 11, 2026
3e8bc7e
Collect compact query parameter names via ignore metrics
Aug 12, 2026
c70cae6
Run BrowserStack tests on Node.js 22.16
Aug 12, 2026
84ef41b
Use numeric BrowserStack test exit codes
Aug 12, 2026
6a74a12
Sync v12 conflict files with current main
Sep 16, 2026
d979bee
Merge current main into v12
simple-analytics-ai[bot] Sep 16, 2026
62d0cda
Use querykeys for query parameter name collection
Sep 16, 2026
3a6d633
Fix v12 CI after main sync
Sep 16, 2026
a2a876c
Document tracker compatibility and size priorities for agents (#115)
simple-analytics-ai[bot] Oct 15, 2026
38248a0
Support inline events in the main v12 script (#106)
simple-analytics-ai[bot] Oct 15, 2026
ee45d52
Preserve distinct manual pageviews in v12 (#108)
simple-analytics-ai[bot] Oct 15, 2026
b568ca3
Leave phone click navigation to the website and browser (#111)
simple-analytics-ai[bot] Oct 15, 2026
3395422
Respect the configured namespace for manual pageviews (#110)
simple-analytics-ai[bot] Oct 15, 2026
58f6679
Fix cmd-click for auto events (#78)
adriaandotcom Oct 15, 2026
6af229d
Count Cloudflare challenge arrivals as unique (#112)
simple-analytics-ai[bot] Oct 15, 2026
a3f1a4a
Accept current and legacy script deployment headers (#117)
simple-analytics-ai[bot] Oct 15, 2026
6b84d42
Remove retired Cloudflare app build from v12 (#121)
simple-analytics-ai[bot] Oct 15, 2026
5ce3453
fix: retain phone metadata with titled events (#122)
simple-analytics-ai[bot] Oct 16, 2026
fa3cbff
test: require current script version in SRI header checks (#123)
simple-analytics-ai[bot] Oct 16, 2026
8f8f885
Stop ignoring screen size when scrolled is ignored (#127)
simpleanalytics-agent Oct 17, 2026
138b76b
Set the loaded flag for custom event globals (#129)
simpleanalytics-agent Oct 18, 2026
58fa30d
Merge branch 'main' into v12
simpleanalytics-agent Oct 19, 2026
5ad1bf5
Count label clicks once in inline events (#133)
simpleanalytics-agent Oct 19, 2026
d46eefe
Run the pageview callback when the pageview is skipped (#132)
simpleanalytics-agent Oct 19, 2026
c0cda96
Send visible time on page when the page gets hidden (#134)
simpleanalytics-agent Oct 20, 2026
3f1cffe
Ask agents to weigh script size against edge cases (#136)
simpleanalytics-agent Oct 20, 2026
61d2ab0
Send the embedded script URL with pageviews (#138)
simpleanalytics-agent Oct 20, 2026
d1c4316
Merge branch 'main' into v12
adriaandotcom Oct 21, 2026
6bc409a
Use the caddy destination in the deploy header test
Oct 21, 2026
663ecbf
Test that automatic link clicks are not cancelled
Oct 21, 2026
5b4622c
Drop the placeholder callback in automatic link events
Oct 21, 2026
7794c2c
Fall back to a pixel when sendBeacon throws
Oct 21, 2026
60567ae
Limit the Cloudflare unique check to this site's referrers
Oct 21, 2026
9e44595
Drop the referrer on Cloudflare challenge arrivals
Oct 21, 2026
245f23f
Detect Cloudflare arrivals from the raw referrer host
Oct 21, 2026
71c84b9
Compare real hostnames to detect same-site referrers
Oct 21, 2026
c689b5d
Release tested script builds and record deployments
Oct 21, 2026
f546d3c
Merge main into feature/embed-script-release-workflow
Oct 22, 2026
b328795
Record deployments per destination and release only from main
Oct 22, 2026
75b052e
Address release and deployment review feedback
Oct 22, 2026
e14d12a
Reuse an existing draft when publishing a release
Oct 22, 2026
52c6d8a
Treat any published release as released
Oct 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env-default
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ DEV_BROWSER_VERSION=
DEV_OS=ios
DEV_DEVICE=
DEV_OS_VERSION=12

# Command that records GitHub deployments, for example a token broker (defaults to gh)
DEPLOY_GH_COMMAND=
16 changes: 15 additions & 1 deletion .github/workflows/browserstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: Browserstack
on:
pull_request:
types: [opened, synchronize, unlabeled]
workflow_call:
inputs:
upload-dist:
description: Upload the tested dist files as the "dist" artifact
type: boolean
default: false

jobs:
build:
Expand Down Expand Up @@ -55,7 +61,7 @@ jobs:
run: pnpm run test:matrix

- name: Run unit tests
run: pnpm run build && pnpm run test:unit && pnpm run test:deploy
run: pnpm run test:unit && pnpm run test:deploy

- name: Prettier check (report only, no writes or commits)
if: always()
Expand All @@ -81,6 +87,14 @@ jobs:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}

- name: Upload tested dist files
if: inputs.upload-dist
uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
if-no-files-found: error

- name: "Stop BrowserStackLocal"
if: always() && steps.browserstack.outputs.skip != 'true'
uses: "browserstack/github-actions/setup-local@master"
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release

# Bumping VERSION in compile.js on main publishes GitHub Release vN with the
# BrowserStack-tested build. Deploying it stays a manual `pnpm run deploy`.
on:
push:
branches: [main]
paths: [compile.js]
workflow_dispatch:
Comment thread
simpleanalytics-agent marked this conversation as resolved.

permissions:
contents: read

concurrency:
group: release
cancel-in-progress: false

jobs:
version:
# workflow_dispatch can run on any branch, but only main is released
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
released: ${{ steps.version.outputs.released }}
steps:
- uses: actions/checkout@v7

- name: Read the script version
id: version
env:
GH_TOKEN: ${{ github.token }}
run: |
version=$(sed -n 's/^const VERSION = \([0-9][0-9]*\);$/\1/p' compile.js)
if [ -z "$version" ]; then
echo "::error file=compile.js::Unable to read const VERSION"
exit 1
fi
tag="v$version"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
# A draft doesn't count (publishing can fail after it's created), and
# this read-only token can't see drafts anyway
if gh release view "$tag" --repo "$GITHUB_REPOSITORY" --json isDraft \
--jq ".isDraft | not" 2> /dev/null | grep -qx true; then
echo "released=true" >> "$GITHUB_OUTPUT"
echo "$tag is already released; bump VERSION in compile.js to release." >> "$GITHUB_STEP_SUMMARY"
fi

test:
needs: version
if: needs.version.outputs.released != 'true'
uses: ./.github/workflows/browserstack.yml
with:
upload-dist: true
secrets: inherit

publish:
needs: [version, test]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist

- name: Publish ${{ needs.version.outputs.tag }}
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.version.outputs.tag }}
run: |
tar -czf "scripts-$TAG.tar.gz" dist
# Reuse the draft of an earlier run whose publish failed
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
gh release upload "$TAG" "scripts-$TAG.tar.gz" --repo "$GITHUB_REPOSITORY" --clobber
Comment thread
simpleanalytics-agent marked this conversation as resolved.
else
gh release create "$TAG" "scripts-$TAG.tar.gz" \
--repo "$GITHUB_REPOSITORY" \
--target "$GITHUB_SHA" \
--title "$TAG" \
--generate-notes \
--draft
fi
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" \
--target "$GITHUB_SHA" --draft=false --latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
*.log
.env
/dist
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Before working here, read the shared [Simple Analytics instructions](https://git

## Dist

- `dist/` is generated output. Builds and `pnpm test` rewrite it (each build stamps the date), and a maintainer builds and commits it separately before deploying. Never commit `dist/` changes in feature work; restore it with `git checkout HEAD -- dist` before committing, and skip `dist/` when reviewing or validating changes.
- `dist/` is gitignored build output. Builds and `pnpm test` write it locally; never commit it.
- Releases are cut by bumping `VERSION` in `compile.js` on `main`. The Release workflow then builds, tests, and publishes GitHub Release `vN` with `scripts-vN.tar.gz`, which `pnpm run deploy` uploads. Published `vN` SRI files never change.

## Tracker changes

Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,24 @@ Install the pinned Node and pnpm versions, run `pnpm install --frozen-lockfile`,

The most important file of the repository is [`/src/default.js`](src/default.js)

## Deploy
## Release

Each release is one script version, `vN`. Its SRI file (`sri/vN.js`) never changes after publication, and the `latest` files serve the newest deployed release. `dist/` is build output and is not committed.

Build and commit the distribution files before deploying. The deployment command itself never builds or changes local distribution files.
1. Open a pull request on `main` that bumps `VERSION` in [`compile.js`](compile.js).
2. Merging it runs the [Release workflow](.github/workflows/release.yml). It builds the scripts once, runs the unit and BrowserStack tests on those files, and publishes GitHub Release `vN` with `scripts-vN.tar.gz`.

## Deploy

```sh
pnpm run deploy
```

The interactive CLI starts in dry-run mode by default. It lets you select scripts and destinations, reads the deployed files, and shows every affected path plus the first-line script-header diff. Choosing a real deployment requires a clean repository and a second confirmation.
The interactive CLI starts in dry-run mode by default. You pick a release (the newest by default), and the CLI downloads its `scripts-vN.tar.gz` and checks the file against the SHA-256 digest GitHub recorded. It then shows the release each destination runs now, every affected path, and the first-line script-header diff. It never builds or reads local `dist/` files. Choosing a real deployment requires a clean repository and a second confirmation. To roll back, deploy an older release; published SRI files are never overwritten.

After a real deployment that includes `latest.js`, the CLI records a GitHub deployment for each destination (`cdn` and `custom-domains`), so [Deployments](https://github.com/simpleanalytics/scripts/deployments) shows what is live. Deployments of only auto-events, SRI or light aren't recorded, because the destination keeps running its recorded release. It runs `gh`, or the command in `DEPLOY_GH_COMMAND`.

CDN writes use `BUNNY_SCRIPTS_ACCESS_KEY` and `BUNNY_SCRIPTS_ACCOUNT_KEY` from `.env`. Custom-domain reads and writes require SSH access to `app@external.simpleanalytics.com`.
CDN writes use `BUNNY_SCRIPTS_ACCESS_KEY` and `BUNNY_SCRIPTS_ACCOUNT_KEY` from `.env`. Caddy reads and writes require SSH access to `user@esapp05.simpleanalytics.com`.

## Device testing is sponsored by BrowserStack

Expand Down
Loading
Loading