API update: Manage source maps
Posted Dec 1, 2024 | 4 min. (775 words)We’re thrilled to announce the latest endpoints for the Raygun API - Source maps. This new release allows developers to efficiently add or remove their sourcemaps, with increased flexibility and control over their Raygun platform.
The Raygun API now gives you multiple endpoints to manage your JavaScript source maps, making handling error tracking for your web apps easier than ever.
When you upload your source maps to Raygun Crash Reporting, we can turn otherwise cryptic stack traces into actionable insights—helping you squash bugs faster. Check out this article to learn more about why source maps are such a game-changer for software engineers.
Manually uploading source maps after every deployment is a thing of the past. With the new Raygun API endpoints, you can automate the whole process, so detailed stack traces are always ready when needed. Use Webpack? Check out our plugin, which automates source map uploads to Raygun.
In this article, we’ll cover the source map endpoints available to Raygun users in detail. The full API spec is available here.
Please note, you’ll need a Personal Access Token (PAT) and your app identifier to interact with the Raygun API. Details on both are available here.
What’s here:
Adding source maps
You can add source maps to Raygun with an HTTP PUT multipart/form-data request. For example:
curl -X PUT 'https://api.raygun.com/v3/applications/{your-application-identifier}/source-maps' \
-H 'Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@path_to_your_source_map_file.map' \
-F 'uri=your_source_map_uri'
In addition to the PAT and application identifier mentioned earlier, this request needs the file path to your source map and the URL of the minified JS file as it appears in your app (URI). Not sure where to find the URL of the minified JS file? Our source map URL guide has you covered.
If the upload is successful, the response will include details about the source map, including its unique identifier. You’ll use this identifier to manage or delete source maps with other endpoints. A typical response is as follows:
{
"identifier": "string",
"applicationIdentifier": "string",
"uri": "string",
"fileName": "string",
"fileSizeBytes": 0,
"uploadedAt": "2024-11-29T02:25:43.969Z",
"createdAt": "2024-11-29T02:25:43.969Z",
"updatedAt": "2024-11-29T02:25:43.969Z",
"isMapFile": true
}
Removing source maps
With our API, you can delete source maps individually using their identifier or clear out all source maps for an application in one go. Rolling out a new deployment? Use a single DELETE request to clean up your old source maps effortlessly.
curl -X DELETE 'https://api.raygun.com/v3/applications/{your-application-identifier}/source-maps' \
-H 'Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN'
Pushing a quick fix? By specifying its identifier, you can remove a single source map with a DELETE request.
curl -X DELETE 'https://api.raygun.com/v3/applications/{your-application-identifier}/source-maps/{source-map-identifier}' \
-H 'Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN'
Managing source maps
These three endpoints let you:
- List information about multiple source maps for an application.
- Retrieve details about a specific source map.
- Update information such as the URI of an existing source map.
To get a list of source maps for an application, send a GET request with your PAT, application identifier, and the following optional parameters:
- Count: The maximum number of items to return.
- Offset: The number of items to skip before starting the result.
- Orderby: The property to sort by.
curl -X GET 'https://api.raygun.com/v3/applications/{your-application-identifier}/source-maps?count={your-count}&offset={your-offset}&orderby={your-orderby}' \
-H 'Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN' \
-H 'accept: application/json'
This request will return a response containing a JSON payload in the following format:
[
{
"identifier": "string",
"applicationIdentifier": "string",
"uri": "string",
"fileName": "string",
"fileSizeBytes": 0,
"uploadedAt": "2024-11-29T01:56:56.538Z",
"createdAt": "2024-11-29T01:56:56.538Z",
"updatedAt": "2024-11-29T01:56:56.538Z",
"isMapFile": true
}
]
You will need its source map identifier to retrieve information about a specific source map.
curl -X GET 'https://api.raygun.com/v3/applications/{your-application-identifier}/source-maps/{source-map-identifier}' \
-H 'Authorization: Bearer YOUR_PERSONAL_ACCESS_TOKEN' \
-H 'accept: application/json'
A typical response is as follows:
{
"identifier": "string",
"applicationIdentifier": "string",
"uri": "string",
"fileName": "string",
"fileSizeBytes": 0,
"uploadedAt": "2024-11-29T01:56:56.538Z",
"createdAt": "2024-11-29T01:56:56.538Z",
"updatedAt": "2024-11-29T01:56:56.538Z",
"isMapFile": true
}
You need the source map identifier to change information about an application’s existing source map. The following example changes the URI for an existing source map.
curl -X PATCH 'https://api.raygun.com/v3/applications/{your-application-identifier}/source-maps/{source-map-identifier}' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"uri": "string"
}'
If successful, the response will contain the updated information for the source map.
{
"identifier": "string",
"applicationIdentifier": "string",
"uri": "string",
"fileName": "string",
"fileSizeBytes": 0,
"uploadedAt": "2024-11-29T01:56:56.538Z",
"createdAt": "2024-11-29T01:56:56.538Z",
"updatedAt": "2024-11-29T01:56:56.538Z",
"isMapFile": true
}
For more information, check out our source map documentation or our API specification.
Other helpful Raygun API endpoints to explore
Got an endpoint you’d like to see in the Raygun API? Submit your interest here.
See more details on the Raygun API in our documentation.
Not a Raygun customer? Try out the full Crash Reporting application free for 14 days!