Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Replace Telemetry pref check with Telemetry API check
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhirsch committed Aug 15, 2018
1 parent d10d08a commit db2f33f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
6 changes: 1 addition & 5 deletions addon/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* globals ADDON_DISABLE Services CustomizableUI LegacyExtensionsUtils AppConstants PageActions */
const ADDON_ID = "screenshots@mozilla.org";
const TELEMETRY_ENABLED_PREF = "datareporting.healthreport.uploadEnabled";
const PREF_BRANCH = "extensions.screenshots.";
const USER_DISABLE_PREF = "extensions.screenshots.disabled";
const UPLOAD_DISABLED_PREF = "extensions.screenshots.upload-disabled";
Expand Down Expand Up @@ -178,10 +177,7 @@ function handleMessage(msg, sender, sendReply) {
return;
}

if (msg.funcName === "isTelemetryEnabled") {
const telemetryEnabled = getBoolPref(TELEMETRY_ENABLED_PREF);
sendReply({type: "success", value: telemetryEnabled});
} else if (msg.funcName === "isUploadDisabled") {
if (msg.funcName === "isUploadDisabled") {
const isESR = AppConstants.MOZ_UPDATE_CHANNEL === "esr";
const uploadDisabled = getBoolPref(UPLOAD_DISABLED_PREF);
sendReply({type: "success", value: uploadDisabled || isESR});
Expand Down
10 changes: 3 additions & 7 deletions addon/webextension/background/analytics.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* globals main, auth, catcher, deviceInfo, communication, log */
/* globals main, auth, browser, catcher, deviceInfo, communication, log */

"use strict";

Expand Down Expand Up @@ -129,13 +129,9 @@ this.analytics = (function() {
};

exports.refreshTelemetryPref = function() {
return communication.sendToBootstrap("isTelemetryEnabled").then((result) => {
return browser.telemetry.canUpload().then((result) => {
telemetryPrefKnown = true;
if (result === communication.NO_BOOTSTRAP) {
telemetryEnabled = true;
} else {
telemetryEnabled = result;
}
telemetryEnabled = result;
}, (error) => {
// If there's an error reading the pref, we should assume that we shouldn't send data
telemetryPrefKnown = true;
Expand Down
1 change: 1 addition & 0 deletions addon/webextension/manifest.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"clipboardWrite",
"contextMenus",
"mozillaAddons",
"telemetry",
"<all_urls>",
"http://localhost:10080/",
"resource://pdf.js/",
Expand Down

0 comments on commit db2f33f

Please sign in to comment.