[Rewards] Only report ads viewed that have a non-zero value (#29955)
This commit is contained in:
@@ -64,6 +64,7 @@ static constexpr webui::LocalizedString kStrings[] = {
|
||||
IDS_REWARDS_ADS_SETTINGS_SUBDIVISION_AUTO_LABEL},
|
||||
{"adsSettingsTitle", IDS_REWARDS_ADS_SETTINGS_TITLE},
|
||||
{"adsSettingsText", IDS_REWARDS_ADS_SETTINGS_TEXT},
|
||||
{"adsViewedTooltip", IDS_REWARDS_ADS_VIEWED_TOOLTIP},
|
||||
{"adTypeInlineContentLabel", IDS_REWARDS_AD_TYPE_INLINE_CONTENT_LABEL},
|
||||
{"adTypeNewTabPageLabel", IDS_REWARDS_AD_TYPE_NEW_TAB_PAGE_LABEL},
|
||||
{"adTypeNotificationLabel", IDS_REWARDS_AD_TYPE_NOTIFICATION_LABEL},
|
||||
|
||||
@@ -20,7 +20,7 @@ size_t GetAdsReceivedForDateRange(const TransactionList& transactions,
|
||||
return transaction.confirmation_type ==
|
||||
mojom::ConfirmationType::kViewedImpression &&
|
||||
transaction.created_at >= from_time &&
|
||||
transaction.created_at <= to_time;
|
||||
transaction.created_at <= to_time && transaction.value > 0;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ TEST_F(BraveAdsAdsReceivedUtilTest, GetAdsReceivedForDateRange) {
|
||||
AdvanceClockTo(test::TimeFromString("25 December 2020"));
|
||||
|
||||
const TransactionInfo transaction_2 = test::BuildUnreconciledTransaction(
|
||||
/*value=*/0.0, mojom::AdType::kNotificationAd,
|
||||
/*value=*/0.1, mojom::AdType::kNotificationAd,
|
||||
mojom::ConfirmationType::kClicked,
|
||||
/*should_generate_random_uuids=*/true);
|
||||
transactions.push_back(transaction_2);
|
||||
@@ -68,6 +68,13 @@ TEST_F(BraveAdsAdsReceivedUtilTest, GetAdsReceivedForDateRange) {
|
||||
transaction_6.ad_type = mojom::AdType::kInlineContentAd;
|
||||
transactions.push_back(transaction_6);
|
||||
|
||||
TransactionInfo transaction_7 = test::BuildUnreconciledTransaction(
|
||||
/*value=*/0.00, mojom::AdType::kNotificationAd,
|
||||
mojom::ConfirmationType::kViewedImpression,
|
||||
/*should_generate_random_uuids=*/true);
|
||||
transaction_7.ad_type = mojom::AdType::kNewTabPageAd;
|
||||
transactions.push_back(transaction_7);
|
||||
|
||||
// Act
|
||||
const size_t ads_received = GetAdsReceivedForDateRange(
|
||||
transactions, from_time, test::DistantFuture());
|
||||
|
||||
@@ -20,7 +20,7 @@ base::flat_map<mojom::AdType, int32_t> GetAdsSummaryForDateRange(
|
||||
if (transaction.confirmation_type ==
|
||||
mojom::ConfirmationType::kViewedImpression &&
|
||||
transaction.created_at >= from_time &&
|
||||
transaction.created_at <= to_time) {
|
||||
transaction.created_at <= to_time && transaction.value > 0) {
|
||||
++ads_summary[transaction.ad_type];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ TEST_F(BraveAdsAdsSummaryUtilTest, GetAdsSummaryForDateRange) {
|
||||
AdvanceClockTo(test::TimeFromString("25 December 2020"));
|
||||
|
||||
const TransactionInfo transaction_2 = test::BuildUnreconciledTransaction(
|
||||
/*value=*/0.0, mojom::AdType::kNotificationAd,
|
||||
/*value=*/0.1, mojom::AdType::kNotificationAd,
|
||||
mojom::ConfirmationType::kClicked,
|
||||
/*should_generate_random_uuids=*/true);
|
||||
transactions.push_back(transaction_2);
|
||||
@@ -67,6 +67,13 @@ TEST_F(BraveAdsAdsSummaryUtilTest, GetAdsSummaryForDateRange) {
|
||||
transaction_6.ad_type = mojom::AdType::kInlineContentAd;
|
||||
transactions.push_back(transaction_6);
|
||||
|
||||
TransactionInfo transaction_7 = test::BuildUnreconciledTransaction(
|
||||
/*value=*/0.00, mojom::AdType::kNotificationAd,
|
||||
mojom::ConfirmationType::kViewedImpression,
|
||||
/*should_generate_random_uuids=*/true);
|
||||
transaction_7.ad_type = mojom::AdType::kNewTabPageAd;
|
||||
transactions.push_back(transaction_7);
|
||||
|
||||
// Act
|
||||
const base::flat_map<mojom::AdType, int32_t> ads_summary =
|
||||
GetAdsSummaryForDateRange(transactions, from_time, test::DistantFuture());
|
||||
|
||||
+14
-2
@@ -29,15 +29,27 @@ export const style = scoped.css`
|
||||
color: ${color.text.tertiary};
|
||||
text-align: center;
|
||||
min-height: 80px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.counter-value {
|
||||
--leo-icon-size: 16px;
|
||||
--leo-icon-size: 14px;
|
||||
|
||||
position: relative;
|
||||
font: ${font.heading.h2};
|
||||
color: ${color.text.primary};
|
||||
|
||||
leo-tooltip {
|
||||
padding-inline-start: 8px;
|
||||
position: absolute;
|
||||
inset-inline-start: calc(100% + 6px);
|
||||
inset-block-start: 4px;
|
||||
|
||||
[slot=content] {
|
||||
max-width: 250px;
|
||||
text-align: start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import * as React from 'react'
|
||||
import Button from '@brave/leo/react/button'
|
||||
import Icon from '@brave/leo/react/icon'
|
||||
import Tooltip from '@brave/leo/react/tooltip'
|
||||
|
||||
import { formatMessage } from '../../../shared/lib/locale_context'
|
||||
import { useAppState } from '../../lib/app_model_context'
|
||||
@@ -84,6 +85,7 @@ export function EarningCard() {
|
||||
$1: (content) => (
|
||||
<div key='value' className='counter-value'>
|
||||
{content}
|
||||
{renderAdsViewedTooltip()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -115,6 +117,15 @@ export function EarningCard() {
|
||||
)
|
||||
}
|
||||
|
||||
function renderAdsViewedTooltip() {
|
||||
return (
|
||||
<Tooltip mode='default' className='info'>
|
||||
<Icon name='info-outline' />
|
||||
<div slot='content'>{getString('adsViewedTooltip')}</div>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
function renderEarningsCounter() {
|
||||
if (!adsInfo) {
|
||||
return
|
||||
@@ -124,6 +135,7 @@ export function EarningCard() {
|
||||
$1: (content) => (
|
||||
<div key='value' className='counter-value'>
|
||||
{content}
|
||||
{renderAdsViewedTooltip()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ export type StringKey =
|
||||
'adsSettingsSubdivisionAutoLabel' |
|
||||
'adsSettingsTitle' |
|
||||
'adsSettingsText' |
|
||||
'adsViewedTooltip' |
|
||||
'adTypeInlineContentLabel' |
|
||||
'adTypeNewTabPageLabel' |
|
||||
'adTypeNotificationLabel' |
|
||||
|
||||
@@ -30,6 +30,7 @@ export const localeStrings: { [K in StringKey]: string } = {
|
||||
adsSettingsSubdivisionAutoLabel: 'Auto-detect',
|
||||
adsSettingsTitle: 'Ads settings',
|
||||
adsSettingsText: 'Control what kinds of Brave Ads you see, and how often. The more you see, the more you can earn.',
|
||||
adsViewedTooltip: 'This shows the number of Brave Ads you\'ve seen this month that qualify for earning BAT.',
|
||||
adTypeInlineContentLabel: 'Brave News ads',
|
||||
adTypeNewTabPageLabel: 'New tab page ads',
|
||||
adTypeNotificationLabel: 'Notification ads',
|
||||
|
||||
@@ -210,7 +210,6 @@ export const earningsHeaderText = styled.div`
|
||||
|
||||
export const earningsInfo = styled.span`
|
||||
position: relative;
|
||||
display: none;
|
||||
|
||||
.icon {
|
||||
height: 12px;
|
||||
@@ -258,24 +257,6 @@ export const earningsTooltip = styled.div.attrs({ 'data-theme': 'light' })`
|
||||
}
|
||||
`
|
||||
|
||||
export const manageAds = styled.div.attrs({ 'data-theme': 'light' })`
|
||||
margin-top: 14px;
|
||||
|
||||
a {
|
||||
color: ${color.text.interactive};
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.icon {
|
||||
height: 9px;
|
||||
width: auto;
|
||||
color: ${color.icon.interactive};
|
||||
}
|
||||
`
|
||||
|
||||
export const earningsDisplay = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -16,10 +16,8 @@ import { ArrowCircleIcon } from '../icons/arrow_circle_icon'
|
||||
import { BatIcon } from '../icons/bat_icon'
|
||||
import { OptInIcon } from '../icons/optin_icon'
|
||||
import { InfoIcon } from './icons/info_icon'
|
||||
import { CaretIcon } from '../icons/caret_icon'
|
||||
import { TokenAmount } from '../token_amount'
|
||||
import { ExchangeAmount } from '../exchange_amount'
|
||||
import { NewTabLink } from '../new_tab_link'
|
||||
import { SelectCountryCard } from './select_country_card'
|
||||
import { PaymentStatusView } from '../payment_status_view'
|
||||
import { TosUpdateNotice } from '../tos_update_notice'
|
||||
@@ -251,12 +249,6 @@ export function RewardsCard (props: Props) {
|
||||
<div className='tooltip'>
|
||||
<style.earningsTooltip>
|
||||
{getString('rewardsEarningInfoText')}
|
||||
<style.manageAds>
|
||||
<NewTabLink href={urls.settingsURL}>
|
||||
{getString('rewardsManageAds')}
|
||||
<CaretIcon direction='right' />
|
||||
</NewTabLink>
|
||||
</style.manageAds>
|
||||
</style.earningsTooltip>
|
||||
</div>
|
||||
</style.earningsInfo>
|
||||
|
||||
@@ -128,9 +128,6 @@
|
||||
<message name="IDS_REWARDS_WIDGET_CONTINUE" desc="">
|
||||
Continue
|
||||
</message>
|
||||
<message name="IDS_REWARDS_WIDGET_EARNING_INFO_TEXT" desc="">
|
||||
This reflects your estimated earnings range for Brave Ads this month.
|
||||
</message>
|
||||
<message name="IDS_REWARDS_WIDGET_HOW_DOES_IT_WORK" desc="">
|
||||
How does it work?
|
||||
</message>
|
||||
@@ -765,6 +762,9 @@
|
||||
<message name="IDS_REWARDS_ADS_SETTINGS_TEXT" desc="">
|
||||
Control what kinds of Brave Ads you see, and how often. The more you see, the more you can earn.
|
||||
</message>
|
||||
<message name="IDS_REWARDS_ADS_VIEWED_TOOLTIP" desc="">
|
||||
This shows the number of Brave Ads you've seen this month that qualify for earning BAT.
|
||||
</message>
|
||||
<message name="IDS_REWARDS_AD_TYPE_INLINE_CONTENT_LABEL" desc="">
|
||||
Brave News ads
|
||||
</message>
|
||||
|
||||
@@ -262,7 +262,7 @@ base::span<const webui::LocalizedString> GetWebUILocalizedStrings(
|
||||
{"rewardsConnectAccountText", IDS_REWARDS_CONNECT_ACCOUNT_TEXT},
|
||||
{"rewardsContinue", IDS_REWARDS_WIDGET_CONTINUE},
|
||||
{"rewardsEarningsTitle", IDS_REWARDS_ESTIMATED_EARNINGS_TITLE},
|
||||
{"rewardsEarningInfoText", IDS_REWARDS_WIDGET_EARNING_INFO_TEXT},
|
||||
{"rewardsEarningInfoText", IDS_REWARDS_ADS_VIEWED_TOOLTIP},
|
||||
{"rewardsHowDoesItWork", IDS_REWARDS_WIDGET_HOW_DOES_IT_WORK},
|
||||
{"rewardsLearnMore", IDS_REWARDS_LEARN_MORE},
|
||||
{"rewardsManageAds", IDS_REWARDS_WALLET_MANAGE_ADS},
|
||||
@@ -692,7 +692,7 @@ base::span<const webui::LocalizedString> GetWebUILocalizedStrings(
|
||||
{"walletViewStatement", IDS_REWARDS_WALLET_VIEW_STATEMENT},
|
||||
{"walletVerified", IDS_REWARDS_WALLET_VERIFIED},
|
||||
{"walletBalanceTitle", IDS_REWARDS_WALLET_BALANCE_TITLE},
|
||||
{"walletEarningInfoText", IDS_REWARDS_WIDGET_EARNING_INFO_TEXT},
|
||||
{"walletEarningInfoText", IDS_REWARDS_ADS_VIEWED_TOOLTIP},
|
||||
|
||||
{"loading", IDS_BRAVE_REWARDS_LOADING_LABEL},
|
||||
}},
|
||||
|
||||
Reference in New Issue
Block a user