Skip to content

Commit 6a7106b

Browse files
authored
Merge branch 'canary' into feature/incremental-typechecking
2 parents 1ae9c69 + cee1565 commit 6a7106b

File tree

5 files changed

+46
-34
lines changed

5 files changed

+46
-34
lines changed

examples/with-sentry/README.md

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Sentry
22

3-
This is an example showing how to use [Sentry](https://sentry.io) to catch & report errors on both client + server side, using the [official Sentry SDK for Next.js](https://docs.sentry.io/platforms/javascript/guides/nextjs/).
3+
This is an example showing how to use [Sentry](https://sentry.io) to catch and report errors on both the front and back ends, using the [official Sentry SDK for Next.js](https://docs.sentry.io/platforms/javascript/guides/nextjs/).
44

5-
- `_app.js` renders on both the server and client
6-
- `_error.js` is rendered by Next.js while handling certain types of exceptions for you. It is overridden so those exceptions can be passed along to Sentry
5+
- `sentry.server.config.js` and `sentry.client.config.js` are used to configure and initialize Sentry
6+
- `next.config.js` automatically injects Sentry into your app using `withSentryConfig`
7+
- `_error.js` (which is rendered by Next.js when handling certain types of exceptions) is overridden so those exceptions can be passed along to Sentry
78
- Each API route is handled with `withSentry`
8-
- `next.config.js` automatically configures the app to use Sentry through `withSentry`
99

1010
## Preview
1111

@@ -15,43 +15,60 @@ Preview the example live on [StackBlitz](http://stackblitz.com/):
1515

1616
## Deploy your own
1717

18-
Once you have access to your [Sentry DSN](https://docs.sentry.io/product/sentry-basics/dsn-explainer/#where-to-find-your-dsn), deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
18+
It only takes a few steps to create and deploy your own version of this example app. Before you begin, make sure you have [linked your Vercel account to GitHub](https://vercel.com/docs/personal-accounts/login-connections), and [set up a project in Sentry](https://docs.sentry.io/product/sentry-basics/guides/integrate-frontend/create-new-project/).
1919

20-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-sentry&project-name=with-sentry&repository-name=with-sentry&env=NEXT_PUBLIC_SENTRY_DSN&envDescription=DSN%20Key%20required%20by%20Sentry&envLink=https://github.com/vercel/next.js/tree/canary/examples/with-sentry%23step-1-enable-error-tracking)
20+
### Option 1: Deploy directly to Vercel
2121

22-
Check out [Sentry’s Vercel Integration](#sentry-integration).
22+
You can deploy a copy of this project directly to [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example).
2323

24-
## How To Use
24+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-sentry&project-name=nextjs-sentry-example&repository-name=nextjs-sentry-example&env=NEXT_PUBLIC_SENTRY_DSN&envDescription=DSN%20Key%20required%20by%20Sentry&envLink=https://github.com/vercel/next.js/tree/canary/examples/with-sentry%23step-1-enable-error-tracking)
2525

26-
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
26+
This will clone this example to your GitHub org, create a linked project in Vercel, and prompt you to install the Vercel Sentry Integration. (You can read more about the integration [on Vercel](https://vercel.com/integrations/sentry) and in [the Sentry docs](https://docs.sentry.io/product/integrations/deployment/vercel/).)
27+
28+
### Option 2: Create locally before deploying
29+
30+
Alternatively, you can create a copy of ths example app locally so you can configure and customize it before you deploy it.
31+
32+
#### Create and configure your app
33+
34+
To begin, execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npx](https://www.npmjs.com/package/npx) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), to create the app and install dependencies:
2735

2836
```bash
29-
npx create-next-app --example with-sentry with-sentry-app
37+
npx create-next-app --example with-sentry nextjs-sentry-example
3038
# or
31-
yarn create next-app --example with-sentry with-sentry-app
39+
yarn create next-app --example with-sentry nextjs-sentry-example
3240
```
3341

34-
## Configuration
42+
Next, run [`sentry-wizard`](https://docs.sentry.io/platforms/javascript/guides/nextjs/#configure), which will create and populate the settings files needed by `@sentry/nextjs` to initialize the SDK and upload source maps to Sentry:
3543

36-
You can [configure your app automatically](https://docs.sentry.io/platforms/javascript/guides/nextjs/#configure) or do the [manual setup](https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/).
37-
Both ways lead to having your custom config files (`next.config.js`, `sentry.client.config.js`, `sentry.server.config.js`, and `sentry.properties`); so you can delete them from the example, they are here to illustrate how an example app looks like.
44+
```bash
45+
npx @sentry/wizard -i nextjs
46+
```
3847

39-
## Deploy on Vercel
48+
Once the files are created, you can further configure your app by adding [SDK settings](https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/) to `sentry.server.config.js` and `sentry.client.config.js` and [`SentryWebpackPlugin` settings](https://github.com/getsentry/sentry-webpack-plugin#options) to `next.config.js`.
4049

41-
You can deploy this app to the cloud with [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
50+
(If you'd rather do the SDK set-up manually, [you can do that, too](https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/).)
4251

43-
#### Deploy Your Local Project
52+
You should now be able to build and run your app locally, upload source maps, and send errors to Sentry. For more details, check out the [Sentry Next.js SDK docs](https://docs.sentry.io/platforms/javascript/guides/nextjs/).
4453

45-
To deploy your local project to Vercel, push it to GitHub/GitLab/Bitbucket and [import to Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example).
54+
#### Deploy your app to Vercel
4655

47-
**Important**: When you import your project on Vercel, make sure to click on **Environment Variables** and set them to match your `.env.local` file.
56+
Vercel reads you code from GitHub, so you first need to [create an empty GitHub repo](https://docs.github.com/en/get-started/quickstart/create-a-repo) for your project and then add it to your local repo [as a remote](https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories):
4857

49-
#### Deploy from Our Template
58+
```bash
59+
git remote add origin https://github.com/<org>/<repo>.git
60+
```
61+
62+
Next, [create a project in Vercel](https://vercel.com/docs/projects/overview#creating-a-project) and [link it to your GitHub repo](https://vercel.com/docs/git#deploying-a-git-repository).
5063

51-
Alternatively, you can deploy using our template by clicking on the Deploy button below.
64+
In order for Vercel to upload source maps to Sentry when building your app, it needs an auth token. To use the personal token set up by the wizard, add an [environment variable](https://vercel.com/docs/projects/environment-variables) to your Vercel project with the key `SENTRY_AUTH_TOKEN` and the value you'll find in `.sentryclirc` at the root level of your project. To use an org-wide token instead, set up the Vercel Sentry Integration. (You can read more about the integration [on Vercel](https://vercel.com/integrations/sentry) and in [the Sentry docs](https://docs.sentry.io/product/integrations/deployment/vercel/).)
5265

53-
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-sentry&project-name=with-sentry&repository-name=with-sentry&env=NEXT_PUBLIC_SENTRY_DSN&envDescription=DSN%20Key%20required%20by%20Sentry&envLink=https://github.com/vercel/next.js/tree/canary/examples/with-sentry%23step-1-enable-error-tracking)
66+
Finally, commit your app and push it to GitHub:
5467

55-
## Sentry Integration
68+
```bash
69+
git add .
70+
git commit -m "initial commit"
71+
git push
72+
```
5673

57-
Sentry’s Vercel Integration connects your Sentry and Vercel projects to automatically upload source maps and notify Sentry of release deployment. Learn more about this integration in [Sentry’s full documentation](https://docs.sentry.io/product/integrations/vercel/).
74+
This will trigger a deployment in Vercel. Head over to your [Vercel dashboard](https://vercel.com/dashboard) and click on your project and then "Visit" to see the results!

examples/with-sentry/next.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const moduleExports = {
99
// Your existing module.exports
1010
}
1111

12-
const SentryWebpackPluginOptions = {
12+
const sentryWebpackPluginOptions = {
1313
// Additional config options for the Sentry Webpack plugin. Keep in mind that
1414
// the following options are set automatically, and overriding them is not
1515
// recommended:
@@ -21,4 +21,4 @@ const SentryWebpackPluginOptions = {
2121

2222
// Make sure adding Sentry options is the last code to run before exporting, to
2323
// ensure that your source maps include changes from all other Webpack plugins
24-
module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions)
24+
module.exports = withSentryConfig(moduleExports, sentryWebpackPluginOptions)

examples/with-sentry/pages/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const Index = () => (
1818
</p>
1919
<ol>
2020
<li>
21-
API route exceptions (note that 1-3 are not expected to work if deployed
22-
to Vercel yet)
21+
API route exceptions (note that 1 and 2 are not expected to work if
22+
deployed to Vercel yet)
2323
</li>
2424
<ol>
2525
<li>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const Test2 = () => <h1>SSR Test 2</h1>
22

33
export async function getServerSideProps() {
4-
throw new Error('SSR Test 2')
4+
return Promise.reject(Error('SSR Test 2'))
55
}
66

77
export default Test2

examples/with-sentry/sentry.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)