Skip to content

Commit 8361005

Browse files
feat(source-maps): Add doc explaining Debug IDs (#13100)
1 parent f696627 commit 8361005

File tree

15 files changed

+114
-62
lines changed

15 files changed

+114
-62
lines changed

Diff for: docs/concepts/migration/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Below is a non-exhaustive list of some items that will not be relocated:
4848
- Issues
4949
- Events
5050
- Replays and/or other [Event Attachments](/platforms/javascript/enriching-events/attachments/)
51-
- Source Maps, [Debug Information Files](/cli/dif/) and/or [Artifact Bundles](/platforms/javascript/sourcemaps/troubleshooting_js/artifact-bundles/)
51+
- Source Maps, [Debug Information Files](/cli/dif/) and/or [Debug IDs](/platforms/javascript/sourcemaps/troubleshooting_js/debug-ids/)
5252
- Release information, including any references to external repositories via specific Pull Requests
5353
- Deployment information
5454
- Custom Avatars

Diff for: docs/platforms/javascript/common/sourcemaps/troubleshooting_js/artifact-bundles.mdx

-10
This file was deleted.
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: What are Debug IDs
3+
sidebar_order: 7
4+
---
5+
6+
This documentation provides an in-depth look at Debug IDs, explaining how they work and why Sentry recommends using them. Visit [Uploading Source Maps](https://docs.sentry.io/platforms/javascript/guides/react/sourcemaps/uploading/) if you're looking for our guides on how to upload source maps.
7+
8+
## Introduction
9+
10+
Modern web applications often use some kind of build process when using JavaScript. This build process takes some input JavaScript, transforms it in some way, then outputs JavaScript that is served alongside the website. Some example transformations include minifying JavaScript code (so the final JavaScript bundle is smaller and faster to load) or removing TypeScript types (only JavaScript can run on the browser).
11+
12+
As a result, the JavaScript code running in production is typically not the same as the code written by the developer in the source editor. Instead, it has undergone several transformations, such as minification, transpilation, downcompilation, bundling, polyfilling, and others, aimed at improving performance and ensuring cross-browser compatibility. Some common tools that transform code in such ways are Babel, Vite, Webpack, Rollup, Terser, or SWC - which are often used by higher-level tools like Next.js, Nuxt, Create React App, and similar.
13+
14+
Stack traces are essential to debug errors, but stack traces that come from generated JavaScript are often unreadable or unusable! They look nothing like the code you wrote and you can't connect them to your source code repository.
15+
16+
To ensure Sentry (and other tools) can provide stack traces that are both readable and useful, you'll want to generate and use [source maps](https://firefox-source-docs.mozilla.org/devtools-user/debugger/how_to/use_a_source_map/index.html). Source maps are additional pieces information (often stored as files) that map the transformed JavaScript back to the original code. This allows Sentry to associate the error with your original source, which means you’ll get stack traces that look like the code you wrote, not the code you generated.
17+
18+
To connect source maps to a JavaScript file, we relied on filenames, but these often were unreliable. For example, when you changed the subpath of where your javascript files are served it would mean that the filenames no longer match and the corresponding sourcemap would not be able to be found by Sentry.
19+
20+
`//# source mappingURL=http://example.com/path/to/your/source-map.js.map`
21+
22+
Given the url-based filename approach was unreliable, we came up with [Debug IDs](/platforms/javascript/sourcemaps/debug-ids#what-are-debug-ids).
23+
24+
## What are Debug IDs
25+
26+
Inspired by approaches in native language ecosystems, Debug IDs are globally unique ids that identify a transformed JavaScript file and its associated source map.
27+
28+
![Debug IDs example](./img/debug-ids.png)
29+
30+
When using sentry-cli or Sentry plugins for Webpack, Vite, or Rollup, Debug IDs are deterministically generated based on the source file contents. Note that deterministic Debug IDs for esbuild are not currently supported.
31+
32+
This approach is Sentry's recommended and most reliable method for associating minified JavaScript files with their original source code, making it easier to trace errors back to their source. Because debug IDs will generally change across releasess if the file content is changed **creating a release is no longer required**. Release names were previously used to disambiguate sourcemaps with the same name across deployments.
33+
34+
<Alert>
35+
36+
If you want to learn more about the rationale behind Debug IDs, we suggest taking a look at our [engineering blog](https://sentry.engineering/blog/the-case-for-debug-ids).
37+
38+
</Alert>
39+
40+
## How Sentry uses Debug IDs
41+
42+
<PlatformSection notSupported={["javascript.nextjs"]}>
43+
To use Debug IDs, ensure that you're using **Sentry's SDK version 7.47 or higher**. Once you're on a supported version, follow the steps outlined below:
44+
</PlatformSection>
45+
<PlatformSection supported={["javascript.nextjs"]}>
46+
For Debug IDs with Next.js, you’ll need **Sentry's SDK version 8.0.0 or higher**. Once you're on a supported version, follow the steps outlined below:
47+
</PlatformSection>
48+
49+
50+
1. **A globally unique Debug ID is generated**: During the build process, if you are using one of Sentry's Bundler Plugins or Sentry CLI a Debug ID is generated, which is globally unique and ideally deterministic.
51+
52+
2. **Debug IDs are embedded in minified files**: Each minified JavaScript file includes a special comment, such as `//# debugId=DEBUG_ID`, where `DEBUG_ID` is the unique identifier generated in the previous step.
53+
54+
3. **The same Debug ID is added to source maps**: Source maps also include the same Debug ID as a new attribute, linking the minified JavaScript file to its corresponding source map.
55+
56+
4. **Stack traces in Sentry link the Debug ID**: When an error occurs, Sentry's event contains the Debug ID, which allows Sentry to automatically link the error to the correct source map. This ensures the stack trace is resolved back to the original source code, providing you with clearer and more accurate debugging information—even if the JavaScript has been minified or transformed.
57+
58+
### Why use Debug IDs to uniminify your code?
59+
60+
Unminifying your code is essential for effective debugging. While there are other [legacy ways](https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js/legacy-uploading-methods/) to achieve this at Sentry, using **Debug IDs are recommended by Sentry** as it is the most reliable method. By unminifying your code, you get much clearer stack traces when errors occur. Instead of seeing obfuscated code, you'll see the exact code you originally wrote, making it far easier to understand and resolve issues. Below are examples that demonstrates the difference:
61+
62+
#### Bad Stack Trace
63+
![bad stack trace example](./img/bad-stack-trace.png)
64+
65+
#### Good Stack Trace
66+
![good stack trace example](./img/good-stack-trace.png)
67+
68+
## Retention Policy
69+
70+
Artifacts including Debug IDs have a retention period of _90 days_, using a _time to idle_ expiration mechanism.
71+
This means that uploaded Debug IDs are retained for as long as they are actively being used for event processing.
72+
Once an ID has not been used to process incoming events for at least 90 days, it will automatically expire and be eligible for deletion.
73+
74+
## Associating a Release with Debug IDs
75+
76+
Since you might still want to know to which release an specific Debug ID is connected to, we designed a new way to still associate a `release` to your bundle.
77+
78+
The new Debug ID format supports a new kind of association to a `release` and optionally `dist`, known as weak release association. This type of association **will not require the creation of a `release`** before uploading source maps and will consequently allow the creation of a `release` as a separate step down the pipeline.
79+
80+
With an associated `release` and optionally `dist` you will be able to quickly go to the Debug ID from your `release` in Sentry, without having to worry about which Debug ID was used for your errors.

Diff for: docs/platforms/javascript/common/sourcemaps/uploading/create-react-app.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
6464
### 3. Inject Debug IDs Into Build Artifacts
6565

6666
Debug IDs are used to match the stack frame of an event with its corresponding minified source and source map file.
67-
Visit [What are Artifact Bundles](/platforms/javascript/sourcemaps/troubleshooting_js/artifact-bundles/) if you want to learn more about Artifact Bundles and Debug IDs.
67+
Visit [What are Debug IDs](/platforms/javascript/sourcemaps/troubleshooting_js/debug-ids/) if you want to learn more about Debug IDs.
6868

6969
To inject Debug IDs, use the following command **every time after building your application**:
7070

Diff for: docs/product/releases/setup/release-automation/github-actions/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ If your application is written in JavaScript you probably deploy minified applic
5656
stack traces in your Sentry errors, you need to upload source maps to Sentry.
5757
5858
Provide the path(s) to your source maps via the `sourcemaps` option to ensure proper un-minification of your stack traces.
59-
Visit [What are Artifact Bundles](/platforms/javascript/sourcemaps/troubleshooting_js/artifact-bundles/) if you want to learn more.
59+
Visit [What are Debug IDs](/platforms/javascript/sourcemaps/troubleshooting_js/debug-ids/) if you want to learn more.
6060

6161
```yml
6262
- uses: actions/checkout@v4

Diff for: includes/sentry-cli-sourcemaps.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
2020

2121
### 3. Inject Debug IDs Into Artifacts
2222

23-
Debug IDs are used to match the stack frame of an event with its corresponding minified source and source map file. Visit [What are Artifact Bundles](/platforms/javascript/sourcemaps/troubleshooting_js/artifact-bundles/) if you want to learn more about Artifact Bundles and Debug IDs.
23+
Debug IDs are used to match the stack frame of an event with its corresponding minified source and source map file. Visit [What are Debug IDs](/platforms/javascript/sourcemaps/troubleshooting_js/debug-ids/) if you want to learn more about Debug IDs.
2424

2525
To inject Debug IDs, use the following command:
2626

Diff for: platform-includes/migration/javascript-v8/important-changes/javascript.sveltekit.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ We now support the following integrations out of the box with 0 configuration:
3636

3737
### Breaking `sentrySvelteKit()` changes
3838

39-
Under the hood, the SvelteKit SDK uses [Sentry Vite Plugin](https://www.npmjs.com/package/@sentry/vite-plugin) to upload sourcemaps and automatically associate add releases to your events. In `8.x`, the SDK now uses `2.x` of the Sentry Vite Plugin which brings many improvements and bug fixes. Sourcemaps uploading with the SvelteKit SDK now uses <Link to="/platforms/javascript/sourcemaps/troubleshooting_js/artifact-bundles/">Debug IDs</Link>.
39+
Under the hood, the SvelteKit SDK uses [Sentry Vite Plugin](https://www.npmjs.com/package/@sentry/vite-plugin) to upload sourcemaps and automatically associate add releases to your events. In `8.x`, the SDK now uses `2.x` of the Sentry Vite Plugin which brings many improvements and bug fixes. Sourcemaps uploading with the SvelteKit SDK now uses <Link to="/platforms/javascript/sourcemaps/troubleshooting_js/debug-ids/">Debug IDs</Link>.
4040

4141
To allow future upgrades of the Vite plugin without breaking stable and public APIs in `sentrySvelteKit`, we modified the `sourceMapsUploadOptions` to remove the hard dependency on the API of the plugin. While you previously could specify all [version 0.x Vite plugin options](https://www.npmjs.com/package/@sentry/vite-plugin/v/0.6.1), we now reduced them to a subset of [2.x options](https://www.npmjs.com/package/@sentry/vite-plugin/v/2.14.2#options).
4242

Diff for: platform-includes/migration/javascript-v8/other-changes/javascript.nextjs.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Improved Source Map Uploading
22

3-
Under the hood, the Next.js SDK uses [Sentry Webpack Plugin](https://www.npmjs.com/package/@sentry/webpack-plugin) to upload sourcemaps and automatically associate add releases to your events. In `8.x`, the SDK now uses `2.x` of the Sentry Webpack Plugin which brings many improvements and bug fixes. Sourcemaps uploading with the Next.js SDK now uses <Link to="/platforms/javascript/sourcemaps/troubleshooting_js/artifact-bundles/">Debug IDs</Link>.
3+
Under the hood, the Next.js SDK uses [Sentry Webpack Plugin](https://www.npmjs.com/package/@sentry/webpack-plugin) to upload sourcemaps and automatically associate add releases to your events. In `8.x`, the SDK now uses `2.x` of the Sentry Webpack Plugin which brings many improvements and bug fixes. Sourcemaps uploading with the Next.js SDK now uses <Link to="/platforms/javascript/sourcemaps/troubleshooting_js/debug-ids/">Debug IDs</Link>.
44

55
### Removal of deprecated API
66

Binary file not shown.

Diff for: platform-includes/sourcemaps/artifact-bundles/javascript.mdx

-36
This file was deleted.
-54.7 KB
Binary file not shown.

Diff for: redirects.js

+28-10
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,16 @@ const userDocsRedirects = [
585585
'/platforms/:platform/guides/:guide/sourcemaps/:section(generating|validating|best-practices|artifact-and-release-bundles)/',
586586
destination: '/platforms/:platform/guides/:guide/sourcemaps/',
587587
},
588+
{
589+
source: '/platforms/javascript/sourcemaps/troubleshooting_js/artifact-bundles/',
590+
destination: '/platforms/javascript/sourcemaps/troubleshooting_js/debug-ids/',
591+
},
592+
{
593+
source:
594+
'/platforms/:platform/guides/:guide/sourcemaps/troubleshooting_js/artifact-bundles/',
595+
destination:
596+
'/platforms/:platform/guides/:guide/sourcemaps/troubleshooting_js/debug-ids/',
597+
},
588598
{
589599
source: '/platforms/minidump/crashpad/:path*',
590600
destination: '/platforms/native/guides/crashpad/:path*',
@@ -997,7 +1007,7 @@ const userDocsRedirects = [
9971007
source: '/platforms/php/:productfeature/troubleshooting/:path*',
9981008
destination: '/platforms/php/troubleshooting/:path*',
9991009
},
1000-
{
1010+
{
10011011
source: '/product/explore/feature-flags/:path*',
10021012
destination: '/product/issues/issue-details/feature-flags/:path*',
10031013
},
@@ -1009,14 +1019,16 @@ const userDocsRedirects = [
10091019
source: '/product/tracing/:path*',
10101020
destination: '/concepts/key-terms/tracing/:path*',
10111021
},
1012-
// Redirects for JavaScript tracing docs
1022+
// Redirects for JavaScript tracing docs
10131023
{
10141024
source: '/platforms/javascript/tracing/trace-propagation/:path*',
10151025
destination: '/platforms/javascript/tracing/distributed-tracing/:path*',
10161026
},
10171027
{
1018-
source: '/platforms/javascript/guides/:guide/tracing/instrumentation/performance-metrics/',
1019-
destination: '/platforms/javascript/guides/:guide/tracing/span-metrics/performance-metrics/',
1028+
source:
1029+
'/platforms/javascript/guides/:guide/tracing/instrumentation/performance-metrics/',
1030+
destination:
1031+
'/platforms/javascript/guides/:guide/tracing/span-metrics/performance-metrics/',
10201032
},
10211033
{
10221034
source: '/platforms/javascript/guides/:guide/tracing/trace-propagation/:path*',
@@ -1027,7 +1039,8 @@ const userDocsRedirects = [
10271039
destination: '/platforms/javascript/tracing/instrumentation/:path*',
10281040
},
10291041
{
1030-
source: '/platforms/javascript/guides/:guide/tracing/instrumentation/custom-instrumentation/:path*',
1042+
source:
1043+
'/platforms/javascript/guides/:guide/tracing/instrumentation/custom-instrumentation/:path*',
10311044
destination: '/platforms/javascript/guides/:guide/tracing/instrumentation/:path*',
10321045
},
10331046
{
@@ -1040,22 +1053,27 @@ const userDocsRedirects = [
10401053
},
10411054
{
10421055
source: '/platforms/dart/guides/flutter/upload-debug/#when-to-upload',
1043-
destination: '/platforms/dart/guides/flutter/debug-symbols/#when-to-upload-debug-symbols',
1056+
destination:
1057+
'/platforms/dart/guides/flutter/debug-symbols/#when-to-upload-debug-symbols',
10441058
},
10451059
{
10461060
source: '/platforms/dart/guides/flutter/upload-debug/#source-context',
1047-
destination: '/platforms/dart/guides/flutter/debug-symbols/dart-plugin/#configuration',
1061+
destination:
1062+
'/platforms/dart/guides/flutter/debug-symbols/dart-plugin/#configuration',
10481063
},
10491064
{
1050-
source: '/platforms/dart/guides/flutter/upload-debug/#uploading-source-code-context-for-flutter-android-ios-and-macos',
1065+
source:
1066+
'/platforms/dart/guides/flutter/upload-debug/#uploading-source-code-context-for-flutter-android-ios-and-macos',
10511067
destination: '/platforms/dart/guides/flutter/debug-symbols/manual-upload/',
10521068
},
10531069
{
10541070
source: '/platforms/dart/guides/flutter/upload-debug/#uploading-for-android-ndk',
1055-
destination: '/platforms/dart/guides/flutter/debug-symbols/manual-upload/#android-ndk',
1071+
destination:
1072+
'/platforms/dart/guides/flutter/debug-symbols/manual-upload/#android-ndk',
10561073
},
10571074
{
1058-
source: '/platforms/dart/guides/flutter/upload-debug/#automatically-upload-debug-symbols',
1075+
source:
1076+
'/platforms/dart/guides/flutter/upload-debug/#automatically-upload-debug-symbols',
10591077
destination: '/dart/guides/flutter/debug-symbols/dart-plugin/',
10601078
},
10611079
{

0 commit comments

Comments
 (0)