Last updated 26 November 2026. By Paul Badarau.
A fictional ticketing site deploys from its main branch about five times a week. Each build has three bundles. Its deploy job builds, uploads the maps, removes them, and publishes the folder, so every error from a new build opens with the original function names and nobody has to remember a manual step.
The job, in order:
- Store two secrets in your CI.
PD_UPLOAD_TOKENis an upload token from Setup in Monitoring, created by an Owner or Administrator and shown once.PD_UPLOAD_URLis the address on your DSN's host, such ashttps://DSN_HOST/api/4821/artifacts/, where 4821 is the number at the end of your DSN. - Build with your usual command, such as
npm run build, with hidden source maps turned on so the bundles do not point browsers at the maps. - Inject debug IDs into the bundles and maps:
sentry-cli sourcemaps inject dist. - Upload each map, and stop at the first refusal:
for map in $(find dist -name '*.map'); do curl --fail -sS -X POST "$PD_UPLOAD_URL" -H "Authorization: Bearer $PD_UPLOAD_TOKEN" -H "Content-Type: application/json" --data-binary "@$map" || exit 1; done - Remove the maps from the output:
find dist -name '*.map' -delete. - Deploy
distas usual.
Steps 3 to 6 must act on the same files. A deploy step that runs the build again gives the bundles new debug IDs, and the uploaded maps match nothing.
Rerunning a failed job is safe. Identical maps are stored once, reported as unchanged, and not counted toward the Project's 60 uploads a minute. Each request counts as one upload, so a zip of up to 32 maps, sent as application/zip, also keeps a large build under that limit.
Decide what a refused upload should do. With || exit 1, a refusal stops the deploy, which keeps every release readable but can hold back a fix. Without it, the release ships and its errors stay minified until you upload the maps by hand. Late maps still apply to stored events, so on a small site the second choice loses little if you upload within 7 days.
A Project holds at most 200 maps, and a map stored by debug ID can be neither replaced nor deleted. The ticketing site adds 15 maps a week, so it fills the Project in about 13 weeks. After that, every upload is refused with 413 map_capacity and new builds stay minified. Upload only the maps of bundles that contain your own code, and skip vendor chunks, to make the room last.
The product page for this is Monitoring.