-
Notifications
You must be signed in to change notification settings - Fork 887
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
Enhance and refactor the Brave Ads component updater #8502
Conversation
3051742
to
770d45d
Compare
770d45d
to
b91552a
Compare
b91552a
to
f81643d
Compare
@@ -1903,17 +1903,19 @@ void AdsServiceImpl::Save(const std::string& name, | |||
std::move(callback))); | |||
} | |||
|
|||
void AdsServiceImpl::LoadUserModelForId(const std::string& id, | |||
ads::LoadCallback callback) { | |||
// TODO(Moritz Haller): Naming clash with |LoadResource| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO... :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
const base::Optional<ComponentInfo> component = | ||
GetComponentInfo(country_code); | ||
if (!component) { | ||
VLOG(1) << "no ads resources support for " << country_code; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Ads resource not supported for
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
const base::Optional<ComponentInfo> component = | ||
GetComponentInfo(language_code); | ||
if (!component) { | ||
VLOG(1) << "no ads resources support for " << language_code; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Ads resource not supported for ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
const base::Optional<int> version = manifest->FindIntPath(kSchemaVersionPath); | ||
if (!version) { | ||
VLOG(1) << "resource schema version is missing"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Capitalize R in resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} | ||
|
||
if (*version != kCurrentSchemaVersion) { | ||
VLOG(1) << "resource schema version mismatch"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Capitalize R in resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
const std::string* id = resource_value.FindStringPath(kResourceIdPath); | ||
if (!id) { | ||
VLOG(1) << *id << " resource id is missing"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: instead of *id
you id.value()
@@ -0,0 +1,57 @@ | |||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright for new files should be 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
virtual void OnUserModelUpdated(const std::string& id) = 0; | ||
// Should be called when a resource component has been updated by | ||
// |brave_ads::ResourceComponent| | ||
virtual void OnResourceComponentUpdate(const std::string& id) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OnResourceComponentUpdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
anti_targeting_resource_->Load(); | ||
} else { | ||
BLOG(0, "Unknown " << id << " user model"); | ||
BLOG(0, "Unknown resource " << id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Unknown resource for
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -33,7 +33,9 @@ class NativeAdsClient : public ads::AdsClient { | |||
void UrlRequest(ads::UrlRequestPtr url_request, ads::UrlRequestCallback callback) override; | |||
void Save(const std::string & name, const std::string & value, ads::ResultCallback callback) override; | |||
void Load(const std::string & name, ads::LoadCallback callback) override; | |||
void LoadUserModelForId(const std::string & id, ads::LoadCallback callback) override; | |||
// TODO(Moritz Haller): Add version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed :)
const int kCurrentVersion = 1; | ||
const int kVersion = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between kCurrentVersion
and kVersion
please. If we could rename kVersion
to be more verbose that would be great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed yesterday - removed redundant version and added as feature parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
License script change looks good.
bed7aa3
to
996fa2f
Compare
3f38111
to
a93442a
Compare
Enable a/b testing for different versions of a resource, e.g. text classification. Change name from UserModel to AdsResource and move code into the brave ads component. Finally removing the bat-native-usermodel dependency from ads.
a93442a
to
f62e5af
Compare
CI fails with unrelated issues on macos and linux |
Resolves brave/brave-browser#12856
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
Run with staging endpoint for component updater
--use-dev-goupdater-url
and confirm all resources load for Beta and Nightly, e.g. for localeen-GB
the following output is expectedBeta for en-GB:
Nightly for en-GB:
Then verify that the models work by spot-checking one purchase intent site/keyword and one text classification on each Beta and Nightly, e.g.:
[text_classification_processor.cc(62)] Classified text with the top segment as technology & computing-software
[purchase_intent_processor.cc(99)] Extracted purchase intent signal from visited URL
Analogous for iOS, verify that resources load for old and new versions: