Fix issue with missing subscriber attributes if set after login but before login callback#809
Merged
tonidero merged 4 commits intoMar 2, 2023
Conversation
tonidero
commented
Feb 21, 2023
| } | ||
| infoLog(AttributionStrings.COPYING_ATTRIBUTES_FROM_TO_USER.format(originalAppUserId, newAppUserID)) | ||
| deviceCache.setAttributes(newAppUserID, unsyncedAttributesPreviousUser) | ||
| deviceCache.clearAllSubscriberAttributesFromUser(originalAppUserId) |
Contributor
Author
There was a problem hiding this comment.
Note how we are deleting the unsynced attributes from the old user id after we set them for the new user id so there should be no chance of losing them.
Codecov Report
@@ Coverage Diff @@
## main #809 +/- ##
==========================================
+ Coverage 81.54% 81.58% +0.04%
==========================================
Files 121 121
Lines 3999 4008 +9
Branches 512 514 +2
==========================================
+ Hits 3261 3270 +9
Misses 535 535
Partials 203 203
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
tonidero
added a commit
to RevenueCat/purchases-ios
that referenced
this pull request
Feb 23, 2023
…efore login callback (#2313) ### Description Deals with [SDK-2817](https://linear.app/revenuecat/issue/SDK-2817/fix-issue-with-missing-subscriber-attributes-on-purchases-[ios]) This is the iOS counterpart to RevenueCat/purchases-android#809 There was an issue where subscriber attributes could be delayed to be synced to the backend. This happened when setting a subscriber attribute AFTER the `logIn` call but BEFORE the `logIn` operation was completed. This issue happens because we start syncing subscriber attributes immediately when calling `logIn`, but if we set any after that but before the login is complete, they will be assigned to the old user id. We would sync those the next time the app is backgrounded/foregrounded but might be missed if there is a purchase before that happens. When there is a purchase, we only sync the current user's unsynced attributes, but not attributes of other users. This PR copies all unsynced attributes from the old user id to the new one upon a successful login. This way, the unsynced attributes will be sent if the user tries to purchase. Note that we only copy these attributes when the old user id was anonymous. This is because there is a possible edge case of copying attributes from a user to a different user if the sync request fails and remains unsynced when changing between user ids.
NachoSoto
approved these changes
Mar 1, 2023
| user to list.map { | ||
| it.key.backendKey to it | ||
| }.toMap() | ||
| user to list.associateBy { |
Contributor
Author
There was a problem hiding this comment.
Suggested by Android Studio, pretty nice yup 😄
vegaro
approved these changes
Mar 1, 2023
tonidero
pushed a commit
that referenced
this pull request
Mar 9, 2023
**This is an automatic release.** ### Bugfixes * Fix docs deployment (#836) via Toni Rico (@tonidero) * Fix issue with missing subscriber attributes if set after login but before login callback (#809) via Toni Rico (@tonidero) ### Other Changes * Fix SDKMAN issues (#822) via Toni Rico (@tonidero) Co-authored-by: revenuecat-ops <ops@revenuecat.com>
tonidero
added a commit
that referenced
this pull request
Mar 9, 2023
## 5.8.2⚠️ ⚠️ ⚠️ ⚠️ Android SDK versions 5.8.0 and 5.8.1 have a major bug that prevents sending purchase tokens to RevenueCat. Users will get charged but won't receive entitlements. An automatic refund will occur after 72 hours unless an unaffected SDK version is used. Downgrade to 5.7.1 or upgrade to 5.8.2 or later to avoid this bug. Users who got charged while using 5.8.0 and 5.8.1 will be able to access their purchases automatically upon opening an app that uses 5.7.1 or lower, or 5.8.2 or higher.⚠️ ⚠️ ⚠️ ⚠️ ### Other changes in 5.8.0 and 5.8.1 ### New Features * Diagnostics (#811) via Toni Rico (@tonidero) ### Bugfixes * Fix issue with missing subscriber attributes if set after login but before login callback (#809) via Toni Rico (@tonidero) ### Dependency Updates * Bump fastlane from 2.212.0 to 2.212.1 (#821) via dependabot[bot] (@dependabot[bot]) * Bump fastlane from 2.211.0 to 2.212.0 (#808) via dependabot[bot] (@dependabot[bot]) * Bump fastlane-plugin-versioning_android from 0.1.0 to 0.1.1 (#798) via dependabot[bot] (@dependabot[bot]) * Bump danger from 8.6.1 to 9.2.0 (#778) via dependabot[bot] (@dependabot[bot]) ### Other Changes * Fix docs deployment (#836) via Toni Rico (@tonidero) * Fix SDKMAN issues (#822) via Toni Rico (@tonidero) * Fix bundle install on CircleCI (#827) via Cesar de la Vega (@vegaro) * Update README.md to include minimum Kotlin version (#786) via Cesar de la Vega (@vegaro) * Remove `tag_release_with_latest_if_needed` fastlane lane (#781) via Cesar de la Vega (@vegaro) * Adds docs for timeouts when closing and releasing (#759) via Cesar de la Vega (@vegaro) * Add Amazon App tester package to purchase tester queries (#789) via Stefan Wehner (@tonidero) --------- Co-authored-by: revenuecat-ops <ops@revenuecat.com> Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
NachoSoto
pushed a commit
to RevenueCat/purchases-ios
that referenced
this pull request
Mar 16, 2023
…efore login callback (#2313) ### Description Deals with [SDK-2817](https://linear.app/revenuecat/issue/SDK-2817/fix-issue-with-missing-subscriber-attributes-on-purchases-[ios]) This is the iOS counterpart to RevenueCat/purchases-android#809 There was an issue where subscriber attributes could be delayed to be synced to the backend. This happened when setting a subscriber attribute AFTER the `logIn` call but BEFORE the `logIn` operation was completed. This issue happens because we start syncing subscriber attributes immediately when calling `logIn`, but if we set any after that but before the login is complete, they will be assigned to the old user id. We would sync those the next time the app is backgrounded/foregrounded but might be missed if there is a purchase before that happens. When there is a purchase, we only sync the current user's unsynced attributes, but not attributes of other users. This PR copies all unsynced attributes from the old user id to the new one upon a successful login. This way, the unsynced attributes will be sent if the user tries to purchase. Note that we only copy these attributes when the old user id was anonymous. This is because there is a possible edge case of copying attributes from a user to a different user if the sync request fails and remains unsynced when changing between user ids.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Deals with SDK-2816
There was an issue where subscriber attributes could be delayed to be synced to the backend. This happened when setting a subscriber attribute AFTER the
logIncall but BEFORE thelogInoperation was completed.This issue happens because we start syncing subscriber attributes immediately when calling
logIn, but if we set any after that but before the login is complete, they will be assigned to the old user id. We would sync those the next time the app is backgrounded/foregrounded but might be missed if there is a purchase in between since when there is a purchase, we only sync the current user's unsynced attributes.This PR copies all unsynced attributes from the old user id to the new one upon a successful login. This way, the unsynced attributes will be sent if the user tries to purchase.
Note that we only copy these attributes when the old user id was anonymous. This is because there is a possible edge case of copying attributes from a user to a different user if the sync request fails and remains unsynced when changing between user ids.