For #4674 - Adds marketing data as a collection choice
parent
5839f5891c
commit
9f3faa43fe
|
@ -18,6 +18,8 @@ import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class AdjustMetricsService(private val application: Application) : MetricsService {
|
class AdjustMetricsService(private val application: Application) : MetricsService {
|
||||||
override fun start() {
|
override fun start() {
|
||||||
|
if (!application.settings().isMarketingTelemetryEnabled) return
|
||||||
|
|
||||||
if ((BuildConfig.ADJUST_TOKEN.isNullOrBlank())) {
|
if ((BuildConfig.ADJUST_TOKEN.isNullOrBlank())) {
|
||||||
Log.i(LOGTAG, "No adjust token defined")
|
Log.i(LOGTAG, "No adjust token defined")
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,8 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
|
||||||
private val token = Token(LeanplumId, LeanplumToken)
|
private val token = Token(LeanplumId, LeanplumToken)
|
||||||
|
|
||||||
override fun start() {
|
override fun start() {
|
||||||
|
if (!application.settings().isMarketingTelemetryEnabled) return
|
||||||
|
|
||||||
val applicationSetLocale = LocaleManager.getCurrentLocale(application)
|
val applicationSetLocale = LocaleManager.getCurrentLocale(application)
|
||||||
val currentLocale = when (applicationSetLocale != null) {
|
val currentLocale = when (applicationSetLocale != null) {
|
||||||
true -> applicationSetLocale.isO3Language
|
true -> applicationSetLocale.isO3Language
|
||||||
|
@ -96,6 +98,7 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun stop() {
|
override fun stop() {
|
||||||
|
if (application.settings().isMarketingTelemetryEnabled) return
|
||||||
// As written in LeanPlum SDK documentation, "This prevents Leanplum from communicating with the server."
|
// As written in LeanPlum SDK documentation, "This prevents Leanplum from communicating with the server."
|
||||||
// as this "isTestMode" flag is checked before LeanPlum SDK does anything.
|
// as this "isTestMode" flag is checked before LeanPlum SDK does anything.
|
||||||
// Also has the benefit effect of blocking the display of already downloaded messages.
|
// Also has the benefit effect of blocking the display of already downloaded messages.
|
||||||
|
|
|
@ -51,6 +51,15 @@ class DataChoicesFragment : PreferenceFragmentCompat() {
|
||||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_telemetry))?.apply {
|
||||||
|
isChecked = context.settings().isMarketingTelemetryEnabled
|
||||||
|
|
||||||
|
val appName = context.getString(R.string.app_name)
|
||||||
|
summary = context.getString(R.string.preferences_marketing_data_description, appName)
|
||||||
|
|
||||||
|
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||||
|
}
|
||||||
|
|
||||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_experimentation))?.apply {
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_experimentation))?.apply {
|
||||||
isChecked = context.settings().isExperimentationEnabled
|
isChecked = context.settings().isExperimentationEnabled
|
||||||
isVisible = Config.channel.isReleaseOrBeta
|
isVisible = Config.channel.isReleaseOrBeta
|
||||||
|
|
|
@ -122,6 +122,11 @@ class Settings private constructor(
|
||||||
default = true
|
default = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val isMarketingTelemetryEnabled by booleanPreference(
|
||||||
|
appContext.getPreferenceKey(R.string.pref_key_marketing_telemetry),
|
||||||
|
default = true
|
||||||
|
)
|
||||||
|
|
||||||
val isExperimentationEnabled by booleanPreference(
|
val isExperimentationEnabled by booleanPreference(
|
||||||
appContext.getPreferenceKey(R.string.pref_key_experimentation),
|
appContext.getPreferenceKey(R.string.pref_key_experimentation),
|
||||||
default = true
|
default = true
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
|
|
||||||
<!-- Data Choices -->
|
<!-- Data Choices -->
|
||||||
<string name="pref_key_telemetry" translatable="false">pref_key_telemetry</string>
|
<string name="pref_key_telemetry" translatable="false">pref_key_telemetry</string>
|
||||||
|
<string name="pref_key_marketing_telemetry" translatable="false">pref_key_marketing_telemetry</string>
|
||||||
<string name="pref_key_crash_reporter" translatable="false">pref_key_crash_reporter</string>
|
<string name="pref_key_crash_reporter" translatable="false">pref_key_crash_reporter</string>
|
||||||
<string name="pref_key_mozilla_location_service" translatable="false">pref_key_mozilla_location_service</string>
|
<string name="pref_key_mozilla_location_service" translatable="false">pref_key_mozilla_location_service</string>
|
||||||
<string name="pref_key_fenix_health_report" translatable="false">pref_key_fenix_health_report</string>
|
<string name="pref_key_fenix_health_report" translatable="false">pref_key_fenix_health_report</string>
|
||||||
|
|
|
@ -9,6 +9,11 @@
|
||||||
android:summary="@string/preferences_usage_data_description"
|
android:summary="@string/preferences_usage_data_description"
|
||||||
android:title="@string/preference_usage_data"
|
android:title="@string/preference_usage_data"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
<androidx.preference.SwitchPreference
|
||||||
|
android:key="@string/pref_key_marketing_telemetry"
|
||||||
|
android:summary="@string/preferences_marketing_data_description"
|
||||||
|
android:title="@string/preferences_marketing_data"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
<androidx.preference.SwitchPreference
|
<androidx.preference.SwitchPreference
|
||||||
android:key="@string/pref_key_experimentation"
|
android:key="@string/pref_key_experimentation"
|
||||||
android:summary="@string/preference_experiments_summary"
|
android:summary="@string/preference_experiments_summary"
|
||||||
|
|
Loading…
Reference in New Issue