Nuxt error tracking installation
- 1
Installing PostHog Nuxt SDK
RequiredYour goal in this step: Install the PostHog Nuxt.js SDK.- Install
posthog-jsusing your package manager:
- Add your PostHog API key and host to your
nuxt.config.jsfile. You can find these in your project settings.
nuxt.config.js- Create a new plugin by creating a new file
posthog.client.jsin your plugins directory.
plugins/posthog.client.js - Install
Verify PostHog is initialized
CheckpointConfirm you can capture events with PostHogBefore proceeding, confirm that you can capture events using
posthog.capture('test_event').- 2
Manually capturing exceptions
RequiredYour goal in this step: Manually capture exceptions in your Nuxt application.To send errors directly using the PostHog client, import it and use the
captureExceptionmethod like this:VueOn the server side, you can use the
posthogobject directly.server/api/example.js - 3
Configuring exception autocapture
RequiredYour goal in this step: Enable automatic exception tracking for your Nuxt application.Update your
posthog.client.jsto add an error hookJavaScript - 5

