Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
8ef3ad2
Restrict analytics tracking and harden settings and releases
jdevalk Nov 15, 2026
4ef7e07
Restrict analytics tracking and harden settings and releases
jdevalk Nov 15, 2026
810c2fc
Add opt-in integrity pinning for analytics scripts
jdevalk Nov 17, 2026
0066201
Keep existing custom domains working and make network admin exclusion…
simpleanalytics-agent Nov 18, 2026
978191c
Merge remote-tracking branch 'origin/main' into codex/security-hardening
simpleanalytics-agent Nov 18, 2026
b7741cd
Guard the merged script attributes test against direct access
simpleanalytics-agent Nov 18, 2026
5f65b91
Merge the updated security hardening branch
simpleanalytics-agent Nov 18, 2026
afe13ff
Bundle the v12 release of the automated-events script
simpleanalytics-agent Nov 18, 2026
c997d4c
Bundle every pinned script from the v12 release
simpleanalytics-agent Nov 18, 2026
0b08c43
Merge remote-tracking branch 'origin/main' into codex/security-hardening
simpleanalytics-agent Nov 19, 2026
7f4cc47
Merge the updated security hardening branch
simpleanalytics-agent Nov 19, 2026
4e1b9db
Apply suggestion from @simpleanalytics-agent
adriaandotcom Nov 19, 2026
9dffee8
Merge the final security hardening branch
simpleanalytics-agent Nov 19, 2026
a4221ce
Merge remote-tracking branch 'origin/main' into codex/script-pinning
simpleanalytics-agent Nov 19, 2026
ecf7ea1
Bundle the source maps of the pinned scripts
simpleanalytics-agent Nov 19, 2026
b13e39a
Drop integrity hashes from pinned scripts and keep earlier releases
simpleanalytics-agent Nov 19, 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 .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/README.md export-ignore

# The regression test checks the exact bytes, including line endings.
/resources/js/pinned/** text eol=lf
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ You need a Simple Analytics account. Start with the [free plan](https://www.simp

- [WordPress plugin page](https://wordpress.org/plugins/simpleanalytics/)
- [Create a Simple Analytics account](https://www.simpleanalytics.com/signup)

## Script pinning

Enable **Pin analytics scripts** under **Settings → Simple Analytics → Advanced** to run the v12 analytics and automated-events scripts bundled with the plugin, instead of the latest scripts from the CDN. Pinning is off by default. Script updates arrive with plugin releases, and the release number is part of each script's URL. Clear page caches after changing this setting, so visitors receive the new script tags.

With a custom domain, the plugin fills the domain into the bundled custom-domain build, as the custom-domain server does for `https://YOUR.DOMAIN/sri/v12.js`, and saves it as `wp-content/uploads/simpleanalytics/v12-YOUR.DOMAIN.js`. That script sends data to the custom domain. Scripts written for earlier releases stay until the custom domain changes. If the uploads folder is not writable, visitors get the bundled script for the default domain and administrators see a warning.

### Updating pinned scripts

- Pinned scripts follow the releases of [simpleanalytics/scripts](https://github.com/simpleanalytics/scripts). `VERSION` in `src/Support/ScriptPinning.php` is the release tag (`v12`), and `resources/js/pinned/v12/` holds `dist/v12/app.js`, `dist/v12/custom/app.js`, `dist/v12/auto-events.js`, `dist/v12/app.js.map` and `dist/v12/auto-events.js.map` from that release's `scripts-v12.tar.gz`, unmodified. Directories of earlier releases stay, so pages cached before a plugin update keep loading their scripts. Browsers request a script's source map when developer tools are open, so a missing map logs an error. The custom-domain map is valid only after its server fills in the hostname, so it is not bundled, and the script written for a custom domain drops its source map comment. `app.js` equals `https://scripts.simpleanalyticscdn.com/sri/v12.js` except for its source map comment. The MIT license is retained in `resources/js/pinned/LICENSE`.
- For a new release such as `v13`: review the upstream changes, put the same five files from `scripts-v13.tar.gz` in `resources/js/pinned/v13/`, keep `v12/`, change `VERSION`, and add the hashes of `app.js`, `custom/app.js` and `auto-events.js` to `$releases` in `tests/Regression/script-pinning.php`. Calculate each hash with `echo "sha384-$(openssl dgst -sha384 -binary FILE | openssl base64 -A)"`. The test fails when a bundled release has no hashes or a file does not match them.
- Run the PHP regressions and browser checks, including a custom domain and event collection.
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ Installing "Simple Analytics" can be done in multiple ways.

== Frequently Asked Questions ==

= Can I pin the analytics scripts? =

Yes. Enable "Pin analytics scripts" under Settings > Simple Analytics > Advanced. The plugin then runs the v12 analytics and automated-events scripts bundled with it, instead of the latest scripts from our CDN. Pinning is off by default. Script updates arrive with plugin releases. Clear page caches after enabling or disabling pinning. With a custom domain, the plugin saves a copy of the script for that domain in the uploads folder. The readable source of the bundled scripts is at https://github.com/simpleanalytics/scripts/tree/v12/src.

= Is Simple Analytics free? =

Yes. You can use Simple Analytics for free forever. You only need to create an account at [Simple Analytics](https://simpleanalytics.com/?ref=wordpress).
Expand Down
21 changes: 21 additions & 0 deletions resources/js/pinned/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018-2026 Simple Analytics

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions resources/js/pinned/v12/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions resources/js/pinned/v12/app.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions resources/js/pinned/v12/auto-events.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading