Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make remote config accessible to background agents #3124

Merged
merged 44 commits into from
Sep 17, 2024

Conversation

SlayterDev
Copy link
Contributor

@SlayterDev SlayterDev commented Aug 20, 2024

Copy link

github-actions bot commented Aug 22, 2024

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against 163a815

@SlayterDev SlayterDev marked this pull request as ready for review September 4, 2024 18:09
Copy link
Collaborator

@samsymons samsymons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worked well for me in testing; regular config updates etc. all worked as expected, updating from other targets also worked, and reading feature flags from the VPN looked good. Left some comments on the other PRs.

Copy link
Contributor

@diegoreymendez diegoreymendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments but nothing blocking.

@@ -34,30 +35,84 @@ final class ConfigurationStore: ConfigurationStoring {
.remoteMessagingConfig: "remote-messaging-config.json"
]

static let shared = ConfigurationStore()
private enum Constants {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicky so feel free to ignore.

In my opinion naming this ETag would result in improved readability:

ETag.configStorageTrackerRadar vs Constants.configStorageTrackerRadarEtag

Comment on lines +33 to +34
var trackerDataManager = TrackerDataManager(etag: ConfigurationStore().loadEtag(for: .trackerDataSet),
data: ConfigurationStore().loadData(for: .trackerDataSet),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not going to change much, but maybe take an easy win and instantiate ConfigurationStore() once since we're using it twice here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to opt to leave these as is. These are instantiating properties on the tests so even adding a dedicated property for the store throws an error in Xcode probably because of init order. Refactoring this to simplify it doesn't seem worth it.

Comment on lines +32 to +33
trackerDataManager: TrackerDataManager(etag: ConfigurationStore().loadEtag(for: .trackerDataSet),
data: ConfigurationStore().loadData(for: .trackerDataSet),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another possibility to use the same instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@@ -155,7 +155,7 @@ final class DataBrokerRunCustomJSONViewModel: ObservableObject {
private let authenticationManager: DataBrokerProtectionAuthenticationManaging

init(authenticationManager: DataBrokerProtectionAuthenticationManaging) {
let privacyConfigurationManager = PrivacyConfigurationManagingMock()
let privacyConfigurationManager = DBPPrivacyConfigurationManager()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has anyone from DBP looked at these changes?

SlayterDev added a commit to duckduckgo/BrowserServicesKit that referenced this pull request Sep 17, 2024
<!--
Note: This checklist is a reminder of our shared engineering
expectations.
-->

Please review the release process for BrowserServicesKit
[here](https://app.asana.com/0/1200194497630846/1200837094583426).

**Required**:

Task/Issue URL:
https://app.asana.com/0/1203581873609357/1207165680693234/f
iOS PR: duckduckgo/iOS#3255
macOS PR: duckduckgo/macos-browser#3124
What kind of version bump will this require?: Major
**Optional**:

Tech Design URL:
CC:

**Description**:
This PR modularizes the config to allow it to be used in background
processes

<!--
Tagging instructions
If this PR isn't ready to be merged for whatever reason it should be
marked with the `DO NOT MERGE` label (particularly if it's a draft)
If it's pending Product Review/PFR, please add the `Pending Product
Review` label.

If at any point it isn't actively being worked on/ready for
review/otherwise moving forward (besides the above PR/PFR exception)
strongly consider closing it (or not opening it in the first place). If
you decide not to close it, make sure it's labelled to make it clear the
PRs state and comment with more information.
-->

**Steps to test this PR**:
1. Run the VPN and DBP background agents
2. Look for `Configuration` logs that indicate the config being
downloaded or refreshed
3. If the config is setup correctly you can watch for the pixel test as
well.
1.

<!--
Before submitting a PR, please ensure you have tested the combinations
you expect the reviewer to test, then delete configurations you *know*
do not need explicit testing.

Using a simulator where a physical device is unavailable is acceptable.
-->

**OS Testing**:

* [ ] iOS 14
* [ ] iOS 15
* [ ] iOS 16
* [ ] macOS 10.15
* [ ] macOS 11
* [ ] macOS 12

---
###### Internal references:
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
@SlayterDev SlayterDev merged commit 9cc7e9c into main Sep 17, 2024
18 checks passed
@SlayterDev SlayterDev deleted the brad/background-config branch September 17, 2024 15:26
Copy link
Contributor

@THISISDINOSAUR THISISDINOSAUR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of edits to existing files things look good.

In terms of new files (e.g. ConfigurationManager), I think the horse might have bolted on this since it's the same across the targets, but generally I think it's lacking clarity on the purpose of each thing without having a lot of wider context.

We ideally should refactor the privacy config out of the main app
Into a local package, so that it can be be used here
*/
public final class PrivacyConfigurationManagingMock: PrivacyConfigurationManaging {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My greatest crime removed

static var config: Logger = { Logger(subsystem: Bundle.main.bundleIdentifier ?? "DuckDuckGo", category: "Configuration") }()
}

final class ConfigurationManager: DefaultConfigurationManager {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably a bit late for this since I see the same pattern is used across the different targets, but I think it would be better if this had a more specific name since there's multiple different configurations flying around (e.g. executionConfig)

PixelKit.fire(DebugEvent(domainEvent, error: error))
}

func log() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, I think this could do with a more descriptive name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants