| ▲ | hawtads an hour ago | |
If you are on react/next.js, defer the client side initialization until after your app has painted. PostHog (especially with their session recording feature) likes to initialize a little before the rest of your app loads through either their context provider or instrumentation.ts (if you are on next.js). It's generally insignificant except if you are building a B2C web app where the extra 100ms makes a difference in retention. On the server side, queue all analytics call and run them after the main request completes (on next.js it would be within an after() function on the server side). You can paste this comment into Claude and it should handle the refactor just fine. Note with the changes in analytics scheduling, you will lose out on real time analytics in favor of better time to first load. So keep the trade-off in mind. | ||