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

Anti-Targeting for Brave Ads #8167

Merged
merged 1 commit into from
Apr 1, 2021
Merged

Anti-Targeting for Brave Ads #8167

merged 1 commit into from
Apr 1, 2021

Conversation

moritzhaller
Copy link
Contributor

@moritzhaller moritzhaller commented Mar 6, 2021

Resolves brave/brave-browser#14224

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:

Detailed test plan https://github.com/brave/internal/issues/767

  • Make sure the anti-targeting resource mkdhnfmjhklfnamlheoliekgeohamoig is added to the staging component for the respective country (matching the test machine system's settings) and the components models.json has been updated.
  • Make sure to have a test catalog with some anti-targeting test lists that match a creative set id from the catalog that is being triggered during test (see below for example)
  • Without having visited a site on the anti-targeting list, verify that the ad with the respective ID is being delivered
  • Now visit a site on the list and verify that the ad with the respective ID is not being delivered [87942:775:0401/172513.733280:VERBOSE2:exclusion_rule_util.h(26)] creativeSetId 5bdeab83-048f-48a7-9602-a1092ded123c excluded as user has previously visited an anti-targeting site

Example anti-targeting test lists

{
  "locale": "gb",
  "version": 1,
  "timestamp": "2021-03-32 00:00:00",
  "sites": {
    "5bdeab83-048f-48a7-9602-a1092ded123c": [
      "https://www.brave.com",
      "https://www.bravesoftware.com/"
    ],
    "ccdaf616-b8a8-481a-aa8b-caf5fb131353": [
      "https://www.bar.org"
    ]
  }
}

@moritzhaller moritzhaller force-pushed the issues/14224 branch 5 times, most recently from 29b7e60 to 2cef13c Compare March 25, 2021 13:29
@moritzhaller moritzhaller changed the title [WIP] Anti-Targeting Anti-Targeting for Brave Ads Mar 25, 2021
@moritzhaller moritzhaller marked this pull request as ready for review March 25, 2021 13:52
@moritzhaller moritzhaller added this to the 1.24.x - Nightly milestone Mar 25, 2021
@moritzhaller moritzhaller force-pushed the issues/14224 branch 2 times, most recently from e1a66fe to f099e14 Compare March 25, 2021 14:47
@moritzhaller moritzhaller force-pushed the issues/14224 branch 2 times, most recently from a2c15fd to bff6d16 Compare March 26, 2021 12:46
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.

Stubs look good, implementation of the callback just needs fixing but other than that 👍

vendor/brave-ios/Ads/BATBraveAds.mm Outdated Show resolved Hide resolved
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++

@moritzhaller moritzhaller force-pushed the issues/14224 branch 4 times, most recently from 8031132 to ca67885 Compare April 1, 2021 08:00
Comment on lines +5 to +6
# Remove when https://github.com/brave/brave-browser/issues/10639 is resolved
check_includes = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need these?

Copy link
Contributor

Choose a reason for hiding this comment

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

this should have been removed @moritzhaller

@@ -94,6 +97,7 @@ class BatAdsAdNotificationPacingTest : public UnitTestBase {
std::unique_ptr<AdTargeting> ad_targeting_;
std::unique_ptr<ad_targeting::geographic::SubdivisionTargeting>
subdivision_targeting_;
std::unique_ptr<resource::AntiTargeting> anti_targeting_;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: anti_targeting_resource_

@@ -33,7 +38,8 @@ class AdServing {
public:
AdServing(
AdTargeting* ad_targeting,
ad_targeting::geographic::SubdivisionTargeting* subdivision_targeting);
ad_targeting::geographic::SubdivisionTargeting* subdivision_targeting,
resource::AntiTargeting* anti_targeting);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: anti_targeting_resource

@@ -97,6 +106,8 @@ class AdServing {

ad_targeting::geographic::SubdivisionTargeting*
subdivision_targeting_; // NOT OWNED

resource::AntiTargeting* anti_targeting_; // NOT OWNED
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: anti_targeting_resource_

return;
}

BLOG(1, "Successfully loaded resource " << kResourceId);
Copy link
Collaborator

@tmancey tmancey Apr 1, 2021

Choose a reason for hiding this comment

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

nit: Successfully loaded anti-targeting resource ... (same for other logs, check if console logs contain filename and if so we then do not need the verbosity)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

file name shows in log, so keeping as is for now


AntiTargetingInfo anti_targeting = anti_targeting_->get();
const auto iter = anti_targeting.sites.find(ad.creative_set_id);
// Always respect if creative set has no anti-targeting sites
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: move to inside if statement

- (void)getBrowsingHistory:(const int)max_count
forDays:(const int)days_ago
callback:(ads::GetBrowsingHistoryCallback)callback {
// Not implemented for iOS
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: 'To be implementedwith a link to abrave-ios` issue so that the work can be prioritized

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++

@moritzhaller moritzhaller merged commit 21f9100 into master Apr 1, 2021
@moritzhaller moritzhaller deleted the issues/14224 branch April 1, 2021 22:56
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.

Implement Brave Ads anti-targeting
4 participants