Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Stop logging error when client is uninitialized #1803

Conversation

rafaeelaudibert
Copy link
Member

@rafaeelaudibert rafaeelaudibert commented Mar 7, 2025

This causes errors on NextJS because it will be uninitialized on the server-side. We already make it pretty clear that you should control initializing the client when passing it in as a prop, so let's give up on the error log altogether

Closes #1802

This causes errors on NextJS because it will be uninitialized on the server-side. We already make it pretty clear that you should control initializing the client when passing it in as a prop, so let's give up on the error log altogether
@rafaeelaudibert rafaeelaudibert requested a review from robbie-c March 7, 2025 17:49
Copy link

vercel bot commented Mar 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js 🔄 Building (Inspect) Visit Preview Mar 7, 2025 5:49pm

@rafaeelaudibert rafaeelaudibert added the bump patch Bump patch version when this PR gets merged label Mar 7, 2025
@rafaeelaudibert rafaeelaudibert enabled auto-merge (squash) March 7, 2025 17:49
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Removed warning message for uninitialized PostHog clients in React provider to better support server-side rendering in Next.js applications.

  • Removed posthogJs.__loaded check and warning in react/src/context/PostHogProvider.tsx to prevent unnecessary console warnings during SSR
  • Change aligns with existing documentation that already guides users on proper client initialization patterns

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

github-actions bot commented Mar 7, 2025

Size Change: 0 B

Total Size: 3.56 MB

ℹ️ View Unchanged
Filename Size
dist/all-external-dependencies.js 220 kB
dist/array.full.es5.js 274 kB
dist/array.full.js 377 kB
dist/array.full.no-external.js 376 kB
dist/array.js 185 kB
dist/array.no-external.js 184 kB
dist/customizations.full.js 14 kB
dist/dead-clicks-autocapture.js 14.5 kB
dist/exception-autocapture.js 9.94 kB
dist/external-scripts-loader.js 2.64 kB
dist/main.js 186 kB
dist/module.full.js 377 kB
dist/module.full.no-external.js 376 kB
dist/module.js 185 kB
dist/module.no-external.js 184 kB
dist/posthog-recorder.js 212 kB
dist/recorder-v2.js 115 kB
dist/recorder.js 115 kB
dist/surveys-preview.js 71.3 kB
dist/surveys.js 76 kB
dist/tracing-headers.js 1.76 kB
dist/web-vitals.js 10.4 kB

compressed-size-action

@rafaeelaudibert rafaeelaudibert merged commit 02c7ec3 into main Mar 7, 2025
29 of 30 checks passed
@rafaeelaudibert rafaeelaudibert deleted the fix-message-being-thrown-on-nextjs-because-of-uninitialized-posthog branch March 7, 2025 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PostHog.js] you should provide an _initialized_ client to PostHogProvider
2 participants