PostHog / posthog-flutter

PostHog Flutter SDK
https://posthog.com/docs/libraries/flutter
MIT License
55 stars 37 forks source link

Posthog identify() function is not working on Android Platform #27

Closed emilmammadov closed 1 year ago

emilmammadov commented 1 year ago

I'm using

Posthog().identify(
  userId: id,
  properties: {
    'first_name': firstName,
    'last_name': lastName,
    'email': email,
  },
);

When I review the events on the Posthog Dashboard it shows these areas for iOS users but not Android users.

emilmammadov commented 1 year ago

I found where is the root of the issue. The issue is in PosthogFlutterPlugin.java on identify() function

private void identify(MethodCall call, Result result) {
  try {
    String userId = call.argument("userId");
    HashMap<String, Object> propertiesData = call.argument("properties");
    HashMap<String, Object> options = call.argument("options");
    this.callIdentify(userId, propertiesData, options);
    result.success(true);
  } catch (Exception e) {
    result.error("PosthogFlutterException", e.getLocalizedMessage(), null);
  }
}

userId property on Posthog().identify() function is dynamic but Android platform requires String.

We can just change userId property to accept only String to avoid developers doing the same mistake.