Skip to content
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

chore: add Node & Cloudflare instructions to docs #10697

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### Setting up Node exception autocapture

> **Note:** A minimum SDK version of v4.5.2 is required, but we recommend keeping up to date with the latest version to ensure you have all of error tracking's features.

Exception autocapture can be enabled during initialization of the PostHog client to automatically capture any exception thrown by your Node application.

```node
import { PostHog } from 'posthog-node'

const client = new PostHog(
'<ph_project_api_key>',
{ enableExceptionAutocapture: true }
)

```

> ⚠️ Error tracking requires access the file system to process stack traces. Cloudflare workers do not support Node.js runtime APIs by default and need to be [included as per their documentation](https://developers.cloudflare.com/workers/runtime-apis/nodejs/#nodejs-compatibility).

For exceptions handled by your application that you would still like sent to PostHog, you can manually call the capture method:

```node
posthog.captureException(e, 'user_distinct_id', additionalProperties)
```
7 changes: 7 additions & 0 deletions contents/docs/error-tracking/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Tab from "components/Tab"
import WebInstall from '../integrate/_snippets/install-web.mdx'
import JSWebErrorTracking from './_snippets/web-install-error-tracking.mdx'
import ReactInstall from '../integrate/_snippets/install-react.mdx'
import NodeInstall from '../integrate/_snippets/install-node.mdx'
import NodeErrorTracking from './_snippets/node-install-error-tracking.mdx'
import PythonInstall from '../integrate/_snippets/install-python.mdx'
import PythonErrorTracking from './_snippets/python-install-error-tracking.mdx'
import SentryInstall from '../libraries/_snippets/install-sentry.mdx'
Expand All @@ -21,6 +23,7 @@ Error tracking enables you to track, investigate, and resolve exceptions your cu
<Tab>Web</Tab>
<Tab>React</Tab>
<Tab>Python</Tab>
<Tab>Node</Tab>
<Tab>Sentry</Tab>
</Tab.List>
<Tab.Panels>
Expand All @@ -36,6 +39,10 @@ Error tracking enables you to track, investigate, and resolve exceptions your cu
<PythonInstall />
<PythonErrorTracking />
</Tab.Panel>
<Tab.Panel>
<NodeInstall />
<NodeErrorTracking />
</Tab.Panel>
<Tab.Panel>
<SentryInstall />
</Tab.Panel>
Expand Down