Bug 1860897 - Change shopping attribution source event and use new static sendAttributionEvent r=geckoview-reviewers,owlish

Differential Revision: https://phabricator.services.mozilla.com/D193459
This commit is contained in:
Cathy Lu 2023-11-13 20:39:49 +00:00
Родитель 79e5a64e33
Коммит 77454b62a0
2 изменённых файлов: 9 добавлений и 11 удалений

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

@ -2425,7 +2425,7 @@ public class GeckoViewActivity extends AppCompatActivity
GeckoResult<String> result = session.requestCreateAnalysis(url);
result.map(
status -> {
Log.d(LOGTAG, "Started analysis, status: " + status);
Log.d(LOGTAG, "Started shopping analysis, status: " + status);
return status;
});
}
@ -2461,14 +2461,15 @@ public class GeckoViewActivity extends AppCompatActivity
aids.add(recs.get(i).aid);
}
if (aids.size() >= 1) {
Log.d(LOGTAG, "Sending attribution events to first AID: " + aids.get(0));
Log.d(LOGTAG, "Sending shopping attribution events to first AID: " + aids.get(0));
session
.sendClickAttributionEvent(aids.get(0))
.then(
new GeckoResult.OnValueListener<Boolean, Void>() {
@Override
public GeckoResult<Void> onValue(final Boolean isSuccessful) {
Log.d(LOGTAG, "Success of click attribution event: " + isSuccessful);
Log.d(
LOGTAG, "Success of shopping click attribution event: " + isSuccessful);
return null;
}
});
@ -2479,7 +2480,9 @@ public class GeckoViewActivity extends AppCompatActivity
new GeckoResult.OnValueListener<Boolean, Void>() {
@Override
public GeckoResult<Void> onValue(final Boolean isSuccessful) {
Log.d(LOGTAG, "Success of impression attribution event: " + isSuccessful);
Log.d(
LOGTAG,
"Success of shopping impression attribution event: " + isSuccessful);
return null;
}
});

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

@ -408,19 +408,14 @@ export class GeckoViewContent extends GeckoViewModule {
}
async _sendAttributionEvent(aEvent, aData, aCallback) {
// TODO (bug1859055): remove product object once sendAttributionEvent() is static
const product = new lazy.ShoppingProduct(
"http://example.com/dp/ABCDEFG123"
);
let result;
if (Services.prefs.getBoolPref("geckoview.shopping.test_response", true)) {
result = { TEST_AID: "TEST_AID_RESPONSE" };
} else {
// TODO (bug 1860897): source will be changed to geckoview_android
result = await product.sendAttributionEvent(
result = await lazy.ShoppingProduct.sendAttributionEvent(
aEvent,
aData.aid,
"firefox_android"
"geckoview_android"
);
}
if (!result || !(aData.aid in result) || !result[aData.aid]) {