Bug 1492174 - Add variants for lifetime caps in CFR messages r=ursula a=pascalc
authork88hudson <k88hudson@gmail.com>
Fri, 21 Sep 2018 19:04:09 +0000
changeset 492660 57154ebfdfb53aabf0e7184cc5666985ac767dff
parent 492659 fc233c29a740ed3d873a650b3bf7c7a5f309e1a1
child 492661 b46cc1949098ab53b9aec8c83b8d6cbce1007c1a
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersursula, pascalc
bugs1492174
milestone63.0
Bug 1492174 - Add variants for lifetime caps in CFR messages r=ursula a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D6517
browser/components/newtab/lib/CFRMessageProvider.jsm
browser/components/newtab/test/unit/asrouter/CFRMessageProvider.test.js
--- a/browser/components/newtab/lib/CFRMessageProvider.jsm
+++ b/browser/components/newtab/lib/CFRMessageProvider.jsm
@@ -77,17 +77,58 @@ const CFR_MESSAGES = [
         secondary: {
           label: {string_id: "cfr-doorhanger-extension-cancel-button"},
           action: {type: "CANCEL"}
         }
       }
     },
     frequency: {lifetime: 1},
     targeting: `
-      (providerCohorts.cfr in ["one_per_day_amazon", "three_per_day_amazon"]) &&
+      (providerCohorts.cfr == "one_per_day_amazon") &&
+      (${JSON.stringify(AMAZON_ASSISTANT_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
+      (${JSON.stringify(AMAZON_ASSISTANT_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${AMAZON_ASSISTANT_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
+    trigger: {id: "openURL", params: AMAZON_ASSISTANT_PARAMS.open_urls},
+  },
+  {
+    id: "AMAZON_ASSISTANT_3",
+    template: "cfr_doorhanger",
+    content: {
+      bucket_id: "CFR_M1",
+      notification_text: {string_id: "cfr-doorhanger-extension-notification"},
+      heading_text: {string_id: "cfr-doorhanger-extension-heading"},
+      info_icon: {
+        label: {string_id: "cfr-doorhanger-extension-sumo-link"},
+        sumo_path: AMAZON_ASSISTANT_PARAMS.sumo_path,
+      },
+      addon: {
+        title: "Amazon Assistant",
+        icon: "resource://activity-stream/data/content/assets/cfr_amazon_assistant.png",
+        rating: 3.3,
+        users: 443046,
+        author: "Amazon",
+        amo_url: "https://addons.mozilla.org/en-US/firefox/addon/amazon-browser-bar/",
+      },
+      text: "Amazon Assistant helps you make better shopping decisions by showing product comparisons at thousands of retail sites.",
+      buttons: {
+        primary: {
+          label: {string_id: "cfr-doorhanger-extension-ok-button"},
+          action: {
+            type: "INSTALL_ADDON_FROM_URL",
+            data: {url: `${BASE_ADDONS_DOWNLOAD_URL}/950930/amazon_assistant_for_firefox-10.1805.2.1019-an+fx.xpi`},
+          },
+        },
+        secondary: {
+          label: {string_id: "cfr-doorhanger-extension-cancel-button"},
+          action: {type: "CANCEL"},
+        },
+      },
+    },
+    frequency: {lifetime: 3},
+    targeting: `
+      (providerCohorts.cfr == "three_per_day_amazon") &&
       (${JSON.stringify(AMAZON_ASSISTANT_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
       (${JSON.stringify(AMAZON_ASSISTANT_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${AMAZON_ASSISTANT_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
     trigger: {id: "openURL", params: AMAZON_ASSISTANT_PARAMS.open_urls}
   },
   {
     id: "FACEBOOK_CONTAINER_1",
     template: "cfr_doorhanger",
     content: {
@@ -118,17 +159,58 @@ const CFR_MESSAGES = [
         secondary: {
           label: {string_id: "cfr-doorhanger-extension-cancel-button"},
           action: {type: "CANCEL"}
         }
       }
     },
     frequency: {lifetime: 1},
     targeting: `
-      (providerCohorts.cfr in ["one_per_day", "three_per_day", "nightly"]) &&
+      (providerCohorts.cfr in ["one_per_day", "nightly"]) &&
+      (${JSON.stringify(FACEBOOK_CONTAINER_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
+      (${JSON.stringify(FACEBOOK_CONTAINER_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${FACEBOOK_CONTAINER_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
+    trigger: {id: "openURL", params: FACEBOOK_CONTAINER_PARAMS.open_urls},
+  },
+  {
+    id: "FACEBOOK_CONTAINER_3",
+    template: "cfr_doorhanger",
+    content: {
+      bucket_id: "CFR_M1",
+      notification_text: {string_id: "cfr-doorhanger-extension-notification"},
+      heading_text: {string_id: "cfr-doorhanger-extension-heading"},
+      info_icon: {
+        label: {string_id: "cfr-doorhanger-extension-sumo-link"},
+        sumo_path: FACEBOOK_CONTAINER_PARAMS.sumo_path,
+      },
+      addon: {
+        title: "Facebook Container",
+        icon: "resource://activity-stream/data/content/assets/cfr_fb_container.png",
+        rating: 4.6,
+        users: 299019,
+        author: "Mozilla",
+        amo_url: "https://addons.mozilla.org/en-US/firefox/addon/facebook-container/",
+      },
+      text: "Stop Facebook from tracking your activity across the web. Use Facebook the way you normally do without annoying ads following you around.",
+      buttons: {
+        primary: {
+          label: {string_id: "cfr-doorhanger-extension-ok-button"},
+          action: {
+            type: "INSTALL_ADDON_FROM_URL",
+            data: {url: `${BASE_ADDONS_DOWNLOAD_URL}/918624/facebook_container-1.3.1-an+fx-linux.xpi`},
+          },
+        },
+        secondary: {
+          label: {string_id: "cfr-doorhanger-extension-cancel-button"},
+          action: {type: "CANCEL"},
+        },
+      },
+    },
+    frequency: {lifetime: 3},
+    targeting: `
+      (providerCohorts.cfr == "three_per_day") &&
       (${JSON.stringify(FACEBOOK_CONTAINER_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
       (${JSON.stringify(FACEBOOK_CONTAINER_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${FACEBOOK_CONTAINER_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
     trigger: {id: "openURL", params: FACEBOOK_CONTAINER_PARAMS.open_urls}
   },
   {
     id: "GOOGLE_TRANSLATE_1",
     template: "cfr_doorhanger",
     content: {
@@ -159,17 +241,58 @@ const CFR_MESSAGES = [
         secondary: {
           label: {string_id: "cfr-doorhanger-extension-cancel-button"},
           action: {type: "CANCEL"}
         }
       }
     },
     frequency: {lifetime: 1},
     targeting: `
-      (providerCohorts.cfr in ["one_per_day", "three_per_day", "nightly"]) &&
+      (providerCohorts.cfr in ["one_per_day", "nightly"]) &&
+      (${JSON.stringify(GOOGLE_TRANSLATE_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
+      (${JSON.stringify(GOOGLE_TRANSLATE_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${GOOGLE_TRANSLATE_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
+    trigger: {id: "openURL", params: GOOGLE_TRANSLATE_PARAMS.open_urls},
+  },
+  {
+    id: "GOOGLE_TRANSLATE_3",
+    template: "cfr_doorhanger",
+    content: {
+      bucket_id: "CFR_M1",
+      notification_text: {string_id: "cfr-doorhanger-extension-notification"},
+      heading_text: {string_id: "cfr-doorhanger-extension-heading"},
+      info_icon: {
+        label: {string_id: "cfr-doorhanger-extension-sumo-link"},
+        sumo_path: GOOGLE_TRANSLATE_PARAMS.sumo_path,
+      },
+      addon: {
+        title: "To Google Translate",
+        icon: "resource://activity-stream/data/content/assets/cfr_google_translate.png",
+        rating: 4.1,
+        users: 313474,
+        author: "Juan Escobar",
+        amo_url: "https://addons.mozilla.org/en-US/firefox/addon/to-google-translate/",
+      },
+      text: "Instantly translate any webpage text. Simply highlight the text, right-click to open the context menu, and choose a text or aural translation.",
+      buttons: {
+        primary: {
+          label: {string_id: "cfr-doorhanger-extension-ok-button"},
+          action: {
+            type: "INSTALL_ADDON_FROM_URL",
+            data: {url: `${BASE_ADDONS_DOWNLOAD_URL}/1008798/al_traductor_de_google-3.3-an+fx.xpi`},
+          },
+        },
+        secondary: {
+          label: {string_id: "cfr-doorhanger-extension-cancel-button"},
+          action: {type: "CANCEL"},
+        },
+      },
+    },
+    frequency: {lifetime: 3},
+    targeting: `
+      (providerCohorts.cfr == "three_per_day") &&
       (${JSON.stringify(GOOGLE_TRANSLATE_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
       (${JSON.stringify(GOOGLE_TRANSLATE_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${GOOGLE_TRANSLATE_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
     trigger: {id: "openURL", params: GOOGLE_TRANSLATE_PARAMS.open_urls}
   },
   {
     id: "YOUTUBE_ENHANCE_1",
     template: "cfr_doorhanger",
     content: {
@@ -200,17 +323,58 @@ const CFR_MESSAGES = [
         secondary: {
           label: {string_id: "cfr-doorhanger-extension-cancel-button"},
           action: {type: "CANCEL"}
         }
       }
     },
     frequency: {lifetime: 1},
     targeting: `
-      (providerCohorts.cfr in ["one_per_day", "three_per_day", "nightly"]) &&
+      (providerCohorts.cfr in ["one_per_day", "nightly"]) &&
+      (${JSON.stringify(YOUTUBE_ENHANCE_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
+      (${JSON.stringify(YOUTUBE_ENHANCE_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${YOUTUBE_ENHANCE_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
+    trigger: {id: "openURL", params: YOUTUBE_ENHANCE_PARAMS.open_urls},
+  },
+  {
+    id: "YOUTUBE_ENHANCE_3",
+    template: "cfr_doorhanger",
+    content: {
+      bucket_id: "CFR_M1",
+      notification_text: {string_id: "cfr-doorhanger-extension-notification"},
+      heading_text: {string_id: "cfr-doorhanger-extension-heading"},
+      info_icon: {
+        label: {string_id: "cfr-doorhanger-extension-sumo-link"},
+        sumo_path: YOUTUBE_ENHANCE_PARAMS.sumo_path,
+      },
+      addon: {
+        title: "Enhancer for YouTube\u2122",
+        icon: "resource://activity-stream/data/content/assets/cfr_enhancer_youtube.png",
+        rating: 4.8,
+        users: 357328,
+        author: "Maxime RF",
+        amo_url: "https://addons.mozilla.org/en-US/firefox/addon/enhancer-for-youtube/",
+      },
+      text: "Take control of your YouTube experience. Automatically block annoying ads, set playback speed and volume, remove annotations, and more.",
+      buttons: {
+        primary: {
+          label: {string_id: "cfr-doorhanger-extension-ok-button"},
+          action: {
+            type: "INSTALL_ADDON_FROM_URL",
+            data: {url: `${BASE_ADDONS_DOWNLOAD_URL}/1028400/enhancer_for_youtubetm-2.0.73-an+fx-linux.xpi`},
+          },
+        },
+        secondary: {
+          label: {string_id: "cfr-doorhanger-extension-cancel-button"},
+          action: {type: "CANCEL"},
+        },
+      },
+    },
+    frequency: {lifetime: 3},
+    targeting: `
+      (providerCohorts.cfr == "three_per_day") &&
       (${JSON.stringify(YOUTUBE_ENHANCE_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
       (${JSON.stringify(YOUTUBE_ENHANCE_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${YOUTUBE_ENHANCE_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
     trigger: {id: "openURL", params: YOUTUBE_ENHANCE_PARAMS.open_urls}
   },
   {
     id: "WIKIPEDIA_CONTEXT_MENU_SEARCH_1",
     template: "cfr_doorhanger",
     content: {
@@ -241,17 +405,58 @@ const CFR_MESSAGES = [
         secondary: {
           label: {string_id: "cfr-doorhanger-extension-cancel-button"},
           action: {type: "CANCEL"}
         }
       }
     },
     frequency: {lifetime: 1},
     targeting: `
-      (providerCohorts.cfr in ["one_per_day", "three_per_day", "nightly"]) &&
+      (providerCohorts.cfr in ["one_per_day", "nightly"]) &&
+      (${JSON.stringify(WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
+      (${JSON.stringify(WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
+    trigger: {id: "openURL", params: WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.open_urls},
+  },
+  {
+    id: "WIKIPEDIA_CONTEXT_MENU_SEARCH_3",
+    template: "cfr_doorhanger",
+    content: {
+      bucket_id: "CFR_M1",
+      notification_text: {string_id: "cfr-doorhanger-extension-notification"},
+      heading_text: {string_id: "cfr-doorhanger-extension-heading"},
+      info_icon: {
+        label: {string_id: "cfr-doorhanger-extension-sumo-link"},
+        sumo_path: WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.sumo_path,
+      },
+      addon: {
+        title: "Wikipedia Context Menu Search",
+        icon: "resource://activity-stream/data/content/assets/cfr_wiki_search.png",
+        rating: 4.9,
+        users: 3095,
+        author: "Nick Diedrich",
+        amo_url: "https://addons.mozilla.org/en-US/firefox/addon/wikipedia-context-menu-search/",
+      },
+      text: "Get to a Wikipedia page fast, from anywhere on the web. Just highlight any webpage text and right-click to open the context menu to start a Wikipedia search.",
+      buttons: {
+        primary: {
+          label: {string_id: "cfr-doorhanger-extension-ok-button"},
+          action: {
+            type: "INSTALL_ADDON_FROM_URL",
+            data: {url: `${BASE_ADDONS_DOWNLOAD_URL}/890224/wikipedia_context_menu_search-1.8-an+fx.xpi`},
+          },
+        },
+        secondary: {
+          label: {string_id: "cfr-doorhanger-extension-cancel-button"},
+          action: {type: "CANCEL"},
+        },
+      },
+    },
+    frequency: {lifetime: 3},
+    targeting: `
+      (providerCohorts.cfr == "three_per_day") &&
       (${JSON.stringify(WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
       (${JSON.stringify(WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
     trigger: {id: "openURL", params: WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.open_urls}
   },
   {
     id: "REDDIT_ENHANCEMENT_1",
     template: "cfr_doorhanger",
     content: {
@@ -282,17 +487,58 @@ const CFR_MESSAGES = [
         secondary: {
           label: {string_id: "cfr-doorhanger-extension-cancel-button"},
           action: {type: "CANCEL"}
         }
       }
     },
     frequency: {lifetime: 1},
     targeting: `
-      (providerCohorts.cfr in ["one_per_day", "three_per_day", "nightly"]) &&
+      (providerCohorts.cfr in ["one_per_day", "nightly"]) &&
+      (${JSON.stringify(REDDIT_ENHANCEMENT_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
+      (${JSON.stringify(REDDIT_ENHANCEMENT_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${REDDIT_ENHANCEMENT_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
+    trigger: {id: "openURL", params: REDDIT_ENHANCEMENT_PARAMS.open_urls},
+  },
+  {
+    id: "REDDIT_ENHANCEMENT_3",
+    template: "cfr_doorhanger",
+    content: {
+      bucket_id: "CFR_M1",
+      notification_text: {string_id: "cfr-doorhanger-extension-notification"},
+      heading_text: {string_id: "cfr-doorhanger-extension-heading"},
+      info_icon: {
+        label: {string_id: "cfr-doorhanger-extension-sumo-link"},
+        sumo_path: REDDIT_ENHANCEMENT_PARAMS.sumo_path,
+      },
+      addon: {
+        title: "Reddit Enhancement Suite",
+        icon: "resource://activity-stream/data/content/assets/cfr_reddit_enhancement.png",
+        rating: 4.6,
+        users: 258129,
+        author: "honestbleeps",
+        amo_url: "https://addons.mozilla.org/en-US/firefox/addon/reddit-enhancement-suite/",
+      },
+      text: "New features include Inline Image Viewer, Never Ending Reddit (never click 'next page' again), Keyboard Navigation, Account Switcher, and User Tagger.",
+      buttons: {
+        primary: {
+          label: {string_id: "cfr-doorhanger-extension-ok-button"},
+          action: {
+            type: "INSTALL_ADDON_FROM_URL",
+            data: {url: `${BASE_ADDONS_DOWNLOAD_URL}/991623/reddit_enhancement_suite-5.12.5-an+fx.xpi`},
+          },
+        },
+        secondary: {
+          label: {string_id: "cfr-doorhanger-extension-cancel-button"},
+          action: {type: "CANCEL"},
+        },
+      },
+    },
+    frequency: {lifetime: 3},
+    targeting: `
+      (providerCohorts.cfr == "three_per_day") &&
       (${JSON.stringify(REDDIT_ENHANCEMENT_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
       (${JSON.stringify(REDDIT_ENHANCEMENT_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${REDDIT_ENHANCEMENT_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
     trigger: {id: "openURL", params: REDDIT_ENHANCEMENT_PARAMS.open_urls}
   }
 ];
 
 const CFRMessageProvider = {
   getMessages() {
new file mode 100644
--- /dev/null
+++ b/browser/components/newtab/test/unit/asrouter/CFRMessageProvider.test.js
@@ -0,0 +1,44 @@
+import {CFRMessageProvider} from "lib/CFRMessageProvider.jsm";
+const messages = CFRMessageProvider.getMessages();
+
+const REGULAR_IDS = [
+  "FACEBOOK_CONTAINER",
+  "GOOGLE_TRANSLATE",
+  "YOUTUBE_ENHANCE",
+  "WIKIPEDIA_CONTEXT_MENU_SEARCH",
+  "REDDIT_ENHANCEMENT",
+];
+
+describe("CFRMessageProvider", () => {
+  it("should have a total of 12 messages", () => {
+    assert.lengthOf(messages, 12);
+  });
+  it("should two variants for each of the five regular addons", () => {
+    for (const id of REGULAR_IDS) {
+      const cohort1 = messages.find(msg => msg.id === `${id}_1`);
+      assert.ok(cohort1, `contains one day cohort for ${id}`);
+      assert.deepEqual(cohort1.frequency, {lifetime: 1}, "one day cohort has the right frequency cap");
+      assert.include(cohort1.targeting, `(providerCohorts.cfr in ["one_per_day", "nightly"])`);
+
+      const cohort3 = messages.find(msg => msg.id === `${id}_3`);
+      assert.ok(cohort3, `contains three day cohort for ${id}`);
+      assert.deepEqual(cohort3.frequency, {lifetime: 3}, "three day cohort has the right frequency cap");
+      assert.include(cohort3.targeting, `(providerCohorts.cfr == "three_per_day")`);
+
+      assert.deepEqual(cohort1.content, cohort3.content, "cohorts should have the same content");
+    }
+  });
+  it("should have the two amazon cohorts", () => {
+    const cohort1 = messages.find(msg => msg.id === `AMAZON_ASSISTANT_1`);
+    const cohort3 = messages.find(msg => msg.id === `AMAZON_ASSISTANT_3`);
+    assert.deepEqual(cohort1.content, cohort3.content, "cohorts should have the same content");
+
+    assert.ok(cohort1, `contains one day cohort for amazon`);
+    assert.deepEqual(cohort1.frequency, {lifetime: 1}, "one day cohort has the right frequency cap");
+    assert.include(cohort1.targeting, `(providerCohorts.cfr == "one_per_day_amazon"`);
+
+    assert.ok(cohort3, `contains three day cohort for amazon`);
+    assert.deepEqual(cohort3.frequency, {lifetime: 3}, "three day cohort has the right frequency cap");
+    assert.include(cohort3.targeting, `(providerCohorts.cfr == "three_per_day_amazon")`);
+  });
+});