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

Referral promo support (& Dow Jones) #287

Closed
bbondy opened this issue Jun 6, 2018 · 8 comments · Fixed by brave/brave-core#428
Closed

Referral promo support (& Dow Jones) #287

bbondy opened this issue Jun 6, 2018 · 8 comments · Fixed by brave/brave-core#428

Comments

@bbondy
Copy link
Member

bbondy commented Jun 6, 2018

Test plan

See brave/brave-core#428

Description

See below text

@bsclifton
Copy link
Member

bsclifton commented Jun 6, 2018

Both the macOS and Windows installers have the referral code in the executable name (instead of DMG on macOS we use PKG). The installer then strips that out and puts into the user's profile directory

The Windows implementation of the installer uses our fork of electron-winstaller (and the changes aren't very readable... since they involve binary file updates). The changes made for the macOS installer (PKG) are a little more interesting:

  1. Use pkg installer for macOS in addition to of dmg image
    Use pkg installer for macOS in addition to of dmg image browser-laptop#12946
  2. macOS: sign pkg installer
    macOS: sign pkg installer browser-laptop#13033
  3. mac - set file mode and group owner for pkg-installed Brave.app
    mac - set file mode and group owner for pkg-installed Brave.app browser-laptop#13111
  4. Update pkg-installed app permissions to $USER:admin
    Update pkg-installed app permissions to $USER:admin browser-laptop#13132

Here's a link to an internal security review which has a link to a detailed spec (includes API details):
https://github.com/brave/internal/issues/250

Relevant PRs from browser-laptop showing the implementation:

  1. Adds promo
    Adds promo browser-laptop#13667
    Initial promo support

  2. Adds referral code read into browser
    Adds referral code read into browser browser-laptop#12798

    • Basically looks for a file promoCode in the user's profile folder
      • if present, reads it in, stores in state, and deletes the file
      • browser-laptop update service is hit (HTTP PUT) - /promo/initialize/nonua with promoCode
      • update service returns a unique downloadId which is then stored
    • If 30 days have passed, browser-laptop update service is hit again (passing downloadId)
  3. Adds s-s to the referral code
    Adds s-s to the referral code browser-laptop#13756
    Adds support for more use-cases than 3letter/3number

  4. Check userAgent before trying to parse
    Check userAgent before trying to parse browser-laptop#13131
    We had a flaw in above logic (since partners can be sent the Brave UA) which caused a crash

@NejcZdovc NejcZdovc self-assigned this Jun 7, 2018
@emerick emerick assigned emerick and unassigned NejcZdovc Aug 7, 2018
@emerick
Copy link
Contributor

emerick commented Aug 7, 2018

@bsclifton Working on this now. Belated thanks on the great details!

@kjozwiak
Copy link
Member

kjozwiak commented Oct 23, 2018

Win 10 x64 - PASSED

  • installed using BraveBrowserSetup-KAM253.exe
  • ensured that promoCode was being created under C:\Users\kjozwiak\AppData\Local\BraveSoftware\Brave-Browser\User Data
  • waited 10-30s and ensured promoCode was removed from C:\Users\kjozwiak\AppData\Local\BraveSoftware\Brave-Browser\User Data
  • checked Local State for {"brave":{"referral":{"download_id":"75cfc36d-8a8d-4883-bda5-adcc1b5aa1a4","promo_code":"KAM253"}}

Win 10 x86 - PASSED

  • installed using BraveBrowserSetup-86-KAM253.exe
  • ensured that promoCode was being created under C:\Users\kjozwiakBrave\AppData\Local\BraveSoftware\Brave-Browser\User Data\
  • waited 10-30s and ensured promoCode was removed from C:\Users\kjozwiakBrave\AppData\Local\BraveSoftware\Brave-Browser\User Data\
  • checked Local State for {"brave":{"referral":{"download_id":"9d3aa2c6-8a5b-4c27-9aa2-67979c8888cd","promo_code":"KAM253"}}

Win 8.1 x64 - PASSED

  • installed using BraveBrowserSetup-KAM253.exe
  • ensured that promoCode was being created under C:\Users\kamil\AppData\Local\BraveSoftware\Brave-Browser\User Data\
  • waited 10-30s and ensured promoCode was removed from C:\Users\kamil\AppData\Local\BraveSoftware\Brave-Browser\User Data\
  • checked Local State for {"brave":{"referral":{"download_id":"c8da7daa-e980-44c4-a3f0-1335df6cb9fd","promo_code":"KAM253"}}

Win 7 x86 - PASSED

  • installed using BraveBrowserSetup-86-KAM253.exe
  • ensured that promoCode was being created under C:\Users\kjozwiak\AppData\Local\BraveSoftware\Brave-Browser\User Data\
  • waited 10-30s and ensured promoCode was removed from C:\Users\kjozwiak\AppData\Local\BraveSoftware\Brave-Browser\User Data`
  • checked Local State for {"brave":{"referral":{"download_id":"896026da-4aae-495c-8b7e-32c93d7af4b1","promo_code":"KAM253"}}

macOS 10.13.6 x64 - PASSED

  • installed using Brave-Browser-KAM253.pkg
  • ensured that promoCode was being created under ~/Library/Application\ Support/BraveSoftware/Brave-Browser/
  • launched Brave
  • waited 10-30s and ensured promoCode was removed from ~/Library/Application\ Support/BraveSoftware/Brave-Browser/
  • checked Local State for {"brave":{"referral":{"download_id":"fe1126e4-58cc-435a-a5ef-043927eec8d0","promo_code":"KAM253"}}

Win 7 x64 @btlechowski laptop - PASSED

  • installed using BraveBrowserSetup-KAM253.exe
  • ensured that promoCode was being created under [user]\AppData\Local\BraveSoftware\Brave-Browser\User Data
  • waited 10-30s and ensured promoCode was removed from [user]\AppData\Local\BraveSoftware\Brave-Browser\User Data
  • checked Local State for ":{"referral":{"download_id":"8241b72f-9014-440b-ad5f-8bf9c2a50487","promo_code":"KAM253"}}

Win 10 x64 @btlechowski laptop - PASSED

  • installed using BraveBrowserSetup-KAM253.exe
  • ensured that promoCode was being created under [user]\AppData\Local\BraveSoftware\Brave-Browser\User Data
  • waited 10-30s and ensured promoCode was removed from [user]\AppData\Local\BraveSoftware\Brave-Browser\User Data
  • checked Local State for ":{"referral":{,"promo_code":"KAM253"}}

@kjozwiak
Copy link
Member

kjozwiak commented Oct 23, 2018

Once the above test were done, @aekeus sent QA a list of download_id associated with KAM253 and we ensured that the above download_id were being counted/listed in the backend.

QA also ensured that the download count was being incremented via https://publishers.basicattentiontoken.org/publishers/home when going through the above. @srirambv also confirmed this was working correctly for his referral promo's.

@kjozwiak
Copy link
Member

The following issues were found when QAing the dowjones referral promo and moved into https://github.com/brave/brave-browser/milestone/14:

• dowjones promotional tabs not loading instantly after launch (taking ~30s) #1810
• promoCode is never claimed after closing browser just after install #1811
• Download instead of subscription page is shown for dowjones referral promo #1805
• sometimes brave crashes when using barrons or marketwatch promotions #1813

@kjozwiak
Copy link
Member

kjozwiak commented Oct 23, 2018

QA we'll need to work with @emerick to figure out how we can check the following using b-c:

• Verifying that we no longer send referral code to update server after 90 days
• Verifying that that service checks for referral finalization 30 days after referral initialization
• Verifying that service retries checking for referral finalization up to 30 times (with 24-hour pauses between attempts) if it doesn't receive "true" on its first try.

Moving this into https://github.com/brave/brave-browser/milestone/14 till the above is also tested and checked.

@kjozwiak
Copy link
Member

kjozwiak commented Nov 7, 2018

Quick dowjones update: We're now able to create accounts via the promo tab that is launched at startup, however, once logged in, b-c is presented with paywalls even though a promo account is being used within a Brave browser. Created #2020 to address this issue.

@kjozwiak
Copy link
Member

kjozwiak commented Nov 9, 2018

Went through verification using the following build under macOS 10.14 x64 - PASSED

Brave 0.56.12 Chromium: 70.0.3538.77 (Official Build) (64-bit)
Revision 0f6ce0b0cd63a12cb4eccea3637b1bc9a29148d9-refs/branch-heads/3538@{#1039}
OS Mac OS X
  • launch brave via BRAVE_REFERRALS_SERVER=laptop-updates-staging.herokuapp.com (make sure you're using a referral code that's on stating and NOT production)
  • wait 10min (this is what the staging server is set too) or you'll receive Referral is not ready, please wait at least 30 days if you do the below steps without waiting 10min
  • after waiting 10min, relaunch using BRAVE_REFERRALS_SERVER=laptop-updates-staging.herokuapp.com BRAVE_REFERRALS_CHECK_TIME=5
  • you should see a timestamp being created next to the promo_code, example: "promo_code":"MIM486","timestamp":"13186203834926030"
  • confirmed with @aekeus that the referral was finalized on the backend.

Verified passed with macOS 10.12.6 x64 and the following build:

Brave 0.56.12 Chromium: 70.0.3538.77 (Official Build) (64-bit)
Revision 0f6ce0b0cd63a12cb4eccea3637b1bc9a29148d9-refs/branch-heads/3538@{#1039}
OS Mac OS X
  • launch brave via BRAVE_REFERRALS_SERVER=laptop-updates-staging.herokuapp.com (make sure you're using a referral code that's on stating and NOT production)
  • wait 10min (this is what the staging server is set too) or you'll receive Referral is not ready, please wait at least 30 days if you do the below steps without waiting 10min
  • after waiting 10min, relaunch using BRAVE_REFERRALS_SERVER=laptop-updates-staging.herokuapp.com BRAVE_REFERRALS_CHECK_TIME=5
  • you should see a timestamp being created next to the promo_code, example: "promo_code":"LAU795","timestamp":"13186246996115100"
  • confirmed with @aekeus that the referral was finalized on the backend.
  • confirmed for YT site (LAU795), Twitch (ILI371), and other site (KJO580)

Verification Passed on

Brave 0.56.12 Chromium: 70.0.3538.77 (Official Build) (64-bit)
Revision 0f6ce0b0cd63a12cb4eccea3637b1bc9a29148d9-refs/branch-heads/3538@{#1039}
OS Windows
  • launch brave via BRAVE_REFERRALS_SERVER=laptop-updates-staging.herokuapp.com (make sure you're using a referral code that's on stating and NOT production)
  • wait 10min (this is what the staging server is set too) or you'll receive Referral is not ready, please wait at least 30 days if you do the below steps without waiting 10min
  • after waiting 10min, relaunch using BRAVE_REFERRALS_SERVER=laptop-updates-staging.herokuapp.com BRAVE_REFERRALS_CHECK_TIME=5
  • you should see a timestamp being created next to the promo_code, example: "promo_code":"GSA362","timestamp":"13186230193401562"
  • confirmed with @aekeus that the referral was finalized on the backend.
  • confirmed for YT site (SGE795), Twitch (GSA362)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment