<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>
<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>
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.