<aside> 💡 This page gives you the two tools to put in your app from the start: PostHog to see how people use it, and Sentry to catch its errors.

</aside>

The stack

How to set it up

  1. Create a free PostHog account and a new project for your app.
  2. Add the PostHog snippet or SDK to your app, following PostHog's install guide for your framework.
  3. Turn on session recordings in PostHog so you can watch real visits.
  4. Create a Sentry account and a project for your app's platform.
  5. Add the Sentry SDK to your app with the project's DSN, following Sentry's install guide.
  6. Deploy to your host, such as Vercel, then open the app and click through it so events and a test error arrive in both dashboards.
  7. Check PostHog sessions for where people get stuck and Sentry for new errors, and fix what you find.

<aside> ⚠️ Watch out: add both tools early in the build, not after launch, because their value is knowing how people use the app and where it breaks while you are still learning.

</aside>

Prompt to build your own

You are helping me add usage tracking and error monitoring to my app. My app is <describe the app in one line> and it is built with <framework, for example Next.js or React Native>. I host it on <host, for example Vercel>, and I have free accounts on PostHog and Sentry.
Please do the following:
1. Add PostHog to the app using its official SDK, with session recordings switched on.
2. Add Sentry to the app using its official SDK, so unhandled errors are reported.
3. Read the keys from environment variables, never hard-code them, and show me where to set them locally and on <host>.
4. Add one deliberate test error and one custom PostHog event so I can confirm both tools receive data.
5. Tell me how to remove the test error once it works.
Constraints: use only these two tools, keep the code changes as small as possible, and do not collect personal data beyond what PostHog collects by default. Return the exact files to change with the code for each, then a short checklist for confirming data appears in both dashboards.

Watch the video · More free guides · Follow @manrajtalks for the next one.