Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Final sunset release of Price Tracker #322

Merged
merged 9 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Price Tracker is a Firefox extension that tracks price changes to help you find the best time to buy.

**NOTE: Price Tracker is no longer under active development.**
**IMPORTANT: Price Tracker is no longer under active development. Official support for Price Tracker ends on September 30, 2019.**

## Data Collection

Expand Down
4,279 changes: 3,381 additions & 898 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"stylelint-config-standard": "18.2.0",
"tap-mocha-reporter": "3.0.7",
"tape": "4.9.1",
"web-ext": "3.0.0",
"web-ext": "^3.1.1",
"webpack": "4.15.1",
"webpack-command": "0.3.1",
"webpack-merge": "4.1.4"
Expand Down
33 changes: 30 additions & 3 deletions src/background/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,38 @@ import {registerEvents, handleWidgetRemoved} from 'commerce/telemetry/extension'
(async function main() {
registerEvents();

// Show the browser action on first install so users see the privacy notice.
browser.runtime.onInstalled.addListener(() => {
browser.tabs.create({url: browser.extension.getURL('intro.html')});
// Show privacy notice on install. Show initial retirement notice on install and on update.
browser.runtime.onInstalled.addListener((details) => {
const {reason} = details;
if (reason === 'install') {
browser.tabs.create({url: browser.extension.getURL('intro.html')});
browser.tabs.create({url: browser.extension.getURL('retirement.html')});
} else if (reason === 'update') {
browser.tabs.create({url: browser.extension.getURL('retirement.html')});
}
});

// If 30 days have passed, show final retirement notice, wait one day, and then uninstall
const initialNoticeDuration = await config.get('initialNoticeDuration');
const currentDate = Math.round(Date.now() / 1000); // convert ms to s
let {initialNoticeDate} = await browser.storage.local.get();
if (initialNoticeDate === undefined) {
initialNoticeDate = currentDate;
await browser.storage.local.set({initialNoticeDate});
} else if (currentDate - initialNoticeDate > initialNoticeDuration) {
const finalNoticeDuration = await config.get('finalNoticeDuration');
let {finalNoticeDate} = await browser.storage.local.get('finalNoticeDate');
if (finalNoticeDate === undefined) {
finalNoticeDate = currentDate;
const retirementUrl = new URL(browser.extension.getURL('retirement.html'));
retirementUrl.searchParams.set('finalNotice', JSON.stringify(true));
browser.tabs.create({url: retirementUrl.href});
await browser.storage.local.set({finalNoticeDate: currentDate});
} else if (currentDate - finalNoticeDate > finalNoticeDuration) {
browser.management.uninstallSelf();
}
}

// Set browser action default badge color, which can't be set via manifest
browser.browserAction.setBadgeBackgroundColor({
color: await config.get('badgeAlertBackground'),
Expand Down
4 changes: 4 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ const CONFIG = {
enableStudyUI: new BoolValue(false),
/** URL for the study's recruitment survey */
studyUrl: new StringValue('https://qsurvey.mozilla.com/s3/Price-Wise-Research-Study'),

// Retirement notices (int pref values are 32 bit longs, so we can't store in units of ms)
initialNoticeDuration: new IntValue(86400 * 30), // 30 days in seconds
finalNoticeDuration: new IntValue(86400), // 1 day in seconds
};

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Price Tracker by Mozilla</title>
<title>Firefox Price Tracker Privacy Notice</title>
<style>
:root {
--blue-50: #0a84ff;
Expand Down
36 changes: 36 additions & 0 deletions src/retirement.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link href="/styles/retirement.css" rel="stylesheet">
<title>Firefox Price Tracker Retirement Notice</title>
</head>
<body>
<div class="stars"></div>
<div class="earth"></div>
<header>
<div>
<h1><a class="wordmark" href="/">Firefox Test Pilot</a></h1>
</div>
</header>
<section>
<div class="container">
<div class="copter"></div>
<div class="content">
<h1>Price Tracker <span id="notice-header">is ending</span></h1>
<p>Mozilla is ending official support for Firefox Price Tracker on September 30, 2019. Price Tracker will uninstall itself from Firefox in approximately <span id="notice-paragraph">30 days</span>. You may also choose to uninstall it now.</p>
<button id="uninstall-addon">Uninstall Price Tracker</button>
<p>Price Tracker began as a proof-of-concept experiment in Firefox Test Pilot, our experimental feature development program. You can learn more about Price Tracker on the <a href="https://support.mozilla.org/kb/price-tracker-retiring">support page</a>.</p>
<h2>Test Pilot is making a comeback!</h2>
<p>Firefox Test Pilot is coming back to life in a new form! Test Pilot users will help us refine promising new privacy and security features, for the future benefit of all Firefox users.</p>
<p>You can join the new Test Pilot early beta program by Joining Firefox. <a href="https://www.mozilla.org/firefox/accounts/">Sign in to your Firefox Account</a> and subscribe to "New Product Testing" under your email preferences.</p>
<div class="close">
<p>Thank you for flying,</p>
<p class="signature">The Test Pilot Team</p>
</div>
</div>
</div>
</section>
<script src="./retirement.js"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions src/retirement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* 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/. */

(function main() {
const button = document.getElementById('uninstall-addon');
button.addEventListener('click', () => browser.management.uninstallSelf({
showConfirmDialog: true,
}));

const url = new URL(window.location.href);
const finalNoticeJSON = url.searchParams.get('finalNotice');
let finalNotice = false;
if (finalNoticeJSON) {
finalNotice = JSON.parse(finalNoticeJSON);
}

if (finalNotice) {
const noticeHeaderElement = document.getElementById('notice-header');
noticeHeaderElement.innerText = 'ends in one day';

const noticeParagraphElement = document.getElementById('notice-paragraph');
noticeParagraphElement.innerText = 'one day';
}
}());
221 changes: 221 additions & 0 deletions src/styles/retirement.css

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions web-ext-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ module.exports = {
'[email protected]=30000',
'extensions.shopping-testpilot@mozilla.org.priceCheckTimeoutInterval=30000',
'[email protected]=10000',
'devtools.storage.extensionStorage.enabled=true',
],
startUrl: [
'http://mozilla.github.io/fake-product-page/',
'about:debugging#/runtime/this-firefox',
],
},
};
2 changes: 2 additions & 0 deletions webpack/common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ module.exports = {
{from: '**/*.png'},
{from: '**/*.ico'},
{from: '**/*.html'},
{from: '**/*.css'},
{from: 'retirement.js'},

// Experimental APIs, which are not bundled
{from: 'experiment_apis/**/*.json'},
Expand Down