andre-paraense / launchdarkly_flutter

A LaunchDarkly Flutter SDK
GNU Lesser General Public License v3.0
4 stars 5 forks source link

[Android] Handle long type when parsing custom attributes #34

Closed anemchinova closed 3 years ago

anemchinova commented 3 years ago

Requirements

Related issues

While testing, we noticed that timestamp in milliseconds since epoch wasn't sent to LaunchDarkly when running on Android. This happens due to long type not being handled when parsing custom attributes.

Unlike Dart, Java has four integer types: byte, short, int and long. Long integers like a timestamp won't fit int and will be converted to a long rather than an int. Meaning, when identify / init is called, those attributes will be omitted from the resulting custom attributes map and won't be sent to LaunchDarkly.

Describe the solution you've provided

I've added another if-else branch to handle long type.

Additional context

Platform channel data types support and codecs

How to test?

The issue can be reproduced with this code:

  import 'package:launchdarkly_flutter/launchdarkly_flutter.dart';
  ...

  Future<void> init() async {
    await LaunchdarklyFlutter().init(
      'your_api_key',
      'test_user',
      custom: {
        'timestamp': DateTime.now().toUtc().millisecondsSinceEpoch,
      },
    );
  }

Thank you for the great package!