-
Notifications
You must be signed in to change notification settings - Fork 131
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
PostHog JS SDK not compatible with Segment analytics-next package #1106
Comments
Created this PR to import the package and try and have proper type checking - but even their types don't show it as being a promise 🙈 #1119 Could you please share your |
Here's how we're initializing
|
Took a while but managed to reproduce and fix. The Segment types and docs are off which was annoying but oh well |
Bug description
Please describe.
The PostHog JS SDK supports integrating with Segment by passing the Segment analytics object into the posthog.init() call, as detailed in this documentation: https://posthog.com/docs/libraries/segment. This works as expected when the Segment analytics object is created from the Segment snippet, but not when it is created from the
analytics-next
package (https://github.com/segmentio/analytics-next/tree/master/packages/browser#readme).When trying to do so, I receive the following error:
Uncaught (in promise) TypeError: s2.segment.user().id is not a function
This appears to be because, with the analytics object from the
analytics-next
package, theuser()
function is async and returns a promise instead of the object that PostHog expects.How to reproduce
analytics
object using theanalytics-next
package instead of the Segment snippetEnvironment
docker compose
, version/commit: [please provide]Additional context
Thank you for your bug report – we love squashing them!
The text was updated successfully, but these errors were encountered: