PostHog / posthog-flutter

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

`identify` method throws exception on `web` #83

Closed hoangdt84 closed 9 months ago

hoangdt84 commented 9 months ago

Version

4.0.0

Steps to Reproduce

This code does not work

Posthog().identify(userId: userId);

But this does

Posthog().identify(userId: userId, userProperties: {}, userPropertiesSetOnce: {});

Result of flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.1, on macOS 13.6.4 22G513 darwin-x64, locale en-VN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.86.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Expected Result

No exception

Actual Result

Error: TypeError: null: type 'Null' is not a subtype of type 'Object'
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 297:3  throw_
dart-sdk/lib/_internal/js_shared/lib/rti.dart 1463:3                         _asObject
packages/posthog_flutter/src/posthog_flutter_web_handler.dart 13:18          handleWebMethodCall
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
packages/posthog_flutter/src/posthog_flutter_web_handler.dart 5:36           handleWebMethodCall
packages/posthog_flutter/posthog_flutter_web.dart 28:5                       handleMethodCall
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
packages/posthog_flutter/posthog_flutter_web.dart 27:35                      handleMethodCall
packages/flutter/src/services/platform_channel.dart 571:55                   _handleAsMethodCall
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
packages/flutter/src/services/platform_channel.dart 568:40                   [_handleAsMethodCall]
packages/flutter/src/services/platform_channel.dart 564:34                   <fn>
packages/flutter_web_plugins/src/plugin_registry.dart 125:33                 handleFrameworkMessage
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
packages/flutter_web_plugins/src/plugin_registry.dart 116:38                 handleFrameworkMessage
lib/_engine/engine/platform_dispatcher.dart 674:7                            [_sendPlatformMessage]
lib/_engine/engine/platform_dispatcher.dart 367:5                            sendPlatformMessage
packages/flutter/src/services/binding.dart 580:27                            send
packages/flutter/src/services/platform_channel.dart 327:31                   _invokeMethod
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
packages/flutter/src/services/platform_channel.dart 322:30                   [_invokeMethod]
packages/flutter/src/services/platform_channel.dart 507:12                   invokeMethod
packages/posthog_flutter/src/posthog_flutter_io.dart 18:28                   identify
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54           runBody
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5           _async
packages/posthog_flutter/src/posthog_flutter_io.dart 12:24                   identify
packages/posthog_flutter/src/posthog.dart 20:21                              identify
marandaneto commented 9 months ago

Thanks @hoangdt84 Fix should be here https://github.com/PostHog/posthog-flutter/pull/84