Freemium PIR: Refactor Freemium PIR State to Remove Dependency on AccountManager #3197
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.
Task/Issue URL: https://app.asana.com/0/1201621853593513/1208197280287450/f
CC: @miasma13
Description: As an outcome of this discussion, I have refactored
FreemiumPIRUserStateManager
to remove it’s dependency onAccountManager
. This includes the removal of theisActiveUser
computed property. The main reason for this change is as follows:In the app we rely on a single instance of
AccountManager
which is used throughout the app and accessed via the “singleton”Subscription
instance, which is a property on the app delegate. By injecting an instance ofAccountManager
intoFreemiumPIRUserStateManager
, we introduce a new possible point of error. Injecting a new instance ofAccountManager
intoFreemiumPIRUserStateManager
, as opposed to the desired single app instance would result in error. This is particularly concerning when it comes to how we make decisions about running PIR opt-outs or not.By removing this injection of
AccountManager
, clients ofFreemiumPIRUserStateManager
are less likely to inject an incorrect instance ofAccountManager
. In places whereFreemiumPIRUserStateManager
is used to make decisions, we usually have an instance ofSubscription
orAccountManager
defined locally, and so it can be used in combination withFreemiumPIRUserStateManager
to make decisions.The
Freemium
package is now simpler, with no dependencies, and simply manages storedFreemium
state.Testing Prerequisites
DataBrokerProtectionAgentManager
line 205DataBrokerProtectionAgentManager
line 207Steps to test this PR:
Test 1 - Checking initial scan works
Test 2 - Checking background scan does not perform opt-outs
Test 3 - Checking background scan with Subscription DOES perform opt-outs
Definition of Done:
—
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation