GetDutchie / datadog_flutter

**This community package has been deprecated in favor of Datadog's official SDK**
https://github.com/DataDog/dd-sdk-flutter
MIT License
24 stars 24 forks source link

datadog_flutter v1.7.0: App crashes when extraInfo property in setUserInfo method is null #89

Closed mkobuolys closed 2 years ago

mkobuolys commented 2 years ago

datadog_flutter v1.7.0: App crashes when extraInfo property in setUserInfo method is null. Based on the changelog, this problem should have been appeared since datadog_flutter v1.5.2 with BREAKING CHANGE all attribute maps have been updated from Map<String, dynamic> to Map<String, Object>. These Maps no longer support nullable values.

This is the error from the native layer:

datadog_flutter/SwiftDatadogFlutterPlugin.swift:327: Fatal error: 'try!' expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Swift.Dictionary<Swift.String, AnyCodable.AnyCodable>, Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data did not contain a top-level value.", underlyingError: nil))

This error occurs when calling the setUserInfo method like this:

DatadogFlutter.setUserInfo(
  id: '123',
  email: 'email@test.com',
);

You can fix the problem by providing an empty object to extraInfo.

DatadogFlutter.setUserInfo(
  id: '123',
  email: 'email@test.com',
  extraInfo: {},
);

I think you should either specify the default value for extraInfo (e.g. empty object) or fix the bug in the native layer to expect a nullable value.

Flutter doctor command output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.4, on macOS 12.0.1 21A559 darwin-arm, locale en-LT)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.65.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

Let me know if you need any more details.

victor-tinoco commented 2 years ago

I'm facing the same issue.

tshedor commented 2 years ago

Thanks @mkobuolys for raising the issue and providing resolution steps. I've published a patch in 1.7.1 cc @victor-tinoco