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

Disables NetP when the waitlist is over #1588

Merged
merged 6 commits into from
Sep 5, 2023

Conversation

diegoreymendez
Copy link
Contributor

@diegoreymendez diegoreymendez commented Sep 4, 2023

Task/Issue URL: https://app.asana.com/0/0/1205416442924461/f

BSK PR: duckduckgo/BrowserServicesKit#491
iOS PR: duckduckgo/iOS#1975

Description

Disables NetP when the waitlist is over.

Known limitation: we're not disabling NetP if the user interacts with the menu agent. This is something to discuss separately.

Testing:

The following flag is intentionally set to false, since this PR does not know which user signed up for the waitlist beta. It's important to keep this to false until we know with certainty, as setting this to true means we would not have any easter-egg users.

Test 1:

  1. Keep the flag false
  2. Run NetP and reset all state

Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

Comment on lines +841 to +847
<menuItem title="Reset All State Keeping Invite" id="Mqz-Le-LgQ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="resetAllKeepingInvite:" target="Rah-lS-gno" id="ypd-Ao-CzY"/>
</connections>
</menuItem>
<menuItem title="Reset All State" id="p4h-oC-tpw">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I fixed "Reset All State" to truly reset all state, it felt to me we may still want to reset all state while keeping the invite code / auth token.

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 Agreed, this is very useful for debugging.

@@ -131,6 +131,8 @@ final class MoreOptionsMenu: NSMenu {
addItem(withTitle: UserText.networkProtection, action: #selector(showNetworkProtectionStatus(_:)), keyEquivalent: "")
.targetting(self)
.withImage(.image(for: .vpnIcon))
} else {
networkProtectionFeatureVisibility.disableForWaitlistUsers()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Disabling NetP at different points in the UI, and I'm making it a bit more explicit than before.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good, I would like to also add some hooks to check feature flags when the privacy config changes, and when the app becomes active, just to make sure we're catching it as often as possible.

Comment on lines +103 to +109
let featureVisibility = DefaultNetworkProtectionVisibility()

if featureVisibility.isNetworkProtectionVisible() {
showNetworkProtectionPopover(usingView: view, withDelegate: delegate)
} else {
featureVisibility.disableForWaitlistUsers()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

More waitlist verification walls.

guard case .alertFirstButtonReturn = await NSAlert.resetNetworkProtectionAlert().runModal() else { return }

do {
try await debugUtilities.resetAllState(keepAuthToken: true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the gist of the new menu option.

Comment on lines -43 to -44
@UserDefaultsWrapper(key: .networkProtectionOnboardingStatusRawValue, defaultValue: OnboardingStatus.default.rawValue, defaults: .shared)
private(set) var onboardingStatusRawValue: OnboardingStatus.RawValue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving this to a specific class designed to disable NetP that we can use from the debug menu and from here.

try await removeSystemExtensionAndAgents()
onboardingStatusRawValue = OnboardingStatus.default.rawValue
func resetAllState(keepAuthToken: Bool) async throws {
networkProtectionFeatureDisabler.disable(keepAuthToken: keepAuthToken, uninstallSystemExtension: true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the debug options we do want to reset the system extension.

Comment on lines +66 to +67
networkProtectionFeatureDisabler.disableLoginItems()
try await networkProtectionFeatureDisabler.disableSystemExtension()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjusting this to do these things all through the disabler.

guard isWaitlistUser else {
return
}

print("NetP Debug: waitlist user - disabling NetP")
#endif
featureDisabler.disable(keepAuthToken: false, uninstallSystemExtension: false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's wired, so we need to keep the isWaitlistUser to false for now, because that interferes with easter egg users.

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.

LGTM!

diegoreymendez added a commit to duckduckgo/BrowserServicesKit that referenced this pull request Sep 5, 2023
…a small bug with a callback (#491)

Task/Issue URL: https://app.asana.com/0/0/1205416442924462/f

iOS PR: duckduckgo/iOS#1975
macOS PR: duckduckgo/macos-browser#1588
What kind of version bump will this require?: Patch

## Description

When the extension receives a `resetAllState` message, it's now properly cleaning the stored auth token.
Executes a callback that was missing.
diegoreymendez added a commit to duckduckgo/iOS that referenced this pull request Sep 5, 2023
Task/Issue URL: https://app.asana.com/0/0/1205416442924463/f

BSK PR: duckduckgo/BrowserServicesKit#491
macOS PR: duckduckgo/macos-browser#1588

## Description

Integrates some changes from BSK that make NetP now clear the auth token in the extension when `resetAllState` is called.
Also fixes a small bugfix with a callback not being called when it should.
@diegoreymendez diegoreymendez merged commit 627946b into develop Sep 5, 2023
@diegoreymendez diegoreymendez deleted the diego/disable-netp-when-waitlist-is-over branch September 5, 2023 21:03
samsymons added a commit that referenced this pull request Sep 6, 2023
# By Fernando Bunn (3) and others
# Via GitHub
* develop:
  Updates sorting for Autofill UI Logins (#1596)
  Update Scheduler (#1599)
  PacketTunnelProvider crash buttons (#1597)
  swizzle WKNavigationAction.request, return empty request if nil (#1595)
  Better error messages in DBP result screen (#1590)
  Disables NetP when the waitlist is over (#1588)
  Settings Sync Provider with support for syncing Email Protection (#1565)
  Tie Find In Page to Bookmarks Bar (#1591)
  Move LoginItem to its own package (#1577)
  Update post merge failed task description (#1589)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift
#	DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionDebugUtilities.swift
#	DuckDuckGo/Waitlist/NetworkProtectionFeatureVisibility.swift
samsymons pushed a commit that referenced this pull request Sep 8, 2023
Task/Issue URL: https://app.asana.com/0/0/1205416442924461/f

BSK PR: duckduckgo/BrowserServicesKit#491
iOS PR: duckduckgo/iOS#1975

## Description

Disables NetP when the waitlist is over.

Known limitation: we're not disabling NetP if the user interacts with
the menu agent. This is something to discuss separately.
# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	LocalPackages/DataBrokerProtection/Package.swift
#	LocalPackages/NetworkProtectionUI/Package.swift
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.

2 participants