2018-05-30 16:48:00 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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";
|
2019-01-30 00:41:48 +03:00
|
|
|
const {Localization} = ChromeUtils.import("resource://gre/modules/Localization.jsm");
|
|
|
|
const {FxAccountsConfig} = ChromeUtils.import("resource://gre/modules/FxAccountsConfig.jsm");
|
|
|
|
const {AttributionCode} = ChromeUtils.import("resource:///modules/AttributionCode.jsm");
|
|
|
|
const {AddonRepository} = ChromeUtils.import("resource://gre/modules/addons/AddonRepository.jsm");
|
2018-11-28 23:31:48 +03:00
|
|
|
|
2019-01-03 15:59:23 +03:00
|
|
|
async function getAddonInfo() {
|
2018-11-28 23:31:48 +03:00
|
|
|
try {
|
2018-12-13 04:06:47 +03:00
|
|
|
let {content, source} = await AttributionCode.getAttrDataAsync();
|
|
|
|
if (!content || source !== "addons.mozilla.org") {
|
2018-11-28 23:31:48 +03:00
|
|
|
return null;
|
|
|
|
}
|
2018-12-13 04:06:47 +03:00
|
|
|
// Attribution data can be double encoded
|
|
|
|
while (content.includes("%")) {
|
|
|
|
try {
|
|
|
|
const result = decodeURIComponent(content);
|
|
|
|
if (result === content) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
content = result;
|
|
|
|
} catch (e) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-01-03 15:59:23 +03:00
|
|
|
const [addon] = await AddonRepository.getAddonsByIDs([content]);
|
|
|
|
if (addon.sourceURI.scheme !== "https") {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
name: addon.name,
|
|
|
|
url: addon.sourceURI.spec,
|
|
|
|
iconURL: addon.icons["64"] || addon.icons["32"],
|
|
|
|
};
|
2018-11-28 23:31:48 +03:00
|
|
|
} catch (e) {
|
2019-01-03 15:59:23 +03:00
|
|
|
Cu.reportError("Failed to get the latest add-on version for Return to AMO");
|
2018-11-28 23:31:48 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2018-11-06 19:28:45 +03:00
|
|
|
|
2018-09-24 23:20:07 +03:00
|
|
|
const L10N = new Localization([
|
|
|
|
"branding/brand.ftl",
|
2018-11-06 19:28:45 +03:00
|
|
|
"browser/branding/sync-brand.ftl",
|
2018-09-24 23:20:07 +03:00
|
|
|
"browser/newtab/onboarding.ftl",
|
|
|
|
]);
|
2018-05-30 16:48:00 +03:00
|
|
|
|
2018-11-06 19:28:45 +03:00
|
|
|
const ONBOARDING_MESSAGES = async () => ([
|
2018-05-30 16:48:00 +03:00
|
|
|
{
|
|
|
|
id: "ONBOARDING_1",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2018-07-25 17:33:31 +03:00
|
|
|
order: 2,
|
2018-05-30 16:48:00 +03:00
|
|
|
content: {
|
2018-09-24 23:20:07 +03:00
|
|
|
title: {string_id: "onboarding-private-browsing-title"},
|
|
|
|
text: {string_id: "onboarding-private-browsing-text"},
|
2018-05-30 16:48:00 +03:00
|
|
|
icon: "privatebrowsing",
|
2018-11-28 23:31:48 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-button-label-try-now"},
|
|
|
|
action: {type: "OPEN_PRIVATE_BROWSER_WINDOW"},
|
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
2018-05-30 16:48:00 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "ONBOARDING_2",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2018-07-25 17:33:31 +03:00
|
|
|
order: 3,
|
2018-05-30 16:48:00 +03:00
|
|
|
content: {
|
2018-09-24 23:20:07 +03:00
|
|
|
title: {string_id: "onboarding-screenshots-title"},
|
|
|
|
text: {string_id: "onboarding-screenshots-text"},
|
2018-05-30 16:48:00 +03:00
|
|
|
icon: "screenshots",
|
2018-11-28 23:31:48 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-button-label-try-now"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
|
|
|
data: {args: "https://screenshots.firefox.com/#tour", where: "tabshifted"},
|
|
|
|
},
|
2018-09-14 23:18:00 +03:00
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
2018-05-30 16:48:00 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "ONBOARDING_3",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2018-07-25 17:33:31 +03:00
|
|
|
order: 1,
|
2018-05-30 16:48:00 +03:00
|
|
|
content: {
|
2018-09-24 23:20:07 +03:00
|
|
|
title: {string_id: "onboarding-addons-title"},
|
|
|
|
text: {string_id: "onboarding-addons-text"},
|
2018-05-30 16:48:00 +03:00
|
|
|
icon: "addons",
|
2018-11-28 23:31:48 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-button-label-try-now"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_ABOUT_PAGE",
|
|
|
|
data: {args: "addons"},
|
|
|
|
},
|
2018-09-24 23:20:07 +03:00
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2019-05-02 00:30:30 +03:00
|
|
|
targeting: "trailheadCohort == 0 && attributionData.campaign != 'non-fx-button' && attributionData.source != 'addons.mozilla.org'",
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
2018-05-30 16:48:37 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "ONBOARDING_4",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2018-07-25 17:33:31 +03:00
|
|
|
order: 1,
|
2018-05-30 16:48:37 +03:00
|
|
|
content: {
|
2018-09-24 23:20:07 +03:00
|
|
|
title: {string_id: "onboarding-ghostery-title"},
|
|
|
|
text: {string_id: "onboarding-ghostery-text"},
|
2018-05-30 16:48:37 +03:00
|
|
|
icon: "gift",
|
2018-11-28 23:31:48 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-button-label-try-now"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
|
|
|
data: {args: "https://addons.mozilla.org/en-US/firefox/addon/ghostery/", where: "tabshifted"},
|
|
|
|
},
|
2018-09-24 23:20:07 +03:00
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2019-05-02 00:30:30 +03:00
|
|
|
targeting: "trailheadCohort == 0 && providerCohorts.onboarding == 'ghostery'",
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
2018-09-14 23:18:00 +03:00
|
|
|
},
|
2018-11-06 19:28:45 +03:00
|
|
|
{
|
|
|
|
id: "ONBOARDING_5",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
order: 4,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-fxa-title"},
|
|
|
|
text: {string_id: "onboarding-fxa-text"},
|
|
|
|
icon: "sync",
|
2018-11-28 23:31:48 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-button-label-get-started"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
|
|
|
data: {args: await FxAccountsConfig.promiseEmailFirstURI("onboarding"), where: "tabshifted"},
|
|
|
|
},
|
2018-11-06 19:28:45 +03:00
|
|
|
},
|
|
|
|
},
|
2019-05-02 00:30:30 +03:00
|
|
|
targeting: "trailheadCohort == 0 && attributionData.campaign == 'non-fx-button' && attributionData.source == 'addons.mozilla.org'",
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
2019-04-27 00:18:28 +03:00
|
|
|
{
|
2019-05-01 22:42:24 +03:00
|
|
|
id: "TRAILHEAD_1",
|
2019-04-27 00:18:28 +03:00
|
|
|
template: "trailhead",
|
2019-05-01 22:42:24 +03:00
|
|
|
targeting: "trailheadCohort == 1",
|
2019-04-27 00:18:28 +03:00
|
|
|
trigger: {id: "firstRun"},
|
2019-04-30 01:00:01 +03:00
|
|
|
includeBundle: {length: 3, template: "onboarding", trigger: {id: "showOnboarding"}},
|
2019-05-01 22:42:24 +03:00
|
|
|
content: {
|
|
|
|
className: "joinCohort",
|
|
|
|
title: {string_id: "onboarding-welcome-body"},
|
|
|
|
benefits: ["products", "knowledge", "privacy"].map(id => (
|
|
|
|
{
|
|
|
|
id,
|
|
|
|
title: {string_id: `onboarding-benefit-${id}-title`},
|
|
|
|
text: {string_id: `onboarding-benefit-${id}-text`},
|
|
|
|
}
|
|
|
|
)),
|
|
|
|
learn: {
|
|
|
|
text: {string_id: "onboarding-welcome-learn-more"},
|
|
|
|
url: "https://www.mozilla.org/firefox/accounts/",
|
|
|
|
},
|
|
|
|
form: {
|
|
|
|
title: {string_id: "onboarding-join-form-header"},
|
|
|
|
text: {string_id: "onboarding-join-form-body"},
|
|
|
|
email: {string_id: "onboarding-join-form-email"},
|
|
|
|
button: {string_id: "onboarding-join-form-continue"},
|
|
|
|
},
|
|
|
|
skipButton: {string_id: "onboarding-start-browsing-button-label"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_2",
|
|
|
|
template: "trailhead",
|
2019-05-02 00:07:50 +03:00
|
|
|
targeting: "trailheadCohort == 2",
|
2019-05-01 22:42:24 +03:00
|
|
|
trigger: {id: "firstRun"},
|
|
|
|
includeBundle: {length: 3, template: "onboarding", trigger: {id: "showOnboarding"}},
|
|
|
|
content: {
|
|
|
|
className: "syncCohort",
|
2019-05-02 22:24:49 +03:00
|
|
|
title: {property_id: "firstrun_title"},
|
|
|
|
subtitle: {property_id: "firstrun_content"},
|
2019-05-01 22:42:24 +03:00
|
|
|
benefits: [],
|
|
|
|
learn: {
|
2019-05-02 22:24:49 +03:00
|
|
|
text: {property_id: "firstrun_learn_more_link"},
|
2019-05-01 22:42:24 +03:00
|
|
|
url: "https://www.mozilla.org/firefox/accounts/",
|
|
|
|
},
|
|
|
|
form: {
|
2019-05-02 22:24:49 +03:00
|
|
|
title: {property_id: "firstrun_form_header"},
|
|
|
|
text: {property_id: "firstrun_form_sub_header"},
|
|
|
|
email: {property_id: "firstrun_email_input_placeholder"},
|
|
|
|
button: {property_id: "firstrun_continue_to_login"},
|
2019-05-01 22:42:24 +03:00
|
|
|
},
|
2019-05-02 22:24:49 +03:00
|
|
|
skipButton: {property_id: "firstrun_skip_login"},
|
2019-05-01 22:42:24 +03:00
|
|
|
},
|
2019-04-27 00:18:28 +03:00
|
|
|
},
|
2019-05-02 00:07:50 +03:00
|
|
|
{
|
|
|
|
id: "TRAILHEAD_3",
|
|
|
|
template: "trailhead",
|
|
|
|
targeting: "trailheadCohort == 3",
|
|
|
|
trigger: {id: "firstRun"},
|
|
|
|
includeBundle: {length: 3, template: "onboarding", trigger: {id: "showOnboarding"}},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_4",
|
|
|
|
template: "trailhead",
|
|
|
|
targeting: "trailheadCohort == 4",
|
|
|
|
trigger: {id: "firstRun"},
|
|
|
|
},
|
2019-04-30 22:11:11 +03:00
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_1",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-tracking-protection-title"},
|
|
|
|
text: {string_id: "onboarding-tracking-protection-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "tracking",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-tracking-protection-button"},
|
|
|
|
action: {
|
2019-05-01 23:42:13 +03:00
|
|
|
type: "OPEN_PREFERENCES_PAGE",
|
|
|
|
data: {category: "privacy-trackingprotection"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_2",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-data-sync-title"},
|
|
|
|
text: {string_id: "onboarding-data-sync-text"},
|
2019-05-02 00:30:30 +03:00
|
|
|
icon: "devices",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-data-sync-button"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-01 23:42:13 +03:00
|
|
|
data: {args: "https://accounts.firefox.com/?service=sync&action=email&context=fx_desktop_v3&entrypoint=activity-stream-firstrun&utm_source=activity-stream&utm_campaign=firstrun", where: "tabshifted"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_3",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-firefox-monitor-title"},
|
|
|
|
text: {string_id: "onboarding-firefox-monitor-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "ffmonitor",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-firefox-monitor-button"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-01 23:42:13 +03:00
|
|
|
data: {args: "https://monitor.firefox.com/", where: "tabshifted"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_4",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-private-browsing-title"},
|
|
|
|
text: {string_id: "onboarding-private-browsing-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "private",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-private-browsing-button"},
|
2019-05-01 23:42:13 +03:00
|
|
|
action: {type: "OPEN_PRIVATE_BROWSER_WINDOW"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_5",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-firefox-send-title"},
|
|
|
|
text: {string_id: "onboarding-firefox-send-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "ffsend",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-firefox-send-button"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-01 23:42:13 +03:00
|
|
|
data: {args: "https://send.firefox.com/?utm_source=activity-stream?utm_medium=referral?utm_campaign=firstrun", where: "tabshifted"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_6",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-mobile-phone-title"},
|
|
|
|
text: {string_id: "onboarding-mobile-phone-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "mobile",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-mobile-phone-button"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-01 23:42:13 +03:00
|
|
|
data: {args: "https://www.mozilla.org/firefox/mobile/", where: "tabshifted"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_7",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-privacy-right-title"},
|
|
|
|
text: {string_id: "onboarding-privacy-right-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "pledge",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-privacy-right-button"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-01 23:42:13 +03:00
|
|
|
data: {args: "https://www.mozilla.org/?privacy-right", where: "tabshifted"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_8",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-send-tabs-title"},
|
|
|
|
text: {string_id: "onboarding-send-tabs-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "sendtab",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-send-tabs-button"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-01 23:42:13 +03:00
|
|
|
data: {args: "https://blog.mozilla.org/firefox/send-tabs-a-better-way/", where: "tabshifted"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_9",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-pocket-anywhere-title"},
|
|
|
|
text: {string_id: "onboarding-pocket-anywhere-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "pocket",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-pocket-anywhere-button"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-01 23:42:13 +03:00
|
|
|
data: {args: "https://getpocket.com/firefox_learnmore", where: "tabshifted"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_10",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-lockwise-passwords-title"},
|
|
|
|
text: {string_id: "onboarding-lockwise-passwords-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "lockwise",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-lockwise-passwords-button"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-01 23:42:13 +03:00
|
|
|
data: {args: "https://lockwise.firefox.com/", where: "tabshifted"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_11",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-facebook-container-title"},
|
|
|
|
text: {string_id: "onboarding-facebook-container-text"},
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "fbcont",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "onboarding-facebook-container-button"},
|
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-01 23:42:13 +03:00
|
|
|
data: {args: "https://addons.mozilla.org/firefox/addon/facebook-container/", where: "tabshifted"},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "trailheadCohort > 0",
|
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
2018-11-15 18:59:55 +03:00
|
|
|
{
|
|
|
|
id: "FXA_1",
|
|
|
|
template: "fxa_overlay",
|
2018-11-06 19:28:45 +03:00
|
|
|
trigger: {id: "firstRun"},
|
|
|
|
},
|
2018-11-28 23:31:48 +03:00
|
|
|
{
|
|
|
|
id: "RETURN_TO_AMO_1",
|
|
|
|
template: "return_to_amo_overlay",
|
|
|
|
content: {
|
|
|
|
header: {string_id: "onboarding-welcome-header"},
|
|
|
|
title: {string_id: "return-to-amo-sub-header"},
|
2019-01-03 15:59:23 +03:00
|
|
|
addon_icon: null,
|
2018-11-28 23:31:48 +03:00
|
|
|
icon: "gift-extension",
|
2019-01-03 15:59:23 +03:00
|
|
|
text: {string_id: "return-to-amo-addon-header", args: {"addon-name": null}},
|
2018-11-28 23:31:48 +03:00
|
|
|
primary_button: {
|
|
|
|
label: {string_id: "return-to-amo-extension-button"},
|
|
|
|
action: {
|
|
|
|
type: "INSTALL_ADDON_FROM_URL",
|
2019-01-03 15:59:23 +03:00
|
|
|
data: {url: null},
|
2018-11-28 23:31:48 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
secondary_button: {
|
|
|
|
label: {string_id: "return-to-amo-get-started-button"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "attributionData.campaign == 'non-fx-button' && attributionData.source == 'addons.mozilla.org'",
|
|
|
|
trigger: {id: "firstRun"},
|
|
|
|
},
|
2018-10-02 23:01:54 +03:00
|
|
|
]);
|
2018-05-30 16:48:00 +03:00
|
|
|
|
|
|
|
const OnboardingMessageProvider = {
|
2018-09-24 23:20:07 +03:00
|
|
|
async getExtraAttributes() {
|
|
|
|
const [header, button_label] = await L10N.formatMessages([
|
|
|
|
{id: "onboarding-welcome-header"},
|
|
|
|
{id: "onboarding-start-browsing-button-label"},
|
|
|
|
]);
|
|
|
|
return {header: header.value, button_label: button_label.value};
|
|
|
|
},
|
|
|
|
async getMessages() {
|
2018-11-06 19:28:45 +03:00
|
|
|
const messages = await this.translateMessages(await ONBOARDING_MESSAGES());
|
2018-09-24 23:20:07 +03:00
|
|
|
return messages;
|
|
|
|
},
|
2018-11-06 19:28:45 +03:00
|
|
|
async getUntranslatedMessages() {
|
2018-10-31 20:51:24 +03:00
|
|
|
// This is helpful for jsonSchema testing - since we are localizing in the provider
|
2018-11-06 19:28:45 +03:00
|
|
|
const messages = await ONBOARDING_MESSAGES();
|
|
|
|
return messages;
|
2018-10-31 20:51:24 +03:00
|
|
|
},
|
2018-09-24 23:20:07 +03:00
|
|
|
async translateMessages(messages) {
|
|
|
|
let translatedMessages = [];
|
|
|
|
for (const msg of messages) {
|
2018-11-28 23:31:48 +03:00
|
|
|
let translatedMessage = {...msg};
|
|
|
|
|
2018-11-15 18:59:55 +03:00
|
|
|
// If the message has no content, do not attempt to translate it
|
2018-11-28 23:31:48 +03:00
|
|
|
if (!translatedMessage.content) {
|
|
|
|
translatedMessages.push(translatedMessage);
|
2018-11-15 18:59:55 +03:00
|
|
|
continue;
|
|
|
|
}
|
2018-11-28 23:31:48 +03:00
|
|
|
|
2019-01-03 15:59:23 +03:00
|
|
|
// We need some addon info if we are showing return to amo overlay, so fetch
|
|
|
|
// that, and update the message accordingly
|
|
|
|
if (msg.template === "return_to_amo_overlay") {
|
|
|
|
try {
|
|
|
|
const {name, iconURL, url} = await getAddonInfo();
|
|
|
|
// If we do not have all the data from the AMO api to indicate to the user
|
|
|
|
// what they are installing we don't want to show the message
|
|
|
|
if (!name || !iconURL || !url) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.content.text.args["addon-name"] = name;
|
|
|
|
msg.content.addon_icon = iconURL;
|
|
|
|
msg.content.primary_button.action.data.url = url;
|
|
|
|
} catch (e) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-28 23:31:48 +03:00
|
|
|
// Translate any secondary buttons separately
|
|
|
|
if (msg.content.secondary_button) {
|
|
|
|
const [secondary_button_string] = await L10N.formatMessages([{id: msg.content.secondary_button.label.string_id}]);
|
|
|
|
translatedMessage.content.secondary_button.label = secondary_button_string.value;
|
|
|
|
}
|
|
|
|
if (msg.content.header) {
|
|
|
|
const [header_string] = await L10N.formatMessages([{id: msg.content.header.string_id}]);
|
|
|
|
translatedMessage.content.header = header_string.value;
|
|
|
|
}
|
2018-09-24 23:20:07 +03:00
|
|
|
translatedMessages.push(translatedMessage);
|
|
|
|
}
|
|
|
|
return translatedMessages;
|
2018-09-14 23:18:00 +03:00
|
|
|
},
|
2018-05-30 16:48:00 +03:00
|
|
|
};
|
|
|
|
this.OnboardingMessageProvider = OnboardingMessageProvider;
|
|
|
|
|
|
|
|
const EXPORTED_SYMBOLS = ["OnboardingMessageProvider"];
|