Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFix #2565: Retry ref code lookup on subsequent launches. #2574
Conversation
| @@ -47,6 +47,7 @@ public class UserReferralProgram { | |||
|
|
|||
| /// Looks for referral and returns its landing page if possible. | |||
| public func referralLookup(refCode: String?, completion: @escaping (_ refCode: String?, _ offerUrl: String?) -> Void) { | |||
| Preferences.URP.referralLookupOutstanding.value = false | |||
This comment has been minimized.
This comment has been minimized.
iccub
May 25, 2020
•
Contributor
Doesn't make sense to me, shouldn't this flag be toggled after the ref lookup network call?
This comment has been minimized.
This comment has been minimized.
jhreis
May 26, 2020
Author
Contributor
Yup
| @@ -23,6 +23,13 @@ public class UserReferralProgram { | |||
| static let prod = "https://laptop-updates.brave.com" | |||
| } | |||
|
|
|||
| // In case of network problems when looking for referrral code | |||
| // we retry the call few times while the app is still alive. | |||
| private var referralLookupRetryTimer: Timer? | |||
This comment has been minimized.
This comment has been minimized.
jhreis
May 27, 2020
Author
Contributor
Probably more clear to just wrap these all in a struct, since all related to the same thing.
struct ReferralLookupRetry {
private var retryTimer: Timer?
private var currentCount = 0
...
}
| if refCode != nil { | ||
| UrpLog.log("Clipboard ref code found: " + (UIPasteboard.general.string ?? "!Clipboard Empty!")) | ||
| UrpLog.log("Clearing clipboard.") | ||
| UIPasteboard.general.clearPasteboard() |
This comment has been minimized.
This comment has been minimized.
jumde
May 27, 2020
Collaborator
If the refcode is cleared here, app won't find the refcode on the next launch if the the 10 network requests are not successful. May be store it in URP preferences?
This comment has been minimized.
This comment has been minimized.
jhreis
May 27, 2020
•
Author
Contributor
Ref code is passed into the look up function, and it is stored internally there:
https://github.com/brave/brave-ios/pull/2574/files#diff-bfe2070e3d8f02013654953e18b60730R280
Here is where it is stored:
https://github.com/brave/brave-ios/pull/2574/files#diff-60f6d7911cf19ceb7bcfcde55f9bc740R126
Then two lines below the network request (and potential retry logic) is executed.
This comment has been minimized.
This comment has been minimized.
jumde
May 27, 2020
•
Collaborator
My concern is that we are still accessing the clipboard on subsequent launches, I think we should just store it in a preference and use it from there: https://github.com/brave/brave-ios/pull/2574/files#diff-bfe2070e3d8f02013654953e18b60730R273 - Let me know if I'm missing something.
This comment has been minimized.
This comment has been minimized.
jhreis
May 27, 2020
Author
Contributor
That make sense, we will add a ref code check to prevent reading the clipboard again. Will be in a follow PR though, as it doesn't pertain to what this PR is.
|
New commits from @iccub lgtm, ++ |
|
Issue to access clipboard on subsequent launches is being addressed here: https://github.com/brave/brave-ios/pull/2585/files - rest looks good to me |
jhreis commentedMay 22, 2020
•
edited
Summary of Changes
This is fully dependent on #2535, do not merge this before that completes.
This pull request fixes #2565
Submitter Checklist:
NSLocalizableString()Test Plan:
This impacts user referral promo logic, so should test all initial download ids and referral code retrieval paths. Download Id redemption has not touched, as this only impacts app opening logic, but it may be good to run a quick test or two on that as well.
User launches with clipboard referral and internet
F83AB73F-9852-4F01-ABA8-7830B8825993and then the specific ref code (e.g. ABC123) from the referralF83AB73F-9852-4F01-ABA8-7830B8825993:ABC123for exampleUser launches with clipboard referral and no internet
F83AB73F-9852-4F01-ABA8-7830B8825993and then the specific ref code (e.g. ABC123) from the referralF83AB73F-9852-4F01-ABA8-7830B8825993:ABC123for exampleUser launches with no clipboard referral and internet
F83AB73F-9852-4F01-ABA8-7830B8825993:and then the specific ref code (e.g. ABC123) from the referralF83AB73F-9852-4F01-ABA8-7830B8825993:ABC123for exampleUser launches with no clipboard referral and no internet
F83AB73F-9852-4F01-ABA8-7830B8825993:and then the specific ref code (e.g. ABC123) from the referralF83AB73F-9852-4F01-ABA8-7830B8825993:ABC123for exampleScreenshots:
Reviewer Checklist:
QA/(Yes|No)release-notes/(include|exclude)bug/enhancement