Repository navigation
Conversation
…r init FIRIAMClearcutUploader's initializer called the consuming popStillValidRecordsForUpTo: only to check whether the log storage had records, and discarded the returned array. On every SDK start this removed up to one batch (50 in production) of Clearcut records restored from the cache file: the scheduled upload then popped the next batch, and the next cache save overwrote the file without them. Add a non-consuming hasStillValidRecords check to FIRIAMClearcutLogStorage and use it to decide whether to schedule an upload, so the cached records stay in storage until the scheduled upload pops and sends them. Records are still popped once per upload attempt and only pushed back on retryable failures, so this does not introduce double sends. Fixes #16803
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
[paulb777-bot] Requesting an automated review, as on the other PRs from this batch. /gemini review |
There was a problem hiding this comment.
Code Review
This pull request fixes an issue where cached In-App Messaging engagement logs from a previous app session could be dropped instead of uploaded when the SDK started. It introduces a new method 'hasStillValidRecords' in 'FIRIAMClearcutLogStorage' to check for existing unexpired records without removing them, and updates 'FIRIAMClearcutUploader' to use this method during initialization. Unit tests have been added to verify the new behavior. There are no review comments to address, and I have no additional feedback to provide.
Problem
FIRIAMClearcutUploader's initializer calledpopStillValidRecordsForUpTo:only to checkwhether the log storage had records. It then threw away the returned array. That call
removes the records from
FIRIAMClearcutLogStorage. So on every SDK start, up to one batch(50 in production) of Clearcut records restored from the cache file was lost: the scheduled
upload popped the next batch, and the next cache save overwrote the file without the
dropped records.
The production upload strategy waits 5 min to 12 h between uploads. Records logged shortly
before the app is terminated are exactly the ones that end up in the cache, and there are
usually fewer than 50. So in practice most cached engagement logs (impressions, clicks,
dismissals) were dropped instead of uploaded.
Change
hasStillValidRecordstoFIRIAMClearcutLogStorage(internalheader). It uses the same expiry rule and lock as
popStillValidRecordsForUpTo:.records now stay in storage until the scheduled
attemptUploadingpops and sends them.Records are still popped once per upload attempt and only pushed back on retryable
failures, so this doesn't introduce double sends.
Testing
Generated the CocoaPods unit test project, then ran it on an iOS 26.5 simulator (iPhone 17):
FIRIAMClearcutUploaderTests/testUploadsRecordsAlreadyInStorageWhenCreated:times out, and
sentLogs.countis 0.FIRIAMClearcutLogStorageTests/testHasStillValidRecordsDoesNotRemoveRecordspasses.FirebaseInAppMessaging-Unit-unittarget: 123 tests, 0 failures.Fixes #16803