Skip to content

Commit

Permalink
Implement promoted content ads
Browse files Browse the repository at this point in the history
  • Loading branch information
tmancey committed Jan 14, 2021
1 parent 7df8720 commit 2ea1555
Show file tree
Hide file tree
Showing 107 changed files with 4,098 additions and 198 deletions.
7 changes: 6 additions & 1 deletion components/brave_ads/browser/ads_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,15 @@ class AdsService : public KeyedService {
const std::string& id) = 0;

virtual void OnNewTabPageAdEvent(
const std::string& wallpaper_id,
const std::string& uuid,
const std::string& creative_instance_id,
const ads::mojom::BraveAdsNewTabPageAdEventType event_type) = 0;

virtual void OnPromotedContentAdEvent(
const std::string& uuid,
const std::string& creative_instance_id,
const ads::mojom::BraveAdsPromotedContentAdEventType event_type) = 0;

virtual void ReconcileAdRewards() = 0;

virtual void GetAdsHistory(
Expand Down
15 changes: 13 additions & 2 deletions components/brave_ads/browser/ads_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1016,14 +1016,25 @@ void AdsServiceImpl::OnViewAdNotification(
}

void AdsServiceImpl::OnNewTabPageAdEvent(
const std::string& wallpaper_id,
const std::string& uuid,
const std::string& creative_instance_id,
const ads::NewTabPageAdEventType event_type) {
if (!connected()) {
return;
}

bat_ads_->OnNewTabPageAdEvent(wallpaper_id, creative_instance_id, event_type);
bat_ads_->OnNewTabPageAdEvent(uuid, creative_instance_id, event_type);
}

void AdsServiceImpl::OnPromotedContentAdEvent(
const std::string& uuid,
const std::string& creative_instance_id,
const ads::PromotedContentAdEventType event_type) {
if (!connected()) {
return;
}

bat_ads_->OnPromotedContentAdEvent(uuid, creative_instance_id, event_type);
}

void AdsServiceImpl::RetryViewingAdNotification(
Expand Down
7 changes: 6 additions & 1 deletion components/brave_ads/browser/ads_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,15 @@ class AdsServiceImpl : public AdsService,
const std::string& id) override;

void OnNewTabPageAdEvent(
const std::string& wallpaper_id,
const std::string& uuid,
const std::string& creative_instance_id,
const ads::NewTabPageAdEventType event_type) override;

void OnPromotedContentAdEvent(
const std::string& uuid,
const std::string& creative_instance_id,
const ads::PromotedContentAdEventType event_type) override;

void ReconcileAdRewards() override;

void GetAdsHistory(
Expand Down
5 changes: 5 additions & 0 deletions components/brave_ads/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ source_set("brave_ads_unit_tests") {
"//brave/vendor/bat-native-ads/src/bat/ads/internal/database/tables/creative_ad_notifications_database_table_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/database/tables/creative_new_tab_page_ads_database_table_test.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/database/tables/creative_new_tab_page_ads_database_table_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/database/tables/creative_promoted_content_ads_database_table_test.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/database/tables/creative_promoted_content_ads_database_table_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/eligible_ads/ad_notifications/eligible_ad_notifications_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/features/bandits/epsilon_greedy_bandit_features_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent/purchase_intent_features_unittest.cc",
Expand All @@ -61,6 +63,7 @@ source_set("brave_ads_unit_tests") {
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/exclusion_rules/new_tab_page_ad_uuid_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/exclusion_rules/per_day_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/exclusion_rules/per_hour_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/exclusion_rules/promoted_content_ad_uuid_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/exclusion_rules/subdivision_targeting_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/exclusion_rules/total_max_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/exclusion_rules/transferred_frequency_cap_unittest.cc",
Expand All @@ -77,6 +80,8 @@ source_set("brave_ads_unit_tests") {
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/permission_rules/network_connection_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/permission_rules/new_tab_page_ads_per_day_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/permission_rules/new_tab_page_ads_per_hour_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/permission_rules/promoted_content_ads_per_day_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/permission_rules/promoted_content_ads_per_hour_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/permission_rules/unblinded_tokens_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/frequency_capping/permission_rules/user_activity_frequency_cap_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/legacy_migration/legacy_migration_util_unittest.cc",
Expand Down
11 changes: 9 additions & 2 deletions components/services/bat_ads/bat_ads_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,17 @@ void BatAdsImpl::OnAdNotificationEvent(
}

void BatAdsImpl::OnNewTabPageAdEvent(
const std::string& wallpaper_id,
const std::string& uuid,
const std::string& creative_instance_id,
const ads::NewTabPageAdEventType event_type) {
ads_->OnNewTabPageAdEvent(wallpaper_id, creative_instance_id, event_type);
ads_->OnNewTabPageAdEvent(uuid, creative_instance_id, event_type);
}

void BatAdsImpl::OnPromotedContentAdEvent(
const std::string& uuid,
const std::string& creative_instance_id,
const ads::PromotedContentAdEventType event_type) {
ads_->OnPromotedContentAdEvent(uuid, creative_instance_id, event_type);
}

void BatAdsImpl::RemoveAllHistory(
Expand Down
7 changes: 6 additions & 1 deletion components/services/bat_ads/bat_ads_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,15 @@ class BatAdsImpl :
const ads::AdNotificationEventType event_type) override;

void OnNewTabPageAdEvent(
const std::string& wallpaper_id,
const std::string& uuid,
const std::string& creative_instance_id,
const ads::NewTabPageAdEventType event_type) override;

void OnPromotedContentAdEvent(
const std::string& uuid,
const std::string& creative_instance_id,
const ads::PromotedContentAdEventType event_type) override;

void RemoveAllHistory(
RemoveAllHistoryCallback callback) override;

Expand Down
3 changes: 2 additions & 1 deletion components/services/bat_ads/public/interfaces/bat_ads.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ interface BatAds {
OnTabClosed(int32 tab_id);
GetAdNotification(string uuid) => (string json);
OnAdNotificationEvent(string uuid, ads.mojom.BraveAdsAdNotificationEventType event_type);
OnNewTabPageAdEvent(string wallpaper_id, string creative_instance_id, ads.mojom.BraveAdsNewTabPageAdEventType event_type);
OnNewTabPageAdEvent(string uuid, string creative_instance_id, ads.mojom.BraveAdsNewTabPageAdEventType event_type);
OnPromotedContentAdEvent(string uuid, string creative_instance_id, ads.mojom.BraveAdsPromotedContentAdEventType event_type);
RemoveAllHistory() => (int32 result);
OnWalletUpdated(string payment_id, string seed);
ReconcileAdRewards();
Expand Down
35 changes: 31 additions & 4 deletions vendor/bat-native-ads/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ source_set("headers") {
"include/bat/ads/export.h",
"include/bat/ads/new_tab_page_ad_info.h",
"include/bat/ads/pref_names.h",
"include/bat/ads/promoted_content_ad_info.h",
"include/bat/ads/result.h",
"include/bat/ads/statement_info.h",
"include/bat/ads/transaction_info.h",
Expand Down Expand Up @@ -160,6 +161,12 @@ source_set("ads") {
"src/bat/ads/internal/ad_events/new_tab_page_ads/new_tab_page_ad_event_factory.h",
"src/bat/ads/internal/ad_events/new_tab_page_ads/new_tab_page_ad_event_viewed.cc",
"src/bat/ads/internal/ad_events/new_tab_page_ads/new_tab_page_ad_event_viewed.h",
"src/bat/ads/internal/ad_events/promoted_content_ads/promoted_content_ad_event_clicked.cc",
"src/bat/ads/internal/ad_events/promoted_content_ads/promoted_content_ad_event_clicked.h",
"src/bat/ads/internal/ad_events/promoted_content_ads/promoted_content_ad_event_factory.cc",
"src/bat/ads/internal/ad_events/promoted_content_ads/promoted_content_ad_event_factory.h",
"src/bat/ads/internal/ad_events/promoted_content_ads/promoted_content_ad_event_viewed.cc",
"src/bat/ads/internal/ad_events/promoted_content_ads/promoted_content_ad_event_viewed.h",
"src/bat/ads/internal/ad_pacing/ad_notifications/ad_notification_pacing.cc",
"src/bat/ads/internal/ad_pacing/ad_notifications/ad_notification_pacing.h",
"src/bat/ads/internal/ad_server/ad_server.cc",
Expand All @@ -173,12 +180,12 @@ source_set("ads") {
"src/bat/ads/internal/ad_serving/ad_targeting/geographic/subdivision/get_subdivision_url_request_builder.h",
"src/bat/ads/internal/ad_serving/ad_targeting/geographic/subdivision/subdivision_targeting.cc",
"src/bat/ads/internal/ad_serving/ad_targeting/geographic/subdivision/subdivision_targeting.h",
"src/bat/ads/internal/ad_serving/ad_targeting/models/behavioral/bandits/epsilon_greedy_bandit_model_values.h",
"src/bat/ads/internal/ad_serving/ad_targeting/models/behavioral/bandits/epsilon_greedy_bandit_model.cc",
"src/bat/ads/internal/ad_serving/ad_targeting/models/behavioral/bandits/epsilon_greedy_bandit_model.h",
"src/bat/ads/internal/ad_serving/ad_targeting/models/behavioral/purchase_intent/purchase_intent_model_values.h",
"src/bat/ads/internal/ad_serving/ad_targeting/models/behavioral/bandits/epsilon_greedy_bandit_model_values.h",
"src/bat/ads/internal/ad_serving/ad_targeting/models/behavioral/purchase_intent/purchase_intent_model.cc",
"src/bat/ads/internal/ad_serving/ad_targeting/models/behavioral/purchase_intent/purchase_intent_model.h",
"src/bat/ads/internal/ad_serving/ad_targeting/models/behavioral/purchase_intent/purchase_intent_model_values.h",
"src/bat/ads/internal/ad_serving/ad_targeting/models/contextual/text_classification/text_classification_model.cc",
"src/bat/ads/internal/ad_serving/ad_targeting/models/contextual/text_classification/text_classification_model.h",
"src/bat/ads/internal/ad_serving/ad_targeting/models/model.h",
Expand Down Expand Up @@ -214,12 +221,12 @@ source_set("ads") {
"src/bat/ads/internal/ad_targeting/processors/behavioral/bandits/bandit_feedback_info.h",
"src/bat/ads/internal/ad_targeting/processors/behavioral/bandits/epsilon_greedy_bandit_processor.cc",
"src/bat/ads/internal/ad_targeting/processors/behavioral/bandits/epsilon_greedy_bandit_processor.h",
"src/bat/ads/internal/ad_targeting/processors/behavioral/purchase_intent/purchase_intent_processor_values.h",
"src/bat/ads/internal/ad_targeting/processors/behavioral/purchase_intent/purchase_intent_processor.cc",
"src/bat/ads/internal/ad_targeting/processors/behavioral/purchase_intent/purchase_intent_processor.h",
"src/bat/ads/internal/ad_targeting/processors/contextual/text_classification/text_classification_processor_values.h",
"src/bat/ads/internal/ad_targeting/processors/behavioral/purchase_intent/purchase_intent_processor_values.h",
"src/bat/ads/internal/ad_targeting/processors/contextual/text_classification/text_classification_processor.cc",
"src/bat/ads/internal/ad_targeting/processors/contextual/text_classification/text_classification_processor.h",
"src/bat/ads/internal/ad_targeting/processors/contextual/text_classification/text_classification_processor_values.h",
"src/bat/ads/internal/ad_targeting/processors/processor.h",
"src/bat/ads/internal/ad_targeting/resources/behavioral/bandits/epsilon_greedy_bandit_resource.cc",
"src/bat/ads/internal/ad_targeting/resources/behavioral/bandits/epsilon_greedy_bandit_resource.h",
Expand All @@ -238,6 +245,9 @@ source_set("ads") {
"src/bat/ads/internal/ads/new_tab_page_ads/new_tab_page_ad.cc",
"src/bat/ads/internal/ads/new_tab_page_ads/new_tab_page_ad.h",
"src/bat/ads/internal/ads/new_tab_page_ads/new_tab_page_ad_observer.h",
"src/bat/ads/internal/ads/promoted_content_ads/promoted_content_ad.cc",
"src/bat/ads/internal/ads/promoted_content_ads/promoted_content_ad.h",
"src/bat/ads/internal/ads/promoted_content_ads/promoted_content_ad_observer.h",
"src/bat/ads/internal/ads_client_helper.cc",
"src/bat/ads/internal/ads_client_helper.h",
"src/bat/ads/internal/ads_history/ads_history.cc",
Expand Down Expand Up @@ -270,6 +280,8 @@ source_set("ads") {
"src/bat/ads/internal/bundle/creative_ad_notification_info.h",
"src/bat/ads/internal/bundle/creative_new_tab_page_ad_info.cc",
"src/bat/ads/internal/bundle/creative_new_tab_page_ad_info.h",
"src/bat/ads/internal/bundle/creative_promoted_content_ad_info.cc",
"src/bat/ads/internal/bundle/creative_promoted_content_ad_info.h",
"src/bat/ads/internal/catalog/catalog.cc",
"src/bat/ads/internal/catalog/catalog.h",
"src/bat/ads/internal/catalog/catalog_ad_notification_payload_info.cc",
Expand All @@ -282,6 +294,8 @@ source_set("ads") {
"src/bat/ads/internal/catalog/catalog_creative_info.h",
"src/bat/ads/internal/catalog/catalog_creative_new_tab_page_ad_info.cc",
"src/bat/ads/internal/catalog/catalog_creative_new_tab_page_ad_info.h",
"src/bat/ads/internal/catalog/catalog_creative_promoted_content_ad_info.cc",
"src/bat/ads/internal/catalog/catalog_creative_promoted_content_ad_info.h",
"src/bat/ads/internal/catalog/catalog_creative_set_info.cc",
"src/bat/ads/internal/catalog/catalog_creative_set_info.h",
"src/bat/ads/internal/catalog/catalog_daypart_info.cc",
Expand All @@ -296,6 +310,8 @@ source_set("ads") {
"src/bat/ads/internal/catalog/catalog_new_tab_page_ad_payload_info.h",
"src/bat/ads/internal/catalog/catalog_os_info.cc",
"src/bat/ads/internal/catalog/catalog_os_info.h",
"src/bat/ads/internal/catalog/catalog_promoted_content_ad_payload_info.cc",
"src/bat/ads/internal/catalog/catalog_promoted_content_ad_payload_info.h",
"src/bat/ads/internal/catalog/catalog_segment_info.cc",
"src/bat/ads/internal/catalog/catalog_segment_info.h",
"src/bat/ads/internal/catalog/catalog_state.cc",
Expand Down Expand Up @@ -358,6 +374,8 @@ source_set("ads") {
"src/bat/ads/internal/database/tables/creative_ads_database_table.h",
"src/bat/ads/internal/database/tables/creative_new_tab_page_ads_database_table.cc",
"src/bat/ads/internal/database/tables/creative_new_tab_page_ads_database_table.h",
"src/bat/ads/internal/database/tables/creative_promoted_content_ads_database_table.cc",
"src/bat/ads/internal/database/tables/creative_promoted_content_ads_database_table.h",
"src/bat/ads/internal/database/tables/dayparts_database_table.cc",
"src/bat/ads/internal/database/tables/dayparts_database_table.h",
"src/bat/ads/internal/database/tables/geo_targets_database_table.cc",
Expand Down Expand Up @@ -402,6 +420,8 @@ source_set("ads") {
"src/bat/ads/internal/frequency_capping/exclusion_rules/per_day_frequency_cap.h",
"src/bat/ads/internal/frequency_capping/exclusion_rules/per_hour_frequency_cap.cc",
"src/bat/ads/internal/frequency_capping/exclusion_rules/per_hour_frequency_cap.h",
"src/bat/ads/internal/frequency_capping/exclusion_rules/promoted_content_ad_uuid_frequency_cap.cc",
"src/bat/ads/internal/frequency_capping/exclusion_rules/promoted_content_ad_uuid_frequency_cap.h",
"src/bat/ads/internal/frequency_capping/exclusion_rules/subdivision_targeting_frequency_cap.cc",
"src/bat/ads/internal/frequency_capping/exclusion_rules/subdivision_targeting_frequency_cap.h",
"src/bat/ads/internal/frequency_capping/exclusion_rules/total_max_frequency_cap.cc",
Expand Down Expand Up @@ -437,10 +457,16 @@ source_set("ads") {
"src/bat/ads/internal/frequency_capping/permission_rules/permission_rule.h",
"src/bat/ads/internal/frequency_capping/permission_rules/permission_rule_util.cc",
"src/bat/ads/internal/frequency_capping/permission_rules/permission_rule_util.h",
"src/bat/ads/internal/frequency_capping/permission_rules/promoted_content_ads_per_day_frequency_cap.cc",
"src/bat/ads/internal/frequency_capping/permission_rules/promoted_content_ads_per_day_frequency_cap.h",
"src/bat/ads/internal/frequency_capping/permission_rules/promoted_content_ads_per_hour_frequency_cap.cc",
"src/bat/ads/internal/frequency_capping/permission_rules/promoted_content_ads_per_hour_frequency_cap.h",
"src/bat/ads/internal/frequency_capping/permission_rules/unblinded_tokens_frequency_cap.cc",
"src/bat/ads/internal/frequency_capping/permission_rules/unblinded_tokens_frequency_cap.h",
"src/bat/ads/internal/frequency_capping/permission_rules/user_activity_frequency_cap.cc",
"src/bat/ads/internal/frequency_capping/permission_rules/user_activity_frequency_cap.h",
"src/bat/ads/internal/frequency_capping/promoted_content_ads/promoted_content_ads_frequency_capping.cc",
"src/bat/ads/internal/frequency_capping/promoted_content_ads/promoted_content_ads_frequency_capping.h",
"src/bat/ads/internal/json_helper.cc",
"src/bat/ads/internal/json_helper.h",
"src/bat/ads/internal/legacy_migration/legacy_migration_util.cc",
Expand Down Expand Up @@ -532,6 +558,7 @@ source_set("ads") {
"src/bat/ads/internal/user_activity/user_activity.h",
"src/bat/ads/new_tab_page_ad_info.cc",
"src/bat/ads/pref_names.cc",
"src/bat/ads/promoted_content_ad_info.cc",
"src/bat/ads/statement_info.cc",
"src/bat/ads/transaction_info.cc",
]
Expand Down
26 changes: 26 additions & 0 deletions vendor/bat-native-ads/data/resources/catalog-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,32 @@
},
"additionalProperties": false
},
{
"properties": {
"domain": {
"type": "string"
},
"feed": {
"type": "string"
},
"title": {
"type": "string"
},
"category": {
"type": "string"
},
"ogImages": {
"type": "boolean"
},
"contentType": {
"type": "string"
},
"description": {
"type": "string"
}
},
"additionalProperties": false
},
{
"properties": {
"logo": {
Expand Down
Loading

0 comments on commit 2ea1555

Please sign in to comment.