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

[ads] Do not fetch geo and catalog on iOS when Brave Rewards/News disabled #24570

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

aseren
Copy link
Collaborator

@aseren aseren commented Jul 9, 2024

Resolves brave/brave-browser#39621

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • 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 wiki
    • npm run presubmit wiki, 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:

Test case 1

  • Fresh install
  • Restart the Brave Browser to make griffin seed applied
  • Open Settings -> New Tab Page. Make sure that Background Image Type is Sponsored.
  • Make sure that Brave Ads started and successfully initialized:
    EXPECTATION: There should be a log line: [ads] Successfully initialized ads
  • Make sure that there is NO network request to https://geo.ads.bravesoftware.com/v1/getstate endpoint
  • Make sure that there is NO network request to https://static.ads.bravesoftware.com/v9/catalog endpoint
  • Enable Brave News
  • Make sure that there is network request to https://geo.ads.bravesoftware.com/v1/getstate endpoint
    EXPECTATION: There should be a log lines:
    [ads] URL Request:
      URL: https://geo.ads.bravesoftware.com/v1/getstate
      Method: kGet
    
  • Make sure that there is network request to https://static.ads.bravesoftware.com/v9/catalog endpoint
    EXPECTATION: There should be a log lines:
    [ads] URL Request:
      URL: https://static.ads.bravesoftware.com/v9/catalog
      Method: kGet
    

Test case 2

  • Fresh install
  • Open Settings -> New Tab Page. Change Background Image Type is Default Images.
  • Restart the Brave Browser to make griffin seed applied
  • Make sure that Brave Ads started and successfully initialized:
    EXPECTATION: There should be a log line: [ads] Successfully initialized ads
  • Make sure that there is NO network request to https://geo.ads.bravesoftware.com/v1/getstate endpoint
  • Make sure that there is NO network request to https://static.ads.bravesoftware.com/v9/catalog endpoint
  • Enable Brave News
  • Make sure that there is network request to https://geo.ads.bravesoftware.com/v1/getstate endpoint
    EXPECTATION: There should be a log lines:
    [ads] URL Request:
      URL: https://geo.ads.bravesoftware.com/v1/getstate
      Method: kGet
    
  • Make sure that there is network request to https://static.ads.bravesoftware.com/v9/catalog endpoint
    EXPECTATION: There should be a log lines:
    [ads] URL Request:
      URL: https://static.ads.bravesoftware.com/v9/catalog
      Method: kGet
    

Copy link
Contributor

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

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

brave_news changes LGTM

components/brave_news/browser/locales_helper.h Outdated Show resolved Hide resolved
@aseren aseren requested a review from diracdeltas July 10, 2024 14:30
Copy link
Contributor

[puLL-Merge] - brave/brave-core@24570

Here's my review of the pull request:

Description

This PR refactors the Brave News preferences and P3A (Privacy Preserving Product Analytics) related code. It moves some functionality from the browser directory to the common directory, separates P3A-specific preferences, and updates various imports and function calls across the codebase to reflect these changes.

Changes

Changes

  1. components/brave_news/common/:

    • Moved locales_helper.cc and locales_helper.h from browser/ to common/
    • Added new files p3a_pref_names.cc and p3a_pref_names.h
    • Updated pref_names.cc and pref_names.h
  2. components/brave_news/browser/:

    • Removed locales_helper.cc and locales_helper.h
    • Updated various files to use the new common headers
  3. browser/brave_profile_prefs.cc:

    • Updated function calls to use new namespaces and functions
  4. browser/ui/day_zero_browser_ui_expt/:

    • Updated imports to use new common headers
  5. chromium_src/chrome/browser/prefs/browser_prefs.cc:

    • Updated function calls to use new namespaces
  6. chromium_src/ios/chrome/browser/shared/model/prefs/:

    • Added dependency on brave_news/common
    • Updated browser_prefs.mm to use new functions
  7. ios/brave-ios/Sources/Brave/Frontend/Rewards/BraveRewards.swift:

    • Updated to implement PreferencesObserver
    • Added method to notify ads service about Brave News preference changes
  8. ios/browser/api/ads/brave_ads.h and brave_ads.mm:

    • Added new method notifyBraveNewsIsEnabledPreferenceDidChange:
    • Updated preference handling

Possible Issues

  • The PR doesn't include any updates to tests for the refactored code, which might be necessary to ensure the changes don't introduce any regressions.

Security Hotspots

No significant security issues were identified in this change.

Copy link
Collaborator

@kylehickinson kylehickinson left a comment

Choose a reason for hiding this comment

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

ios++

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

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

chromium_src++

@aseren aseren merged commit 6bb2cf7 into master Jul 10, 2024
17 checks passed
@aseren aseren deleted the issues/39621 branch July 10, 2024 22:32
@github-actions github-actions bot added this to the 1.69.x - Nightly milestone Jul 10, 2024
aseren added a commit that referenced this pull request Jul 12, 2024
[ads] Do not fetch geo and catalog on iOS when Brave Rewards/News disabled
@btlechowski
Copy link

Verified with 1.69.107 on iPhone 13 Pro Max

Testcase 1

image

Brave Ads started and successfully initialized

info	02:52:49.754250+0200	Client	[ads] Successfully initialized ads

there is NO network request to https://geo.ads.bravesoftware.com/v1/getstate endpoint
there is NO network request to https://static.ads.bravesoftware.com/v9/catalog endpoint

there is network request to https://geo.ads.bravesoftware.com/v1/getstate endpoint after enabling Brave News

info	02:48:44.719172+0200	Client	[ads] URL Response:
  URL: https://geo.ads.brave.com/v1/getstate
  Response Status Code: 200

there is network request to https://static.ads.bravesoftware.com/v9/catalog endpoint after enabling Brave News

info	02:48:44.596693+0200	Client	[ads] URL Request:
  URL: https://static.ads.brave.com/v9/catalog
  Method: kGet

Testcase 2

image

Brave Ads started and successfully initialized

info	02:52:49.754250+0200	Client	[ads] Successfully initialized ads

there is NO network request to https://geo.ads.bravesoftware.com/v1/getstate endpoint
there is NO network request to https://static.ads.bravesoftware.com/v9/catalog endpoint

there is network request to https://geo.ads.bravesoftware.com/v1/getstate endpoint after enabling Brave News

info	02:55:51.327893+0200	Client	[ads] URL Request:
  URL: https://geo.ads.brave.com/v1/getstate
  Method: kGet

there is network request to https://static.ads.bravesoftware.com/v9/catalog endpoint after enabling Brave News

info	02:55:51.327385+0200	Client	[ads] URL Request:
  URL: https://static.ads.brave.com/v9/catalog
  Method: kGet

kjozwiak pushed a commit that referenced this pull request Jul 16, 2024
…abled (uplift to 1.68.x) (#24616)

Merge pull request #24570 from brave/issues/39621

[ads] Do not fetch geo and catalog on iOS when Brave Rewards/News disabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ads] Should not fetch geo and catalog on iOS when Brave Rewards/News disabled
8 participants