diff --git a/src/includes/sourcemaps-create-react-app.mdx b/src/includes/sourcemaps-create-react-app.mdx new file mode 100644 index 0000000000000..d913485112bd0 --- /dev/null +++ b/src/includes/sourcemaps-create-react-app.mdx @@ -0,0 +1,114 @@ + + +## Automatic Setup + +The easiest way to configure uploading source maps with Sentry CLI is by using the Sentry Wizard: + + + +If you want to configure source maps upload with the CLI manually instead, follow the steps below. + +## Manual Setup + +### 1. Generate Source Maps + +Verify that you are generating source maps when building your React app. +This should already be the case, unless you set the `GENERATE_SOURCEMAPS` environment variable to "false". + +**Make sure to run a production build.** +In the next steps we will modify and upload the artifacts that were generated during the build. +Running a development build will not emit the necessary files. + +### 2. Configure Sentry CLI + +Install Sentry CLI as a dev-dependency with the package manager of your choice: + +```bash {tabTitle:npm} +npm install @sentry/cli --save-dev +``` + +```bash {tabTitle:Yarn} +yarn add @sentry/cli --dev +``` + +```bash {tabTitle:pnpm} +pnpm add @sentry/cli --save-dev +``` + + + +For more info on `sentry-cli` configuration visit the [Sentry CLI configuration docs](/product/cli/configuration/). + + + +Make sure `sentry-cli` is configured for your project. For that you can use environment variables: + + + + + +```bash {filename:.env} +SENTRY_ORG=___ORG_SLUG___ +SENTRY_PROJECT=___PROJECT_SLUG___ +# Auth tokens can be obtained from +# https://sentry.io/settings/auth-tokens/ +SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___ +``` + +### 3. Inject Debug IDs Into Build Artifacts + +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. + +To inject Debug IDs, use the following command **every time after building your application**: + +```bash +sentry-cli sourcemaps inject /path/to/build +``` + +Make sure to replace `/path/to/build` with the actual path where your build output is generated. +In a Create React App application, this is usually the `build` folder. + +#### Verify Debug IDs Were Injected Into Build Artifacts + +After running the `sentry-cli sourcemaps inject` command, minified source files should contain a `debugId` comment at the end: + +```javascript {filename:exampleMinifiedFile.js} +... +//# debugId= +//# sourceMappingURL= +``` + +Source maps should now contain a field named `debug_id`: + +```json {filename:exampleSourceMap.js.map} +{ + ... + "debug_id":"", + ... +} +``` + +### 4. Upload Artifacts + +After you've injected Debug IDs into your artifacts, upload them using the following command: + +```bash +sentry-cli sourcemaps upload /path/to/build +``` + +#### Verify That Artifact Bundles Were Uploaded + +Open up Sentry and navigate to **Project Settings > Source Maps**. +If you choose “Artifact Bundles” in the tabbed navigation, you'll see all the artifact bundles that have been successfully uploaded to Sentry. + +### 5. Deploy Your Application + +If you're following this guide from your local machine, then you've successfully: + +1. Generated minified source and source map files (artifacts) by running your application's build process +2. Injected Debug IDs into the artifacts you've just generated +3. Uploaded those artifacts to Sentry with our upload command + +The last step is deploying a new version of your application using the generated artifacts you created in step one. +**We strongly recommend running everything you've configured above inside your CI/CD pipeline** to ensure each subsequent deploy will have readable stack traces in Sentry error events. diff --git a/src/platform-includes/sourcemaps/overview/javascript.mdx b/src/platform-includes/sourcemaps/overview/javascript.mdx index 9206914e130f1..7647f6f938efb 100644 --- a/src/platform-includes/sourcemaps/overview/javascript.mdx +++ b/src/platform-includes/sourcemaps/overview/javascript.mdx @@ -6,6 +6,14 @@ The easiest way to configure uploading source maps is by using the Sentry Wizard If you want to configure source maps upload manually, follow the guide for your bundler or build tool below. + + +### Create React App + +If you used Create React App to set up your React application see our Create React App guide to upload source maps. + + + ### Sentry Bundler Support - Webpack diff --git a/src/platform-includes/sourcemaps/upload/create-react-app/javascript.mdx b/src/platform-includes/sourcemaps/upload/create-react-app/javascript.mdx new file mode 100644 index 0000000000000..170bf1ba301fa --- /dev/null +++ b/src/platform-includes/sourcemaps/upload/create-react-app/javascript.mdx @@ -0,0 +1,3 @@ +In this guide, you'll learn how to upload source maps for Create React App using our `sentry-cli` tool. + + diff --git a/src/platforms/javascript/common/sourcemaps/uploading/cli.mdx b/src/platforms/javascript/common/sourcemaps/uploading/cli.mdx index bb9c8d3177e47..dc6178b308579 100644 --- a/src/platforms/javascript/common/sourcemaps/uploading/cli.mdx +++ b/src/platforms/javascript/common/sourcemaps/uploading/cli.mdx @@ -1,7 +1,7 @@ --- title: Sentry CLI description: "Upload your source maps using Sentry CLI." -sidebar_order: 8 +sidebar_order: 6 --- diff --git a/src/platforms/javascript/common/sourcemaps/uploading/create-react-app.mdx b/src/platforms/javascript/common/sourcemaps/uploading/create-react-app.mdx new file mode 100644 index 0000000000000..e6d367f406efc --- /dev/null +++ b/src/platforms/javascript/common/sourcemaps/uploading/create-react-app.mdx @@ -0,0 +1,9 @@ +--- +title: Create React App +description: "Upload source maps using Create React App and Sentry CLI." +sidebar_order: 7 +supported: + - javascript.react +--- + + diff --git a/src/platforms/javascript/common/sourcemaps/uploading/esbuild.mdx b/src/platforms/javascript/common/sourcemaps/uploading/esbuild.mdx index 07f571cbba217..cb1c3595d9807 100644 --- a/src/platforms/javascript/common/sourcemaps/uploading/esbuild.mdx +++ b/src/platforms/javascript/common/sourcemaps/uploading/esbuild.mdx @@ -1,7 +1,7 @@ --- title: esbuild description: "Upload your source maps with the Sentry esbuild Plugin." -sidebar_order: 5 +sidebar_order: 4 --- diff --git a/src/platforms/javascript/common/sourcemaps/uploading/hosting-publicly.mdx b/src/platforms/javascript/common/sourcemaps/uploading/hosting-publicly.mdx index f06006441a4c3..028a1df614efd 100644 --- a/src/platforms/javascript/common/sourcemaps/uploading/hosting-publicly.mdx +++ b/src/platforms/javascript/common/sourcemaps/uploading/hosting-publicly.mdx @@ -3,7 +3,7 @@ title: Hosting Publicly description: "Learn about publicly hosting your source maps, including how to address various security concerns." redirect_from: - /platforms/javascript/sourcemaps/hosting-publicly/ -sidebar_order: 9 +sidebar_order: 10 --- diff --git a/src/platforms/javascript/common/sourcemaps/uploading/rollup.mdx b/src/platforms/javascript/common/sourcemaps/uploading/rollup.mdx index 3c58467e10f79..92942b8208923 100644 --- a/src/platforms/javascript/common/sourcemaps/uploading/rollup.mdx +++ b/src/platforms/javascript/common/sourcemaps/uploading/rollup.mdx @@ -1,7 +1,7 @@ --- title: Rollup description: "Upload your source maps with the Sentry Rollup Plugin." -sidebar_order: 3 +sidebar_order: 5 --- diff --git a/src/platforms/javascript/common/sourcemaps/uploading/systemjs.mdx b/src/platforms/javascript/common/sourcemaps/uploading/systemjs.mdx index af3606157fe5e..8f3d142cd87b8 100644 --- a/src/platforms/javascript/common/sourcemaps/uploading/systemjs.mdx +++ b/src/platforms/javascript/common/sourcemaps/uploading/systemjs.mdx @@ -1,7 +1,7 @@ --- title: SystemJS description: "Upload your source maps using SystemJS and Sentry CLI." -sidebar_order: 7 +sidebar_order: 9 notSupported: - javascript.svelte - javascript.sveltekit diff --git a/src/platforms/javascript/common/sourcemaps/uploading/uglifyjs.mdx b/src/platforms/javascript/common/sourcemaps/uploading/uglifyjs.mdx index f61aa8bf45bfe..99b91d2c4d162 100644 --- a/src/platforms/javascript/common/sourcemaps/uploading/uglifyjs.mdx +++ b/src/platforms/javascript/common/sourcemaps/uploading/uglifyjs.mdx @@ -1,7 +1,7 @@ --- title: UglifyJS description: "Upload your source maps using UglifyJS and Sentry CLI." -sidebar_order: 6 +sidebar_order: 8 notSupported: - javascript.svelte - javascript.vue diff --git a/src/platforms/javascript/common/sourcemaps/uploading/vite.mdx b/src/platforms/javascript/common/sourcemaps/uploading/vite.mdx index bda4bc392215f..47ea43e6bcc72 100644 --- a/src/platforms/javascript/common/sourcemaps/uploading/vite.mdx +++ b/src/platforms/javascript/common/sourcemaps/uploading/vite.mdx @@ -1,7 +1,7 @@ --- title: Vite description: "Upload your source maps with the Sentry Vite Plugin." -sidebar_order: 4 +sidebar_order: 3 ---