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

Fix state-level ad targeting shown for non-US region #11216

Merged
merged 1 commit into from
Nov 25, 2021

Conversation

emerick
Copy link
Contributor

@emerick emerick commented Nov 22, 2021

Resolves brave/brave-browser#19589

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Follow STR in brave/brave-browser#19589

@emerick emerick requested a review from a team as a code owner November 22, 2021 16:55
@emerick emerick self-assigned this Nov 22, 2021
Copy link
Collaborator

@tmancey tmancey left a comment

Choose a reason for hiding this comment

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

LGTM

@emerick emerick force-pushed the rewards-fix-brave-settings-state-level-targeting branch from ecd4452 to f7f146a Compare November 22, 2021 17:30
@emerick emerick removed the request for review from szilardszaloki November 23, 2021 00:15
@@ -546,6 +546,23 @@ bool AdsServiceImpl::ShouldStart() const {
return IsEnabled() || IsBraveNewsEnabled();
}

base::DictionaryValue AdsServiceImpl::GetSettingsAsValue() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like the motivation for moving this JSON-construction code into the service layer is to avoid sharing it between the rewards page and the rewards extension API, and that the Ads service does JSON-construction already in GetInlineContentAd.

It seems to me that the service layer shouldn't be concerned with how the front-end might need data packaged up, but we currently don't have a good alternative for where to put this code. Options are:

  1. Leave the code duplicated for now, since we expect to deprecate the rewards page in the future.
  2. Move this code to the rewards extension API and have the rewards page use that (I'm pretty sure that chrome.braveRewards is already used there.
  3. Introduce some new class (service?) for JSON-ifying data for rewards UIs.

My personal preference would be for 1 or 2. I'd probably shy away from adding the code to the Ads service since the Ads service shouldn't need to know how the data is used on the settings page or rewards page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes total sense, I'll just copy the function for now.

@emerick emerick force-pushed the rewards-fix-brave-settings-state-level-targeting branch 3 times, most recently from 1dac49a to 2548435 Compare November 24, 2021 20:46
@emerick emerick force-pushed the rewards-fix-brave-settings-state-level-targeting branch from 2548435 to 2f2d9a0 Compare November 24, 2021 20:46
@emerick emerick merged commit 5c23ad5 into master Nov 25, 2021
@emerick emerick deleted the rewards-fix-brave-settings-state-level-targeting branch November 25, 2021 01:54
@emerick emerick added this to the 1.34.x - Nightly milestone Nov 25, 2021
@GeetaSarvadnya
Copy link

GeetaSarvadnya commented Nov 26, 2021

Verification passed on

Brave | 1.34.40 Chromium: 96.0.4664.45 (Official Build) nightly (64-bit)
-- | --
Revision | 76e4c1bb2ab4671b8beba3444e61c0f17584b2fc-refs/branch-heads/4664@{#947}
OS | Windows 10 Version 21H2 (Build 19044.1387)

Confirmed state-level ad targeting dropdown isn't shown for the non-US region India

brave://settings/rewards brave://rewards/
image image

Confirmed state-level ad targeting dropdown is shown only for US region

brave://settings/rewards brave://rewards/
image image

@goodov
Copy link
Member

goodov commented Nov 29, 2021

@emerick I got a DCHECK when I open Settings page:

[98904:10884:1129/174909.495:FATAL:api_response_validator.cc(78)] Check failed: false. Error validating response to `braveRewards.getAdsData`: Error at parameter 'adsIsSupported': Invalid type: expected boolean, found object.

Seems like brave_rewards.json should be like this:

      {
        "name": "getAdsData",
        "type": "function",
        "description": "Gets whether ads is supported in the user's region",
        "parameters": [
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "adsData",
                "type": "object",
                "properties": {
                  "adsIsSupported": {
                    "type": "boolean"
                  },
                  "adsEnabled": {
                    "type": "boolean"
                  },
                  "adsPerHour": {
                    "type": "number"
                  },
                  "adsSubdivisionTargeting": {
                    "type": "string"
                  },
                  "automaticallyDetectedAdsSubdivisionTargeting": {
                    "type": "string"
                  },
                  "shouldAllowAdsSubdivisionTargeting": {
                    "type": "boolean"
                  },
                  "adsUIEnabled": {
                    "type": "boolean"
                  }
                }
              }
            ]
          }
        ]
      },

@emerick
Copy link
Contributor Author

emerick commented Nov 29, 2021

Thanks for catching and reporting this @goodov! I entered brave/brave-browser#19802 to track this.

emerick added a commit that referenced this pull request Nov 29, 2021
…-level-targeting

Fix state-level ad targeting shown for non-US region
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.

State-level ads targeting dropdown is shown for the non-US region in brave://settings/rewards
5 participants