Bug 1504864 - Add fix for pocket double-adding spocs, remove Amazon CFR metadata to Activity Stream r=andreio

Differential Revision: https://phabricator.services.mozilla.com/D10976

--HG--
extra : moz-landing-system : lando
This commit is contained in:
k88hudson 2018-11-06 15:43:41 +00:00
parent c8086c4f6e
commit ac49075905
13 changed files with 40 additions and 141 deletions

View file

@ -271,7 +271,10 @@ function Sections(prevState = INITIAL_STATE.Sections, action) {
const rows = Array.from(action.data.rows);
section.rows.forEach((card, index) => {
if (card.pinned) {
rows.splice(index, 0, card);
// Only add it if it's not already there.
if (rows[index].guid !== card.guid) {
rows.splice(index, 0, card);
}
}
});
return Object.assign({}, section, initialized, Object.assign({}, action.data, {rows}));

View file

@ -239,13 +239,14 @@ export class ASRouterAdmin extends React.PureComponent {
renderTargetingParameters() {
// There was no error and the result is truthy
const success = this.state.evaluationStatus.success && !!this.state.evaluationStatus.result;
const result = JSON.stringify(this.state.evaluationStatus.result, null, 2) || "(Empty result)";
return (<table><tbody>
<tr><td><h2>Evaluate JEXL expression</h2></td></tr>
<tr>
<td>
<p><textarea ref="expressionInput" rows="10" cols="60" placeholder="Evaluate JEXL expressions and mock parameters by changing their values below" /></p>
<p>Status: <span ref="evaluationStatus">{success ? "✅" : "❌"}, Result: {JSON.stringify(this.state.evaluationStatus.result, null, 2)}</span></p>
<p>Status: <span ref="evaluationStatus">{success ? "✅" : "❌"}, Result: {result}</span></p>
</td>
<td>
<button className="ASRouterButton secondary" onClick={this.handleExpressionEval}>Evaluate</button>

View file

@ -2102,6 +2102,7 @@ class ASRouterAdmin extends react__WEBPACK_IMPORTED_MODULE_1___default.a.PureCom
renderTargetingParameters() {
// There was no error and the result is truthy
const success = this.state.evaluationStatus.success && !!this.state.evaluationStatus.result;
const result = JSON.stringify(this.state.evaluationStatus.result, null, 2) || "(Empty result)";
return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(
"table",
@ -2142,7 +2143,7 @@ class ASRouterAdmin extends react__WEBPACK_IMPORTED_MODULE_1___default.a.PureCom
{ ref: "evaluationStatus" },
success ? "✅" : "❌",
", Result: ",
JSON.stringify(this.state.evaluationStatus.result, null, 2)
result
)
)
),
@ -9385,7 +9386,10 @@ function Sections(prevState = INITIAL_STATE.Sections, action) {
const rows = Array.from(action.data.rows);
section.rows.forEach((card, index) => {
if (card.pinned) {
rows.splice(index, 0, card);
// Only add it if it's not already there.
if (rows[index].guid !== card.guid) {
rows.splice(index, 0, card);
}
}
});
return Object.assign({}, section, initialized, Object.assign({}, action.data, { rows }));

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -773,8 +773,8 @@ CFR impression ping has two forms, in which the message_id could be of different
"addon_version": "20180710100040",
"locale": "en-US",
"source": "CFR",
// message_id could be the ID of the recommendation, such as "amazon_addon"
"message_id": "amazon_addon",
// message_id could be the ID of the recommendation, such as "wikipedia_addon"
"message_id": "wikipedia_addon",
"event": "IMPRESSION"
}
```
@ -836,8 +836,8 @@ This reports the user's interaction with Activity Stream Router.
"impression_id": "n/a",
"locale": "en-US",
"source": "CFR",
// message_id could be the ID of the recommendation, such as "amazon_addon"
"message_id": "amazon_addon",
// message_id could be the ID of the recommendation, such as "wikipedia_addon"
"message_id": "wikipedia_addon",
"event": "[INSTALL | BLOCK | DISMISS | RATIONALE | LEARN_MORE | CLICK_DOORHANGER]"
}
```

View file

@ -561,7 +561,7 @@ class _ASRouter {
try {
evaluationStatus = {result: await ASRouterTargeting.isMatch(expression, context), success: true};
} catch (e) {
evaluationStatus = {result: e, success: false};
evaluationStatus = {result: e.message, success: false};
}
channel.sendAsyncMessage(OUTGOING_MESSAGE_NAME, {type: "ADMIN_SET_STATE", data: {...this.state, evaluationStatus}});

View file

@ -2,12 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const AMAZON_ASSISTANT_PARAMS = {
existing_addons: ["abb@amazon.com", "{75c7fe97-5a90-4b54-9052-3534235eaf41}", "{ef34596e-1e43-4e84-b2ff-1e58e287e08d}", "{ea280feb-155a-492e-8016-ac96dd995f2c}", "izer@camelcamelcamel.com", "amptra@keepa.com", "pricealarm@icopron.ch", "{774f76c7-6807-481e-bf64-f9b7d5cda602}"],
open_urls: ["smile.amazon.com", "www.audible.com", "www.amazon.com", "amazon.com", "audible.com"],
sumo_path: "extensionrecommendations",
min_frecency: 10000,
};
const FACEBOOK_CONTAINER_PARAMS = {
existing_addons: ["@contain-facebook", "{bb1b80be-e6b3-40a1-9b6e-9d4073343f0b}", "{a50d61ca-d27b-437a-8b52-5fd801a0a88b}"],
open_urls: ["www.facebook.com", "facebook.com"],
@ -45,110 +39,6 @@ const REDDIT_ENHANCEMENT_PARAMS = {
};
const CFR_MESSAGES = [
{
id: "AMAZON_ASSISTANT_1",
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: {
id: "337359",
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: null},
},
},
secondary: [{
label: {string_id: "cfr-doorhanger-extension-cancel-button"},
action: {type: "CANCEL"},
}, {
label: {string_id: "cfr-doorhanger-extension-never-show-recommendation"},
}, {
label: {string_id: "cfr-doorhanger-extension-manage-settings-button"},
action: {
type: "OPEN_PREFERENCES_PAGE",
data: {category: "general-cfr", origin: "CFR"},
},
}],
},
},
frequency: {lifetime: 1},
targeting: `
localeLanguageCode == "en" &&
(providerCohorts.cfr == "one_per_day_amazon") &&
(xpinstallEnabled == true) &&
(${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: {
id: "337359",
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: null},
},
},
secondary: [{
label: {string_id: "cfr-doorhanger-extension-cancel-button"},
action: {type: "CANCEL"},
}, {
label: {string_id: "cfr-doorhanger-extension-never-show-recommendation"},
}, {
label: {string_id: "cfr-doorhanger-extension-manage-settings-button"},
action: {
type: "OPEN_PREFERENCES_PAGE",
data: {category: "general-cfr", origin: "CFR"},
},
}],
},
},
frequency: {lifetime: 3},
targeting: `
localeLanguageCode == "en" &&
(providerCohorts.cfr == "three_per_day_amazon") &&
(xpinstallEnabled == true) &&
(${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",

View file

@ -7680,10 +7680,9 @@
}
},
"merge": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/merge/-/merge-1.2.0.tgz",
"integrity": "sha1-dTHjnUlJwoGma4xabgJl6LBYlNo=",
"dev": true
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz",
"integrity": "sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ=="
},
"micromatch": {
"version": "2.3.11",
@ -10250,7 +10249,7 @@
"known-css-properties": "0.3.0",
"lodash.capitalize": "4.2.1",
"lodash.kebabcase": "4.1.1",
"merge": "1.2.0",
"merge": "^1.2.0",
"path-is-absolute": "1.0.1",
"util": "0.10.3"
},

View file

@ -110,6 +110,10 @@
"buildmc:copy": "rsync --exclude-from .mcignore -a . $npm_package_config_mc_dir/browser/components/newtab/",
"buildmc:stringsExport": "cp $npm_package_config_locales_dir/$npm_package_config_default_locale/strings.properties $npm_package_config_mc_dir/browser/locales/$npm_package_config_default_locale/chrome/browser/activity-stream/newtab.properties",
"buildmc:copyPingCentre": "cpx \"ping-centre/PingCentre.jsm\" $npm_package_config_mc_dir/browser/modules",
"builduplift": "npm-run-all builduplift:*",
"prebuilduplift": "npm run prebuildmc",
"builduplift:bundle": "npm run bundle",
"builduplift:copy": "npm run buildmc:copy",
"buildlibrary": "npm-run-all buildlibrary:*",
"buildlibrary:webpack": "webpack --config webpack.aboutlibrary.config.js",
"buildlibrary:css": "node-sass --source-map true --source-map-contents content-src/aboutlibrary -o aboutlibrary/content",

View file

@ -10,8 +10,8 @@ const REGULAR_IDS = [
];
describe("CFRMessageProvider", () => {
it("should have a total of 12 messages", () => {
assert.lengthOf(messages, 12);
it("should have a total of 10 messages", () => {
assert.lengthOf(messages, 10);
});
it("should two variants for each of the five regular addons", () => {
for (const id of REGULAR_IDS) {
@ -28,19 +28,6 @@ describe("CFRMessageProvider", () => {
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")`);
});
it("should always have xpinstallEnabled as targeting if it is an addon", () => {
for (const message of messages) {
// Ensure that the CFR messages that are recommending an addon have this targeting.

View file

@ -338,7 +338,12 @@ describe("Reducers", () => {
let updatedSection = newState.find(section => section.id === "foo_bar_2");
assert.deepEqual(updatedSection.rows, [ROW]);
const PINNED_ROW = {id: "pinned", pinned: true};
const PINNED_ROW = {id: "pinned", pinned: true, guid: "pinned"};
newState = Sections(newState, {type: at.SECTION_UPDATE, data: Object.assign({rows: [PINNED_ROW]}, {id: "foo_bar_2"})});
updatedSection = newState.find(section => section.id === "foo_bar_2");
assert.deepEqual(updatedSection.rows, [PINNED_ROW]);
// Updating the section again should not duplicate pinned cards
newState = Sections(newState, {type: at.SECTION_UPDATE, data: Object.assign({rows: [PINNED_ROW]}, {id: "foo_bar_2"})});
updatedSection = newState.find(section => section.id === "foo_bar_2");
assert.deepEqual(updatedSection.rows, [PINNED_ROW]);

View file

@ -27,6 +27,12 @@ scripts:
stringsExport: cp $npm_package_config_locales_dir/$npm_package_config_default_locale/strings.properties $npm_package_config_mc_dir/browser/locales/$npm_package_config_default_locale/chrome/browser/activity-stream/newtab.properties
copyPingCentre: cpx "ping-centre/PingCentre.jsm" $npm_package_config_mc_dir/browser/modules
# builduplift: Build and export to mozilla central for uplifts without exporting strings to browser/locales
builduplift:
pre: =>prebuildmc
bundle: => bundle
copy: =>buildmc:copy
# buildlibrary: Export about:library code to mozilla-central - intentionally not included in buildmc for now
buildlibrary:
webpack: webpack --config webpack.aboutlibrary.config.js