[ads] NTT metric reporting (#28080)

* [ads] Report new tab page ad metrics via confirmation with an optional fallback to P3A

* [ads] Always serve new tab page ads through the component

* [ads] Do not frequency cap last served new tab page ad

* [ads] Deprecate redundant conditon matcher code

* [ads] Transition to v4 confirmation endpoint

* [ads] Include firstTime in the confirmation payload if it is the first impression for the campaign

* [ads] Deprecate HTTP_IM_A_TEAPOT

* [ads] Do not load unnecessary resources

* [ads] Migrate P3A opted-in status

* [ads] Deprecate AdInfoMatchesSponsoredImage

* [ads] Add ad events to brave://ads-internals

* [ads] Optimize firstTime database query

* [ads] Purge ad events when opting out

* [ads] Add grace period

* [ads] General code health

* [ads] Purge Brave News ads for all users when opting out
This commit is contained in:
Terry Mancey
2025-03-21 17:01:23 +01:00
committed by GitHub
parent c0995e1dbe
commit f1545f26f0
129 changed files with 2581 additions and 1438 deletions
@@ -94,10 +94,14 @@ public class NTPBackgroundImagesBridge {
}
public void wallpaperLogoClicked(Wallpaper wallpaper) {
NTPBackgroundImagesBridgeJni.get().wallpaperLogoClicked(
mNativeNTPBackgroundImagesBridge, NTPBackgroundImagesBridge.this,
wallpaper.getCreativeInstanceId(),
wallpaper.getLogoDestinationUrl(), wallpaper.getWallpaperId());
NTPBackgroundImagesBridgeJni.get()
.wallpaperLogoClicked(
mNativeNTPBackgroundImagesBridge,
NTPBackgroundImagesBridge.this,
wallpaper.getWallpaperId(),
wallpaper.getCreativeInstanceId(),
wallpaper.getLogoDestinationUrl(),
wallpaper.shouldMetricsFallbackToP3a());
}
public boolean isSuperReferral() {
@@ -156,7 +160,8 @@ public class NTPBackgroundImagesBridge {
boolean isSponsored,
String creativeInstanceId,
String wallpaperId,
boolean isRichMedia) {
boolean isRichMedia,
boolean shouldMetricsFallbackToP3a) {
return new Wallpaper(
imagePath,
focalPointX,
@@ -167,7 +172,8 @@ public class NTPBackgroundImagesBridge {
isSponsored,
creativeInstanceId,
wallpaperId,
isRichMedia);
isRichMedia,
shouldMetricsFallbackToP3a);
}
@CalledByNative
@@ -180,23 +186,33 @@ public class NTPBackgroundImagesBridge {
@NativeMethods
interface Natives {
NTPBackgroundImagesBridge getInstance(Profile profile);
NTPImage getCurrentWallpaper(
long nativeNTPBackgroundImagesBridge, NTPBackgroundImagesBridge caller);
void registerPageView(long nativeNTPBackgroundImagesBridge,
NTPBackgroundImagesBridge caller);
void wallpaperLogoClicked(long nativeNTPBackgroundImagesBridge,
NTPBackgroundImagesBridge caller,
String creativeInstanceId,
String destinationUrl, String wallpaperId);
void getTopSites(long nativeNTPBackgroundImagesBridge,
NTPBackgroundImagesBridge caller);
boolean isSuperReferral(long nativeNTPBackgroundImagesBridge,
NTPBackgroundImagesBridge caller);
String getSuperReferralThemeName(long nativeNTPBackgroundImagesBridge,
NTPBackgroundImagesBridge caller);
String getSuperReferralCode(long nativeNTPBackgroundImagesBridge,
NTPBackgroundImagesBridge caller);
String getReferralApiKey(long nativeNTPBackgroundImagesBridge,
NTPBackgroundImagesBridge caller);
void registerPageView(
long nativeNTPBackgroundImagesBridge, NTPBackgroundImagesBridge caller);
void wallpaperLogoClicked(
long nativeNTPBackgroundImagesBridge,
NTPBackgroundImagesBridge caller,
String wallpaperId,
String creativeInstanceId,
String destinationUrl,
boolean shouldMetricsFallbackToP3a);
void getTopSites(long nativeNTPBackgroundImagesBridge, NTPBackgroundImagesBridge caller);
boolean isSuperReferral(
long nativeNTPBackgroundImagesBridge, NTPBackgroundImagesBridge caller);
String getSuperReferralThemeName(
long nativeNTPBackgroundImagesBridge, NTPBackgroundImagesBridge caller);
String getSuperReferralCode(
long nativeNTPBackgroundImagesBridge, NTPBackgroundImagesBridge caller);
String getReferralApiKey(
long nativeNTPBackgroundImagesBridge, NTPBackgroundImagesBridge caller);
}
}
@@ -16,6 +16,7 @@ public class Wallpaper extends NTPImage {
private String mCreativeInstanceId;
private String mWallpaperId;
private boolean mIsRichMedia;
private boolean mShouldMetricsFallbackToP3a;
public Wallpaper(
String imagePath,
@@ -27,7 +28,8 @@ public class Wallpaper extends NTPImage {
boolean isSponsored,
String creativeInstanceId,
String wallpaperId,
boolean isRichMedia) {
boolean isRichMedia,
boolean shouldMetricsFallbackToP3a) {
mImagePath = imagePath;
mFocalPointX = focalPointX;
mFocalPointY = focalPointY;
@@ -38,6 +40,7 @@ public class Wallpaper extends NTPImage {
mCreativeInstanceId = creativeInstanceId;
mWallpaperId = wallpaperId;
mIsRichMedia = isRichMedia;
mShouldMetricsFallbackToP3a = shouldMetricsFallbackToP3a;
}
public String getImagePath() {
@@ -79,4 +82,8 @@ public class Wallpaper extends NTPImage {
public boolean isRichMedia() {
return mIsRichMedia;
}
public boolean shouldMetricsFallbackToP3a() {
return mShouldMetricsFallbackToP3a;
}
}