What you need
- A key with the
sourcemaps:writescope. The ingest key from the Setup page has only theevents:ingestscope, so it cannot upload. To create a key with other scopes, see the API keys reference. - Your project ID, and the release name that your SDK sends, for example the git commit SHA.
- The
.mapfiles of your production build, or the bundle.jsfiles that link to them.
Set the release in the SDK
Squasher finds the maps of an error by its release. Send the same release name from the SDK that you use for the upload. For example, passrelease: import.meta.env.VITE_RELEASE to init in the
Browser SDK, or let the Node.js SDK detect it. The SDK sends
the release as the service.version resource attribute.
Upload the source maps of a build
Run this in CI after the build, for each deploy:.map files, bundle .js files, and directories. For a bundle file, it reads
the sourceMappingURL comment at the end of the file and uploads that map as <bundle>.map, for
example app-3f9a.js.map for app-3f9a.js.
--service is optional. Use the same value as the service.name of your events. A map uploaded
with a service is used only for events of that service. A map uploaded without a service is used
for every service of the release.
You can also upload with the API. A request can carry more than one files field:
How Squasher finds the map of a frame
Squasher applies the maps when you read an error, not when it receives the error. A map that you upload after an error happened also applies to that error. The stored event keeps its minified frames, so the upload does not change how Squasher groups errors. For each frame, Squasher picks one map:- Debug ID. When the frame has a debug ID and a map with the same
debugIdis uploaded, that map is used. The release and the file name are then not needed. - Release and file name. Otherwise, Squasher takes the maps of the event’s release and
compares each map name without
.mapwith the end of the frame path. The scheme, host, query, and fragment of the frame URL are ignored. A map namedapp-3f9a.js.mapmatches the framehttps://example.com/assets/app-3f9a.js.
assets/app-3f9a.js.map) wins over a map that matches only the file name. When two maps match
equally, the newest upload wins.
Use debug IDs
A debug ID is a UUID that a bundler writes into each bundle file and into its map (thedebugId
field). With debug IDs, a frame finds its map even when the release is missing or the file name
changes.
- Turn on debug IDs in your bundler.
- Upload the maps. Squasher reads
debugIdfrom each map and returns it asdebug_idwhen you upload or list maps. - Use the Browser SDK. It reads the debug ID registry that the bundle code fills at runtime and sends the debug ID of each frame. The bundler must add this registry code.
Upload with sentry-cli or a Sentry bundler plugin
If your build uploads source maps to Sentry withsentry-cli or a Sentry bundler plugin
(@sentry/vite-plugin, @sentry/webpack-plugin, @sentry/rollup-plugin, @sentry/esbuild-plugin,
or withSentryConfig in Next.js), point it at Squasher. Set these variables in CI:
sentry-cli sourcemaps inject and sentry-cli sourcemaps upload work as before, and so do the
plugins. Squasher stores each map with its debug ID, so frames find their maps without a release.
The Sentry JavaScript SDK sends the debug ID of each frame.
One upload can be at most 32 MiB. For a larger build, run
sourcemaps upload once for each part
of the output folder.
Show the original source code
The lines of source around the error come from thesourcesContent field of the map. When your
bundler leaves out sourcesContent, frames still show the original file, line, and function, but
no code. The issue page shows up to 5 lines before and after the error line.
Why a frame stays minified
The issue page shows a short reason next to each frame that keeps its minified location. You can switch between the original frames and the raw frames.Resolve frames from the CLI
To check a map before an error happens, resolve frames by hand:--stack-file <file> to resolve a whole stack trace from a file. The command reads only. For
the request and response fields, see the source maps API.
List and delete uploads
The dashboard does not show source maps. Use the CLI or the API:sourcemaps:read scope. To delete one file, send DELETE to
/v1/projects/<project_id>/sourcemaps/<sourcemap_id>, or run squasher sourcemaps delete.
Keep source maps private
Source maps can contain your original source code. Upload them to Squasher, and do not deploy the.map files to your public site unless you want them to be public.
Next steps
Browser SDK
Set the release name in the browser.
Source maps API
See the request and response fields.