Closed suztomo closed 3 years ago
The problem with dates was a bug in the library that's been fixed, but I did add a few things in this direction:
Logger
instance and publish some warning/info to it. This logger can be subscribed to as a stream to accomplish roughly what you've laid out above.Thank you.
When thinking about https://github.com/SunnyApp/flutter_contact/issues/31, this library treats the unexpected data as
null
. I dug the source code and identified that it wasvalue
key that was unexpected to this library when I use BlackBerry Priv (Android 6.0.1). This can be fixed by checking thevalue
key in the map in addition to existingdate
key.However, this fix only applies to the devices that return
value
anddate
for the dates. There could be other type of devices that return data in a different format. If I'm lucky, my user who suffer from the glitch would communicate to me about the glitch and I happen to have the same device as them to debug further to find the unexpected data. It's very unlikely.I need a way to troubleshoot the unexpected data from my users' devices, without requiring them a special effort. Here are few options I thought of:
Option 1: Throw an exception upon unexpected data
Currently it return null for unexpected date map (see the screenshot in #31). I thought about throwing an exception rather than returning null. I can catch the exception from the library and send some message to me via Firebase Crashlytics.
However, this option might crash apps that use this library, even when the unexpected data is unused. Furthermore, one unexpected data prevents a user of app from listing contacts.
Option 2: Add a handler for unexpected data
How about this library taking a handler for error reporting on unexpected format of the contract data? I have an opportunity to report error while the library continue to work only except the unexpected data..
The idea is when initializing
ContactService
in this library, it would optionally take a handler (a function) with typevoid Function(Exception unexpectedDataException)
. When this library hits an unexpected data, it calls the handler and continues processing next data. I would pass a call to Firebase Crashlytics. This way, the library continues to work for users and I can get understanding of unexpected format of users data and devices.