brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.08k stars 2.23k forks source link

`brave://settings/rewards` incorrectly says Brave Rewards are disabled #22003

Closed Miyayes closed 2 years ago

Miyayes commented 2 years ago

Description

@lukaslevert noticed that brave://settings/rewards reports that his Brave Rewards are not enabled, even though he is using Brave Rewards and is verified.

His simultaneous screenshots:

image image

cc: @GeetaSarvadnya

GeetaSarvadnya commented 2 years ago

@lukaslevert - Did you reset rewards and enable AC and Ads switches manually?

I can reproduce the issue in the rewards reset case, the steps are mentioned below:

  1. Clean profile 1.37.109 or 1.38.x
  2. Enable rewards via BR panel/NTP/Hamburger menu
  3. Make sure rewards is enabled in both brave://rewards/ and brave://settings/rewards
  4. Reset the rewards via Manage Brave Rewards
  5. Make sure rewards in disabled in brave://settings/rewards
  6. Make sure Ads and AC switches are OFF and rewards is disabled in brave://rewards
  7. Enable the Ads and AC switches manually in the brave://rewrads page
  8. Reload the brave://settings/rewards page
  9. Rewards is still in disabled mode in settings page although it'e enabled in brave://rewards page
lukaslevert commented 2 years ago

Hey Geeta,

I haven't reset rewards, but I have turned them on and off a handful of times for client demos while walking them through Brave Ads and how a user can opt-in/out of advertising.

Could that be the cause here?

Thanks,

On Thu, Mar 31, 2022 at 7:02 AM GeetaSarvadnya @.***> wrote:

@lukaslevert https://github.com/lukaslevert - Did you reset rewards and enable AC and Ads switches manually?

I can reproduce the issue in the rewards reset case, the steps are mentioned below:

  1. Clean profile
  2. Enable rewards via BR panel/NTP/Hamburger menu
  3. Make sure rewards is enabled in both brave://rewards/ and brave://settings/rewards
  4. Reset the rewards via Manage Brave Rewards
  5. Make sure rewards in disabled in brave://settings/rewards
  6. Make sure Ads and AC switches are OFF and rewards is disabled in brave://rewards
  7. Enable the Ads and AC switches manually in the brave://rewrads page
  8. Reload the brave://settings/rewards page
  9. Rewards is still in disabled mode in settings page although it'e enabled in brave://rewards page

— Reply to this email directly, view it on GitHub https://github.com/brave/brave-browser/issues/22003#issuecomment-1084424796, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATCKYA4MCMDEYEB2JQNPSSTVCWA27ANCNFSM5SDWDUDA . You are receiving this because you were mentioned.Message ID: @.***>

emerick commented 2 years ago

This issue comes about when the brave.rewards.enabled preference (which is essentially our Rewards opt-in preference) gets toggled to false. Looking at our code, I don't see a way for that to occur just by enabling/disabling Ads or Auto-Contribute but I could be missing some subtle interaction there.

I am definitely able to repro the problem when resetting Rewards as in @GeetaSarvadnya's example. The issue in this "reset scenario" is that when a user resets Rewards, as part of that process, we clear all brave.rewards preferences. This includes the brave.rewards.enabled opt-in preference, which is the value that brave://settings/rewards considers when determining if Rewards is enabled or disabled.

In order to fix that particular case, I see three potential approaches:

  1. Resetting Rewards should clear all brave.rewards preferences but it should keep brave.rewards.enabled set to true as the user has already opted-in to Rewards. In fact, this state of affairs is reflected in our UI, as resetting Rewards does not make you opt-in to Rewards again.
  2. Resetting Rewards should clear all brave.rewards preferences including the brave.rewards.enabled "opt-in" preference and the brave://rewards page UI should once again reflect that the user must opt-in to Rewards. (Currently, there is probably some React state that still indicates Rewards is enabled in this scenario, so that would need to be fixed.)
  3. brave://settings could perhaps be made to consider brave.rewards.enabled, the Ads toggle, and the AC toggle. If any one of those are true, then it could consider Rewards to be enabled. I haven't looked deeply into the code to see how feasible this is, but it seems like it could be made to work.

My gut instinct is that 1 would be easiest to achieve and it seems like a reasonable approach that we're already pretty close to. cc: @Miyayes @zenparsing for additional thoughts/opinions.

GeetaSarvadnya commented 2 years ago

Tried a bunch of cases with Ads/AC enables/disable multiple times unable to reproduce the issue that @lukaslevert mentioned. I could reproduce the issue 100% only with the reset rewards case (mentioned above https://github.com/brave/brave-browser/issues/22003#issuecomment-1084424796)

While testing the issue, found a new bug https://github.com/brave/brave-browser/issues/22022. Not sure it's expected or not. cc: @Miyayes @emerick @zenparsing

emerick commented 2 years ago

Spoke with @Miyayes and we'll go with option 2 above (i.e., resetting Rewards should clear all preferences and reset the opt-in state to false as if the user has never seen Rewards before). The Rewards panel actually does seem to show this state correctly after a reset, it's just the brave://rewards page that seems to have cached the opt-in state.

LaurenWags commented 2 years ago

Verified with

Brave | 1.39.86 Chromium: 101.0.4951.41 (Official Build) beta (x86_64)
-- | --
Revision | 93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS | macOS Version 12.3.1 (Build 21E258)

Verified test plan from https://github.com/brave/brave-core/pull/12877#issue-1192154898

MadhaviSeelam commented 2 years ago

Verified PASSED using

Brave 1.39.95 Chromium: 101.0.4951.54 (Official Build) beta (64-bit)
Revision 67da1aeb32cedd27634ca6634fb79cbd85d3f0ab-refs/branch-heads/4951@{#1126}
OS Windows 11 Version 21H2 (Build 22000.613)
ex1 ex2 ex3 ex4 ex5
ResetRewards RewardsPage RewardsPanel Rewardsdisabledafterreset Rewardsenabled
btlechowski commented 2 years ago

Verification passed on

Brave 1.39.100 Chromium: 101.0.4951.61 (Official Build) beta (64-bit)
Revision 3b3633b32c491b4cba5fd7df3c7c0f628547cbcc-refs/branch-heads/4951@{#1189}
OS Ubuntu 18.04 LTS

Verified test plan from https://github.com/brave/brave-core/pull/12877#issue-1192154898