-
Notifications
You must be signed in to change notification settings - Fork 39
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: flutter web identify getAnonymousId error. #16
fix: flutter web identify getAnonymousId error. #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for the PR! Nice catch on the get_distinct_id
call.
Can you try passing your userId
as distinctId
parameter in identify
to see if that works?
@@ -20,7 +19,7 @@ class PosthogWeb { | |||
switch (call.method) { | |||
case 'identify': | |||
analytics.callMethod('identify', [ | |||
call.arguments['distinctId'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think keeping it as distinctId
keeps it aligned with our JS library
https://github.com/PostHog/posthog-js/blob/master/src/posthog-core.js#L810
Have you tried passing your userId
as the distinctId
parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fuziontech
Thank you for giving me a feedback!
I changed distinctId to userId because of the default setting of Posthog().identify.
To use Posthog().identify, there is a required parameter "userId".
So I have to use like this.
Posthog().identify(userId: "Shinyoung Tyga Lee");
I think that using distinctId should make change about default setting of required parameter "userId" name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are totally right!
posthog-flutter/lib/src/posthog.dart
Line 19 in 7beff56
required userId, |
Your changes look great and make this more consistent.
final user = analytics.callMethod('user'); | ||
final anonymousId = user.callMethod('anonymousId'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Great catch here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good!
Thank you! |
No prob! give |
In posthog-js, getting the anonymous Id is able to call the method "get_distinct_id". So, I changed the code to call method "get_distinct_id".
https://posthogusers.slack.com/archives/CT7HXDEG3/p1624946446377900
I sended at Slack about the error.