fix(ss_inapps) - fix in-app id data type conversion from Int to Long fo SS in-apps SDK-4246 #731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue happened in below code
store.readEvaluatedServerSideInAppIds()
returns in-app Ids asInt
instead ofLong
andevaluatedServerSideCampaignIds
expects in-app Ids asLong
7.2.0
it was working as expected but in7.2.0
we bumped kotlin version to2.0.10
which caused an issue.Int
andLong
comparison inside lambda. Basically it’s not allowed to compareInt
withLong
in lambda from1.8.0
onwards.https://youtrack.jetbrains.com/issue/KTLC-177/NI-False-negative-no-compilation-error-Operator-cannot-be-applied-to-Long-and-Int-is-reported-in-builder-inference-lambdas
https://kotlinlang.org/docs/compatibility-guide-18.html#prohibit-using-operator-on-incompatible-numeric-types-in-builder-inference-context
store.readEvaluatedServerSideInAppIds()
reads in-app Ids from shared preference as aString
and converts it toJSONObject
usingnew JSONObject(string from SP)
.JSONObject
internally converts in-app id toInt
instead ofLong
which is the root cause. However nothing can be done here as thats how JSONObject works.Solution implemented as below:
JSONObject
, so consider it as aNumber
JSONObject
to aMap
.evaluatedServerSideCampaignIds
has generic type declared as<String,MutableList<Long>>
but at runtime type is erased and hence during conversionMutableList
contains anInt
Int
s inMutableList
toLong
s and proceed as before.Note
As per BE contract in-app ids must be passed as numeric and not text hence we are not making any changes to
MutableList
type here. AlsoloadSuppressedCSAndEvaluatedSSInAppsIds()
method called only once in a session, during CT instance creation, hence there won't be much performance impact ofInt
toLong
conversion.