In CI
In CI, the CLI is mostly used for two things: uploading each build's source maps and checking that the DSN works. Neither needs collector login.
The credentials
| For | Use | Variable |
|---|---|---|
collector upload | An upload token | COLLECTOR_UPLOAD_TOKEN (only read from there, never from a flag or a file) |
collector test, and where Collector is | The project's DSN | COLLECTOR_DSN |
| Any other command | An access token, preferably read-only and limited to one organization | COLLECTOR_TOKEN |
Keep all three in your CI's secrets. For a Collector other than app.clt.chrom.ar, add COLLECTOR_URL.
An example with GitHub Actions
- name: Install collector
run: curl -fsSL https://packages.chrom.ar/collector/install.sh | sh
- name: Build
run: npm run build
env:
GIT_SHA: ${{ github.sha }}
- name: Upload source maps
run: collector upload ./dist --release "$GITHUB_SHA" --delete
env:
COLLECTOR_UPLOAD_TOKEN: ${{ secrets.COLLECTOR_UPLOAD_TOKEN }}
COLLECTOR_DSN: ${{ secrets.COLLECTOR_DSN }}
Upload before you deploy: events from a release without maps stay minified. The --release must be exactly the one your application reports. See Source maps.
The exit codes
upload and test end with 0 when it worked, 1 when Collector refused or didn't answer, and 2 when the command was misused. A CI step fails only when something really went wrong. The other commands add 3 for token problems; see Exit codes.