[Bug] Make null values safe for IAM requests #1457
Merged
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.
Description
One Line Summary
Make null values safe for IAM payload such as subscription ID (most common) or other data required in the payload is
nil
.Details
nil
, the app crashes when requests for IAM impressions or clicks are created.[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]
""
and receives a 400 response.How could this happen?
null
subscription ID, but to get IAMs, we need a subscription IDshouldShowInAppMessage
, there is an additional check for subscription ID before presenting an IAM. No IAM should be shown when subscription ID isnull
.Motivation
Fix crashes, reported in #1453 and others. The crash reports all look like they are for player ID.
Scope
Correctly handle and pass along null values.
Testing
Unit testing
Ported over 2 existing IAM-related request tests, and add a few more with null values and check it does not crash
Manual testing
Physical iPhone 13 on iOS 17.4
nil
subscription ID to theOSRequestInAppMessageViewed
andOSRequestInAppMessageClicked
I was able to recreate this scenario "naturally" with this flow:
shouldShowInAppMessage
check passesAffected code checklist
Checklist
Overview
Testing
Final pass
This change is