Closed litmon closed 2 years ago
Thank you for your feature request! I will consider it and comment later.
@litmon Thank you for your valuable feedback.
First, in JSON in values
accepted by KARTE, the behavior of null values is undefined and ignored, so sending is not recommended.
Therefore, as you pointed out, SDK filters null values in JSON as unacceptable.
Currently, the Values
type is NonNull in order to prevent the confusingness of implicit filtering by the KARTE side.
As you said, org.json.JSONObject
allows Nullable, but internally treats them as non-nullable.
This is because the JSONObject
itself cannot be nullable.
In addition, the API that accepts JSONObject
is maintained and published for the purpose of facilitating migration with the API of SDKs less than v2.
Actually, we discussed this type several times when designing the API. We decided on the current format to clarify the consistency and intent of the internal processing and the public interface.
In your use case, we think you should consider how you want to handle values
that can be null on KARTE.
Map
.Thank you for suggesting an alternative. It cannot be implemented as it is to maintain API compatibility. Instead, we would like to consider publishing a helper function that can be easily converted by filtering nullable types.
Internal helper function example:
If you have use cases that you can't solve, or better solutions, please continue to comment.
We decided on the current format to clarify the consistency and intent of the internal processing and the public interface. Instead, we would like to consider publishing a helper function that can be easily converted by filtering nullable types.
I understand. I will hope to provide helper function!
Is your feature request related to a problem? Please describe.
Hi, I want to change type of
values
argument toMap<String, Any?>
in Event constructor. Because its behavior is different from initialization with JSONObject. https://github.com/plaidev/karte-android-sdk/blob/18e176a019abf23a3166c47796e05e26bbf84cc5/core/src/main/java/io/karte/android/tracking/Event.kt#L74-L83↑In this case, the null-value is filtered through
jsonObject.format()
method.https://github.com/plaidev/karte-android-sdk/blob/18e176a019abf23a3166c47796e05e26bbf84cc5/core/src/main/java/io/karte/android/tracking/Event.kt#L85-L90
↑ But this case is prohibited null-value at the compile time because the type
Values
is same asMap<String, Any>
. https://github.com/plaidev/karte-android-sdk/blob/18e176a019abf23a3166c47796e05e26bbf84cc5/core/src/main/java/io/karte/android/tracking/Event.kt#L23My usecase sample is below code.
Describe the solution you'd like Please describe the desired behavior.
I will suggest this. https://github.com/plaidev/karte-android-sdk/blob/18e176a019abf23a3166c47796e05e26bbf84cc5/core/src/main/java/io/karte/android/tracking/Event.kt#L85-L90
Describe alternatives you've considered Please describe alternative solutions or features you have considered.