Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 14 additions & 11 deletions .github/workflows/browserstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ jobs:
runs-on: ubuntu-latest
if: "${{ github.event.action != 'unlabeled' || github.event.label.name == 'skip: browserstack' }}"

strategy:
matrix:
node-version: [16.16]

steps:
- name: Check BrowserStack skip label
id: browserstack
Expand Down Expand Up @@ -40,16 +36,23 @@ jobs:
ref: ${{ github.head_ref }}
set-safe-directory: "/github/workspace"

- name: Use Node.js ${{ matrix.node-version }}
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 11.17.0

- name: Use Node.js from .nvmrc
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
node-version-file: .nvmrc
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Run npm ci
run: sudo npm ci
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Test BrowserStack matrix selection
run: npm run test:matrix
run: pnpm run test:matrix

- name: Prettier check (report only, no writes or commits)
if: always()
Expand All @@ -64,9 +67,9 @@ jobs:
echo '```'
} >> "$GITHUB_STEP_SUMMARY"

- name: Run npm test with BrowserStack Local
- name: Run tests with BrowserStack Local
if: steps.browserstack.outputs.skip != 'true'
run: npm run build && node ./test/index.js
run: pnpm run build && node ./test/index.js
env:
CI: true
NODE_ENV: test
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.16
24.18.0
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,26 @@ If you want to contribute, you probabaly want to contribute to our [`/src/defaul

In `default.js` you see some weird syntax in the comments. For example, `/** if ignorepages **/` _\[some code\]_ `/** endif **/`. These comments are converted to handlebars like this: `{{#if ignorepages }}` _\[some code\]_ `{{/if}}`. In this case, [`ignorepages` is a variable](https://github.com/simpleanalytics/scripts/blob/3874b44ce5f1b0b8a7d50fb512fdcf5285a0138f/minify.js#L66) used in `minify.js` that takes care of what functionality to show in what script. Our main script is the `latest.js` script which includes all features. We also have a `light.js` script that obviously doesn't.

If you contribute, make sure to use `npm run build`, copy the script to a website, and check if it works correctly.
If you contribute, make sure to use `pnpm run build`, copy the script to a website, and check if it works correctly.

## Run this locally

Just run `npm run watch` and every file will be validated and compiled on save. We minify our scripts with [UglifyJS](http://lisperator.net/uglifyjs/), a well-known JavaScript minifier.
Install the pinned Node and pnpm versions, run `pnpm install --frozen-lockfile`, and then use `pnpm run watch`. Every file will be validated and compiled on save. We minify our scripts with [UglifyJS](http://lisperator.net/uglifyjs/), a well-known JavaScript minifier.

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

## Deploy

Build and commit the distribution files before deploying. The deployment command itself never builds or changes local distribution files.

```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.

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`.

## Device testing is sponsored by BrowserStack

We run our public script on a live, representative matrix of [browsers and real devices](https://github.com/simpleanalytics/scripts/blob/main/test/helpers/get-browsers.js). Simple Analytics supports vendor-maintained browser, OS, and device versions and continues compatibility testing for two years after published end of life. Older browser versions with more than 0.1% global usage remain covered. We get amazing sponsorship from [BrowserStack](https://www.browserstack.com/). Thanks, BrowserStack!
Expand Down
Loading
Loading