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

browser requires restart for "x-brave-partner" headers to start working #3143

Closed
kjozwiak opened this issue Jan 29, 2019 · 3 comments · Fixed by brave/brave-core#1493
Closed

Comments

@kjozwiak
Copy link
Member

Description

Similar to #2020 (might be the same issue), the x-brave-partner headers are not being used when initially launching Brave. I'm not 100% sure if it's timed base and we have to wait X amount of minutes before x-brave-partner starts being being used or if there's an issue with the header on first launch. Restarting the browser fixes the problem.

Steps to Reproduce

  1. download & install 0.58.21 Chromium: 71.0.3578.98
  2. launch 0.58.21 and visit https://cheddar.com
  3. open the browser console within DevTools
  4. you'll notice that x-brave-partner: cheddar is missing
  5. restart the browser, open the browser console under https://cheddar.com
  6. you'll notice that x-brave-partner: cheddar is now appearing

Actual result:

screen shot 2019-01-29 at 12 43 41 pm

Expected result:

screen shot 2019-01-29 at 12 47 12 pm

Reproduces how often:

100% reproducible when going through the above STR.

Brave version (brave://version info)

Brave 0.58.21 Chromium: 71.0.3578.98 (Official Build) (64-bit)
Revision 15234034d19b85dcd9a03b164ae89d04145d8368-refs/branch-heads/3578@{#897}
OS Mac OS X

Reproducible on current release:

  • Does it reproduce on brave-browser dev/beta builds?

Yes, also reproducible on the following build:

Brave 0.59.31 Chromium: 72.0.3626.71 (Official Build) (64-bit)
Revision f52ccad2a6a3c65fc9e0c591a517ceab1198dac0-refs/branch-heads/3626@{#763}

Website problems only:

  • Does the issue resolve itself when disabling Brave Shields?

N/A

  • Is the issue reproducible on the latest version of Chrome?

N/A

Additional Information

@GeetaSarvadnya
Copy link

Reproducible on Windows 10 x64 - 0.58.21

image

@emerick
Copy link
Contributor

emerick commented Jan 29, 2019

We have the following logic in our code and I think it's the root cause of the problem:

  // On first run, read the promo code from user-data-dir and
  // initialize the referral.
  bool checked_for_promo_code_file =
      pref_service_->GetBoolean(kReferralCheckedForPromoCodeFile);
  std::string download_id = pref_service_->GetString(kReferralDownloadID);
  if (!checked_for_promo_code_file && download_id.empty())
    task_runner_->PostTaskAndReply(
        FROM_HERE,
        base::Bind(&BraveReferralsService::ReadPromoCode,
                   base::Unretained(this)),
        base::Bind(&BraveReferralsService::OnReadPromoCodeComplete,
                   weak_factory_.GetWeakPtr()));
  else
    FetchReferralHeaders();

If it's the first run, we read the promo code and initialize the referral. If it's not the first run, we fetch the referral headers. That means the first run won't have referral headers until a restart (or until the next time we periodically fetch them, but that's once a day so that's not terribly useful).

Seems like the fix would be to just remove the else and always fetch the referral headers on startup.

cc: @rebron

@GeetaSarvadnya
Copy link

GeetaSarvadnya commented Jan 30, 2019

Verification passed on

Brave 0.59.32 Chromium: 72.0.3626.81 (Official Build) (64-bit)
Revision ac8b982e05014492d1bd7d317628a4f22a97ffa0-refs/branch-heads/3626@{#796}
OS Windows 10
  • Verified the STR from description, x-brave-partner: cheddar is displayed without browser restart

image

Verification passed on

Brave 0.59.32 Chromium: 72.0.3626.81 (Official Build) (64-bit)
Revision ac8b982e05014492d1bd7d317628a4f22a97ffa0-refs/branch-heads/3626@{#796}
OS Windows 7

image

Verified passed with

Brave 0.59.32 Chromium: 72.0.3626.81 (Official Build) (64-bit)
Revision ac8b982e05014492d1bd7d317628a4f22a97ffa0-refs/branch-heads/3626@{#796}
OS Mac OS X
  • Verified partner headers are sent (Barrons, MarketWatch and Cheddar) on fresh installs without needing to restart the browser.

Verification PASSED on macOS 10.14.2 x64 using the following build:

Brave 0.59.33 Chromium: 72.0.3626.81 (Official Build) (64-bit)
Revision ac8b982e05014492d1bd7d317628a4f22a97ffa0-refs/branch-heads/3626@{#796}
OS Mac OS X

MW Test Case:

  • installed using Brave-Browser-dowjones-marketwatch.pkg and ensured that the promotion tab was opened on initial launch and that I could create an account
  • visited https://www.marketwatch.com without restarting the browser and ensured that the X-Brave-Partner: dowjones request header is being sent
  • logged into the newly created account and ensured that I could view Revolution Investing (premium content)
  • Removed the entire profile and re-launched Brave, revisted https://www.marketwatch.com and ensured that the X-Brave-Partner: dowjones request header is being sent (x5 times)
  • logged into the account that I previously created and ensured that I can view the Revolution Investing premium content

Barrons Test Case:

  • installed using Brave-Browser-dowjones-barrons.pkg and ensured that the promotion tab was opened on initial launch and that I could create an account
  • visited https://www.barrons.com without restarting the browser and ensured that the X-Brave-Partner: dowjones request header is being sent
  • Removed the entire profile and re-launched Brave, revisted https://www.barrons.com and ensured that the X-Brave-Partner: dowjones request header is being sent (x5 times)

Cheddar Test Case:

  • ensured that the X-Brave-Partner: cheddar request header is being sent when loading cheddar.com without requiring a restart (x5 times)

Verification passed on

Brave 0.59.32 Chromium: 72.0.3626.81 (Official Build) (64-bit)
Revision ac8b982e05014492d1bd7d317628a4f22a97ffa0-refs/branch-heads/3626@{#796}
OS Linux

screenshot from 2019-01-31 20-30-21

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