Adds a PLAUSIBLE_SCRIPT config option so the package can proxy Plausible's site-specific scripts (js/pa-XXXXX.js) and legacy script extensions (e.g. js/script.outbound-links.js).
New config key script (env PLAUSIBLE_SCRIPT), default js/script.js, so existing installs are unaffected
The script is still served locally from /js/script.js
Leading/trailing slashes in domain and script are normalised
Cache key is derived from the script URL, so changing the script takes effect immediately instead of serving the old cached script for up to 6 hours
README documents the site-specific script setup, including plausible.init({ endpoint: '/api/event' }) so events go through the proxy
Testing
composer test: 10 passed (new tests for custom path, slash normalisation, cache invalidation on script change and caching)
composer analyse: no errors
vendor/bin/pint --test: passed
To verify before merge
That the endpoint option in plausible.init() is the correct way to route events from the new pa- script through the proxy (not tested against a real pa- script).
Closes #14
## Summary
Adds a `PLAUSIBLE_SCRIPT` config option so the package can proxy Plausible's site-specific scripts (`js/pa-XXXXX.js`) and legacy script extensions (e.g. `js/script.outbound-links.js`).
- New config key `script` (env `PLAUSIBLE_SCRIPT`), default `js/script.js`, so existing installs are unaffected
- The script is still served locally from `/js/script.js`
- Leading/trailing slashes in `domain` and `script` are normalised
- Cache key is derived from the script URL, so changing the script takes effect immediately instead of serving the old cached script for up to 6 hours
- README documents the site-specific script setup, including `plausible.init({ endpoint: '/api/event' })` so events go through the proxy
## Testing
- `composer test`: 10 passed (new tests for custom path, slash normalisation, cache invalidation on script change and caching)
- `composer analyse`: no errors
- `vendor/bin/pint --test`: passed
## To verify before merge
- That the `endpoint` option in `plausible.init()` is the correct way to route events from the new `pa-` script through the proxy (not tested against a real `pa-` script).
Add a PLAUSIBLE_SCRIPT config option so site-specific scripts
(js/pa-XXXXX.js) and legacy script extensions can be proxied. The
script is still served locally from /js/script.js and the cache key
is derived from the script URL so changing the script takes effect
immediately.
Closes#14
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #14
Summary
Adds a
PLAUSIBLE_SCRIPTconfig option so the package can proxy Plausible's site-specific scripts (js/pa-XXXXX.js) and legacy script extensions (e.g.js/script.outbound-links.js).script(envPLAUSIBLE_SCRIPT), defaultjs/script.js, so existing installs are unaffected/js/script.jsdomainandscriptare normalisedplausible.init({ endpoint: '/api/event' })so events go through the proxyTesting
composer test: 10 passed (new tests for custom path, slash normalisation, cache invalidation on script change and caching)composer analyse: no errorsvendor/bin/pint --test: passedTo verify before merge
endpointoption inplausible.init()is the correct way to route events from the newpa-script through the proxy (not tested against a realpa-script).