Next.js error tracking guide: recommend `@posthog/next`'s `onRequestError` instead of a hand-written one
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- next.js, node.js, typescript
- Domain
- documentation
Research direction
Start with the server-side section of the Next.js error tracking guide at https://posthog.com/docs/error-tracking/installation/nextjs and compare its hand-written instrumentation.ts example with the onRequestError and createOnRequestError exports from @posthog/next. Update the guide to recommend the package API and show the options example if useful; done when the documented setup reflects the built-in integration and its stated benefits.
Written by the indexing model from the issue text.
Description
The server-side section of the Next.js error tracking guide has every app write its own onRequestError in instrumentation.ts: create a posthog-node client, parse the posthog-js cookie by hand to find the person, and call captureException.
@posthog/next already ships this as onRequestError / createOnRequestError, so the guide could be:
// instrumentation.ts
export { onRequestError } from '@posthog/next'
or, with options:
import { createOnRequestError } from '@posthog/next'
export const onRequestError = createOnRequestError({
serverOptions: { requestTimeout: 3000, fetchRetryCount: 0 },
})
Compared with the guide's snippet, it:
- reads the cookie for this project's key, not whichever
ph_phc_…_posthogcookie the regex matches first - adds
$session_idand$device_id, so the server exception links to the session replay - adds the Next.js request context (
$pathname,$http_method, route path and type, error digest) - respects the posthog-js opt-out cookie
- sends immediately and never throws from the hook
We only found @posthog/next by reading the posthog-js source, after hand-rolling the guide's version ourselves.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 932
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 708
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PostHog/posthog.com
-
website
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
PostHog/posthog.com#21690 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PostHog/posthog.com#21607 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
PostHog/posthog.com#21523 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
PostHog/posthog.com#21495 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
PostHog/posthog.com#21457 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
All issues in PostHog/posthog.com
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gnosis/gnosis_vpn#661 ·
Maintainers usually reply within 1 day
-
content-freshness: staleOwnedContent doc comments still say 'complete receipt' (follow-up to #7912)Opentriage:bug-verified
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
fix: reject sourceStorage/packagedStorage bucket that differs from the stack default (fail loud)Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Eyevinn/open-videocore#1300 ·
Maintainers usually reply within 1 day
-
nextjs-tracking
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
cloudflare/vinext#4390 ·
Maintainers usually reply within 1 day
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
kubernetes-sigs/headlamp#8175 ·
Maintainers usually reply within 2 days