Skip to content

Commit 79d1ce9

Browse files
gewenyu99edwinyjlimivanagas
authored
Improve stack trace instructions for Next.js (#11967)
Co-authored-by: Edwin Lim <[email protected]> Co-authored-by: Ian Vanagas <[email protected]>
1 parent a497129 commit 79d1ce9

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

contents/docs/error-tracking/_snippets/cli/authenticate.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ To authenticate the CLI, you can call the `login` command and follow the instruc
44
posthog-cli login
55
```
66

7-
If you are using the CLI in a CI/CD environment such as GitHub Actions, you can set environment variables to authenticate. [`POSTHOG_CLI_ENV_ID`](https://app.posthog.com/settings/environment#variables) and [`POSTHOG_CLI_TOKEN`](https://app.posthog.com/settings/user-api-keys#variables) should be the number in your PostHog homepage URL and a [personal API key](/docs/api#private-endpoint-authentication) respectively.
7+
If you are using the CLI in a CI/CD environment such as GitHub Actions, you can set environment variables to authenticate:
88

9-
Uploading source maps requires the **error tracking write** scope when creating a [personal API key](https://us.posthog.com/settings/user-api-keys).
9+
| Environment Variable | Description | Source |
10+
| --- | --- | --- |
11+
| `POSTHOG_CLI_ENV_ID` | PostHog project ID | [Environment settings](https://app.posthog.com/settings/environment#variables) |
12+
| `POSTHOG_CLI_TOKEN` | **Personal API key** with `error tracking write` scope | [API key settings](https://app.posthog.com/settings/user-api-keys#variables) |
1013

1114
Use the `--host` option in subsequent commands to specify a different PostHog instance / or region. For EU users:
1215

contents/docs/error-tracking/_snippets/cli/download.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Install posthog-cli
1+
Install `posthog-cli`:
22

33
<MultiLanguage>
44

contents/docs/error-tracking/_snippets/nextjs-install-error-tracking.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ export const onRequestError = async (err, request, context) => {
111111

112112
You can find a full example of both this and client-side error tracking in our [Next.js error monitoring tutorial](/tutorials/nextjs-error-monitoring).
113113

114-
## Uploading source maps
114+
## Stack traces
115+
PostHog needs access to source maps to properly display stack traces. Use the `posthog-cli` to inject and upload your source maps to PostHog.
115116

116-
If your source maps are not publicly hosted, you will need to upload them during your build process to see unminified code in your stack traces.
117-
118-
<NextJsUploadSourceMaps/>
117+
<NextJsUploadSourceMaps/>

contents/docs/error-tracking/_snippets/nextjs-upload-source-maps.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ export default withPostHogConfig(nextConfig, {
3030

3131
```
3232

33-
Where:
34-
- [`POSTHOG_API_KEY`](https://app.posthog.com/settings/user-api-keys#variables): Personal API Key with at least `write` access on `error tracking`.
35-
- [`POSTHOG_ENV_ID`](https://app.posthog.com/settings/environment#variables): Project ID you can find in your project settings or in the URL of your PostHog instance (54321 in `http://us.posthog.com/project/54321`).
33+
Where you should set the following environment variables:
34+
35+
| Environment Variable | Description |
36+
| --- | --- |
37+
| `POSTHOG_API_KEY` | [Personal API key]((https://app.posthog.com/settings/user-api-keys#variables)) with at least `write` access on `error tracking` |
38+
| `POSTHOG_ENV_ID` | Project ID you can find in your [project settings](https://app.posthog.com/settings/environment#variables) |
39+
| `NEXT_PUBLIC_POSTHOG_HOST` | Your PostHog instance URL. Defaults to `https://us.posthog.com` |
3640

3741
### That's it!
3842

0 commit comments

Comments
 (0)