Skip to content

Commit 77c24e7

Browse files
author
Cristian Tuns
committed
Revert "Bug 1993295 - Allow legacy telemetry upload for users who predate the new user TOU experience r=toolkit-telemetry-reviewers,dmose,TravisLong" for causing xpcshell failures in /test_TOUNotificationFlow.js
This reverts commit a01bc22.
1 parent a01bc22 commit 77c24e7

File tree

5 files changed

+134
-291
lines changed

5 files changed

+134
-291
lines changed

toolkit/components/telemetry/app/TelemetryReportingPolicy.sys.mjs

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,16 @@ var TelemetryReportingPolicyImpl = {
760760
* Check if we are allowed to upload data.
761761
* Prerequisite: data submission is enabled (this.dataSubmissionEnabled).
762762
*
763-
* For upload to be allowed from a data reporting standpoint, the user should
764-
* not qualify to see the legacy policy notification flow and also not qualify
765-
* to see the Terms of Use acceptance flow.
763+
* In order to submit data, at least ONE of these conditions should be true:
764+
* 1. The TOU flow is bypassed via a pref or Nimbus variable AND the legacy
765+
* notification flow bypass pref is set, so users bypass BOTH flows.
766+
* 2. The TOU flow is bypassed via a pref or Nimbus variable and the legacy
767+
* notification flow bypass pref is NOT set, so has been been shown the
768+
* legacy flow (the data submission pref should be true and the
769+
* datachoices infobar should have been displayed).
770+
* 3. The user has accepted the Terms of Use AND the user has opted-in to
771+
* sharing technical interaction data (the upload enabled pref should be
772+
* true).
766773
* @return {Boolean} True if we are allowed to upload data, false otherwise.
767774
*/
768775
canUpload() {
@@ -772,7 +779,33 @@ var TelemetryReportingPolicyImpl = {
772779
return false;
773780
}
774781

775-
return !this._shouldNotifyDataReportingPolicy() && !this._shouldShowTOU();
782+
const bypassLegacyFlow = Services.prefs.getBoolPref(
783+
TelemetryUtils.Preferences.BypassNotification,
784+
false
785+
);
786+
// TOU flow is bypassed if the Nimbus preonboarding feature is disabled
787+
// (disabled by default for Linux via the fallback
788+
// browser.preonboarding.enabled pref) or if the explicit bypass pref is
789+
// set.
790+
const bypassTOUFlow =
791+
Services.prefs.getBoolPref(TOU_BYPASS_NOTIFICATION_PREF, false) ||
792+
(!Services.prefs.getBoolPref("browser.preonboarding.enabled", false) &&
793+
this._nimbusVariables?.enabled !== true) ||
794+
this._nimbusVariables?.enabled === false;
795+
const allowInteractionData = Services.prefs.getBoolPref(
796+
"datareporting.healthreport.uploadEnabled",
797+
false
798+
);
799+
800+
// Condition 1
801+
const canUploadBypassLegacyAndTOU = bypassLegacyFlow && bypassTOUFlow;
802+
// Condition 2
803+
const canUploadLegacy =
804+
bypassTOUFlow && !bypassLegacyFlow && this.isUserNotifiedOfCurrentPolicy;
805+
// Condition 3
806+
const canUploadTOU = this.hasUserAcceptedCurrentTOU && allowInteractionData;
807+
808+
return canUploadBypassLegacyAndTOU || canUploadLegacy || canUploadTOU;
776809
},
777810

778811
isFirstRun() {
@@ -839,20 +872,6 @@ var TelemetryReportingPolicyImpl = {
839872
* Determine whether the user should be shown the terms of use.
840873
*/
841874
_shouldShowTOU() {
842-
// In some cases, _shouldShowTOU can be called before the Nimbus variables
843-
// are set. When this happens, we call _configureFromNimbus to initialize
844-
// these variables before evaluating them. This ensures we have accurate
845-
// data regarding whether preonboarding is enabled for the user. When
846-
// preonboarding is explicitly disabled, it should be treated the same the
847-
// bypassing the TOU flow via the bypass pref.
848-
if (
849-
!this._nimbusVariables ||
850-
(typeof this._nimbusVariables === "object" &&
851-
Object.keys(this._nimbusVariables).length === 0)
852-
) {
853-
this._configureFromNimbus();
854-
}
855-
856875
if (!this._nimbusVariables.enabled || !this._nimbusVariables.screens) {
857876
this._log.trace(
858877
"_shouldShowTOU - TOU not enabled or no screens configured."
@@ -1077,7 +1096,7 @@ var TelemetryReportingPolicyImpl = {
10771096
// _during_ the Firefox process lifetime; right now, we only notify the user
10781097
// at Firefox startup.
10791098
this.updateTOUPrefsForLegacyUsers();
1080-
this._configureFromNimbus();
1099+
await this._configureFromNimbus();
10811100

10821101
if (this.isFirstRun()) {
10831102
// We're performing the first run, flip firstRun preference for subsequent runs.
@@ -1214,7 +1233,7 @@ var TelemetryReportingPolicyImpl = {
12141233
* Capture Nimbus configuration: record feature variables for future use and
12151234
* set Gecko preferences based on values.
12161235
*/
1217-
_configureFromNimbus() {
1236+
async _configureFromNimbus() {
12181237
if (AppConstants.MOZ_BUILD_APP != "browser") {
12191238
// OnboardingMessageProvider is browser/ only
12201239
return;

toolkit/components/telemetry/tests/unit/head.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -594,17 +594,6 @@ if (runningInParent) {
594594
);
595595
}
596596

597-
// Disable TOU pre-onboarding in xpcshell so Telemetry isn't gated on Browser
598-
// UI.
599-
const TOS_ENABLED_PREF = "browser.preonboarding.enabled";
600-
const previous = Services.prefs.getBoolPref(TOS_ENABLED_PREF, false);
601-
602-
Services.prefs.setBoolPref(TOS_ENABLED_PREF, false);
603-
604-
registerCleanupFunction(() => {
605-
Services.prefs.setBoolPref(TOS_ENABLED_PREF, previous);
606-
});
607-
608597
fakePingSendTimer(
609598
callback => {
610599
Services.tm.dispatchToMainThread(() => callback());

toolkit/components/telemetry/tests/unit/test_PrefMigrationForTOU.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ const skipIfNotBrowser = () => ({
3838
skip_if: () => AppConstants.MOZ_BUILD_APP != "browser",
3939
});
4040

41-
add_setup(() => {
42-
// In head.js, we force TOU pre-onboarding off in xpcshell so Telemetry isn't
43-
// gated on Browser UI. Revert for these tests.
44-
const TOS_ENABLED_PREF = "browser.preonboarding.enabled";
45-
Services.prefs.clearUserPref(TOS_ENABLED_PREF);
46-
});
47-
4841
function setupLegacyAndRolloutPrefs({
4942
acceptedVersion,
5043
notifiedTime,

0 commit comments

Comments
 (0)