Skip to content

Commit

Permalink
Include PostClick conversion metric for all Brave News users
Browse files Browse the repository at this point in the history
  • Loading branch information
tmancey committed Dec 28, 2021
1 parent b19a172 commit 56fc329
Show file tree
Hide file tree
Showing 5 changed files with 591 additions and 16 deletions.
4 changes: 0 additions & 4 deletions vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc
Expand Up @@ -923,10 +923,6 @@ void AdsImpl::OnFailedToTransferAd(const AdInfo& ad) {

void AdsImpl::OnConversion(
const ConversionQueueItemInfo& conversion_queue_item) {
if (!ShouldRewardUser()) {
return;
}

account_->DepositFunds(conversion_queue_item.creative_instance_id,
conversion_queue_item.ad_type,
ConfirmationType::kConversion);
Expand Down
Expand Up @@ -13,6 +13,7 @@
#include "base/time/time.h"
#include "bat/ads/ads.h"
#include "bat/ads/ads_client.h"
#include "bat/ads/internal/account/account_util.h"
#include "bat/ads/internal/ad_events/ad_event_info.h"
#include "bat/ads/internal/ad_events/ad_events.h"
#include "bat/ads/internal/ads_client_helper.h"
Expand Down Expand Up @@ -52,6 +53,24 @@ bool HasObservationWindowForAdEventExpired(const int observation_window,
return true;
}

bool ShouldConvertAdEvent(const AdEventInfo& ad_event) {
if (ad_event.type == AdType::kInlineContentAd) {
if (ad_event.confirmation_type == ConfirmationType::kViewed) {
// Do not convert views for inline content ads
return false;
}

return true;
}

if (!ShouldRewardUser()) {
// Do not convert if the user has not joined rewards for all other ad types
return false;
}

return true;
}

bool DoesConfirmationTypeMatchConversionType(
const ConfirmationType& confirmation_type,
const std::string& conversion_type) {
Expand Down Expand Up @@ -152,6 +171,10 @@ AdEventList FilterAdEventsForConversion(const AdEventList& ad_events,
return false;
}

if (!ShouldConvertAdEvent(ad_event)) {
return false;
}

if (!DoesConfirmationTypeMatchConversionType(ad_event.confirmation_type,
conversion.type)) {
return false;
Expand Down

0 comments on commit 56fc329

Please sign in to comment.