Nuxt error tracking installation
- 1
Installing PostHog Nuxt SDK
RequiredYour goal in this step: Install the PostHog Nuxt.js SDK.- Install
posthog-js
using your package manager:
- Add your PostHog API key and host to your
nuxt.config.js
file. You can find these in your project settings.
nuxt.config.js- Create a new plugin by creating a new file
posthog.client.js
in 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
captureException
method like this:VueOn the server side, you can use the
posthog
object 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.js
to add an error hookJavaScript - 5