duckduckgo / macos-browser

DuckDuckGo macOS Browser
Apache License 2.0
246 stars 9 forks source link

Freemium PIR: Improve Feature Availability Checks By Observing Config & Subscription Changes #3251

Closed aataraxiaa closed 1 month ago

aataraxiaa commented 1 month ago

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

Description: This PR improves upon existing behavior by doing the following:

  1. Updates FreemiumPIRFeature to observe changes to Privacy Config and Subscription status
  2. Moves the declaration of FreemiumPIRFeature to the AppDelegate, to be accessed my multiple, distinct types
  3. Observes Feature Availability changes in the new tab view Promotion Coordinator (future work will likely mean other types will also observe Feature Availability changes)

Testing Prerequisites

  1. Make sure you are an internal user
  2. Disable/Signout of Privacy Pro (Settings menu -> PP -> Remove from this device)
  3. Remove an Freemium DBP data (i.e profile data) - Launch the browser and remove it via the DBP Dashboard Edit My Info button and Turn Personal Information Removal off and delete my information at the bottom
  4. Reset all freemium state via Debug Menu -> Freemium -> RESET ALL STATE
  5. Set the Freemium feature to disabled in this JSON Blob
  6. Set a custom config in the browser via the debug menu to https://www.jsonblob.com/api/1282779040355049472
  7. Relaunch the browser

Steps to test this PR: TEST 1 - ENABLING THE FEATURE FLAG CAUSES A NEW TAB TO DISPLAY THE PROMOTION BANNER

  1. Launch the browser
  2. Ensure the Freemium Promotion banner is NOT visible on the new tab page
  3. Set the Freemium feature to internal in the JSON Blob
  4. Reload the config via the debug menu
  5. Open a new tab
  6. Ensure you see the Promotion banner

TEST 1 - SUBSCRIBING TO PRIVACY PRO REMOVES THE PROMOTION BANNER

  1. With the promotion banner still visible, subscribe to PP (or enter your email and confirm it etc.)
  2. Navigate back to the new tab page
  3. Ensure the Freemium Promotion banner is gone (it may take a second, the internal notification from Subscription code is a bit slow)

Definition of Done:

Internal references:

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

github-actions[bot] commented 1 month ago
Warnings
:warning: PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by :no_entry_sign: dangerJS against ddbc90d0a75c76489c32c506061fa7f80e0555f7