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

Implement ad conversion attribution for Brave Ads #4253

Merged
merged 9 commits into from
Jan 9, 2020
Merged

Conversation

tmancey
Copy link
Collaborator

@tmancey tmancey commented Dec 18, 2019

Fixes brave/brave-browser#6536
Requires: #3980

Submitter Checklist:

Test Plan:

See brave/brave-browser#6536

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@tmancey
Copy link
Collaborator Author

tmancey commented Dec 18, 2019

@karenkliu @jenn-rhim Could you please confirm if the design below for "Opt-out of ad conversions" is ok, or if you would like changes:

Screenshot 2019-12-18 at 14 42 42

Screenshot 2019-12-18 at 14 42 50

@@ -173,6 +174,17 @@ std::unique_ptr<BundleState> Bundle::GenerateFromCatalog(
}
}

// Conversions
for (const auto& conversion : creative_set.conversions) {
AdConversionInfo ad_conversion_info;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we initialize ad_conversion_info with copy constructor here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed as refactored code to use a single data structure

GetDB().RollbackTransaction();
return false;
}

auto categories = bundle_state.categories;
for (std::map<std::string, std::vector<ads::AdInfo>>::iterator it =
categories.begin(); it != categories.end(); ++it) {
for (auto it = categories.begin(); it != categories.end(); ++it) {
Copy link
Contributor

Choose a reason for hiding this comment

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

end is called on every iteration if not optimized by compiler. We can read this value before for-loop and use it in condition evaluation statement. range-based for loops are even more readable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

components/brave_ads/browser/ads_service_impl.cc Outdated Show resolved Hide resolved

AdConversionInfo::~AdConversionInfo() = default;

const std::string AdConversionInfo::ToJson() const {
Copy link
Member

Choose a reason for hiding this comment

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

as far as std::string is a component of a standard library we can assume it is a built-in type. You should avoid confusing the client programmer and leave off the const when returning a built-in type by value. That technique works good with user-defined types otherwise it creates unneeded confusion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@tmancey tmancey force-pushed the issues/6536 branch 11 times, most recently from eb41207 to ec08a77 Compare December 20, 2019 03:31
@NejcZdovc NejcZdovc modified the milestones: 1.4.x - Dev, 1.5.x - Nightly Jan 3, 2020
@tmancey tmancey added CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux labels Jan 3, 2020
@tmancey
Copy link
Collaborator Author

tmancey commented Jan 3, 2020

All passed other than macOS, restarting macOS

@tmancey tmancey removed CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux labels Jan 4, 2020
Copy link
Contributor

@NejcZdovc NejcZdovc left a comment

Choose a reason for hiding this comment

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

rewards code looks good

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.

Implement ad conversion attribution for Brave Ads
8 participants