Better support for SSR - graceful handling of method calls without init()
If you're running your frontend with server-side rendering you need to wrap up all function calls to PostHog to only run after posthog.init() has been called. As a user suggested (original thread), we could do the same thing that Sentry SDK does. If you call methods (such as isFeatureEnabled, capture, identify or reset) without having called posthog.init(), we could simply have a noop instead of raising an error. We could consider just logging a warning to make sure this doesn't fail silently if you accidentally forget to add the posthog.init() call.
Have been dealing with this exact issue when testing component-level stories via Storybook.
Have to try/catch every posthog call to avoid breaking the story when calling posthog.capture :-)
This issue hasn't seen activity in two years! If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in two weeks.
This issue was closed due to lack of activity. Feel free to reopen if it's still relevant.