mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1246130 - Gather onboarding telemetry experiments separately from other active experiments. r=margaret
MozReview-Commit-ID: KPqdlzoqTBH
This commit is contained in:
parent
28b383cdfa
commit
39dce1f7b6
@ -8,8 +8,7 @@ package org.mozilla.gecko.firstrun;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import com.keepsafe.switchboard.SwitchBoard;
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
@ -28,22 +27,25 @@ public class FirstrunPagerConfig {
|
||||
public static List<FirstrunPanelConfig> getDefault(Context context) {
|
||||
final List<FirstrunPanelConfig> panels = new LinkedList<>();
|
||||
|
||||
if (isInExperimentLocal(context, Experiments.ONBOARDING2_A)) {
|
||||
if (Experiments.isInExperimentLocal(context, Experiments.ONBOARDING2_A)) {
|
||||
panels.add(new FirstrunPanelConfig(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
|
||||
Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, Experiments.ONBOARDING2_A);
|
||||
} else if (isInExperimentLocal(context, Experiments.ONBOARDING2_B)) {
|
||||
GeckoSharedPrefs.forProfile(context).edit().putString(Experiments.PREF_ONBOARDING_VERSION, Experiments.ONBOARDING2_A).apply();
|
||||
} else if (Experiments.isInExperimentLocal(context, Experiments.ONBOARDING2_B)) {
|
||||
panels.add(SimplePanelConfigs.urlbarPanelConfig);
|
||||
panels.add(SimplePanelConfigs.bookmarksPanelConfig);
|
||||
panels.add(SimplePanelConfigs.syncPanelConfig);
|
||||
panels.add(new FirstrunPanelConfig(SyncPanel.class.getName(), SyncPanel.TITLE_RES));
|
||||
Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, Experiments.ONBOARDING2_B);
|
||||
} else if (isInExperimentLocal(context, Experiments.ONBOARDING2_C)) {
|
||||
GeckoSharedPrefs.forProfile(context).edit().putString(Experiments.PREF_ONBOARDING_VERSION, Experiments.ONBOARDING2_B).apply();
|
||||
} else if (Experiments.isInExperimentLocal(context, Experiments.ONBOARDING2_C)) {
|
||||
panels.add(SimplePanelConfigs.urlbarPanelConfig);
|
||||
panels.add(SimplePanelConfigs.bookmarksPanelConfig);
|
||||
panels.add(SimplePanelConfigs.dataPanelConfig);
|
||||
panels.add(SimplePanelConfigs.syncPanelConfig);
|
||||
panels.add(new FirstrunPanelConfig(SyncPanel.class.getName(), SyncPanel.TITLE_RES));
|
||||
Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, Experiments.ONBOARDING2_C);
|
||||
GeckoSharedPrefs.forProfile(context).edit().putString(Experiments.PREF_ONBOARDING_VERSION, Experiments.ONBOARDING2_C).apply();
|
||||
} else {
|
||||
Log.d(LOGTAG, "Not in an experiment!");
|
||||
panels.add(new FirstrunPanelConfig(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
|
||||
@ -52,22 +54,6 @@ public class FirstrunPagerConfig {
|
||||
return panels;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper method for using local bucketing rather than server-side.
|
||||
* This needs to match the server-side bucketing used on mozilla-switchboard.herokuapp.com.
|
||||
*/
|
||||
private static boolean isInExperimentLocal(Context context, String name) {
|
||||
if (AppConstants.MOZ_SWITCHBOARD) {
|
||||
if (SwitchBoard.isInBucket(context, 0, 33)) {
|
||||
return Experiments.ONBOARDING2_A.equals(name);
|
||||
} else if (SwitchBoard.isInBucket(context, 33, 66)) {
|
||||
return Experiments.ONBOARDING2_B.equals(name);
|
||||
} else if (SwitchBoard.isInBucket(context, 66, 100)) {
|
||||
return Experiments.ONBOARDING2_C.equals(name);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<FirstrunPanelConfig> getRestricted() {
|
||||
final List<FirstrunPanelConfig> panels = new LinkedList<>();
|
||||
|
@ -8,12 +8,11 @@ package org.mozilla.gecko.telemetry;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import com.keepsafe.switchboard.SwitchBoard;
|
||||
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.Locales;
|
||||
import org.mozilla.gecko.sync.ExtendedJSONObject;
|
||||
import org.mozilla.gecko.telemetry.TelemetryConstants.CorePing;
|
||||
import org.mozilla.gecko.util.Experiments;
|
||||
import org.mozilla.gecko.util.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -87,9 +86,7 @@ public class TelemetryPingGenerator {
|
||||
ping.put(CorePing.LOCALE, Locales.getLanguageTag(Locale.getDefault()));
|
||||
ping.put(CorePing.OS_VERSION, Integer.toString(Build.VERSION.SDK_INT)); // A String for cross-platform reasons.
|
||||
ping.put(CorePing.SEQ, seq);
|
||||
if (AppConstants.MOZ_SWITCHBOARD) {
|
||||
ping.putArray(CorePing.EXPERIMENTS, SwitchBoard.getActiveExperiments(context));
|
||||
}
|
||||
ping.putArray(CorePing.EXPERIMENTS, Experiments.getActiveExperiments(context));
|
||||
// TODO (bug 1246816): Remove this "optional" parameter work-around when
|
||||
// GeckoProfile.getAndPersistProfileCreationDateFromFilesystem is implemented. That method returns -1
|
||||
// while it's not implemented so we don't include the parameter in the ping if that's the case.
|
||||
|
@ -4,8 +4,16 @@
|
||||
|
||||
package org.mozilla.gecko.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import android.util.Log;
|
||||
import org.mozilla.gecko.mozglue.ContextUtils.SafeIntent;
|
||||
import android.text.TextUtils;
|
||||
import com.keepsafe.switchboard.SwitchBoard;
|
||||
import org.mozilla.gecko.GeckoSharedPrefs;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class should reflect the experiment names found in the Switchboard experiments config here:
|
||||
@ -22,6 +30,8 @@ public class Experiments {
|
||||
public static final String ONBOARDING2_B = "onboarding2-b"; // 4 static Feature slides
|
||||
public static final String ONBOARDING2_C = "onboarding2-c"; // 4 static + 1 clickable (Data saving) Feature slides
|
||||
|
||||
public static final String PREF_ONBOARDING_VERSION = "onboarding_version";
|
||||
|
||||
// Show search mode (instead of home panels) when tapping on urlbar if there is a search term in the urlbar.
|
||||
public static final String SEARCH_TERM = "search-term";
|
||||
|
||||
@ -55,4 +65,38 @@ public class Experiments {
|
||||
disabled = false;
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if a user is in certain local experiment.
|
||||
* @param experiment Name of experiment to look up
|
||||
* @return returns value for experiment or false if experiment does not exist.
|
||||
*/
|
||||
public static boolean isInExperimentLocal(Context context, String experiment) {
|
||||
if (SwitchBoard.isInBucket(context, 0, 33)) {
|
||||
return Experiments.ONBOARDING2_A.equals(experiment);
|
||||
} else if (SwitchBoard.isInBucket(context, 33, 66)) {
|
||||
return Experiments.ONBOARDING2_B.equals(experiment);
|
||||
} else if (SwitchBoard.isInBucket(context, 66, 100)) {
|
||||
return Experiments.ONBOARDING2_C.equals(experiment);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of all active experiments, remote and local.
|
||||
* @return List of experiment names Strings
|
||||
*/
|
||||
public static List<String> getActiveExperiments(Context c) {
|
||||
final List<String> experiments = new LinkedList<>();
|
||||
experiments.addAll(SwitchBoard.getActiveExperiments(c));
|
||||
|
||||
// Add onboarding version.
|
||||
final String onboardingExperiment = GeckoSharedPrefs.forProfile(c).getString(Experiments.PREF_ONBOARDING_VERSION, null);
|
||||
if (!TextUtils.isEmpty(onboardingExperiment)) {
|
||||
experiments.add(onboardingExperiment);
|
||||
}
|
||||
|
||||
return experiments;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,6 @@ gujar.sources += ['java/org/mozilla/gecko/' + x for x in [
|
||||
'util/ColorUtils.java',
|
||||
'util/DrawableUtil.java',
|
||||
'util/EventCallback.java',
|
||||
'util/Experiments.java',
|
||||
'util/FileUtils.java',
|
||||
'util/FloatUtils.java',
|
||||
'util/GamepadUtils.java',
|
||||
@ -578,6 +577,7 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
|
||||
'trackingprotection/TrackingProtectionPrompt.java',
|
||||
'updater/UpdateService.java',
|
||||
'updater/UpdateServiceHelper.java',
|
||||
'util/Experiments.java',
|
||||
'Webapp.java',
|
||||
'webapp/Allocator.java',
|
||||
'webapp/ApkResources.java',
|
||||
|
Loading…
Reference in New Issue
Block a user