Bug 1875105 - Add API call for trusted deal placement attribution event in GV r=geckoview-reviewers,owlish,ohall

Differential Revision: https://phabricator.services.mozilla.com/D198844
This commit is contained in:
Cathy Lu 2024-01-18 21:25:20 +00:00
Родитель 44d87af8f3
Коммит 4219152c32
6 изменённых файлов: 39 добавлений и 2 удалений

Просмотреть файл

@ -1037,6 +1037,7 @@ package org.mozilla.geckoview {
method @AnyThread @NonNull public GeckoResult<InputStream> saveAsPdf();
method @AnyThread @NonNull public GeckoResult<Boolean> sendClickAttributionEvent(@NonNull String);
method @AnyThread @NonNull public GeckoResult<Boolean> sendImpressionAttributionEvent(@NonNull String);
method @AnyThread @NonNull public GeckoResult<Boolean> sendPlacementAttributionEvent(@NonNull String);
method @AnyThread public void setActive(boolean);
method @UiThread public void setAutofillDelegate(@Nullable Autofill.Delegate);
method @AnyThread public void setContentBlockingDelegate(@Nullable ContentBlocking.Delegate);

Просмотреть файл

@ -219,6 +219,12 @@ class ReviewQualityCheckerTest : BaseSessionTest() {
sessionRule.waitForResult(validImpressionResult),
equalTo(true),
)
val validPlacementResult = mainSession.sendPlacementAttributionEvent(aid)
assertThat(
"Placement event success result should be true",
sessionRule.waitForResult(validPlacementResult),
equalTo(true),
)
}
@Test

Просмотреть файл

@ -3071,6 +3071,19 @@ public class GeckoSession {
return mEventDispatcher.queryBoolean("GeckoView:SendImpressionAttributionEvent", bundle);
}
/**
* Send a placement event to the Ad Attribution API.
*
* @param aid Ad id of the recommended product.
* @return a {@link GeckoResult} result of whether or not sending the event was successful.
*/
@AnyThread
public @NonNull GeckoResult<Boolean> sendPlacementAttributionEvent(@NonNull final String aid) {
final GeckoBundle bundle = new GeckoBundle(1);
bundle.putString("aid", aid);
return mEventDispatcher.queryBoolean("GeckoView:SendPlacementAttributionEvent", bundle);
}
/**
* Request product recommendations given a specific product url.
*

Просмотреть файл

@ -17,9 +17,11 @@ exclude: true
- For Translations, added [`checkPairDownloadSize`][123.1] and [`TranslationsException.ERROR_MODEL_LANGUAGE_REQUIRED`][123.2] as an error state.
- ⚠️ Deprecated [`GeckoSession.requestAnalysisCreationStatus`][119.2] by 124, please use [`GeckoSession.requestCreateAnalysis`][122.2] instead.
- ⚠️ Removed deprecated [`GeckoSession.requestAnalysisCreationStatus`][119.2]
- Added [`GeckoSession.sendPlacementAttributionEvent`][123.3] for sending placement attribution event for a given product recommendation.
[123.1]: {{javadoc_uri}}/TranslationsController.RuntimeTranslation.html#checkPairDownloadSize(java.lang.String,java.lang.String)
[123.2]: {{javadoc_uri}}/TranslationsController.TranslationsException.html#ERROR_MODEL_LANGUAGE_REQUIRED
[121.3]: {{javadoc_uri}}/GeckoSession.html#sendPlacementAttributionEvent(String)
## v122
- ⚠️ Removed [`onGetNimbusFeature`][115.5], please use `ExperimentDelegate.onGetExperimentFeature` instead.
@ -1502,4 +1504,4 @@ to allow adding gecko profiler markers.
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport(android.content.Context,android.os.Bundle,java.lang.String)
[65.25]: {{javadoc_uri}}/GeckoResult.html
[api-version]: 37c99c6944c474d502ea836194b93fae8d1d25e0
[api-version]: 2aa9a3cb60f30cdb5f9ec1550486a12a595b544f

Просмотреть файл

@ -2511,7 +2511,6 @@ public class GeckoViewActivity extends AppCompatActivity
return null;
}
});
session
.sendImpressionAttributionEvent(aids.get(0))
.then(
@ -2524,6 +2523,18 @@ public class GeckoViewActivity extends AppCompatActivity
return null;
}
});
session
.sendPlacementAttributionEvent(aids.get(0))
.then(
new GeckoResult.OnValueListener<Boolean, Void>() {
@Override
public GeckoResult<Void> onValue(final Boolean isSuccessful) {
Log.d(
LOGTAG,
"Success of shopping placement attribution event: " + isSuccessful);
return null;
}
});
} else {
Log.d(LOGTAG, "No shopping recommendations. No attribution events were sent.");
}

Просмотреть файл

@ -26,6 +26,7 @@ export class GeckoViewContent extends GeckoViewModule {
"GeckoView:PollForAnalysisCompleted",
"GeckoView:SendClickAttributionEvent",
"GeckoView:SendImpressionAttributionEvent",
"GeckoView:SendPlacementAttributionEvent",
"GeckoView:RequestAnalysis",
"GeckoView:RequestRecommendations",
"GeckoView:ReportBackInStock",
@ -258,6 +259,9 @@ export class GeckoViewContent extends GeckoViewModule {
case "GeckoView:SendImpressionAttributionEvent":
this._sendAttributionEvent("impression", aData, aCallback);
break;
case "GeckoView:SendPlacementAttributionEvent":
this._sendAttributionEvent("placement", aData, aCallback);
break;
case "GeckoView:RequestRecommendations":
this._requestRecommendations(aData, aCallback);
break;