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); GeckoResult<String> result = session.requestCreateAnalysis(url);
result.map( result.map(
status -> { status -> {
Log.d(LOGTAG, "Started analysis, status: " + status); Log.d(LOGTAG, "Started shopping analysis, status: " + status);
return status; return status;
}); });
} }
@ -2461,14 +2461,15 @@ public class GeckoViewActivity extends AppCompatActivity
aids.add(recs.get(i).aid); aids.add(recs.get(i).aid);
} }
if (aids.size() >= 1) { 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 session
.sendClickAttributionEvent(aids.get(0)) .sendClickAttributionEvent(aids.get(0))
.then( .then(
new GeckoResult.OnValueListener<Boolean, Void>() { new GeckoResult.OnValueListener<Boolean, Void>() {
@Override @Override
public GeckoResult<Void> onValue(final Boolean isSuccessful) { 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; return null;
} }
}); });
@ -2479,7 +2480,9 @@ public class GeckoViewActivity extends AppCompatActivity
new GeckoResult.OnValueListener<Boolean, Void>() { new GeckoResult.OnValueListener<Boolean, Void>() {
@Override @Override
public GeckoResult<Void> onValue(final Boolean isSuccessful) { 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; return null;
} }
}); });

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

@ -408,19 +408,14 @@ export class GeckoViewContent extends GeckoViewModule {
} }
async _sendAttributionEvent(aEvent, aData, aCallback) { 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; let result;
if (Services.prefs.getBoolPref("geckoview.shopping.test_response", true)) { if (Services.prefs.getBoolPref("geckoview.shopping.test_response", true)) {
result = { TEST_AID: "TEST_AID_RESPONSE" }; result = { TEST_AID: "TEST_AID_RESPONSE" };
} else { } else {
// TODO (bug 1860897): source will be changed to geckoview_android result = await lazy.ShoppingProduct.sendAttributionEvent(
result = await product.sendAttributionEvent(
aEvent, aEvent,
aData.aid, aData.aid,
"firefox_android" "geckoview_android"
); );
} }
if (!result || !(aData.aid in result) || !result[aData.aid]) { if (!result || !(aData.aid in result) || !result[aData.aid]) {