Skip to content

Commit

Permalink
Bug 1869413 - New event for clicking the opt out button r=TravisLong,…
Browse files Browse the repository at this point in the history
…shopping-reviewers,Gijs

Differential Revision: https://phabricator.services.mozilla.com/D196111
  • Loading branch information
perrymcmanis144 committed Dec 12, 2023
1 parent bf29a3b commit 9750ce6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions browser/components/shopping/content/settings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ShoppingSettings extends MozLitElement {
// is never flipped, leaving the toolbar button in the active state.
RPMSetPref("browser.shopping.experience2023.active", false);
RPMSetPref("browser.shopping.experience2023.optedIn", 2);
Glean.shopping.surfaceOptOutButtonClicked.record();
}

fakespotLinkClicked(e) {
Expand Down
17 changes: 17 additions & 0 deletions browser/components/shopping/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -622,3 +622,20 @@ shopping:
Whether the toggle was used to enable or disable ads. Possible values
are `enabled` and `disabled`.
type: string

surface_opt_out_button_clicked:
type: event
description: |
The user clicked the button in the settings panel to turn off the shopping experience.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1869413
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1869413
data_sensitivity:
- interaction
expires: 134
notification_emails:
- [email protected]
- [email protected]
send_in_pings:
- events
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,51 @@ add_task(async function test_shopping_setting_update() {

await SpecialPowers.popPrefEnv();
});

add_task(async function test_shopping_settings_ads_enabled() {
await SpecialPowers.pushPrefEnv({
set: [["browser.shopping.experience2023.optedIn", 1]],
});
await Services.fog.testFlushAllChildren();
Services.fog.testResetFOG();

await BrowserTestUtils.withNewTab(
{
url: "about:shoppingsidebar",
gBrowser,
},
async browser => {
await SpecialPowers.spawn(
browser,
[MOCK_ANALYZED_PRODUCT_RESPONSE],
async mockData => {
let shoppingContainer =
content.document.querySelector(
"shopping-container"
).wrappedJSObject;

shoppingContainer.data = Cu.cloneInto(mockData, content);
shoppingContainer.adsEnabled = true;
await shoppingContainer.updateComplete;

let shoppingSettings = shoppingContainer.settingsEl;
ok(shoppingSettings, "Got the shopping-settings element");

let optOutButton = shoppingSettings.optOutButtonEl;
ok(optOutButton, "There should be an opt-out button");

optOutButton.click();
}
);
}
);

await Services.fog.testFlushAllChildren();
var optOutClickedEvents =
Glean.shopping.surfaceOptOutButtonClicked.testGetValue();

Assert.equal(optOutClickedEvents.length, 1);
Assert.equal(optOutClickedEvents[0].category, "shopping");
Assert.equal(optOutClickedEvents[0].name, "surface_opt_out_button_clicked");
await SpecialPowers.popPrefEnv();
});

0 comments on commit 9750ce6

Please sign in to comment.