Bug 1805576 - Add back telemetry tests for improve_suggest_experience_checked = true. r=daleharvey

This adds checks to the main sponsored and nonsponsored tests to ensure we have
test cases where this value is both true and false. I think it's important to
have test cases for both sponsored and nonsponsored suggestions since these are
the two main types of Firefox Suggest suggestions. I don't think it's necessary
for other types of suggestions because they all use the same logic, so if these
checks pass for sponsored and nonsponsored suggestions, we can be reasonably
sure other suggestion types are handled correctly.

Differential Revision: https://phabricator.services.mozilla.com/D164617
This commit is contained in:
Drew Willcoxon 2022-12-15 21:12:51 +00:00
parent 3ab309d3e4
commit da2063ac08
2 changed files with 274 additions and 246 deletions

View File

@ -38,150 +38,164 @@ add_setup(async function() {
// nonsponsored
add_task(async function nonsponsored() {
let match_type = "firefox-suggest";
await doTelemetryTest({
index,
suggestion,
// impression-only
impressionOnly: {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_NONSPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "impression_only",
extra: {
suggestion_type,
match_type,
position: position.toString(),
},
},
ping: {
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
is_clicked: false,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
},
selectables: {
// click
"urlbarView-row-inner": {
// Make sure `improve_suggest_experience_checked` is recorded correctly
// depending on the value of the related pref.
for (let improve_suggest_experience_checked of [false, true]) {
await SpecialPowers.pushPrefEnv({
set: [
[
"browser.urlbar.quicksuggest.dataCollection.enabled",
improve_suggest_experience_checked,
],
],
});
await doTelemetryTest({
index,
suggestion,
// impression-only
impressionOnly: {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_NONSPONSORED]: position,
[TELEMETRY_SCALARS.CLICK_NONSPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "click",
object: "impression_only",
extra: {
suggestion_type,
match_type,
position: position.toString(),
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
is_clicked: true,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_SELECTION,
payload: {
match_type,
position,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
],
},
// block
"urlbarView-button-block": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_NONSPONSORED]: position,
[TELEMETRY_SCALARS.BLOCK_NONSPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "block",
extra: {
suggestion_type,
ping: {
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position: position.toString(),
position,
improve_suggest_experience_checked,
is_clicked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
is_clicked: false,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_BLOCK,
payload: {
match_type,
position,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
iab_category: suggestion.iab_category,
},
},
],
},
// help
"urlbarView-button-help": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_NONSPONSORED]: position,
[TELEMETRY_SCALARS.HELP_NONSPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "help",
extra: {
suggestion_type,
match_type,
position: position.toString(),
selectables: {
// click
"urlbarView-row-inner": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_NONSPONSORED]: position,
[TELEMETRY_SCALARS.CLICK_NONSPONSORED]: position,
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "click",
extra: {
suggestion_type,
match_type,
position,
is_clicked: false,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
position: position.toString(),
},
},
],
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
improve_suggest_experience_checked,
is_clicked: true,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_SELECTION,
payload: {
match_type,
position,
improve_suggest_experience_checked,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
],
},
// block
"urlbarView-button-block": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_NONSPONSORED]: position,
[TELEMETRY_SCALARS.BLOCK_NONSPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "block",
extra: {
suggestion_type,
match_type,
position: position.toString(),
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
improve_suggest_experience_checked,
is_clicked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_BLOCK,
payload: {
match_type,
position,
improve_suggest_experience_checked,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
iab_category: suggestion.iab_category,
},
},
],
},
// help
"urlbarView-button-help": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_NONSPONSORED]: position,
[TELEMETRY_SCALARS.HELP_NONSPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "help",
extra: {
suggestion_type,
match_type,
position: position.toString(),
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
improve_suggest_experience_checked,
is_clicked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
],
},
},
},
});
});
await SpecialPowers.popPrefEnv();
}
});
// nonsponsored best match

View File

@ -37,150 +37,164 @@ add_setup(async function() {
// sponsored
add_task(async function sponsored() {
let match_type = "firefox-suggest";
await doTelemetryTest({
index,
suggestion,
// impression-only
impressionOnly: {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_SPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "impression_only",
extra: {
suggestion_type,
match_type,
position: position.toString(),
},
},
ping: {
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
is_clicked: false,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
},
selectables: {
// click
"urlbarView-row-inner": {
// Make sure `improve_suggest_experience_checked` is recorded correctly
// depending on the value of the related pref.
for (let improve_suggest_experience_checked of [false, true]) {
await SpecialPowers.pushPrefEnv({
set: [
[
"browser.urlbar.quicksuggest.dataCollection.enabled",
improve_suggest_experience_checked,
],
],
});
await doTelemetryTest({
index,
suggestion,
// impression-only
impressionOnly: {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_SPONSORED]: position,
[TELEMETRY_SCALARS.CLICK_SPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "click",
object: "impression_only",
extra: {
suggestion_type,
match_type,
position: position.toString(),
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
is_clicked: true,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_SELECTION,
payload: {
match_type,
position,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
],
},
// block
"urlbarView-button-block": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_SPONSORED]: position,
[TELEMETRY_SCALARS.BLOCK_SPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "block",
extra: {
suggestion_type,
ping: {
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position: position.toString(),
position,
improve_suggest_experience_checked,
is_clicked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
is_clicked: false,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_BLOCK,
payload: {
match_type,
position,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
iab_category: suggestion.iab_category,
},
},
],
},
// help
"urlbarView-button-help": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_SPONSORED]: position,
[TELEMETRY_SCALARS.HELP_SPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "help",
extra: {
suggestion_type,
match_type,
position: position.toString(),
selectables: {
// click
"urlbarView-row-inner": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_SPONSORED]: position,
[TELEMETRY_SCALARS.CLICK_SPONSORED]: position,
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "click",
extra: {
suggestion_type,
match_type,
position,
is_clicked: false,
improve_suggest_experience_checked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
position: position.toString(),
},
},
],
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
improve_suggest_experience_checked,
is_clicked: true,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_SELECTION,
payload: {
match_type,
position,
improve_suggest_experience_checked,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
],
},
// block
"urlbarView-button-block": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_SPONSORED]: position,
[TELEMETRY_SCALARS.BLOCK_SPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "block",
extra: {
suggestion_type,
match_type,
position: position.toString(),
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
improve_suggest_experience_checked,
is_clicked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_BLOCK,
payload: {
match_type,
position,
improve_suggest_experience_checked,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
iab_category: suggestion.iab_category,
},
},
],
},
// help
"urlbarView-button-help": {
scalars: {
[TELEMETRY_SCALARS.IMPRESSION_SPONSORED]: position,
[TELEMETRY_SCALARS.HELP_SPONSORED]: position,
},
event: {
category: QuickSuggest.TELEMETRY_EVENT_CATEGORY,
method: "engagement",
object: "help",
extra: {
suggestion_type,
match_type,
position: position.toString(),
},
},
pings: [
{
type: CONTEXTUAL_SERVICES_PING_TYPES.QS_IMPRESSION,
payload: {
match_type,
position,
improve_suggest_experience_checked,
is_clicked: false,
block_id: suggestion.id,
advertiser: suggestion.advertiser,
},
},
],
},
},
},
});
});
await SpecialPowers.popPrefEnv();
}
});
// sponsored best match