Skip to content

Use org auth token in JS and Sentry CLI docs #7714

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 1, 2023
4 changes: 2 additions & 2 deletions src/docs/product/cli/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ By default, `sentry-cli` will connect to sentry.io, but for self-hosted you can
sentry-cli --url https://myserver.invalid/ login
```

## To authenticate manually:
## To Authenticate Manually:

Visit your [auth token user settings page](https://sentry.io/settings/account/api/auth-tokens/) and create or copy an existing token. Then either:
Visit the [Organization Auth Token Settings](https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/) and create a new token. Then either:

- add it to `~/.sentryclirc`:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,25 @@ The Sentry webpack plugin can automatically configure release information and se

1. Go back to your `frontend-tutorial` project and stop it with `Ctrl + C`.

1. Create a sentry auth token:

<OrgAuthTokenNote />

```bash {filename:.env}
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

You'll need to pass your auth token to your build command later on. We recommend storing it inside an environment variable. Auth tokens should always stay secret, so avoid storing yours inside your version control.

1. To start associating commits and releases, add the following lines of code to `webpack.config.js` in your Sentry webpack plugin config:

```javascript {filename:webpack.config.js}
sentryWebpackPlugin({
org: "<your_org>",
project: "<your_project>",

// Auth tokens can be obtained by creating an internal integration
// at https://<organiaztion_id>.sentry.io/settings/developer-settings/
// and need "Release: Admin" and "Organization: Read & Write" permissions
// Auth tokens can be obtained from
// https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/
authToken: process.env.SENTRY_AUTH_TOKEN,

// Enable automatically creating releases and associating commits
Expand Down
10 changes: 2 additions & 8 deletions src/includes/sentry-cli-sourcemaps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ For more info on `sentry-cli` configuration visit the [Sentry CLI configuration

Make sure `sentry-cli` is configured for your project. For that you can use environment variables:

<Note>

Visit the [auth token user settings page](https://sentry.io/settings/account/api/auth-tokens/) to find your auth tokens.

</Note>

<SignInNote />
<OrgAuthTokenNote />

```bash {filename:.env.local}
SENTRY_AUTH_TOKEN=your-auth-token
SENTRY_ORG=___ORG_SLUG___
SENTRY_PROJECT=___PROJECT_SLUG___
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

### 3. Inject Debug IDs Into Artifacts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ module.exports = {
// Specify the directory containing build artifacts
include: "./dist",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and needs the `project:releases` and `org:read` scopes
// Auth tokens can be obtained from
// https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/
authToken: process.env.SENTRY_AUTH_TOKEN,

// Optionally uncomment the line below to override automatic release name detection
Expand Down Expand Up @@ -129,7 +129,7 @@ module.exports = {
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// Auth tokens can be obtained from your User Settings
// and need `project:releases` and `org:read` scopes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the reason we are not replacing this with org tokens here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the legacy docs. People here may use a self hosted version that is not yet compatible with org auth tokens.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, makes sense! 👍

authToken: process.env.SENTRY_AUTH_TOKEN,

Expand Down Expand Up @@ -159,8 +159,8 @@ export default defineConfig({
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
// Auth tokens can be obtained from your User Settings
// and need `project:releases` and `org:read` scopes
authToken: process.env.SENTRY_AUTH_TOKEN,

release: {
Expand All @@ -186,7 +186,7 @@ require("esbuild").build({
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// Auth tokens can be obtained from your User Settings
// and need `project:releases` and `org:read` scopes
authToken: process.env.SENTRY_AUTH_TOKEN,

Expand All @@ -211,7 +211,7 @@ export default {
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// Auth tokens can be obtained from your User Settings
// and need `project:releases` and `org:read` scopes
authToken: process.env.SENTRY_AUTH_TOKEN,

Expand Down
16 changes: 5 additions & 11 deletions src/platform-includes/sourcemaps/overview/javascript.remix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,21 @@ Under the hood, it uses the Sentry CLI.

This script requires some configuration, which can either be done through a `.sentryclirc` file in the root of your project or through environment variables:

<Note>

Visit the [auth token user settings page](https://sentry.io/settings/account/api/auth-tokens/) to find your auth tokens.

</Note>

<SignInNote />
<OrgAuthTokenNote />

```ini {filename:.sentryclirc}
[auth]
token=your-auth-token

[defaults]
org=___ORG_SLUG___
project=___PROJECT_SLUG___

[auth]
token=___ORG_AUTH_TOKEN___
```

```bash
export SENTRY_AUTH_TOKEN=your-auth-token
export SENTRY_ORG=___ORG_SLUG___
export SENTRY_PROJECT=___PROJECT_SLUG___
export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

Next, run the upload script with the following command:
Expand Down
14 changes: 12 additions & 2 deletions src/platform-includes/sourcemaps/overview/javascript.svelte.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ npm install @sentry/vite-plugin --save-dev
yarn add @sentry/vite-plugin --dev
```

To upload source maps you have to configure an auth token.
Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a `SENTRY_AUTH_TOKEN` environment variable, or with a `.env.sentry-build-plugin` file in the working directory when building your project.
You likely want to add the auth token as an environment variable to your CI/CD environment.

<OrgAuthTokenNote />

```bash {filename:.env.sentry-build-plugin}
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

Configure Vite to emit source maps and use the Sentry Vite plugin:

<SignInNote />
Expand All @@ -66,8 +76,8 @@ export default defineConfig({
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
// Auth tokens can be obtained from
// https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
Expand Down
14 changes: 12 additions & 2 deletions src/platform-includes/sourcemaps/overview/javascript.vue.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ yarn add @sentry/vite-plugin --dev

Learn more about configuring the plugin in our [Sentry Vite Plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).

To upload source maps you have to configure an auth token.
Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a `SENTRY_AUTH_TOKEN` environment variable, or with a `.env.sentry-build-plugin` file in the working directory when building your project.
You likely want to add the auth token as an environment variable to your CI/CD environment.

<OrgAuthTokenNote />

```bash {filename:.env.sentry-build-plugin}
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

Example:

<SignInNote />
Expand All @@ -47,8 +57,8 @@ export default defineConfig({
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
// Auth tokens can be obtained from
// https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
Expand Down
14 changes: 12 additions & 2 deletions src/platform-includes/sourcemaps/upload/esbuild/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ yarn add @sentry/esbuild-plugin --dev

### Configure

To upload source maps you have to configure an auth token.
Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a `SENTRY_AUTH_TOKEN` environment variable, or with an `.env.sentry-build-plugin` file in the working directory when building your project.
We recommend you add the auth token to your CI/CD environment as an environment variable.

Learn more about configuring the plugin in our [Sentry esbuild Plugin documentation](https://www.npmjs.com/package/@sentry/esbuild-plugin).

<OrgAuthTokenNote />

```bash {filename:.env.sentry-build-plugin}
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

Example:

<SignInNote />
Expand All @@ -47,8 +57,8 @@ require("esbuild").build({
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
// Auth tokens can be obtained from
// https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
Expand Down
14 changes: 12 additions & 2 deletions src/platform-includes/sourcemaps/upload/rollup/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ yarn add @sentry/rollup-plugin --dev

### Configuration

To upload source maps you have to configure an auth token.
Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a `SENTRY_AUTH_TOKEN` environment variable, or with an `.env.sentry-build-plugin` file in the working directory when building your project.
We recommend you add the auth token to your CI/CD environment as an environment variable.

Learn more about configuring the plugin in our [Sentry Rollup Plugin documentation](https://www.npmjs.com/package/@sentry/rollup-plugin).

<OrgAuthTokenNote />

```bash {filename:.env.sentry-build-plugin}
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

Example:

<SignInNote />
Expand All @@ -49,8 +59,8 @@ export default {
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
// Auth tokens can be obtained from
// https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
Expand Down
14 changes: 12 additions & 2 deletions src/platform-includes/sourcemaps/upload/vite/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ yarn add @sentry/vite-plugin --dev

### Configuration

To upload source maps you have to configure an auth token.
Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a `SENTRY_AUTH_TOKEN` environment variable, or with an `.env.sentry-build-plugin` file in the working directory when building your project.
We recommend you add the auth token to your CI/CD environment as an environment variable.

Learn more about configuring the plugin in our [Sentry Vite Plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).

<OrgAuthTokenNote />

```bash {filename:.env.sentry-build-plugin}
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

Example:

<SignInNote />
Expand All @@ -50,8 +60,8 @@ export default defineConfig({
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
// Auth tokens can be obtained from
// https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
Expand Down
25 changes: 13 additions & 12 deletions src/platform-includes/sourcemaps/upload/webpack/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ yarn add @sentry/webpack-plugin --dev

### Configuration

Learn more about configuring the plugin in our [Sentry webpack plugin documentation](https://www.npmjs.com/package/@sentry/webpack-plugin).

<PlatformSection notSupported={["javascript.gatsby"]}>
To upload source maps you have to configure an auth token.
Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a `SENTRY_AUTH_TOKEN` environment variable, or with an `.env.sentry-build-plugin` file in the working directory when building your project.
We recommend you add the auth token to your CI/CD environment as an environment variable.

You'll have to setup your environment variables first. In most cases, you'll either want to add the env. variables to a `.env` file (e.g. when deploying locally), or you'll have to add them to your CI/CD environment.
Learn more about configuring the plugin in our [Sentry webpack plugin documentation](https://www.npmjs.com/package/@sentry/webpack-plugin).

<OrgAuthTokenNote />

```bash {filename:.env}
SENTRY_ORG=___ORG_SLUG___
SENTRY_PROJECT=___PROJECT_SLUG___
```bash {filename:.env.sentry-build-plugin}
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

<PlatformSection notSupported={["javascript.gatsby"]}>

<SignInNote />

And the following webpack config:

```javascript {filename:webpack.config.js}
Expand All @@ -55,8 +57,8 @@ module.exports = {
devtool: "source-map", // Source map generation must be turned on
plugins: [
sentryWebpackPlugin({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
Expand All @@ -67,6 +69,8 @@ module.exports = {

<PlatformSection supported={["javascript.gatsby"]}>

Add the following to your `gatsby-node.js` file:

<SignInNote />

```javascript {filename:gatsby-node.js}
Expand All @@ -78,9 +82,6 @@ exports.onCreateWebpackConfig = ({ actions }) => {
sentryWebpackPlugin({
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ If you are on an older version and you want to upload source maps we recommend u

</Note>

To upload source maps you have to configure an auth token.
Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a `SENTRY_AUTH_TOKEN` environment variable, or with an `.env.sentry-build-plugin` file in the working directory when building your project.
We recommend you add the auth token to your CI/CD environment as an environment variable.

<OrgAuthTokenNote />

```bash {filename:.env.sentry-build-plugin}
SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___
```

Register the Sentry webpack plugin in your `webpack.config.js`:

<SignInNote />
Expand All @@ -76,8 +86,8 @@ module.exports = {
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need the `project:releases` and `org:read` scopes
// Auth tokens can be obtained from
// https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/
authToken: process.env.SENTRY_AUTH_TOKEN,
}),
],
Expand Down
Loading