diff --git a/app/metrics.yaml b/app/metrics.yaml index 318e75deb..d0377a139 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -410,6 +410,21 @@ metrics: notification_emails: - fenix-core@mozilla.com expires: "2020-03-01" + adjust_campaign: + type: string + lifetime: application + description: > + A string containing the Adjust campaign ID from which the user installed Fenix + send_in_pings: + - metrics + bugs: + - 1298 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/5579 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + search.default_engine: code: diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt index 15e360b43..f3d539363 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/AdjustMetricsService.kt @@ -13,6 +13,7 @@ import com.adjust.sdk.AdjustConfig import com.adjust.sdk.LogLevel import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.Config +import org.mozilla.fenix.ext.settings class AdjustMetricsService(private val application: Application) : MetricsService { override fun start() { @@ -33,6 +34,10 @@ class AdjustMetricsService(private val application: Application) : MetricsServic true ) + config.setOnAttributionChangedListener { + application.settings().adjustCampaignId = it.campaign + } + config.setLogLevel(LogLevel.SUPRESS) Adjust.onCreate(config) diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index d31c26ec4..d1f181920 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -40,6 +40,7 @@ import org.mozilla.fenix.GleanMetrics.SyncAuth import org.mozilla.fenix.GleanMetrics.Tab import org.mozilla.fenix.GleanMetrics.TrackingProtection import org.mozilla.fenix.ext.components +import org.mozilla.fenix.ext.settings private class EventWrapper>( private val recorder: ((Map?) -> Unit), @@ -444,6 +445,7 @@ class GleanMetricsService(private val context: Context) : MetricsService { defaultMozBrowser.set(it) } mozillaProducts.set(MozillaProductDetector.getInstalledMozillaProducts(context)) + adjustCampaign.set(context.settings().adjustCampaignId) } SearchDefaultEngine.apply { diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index 5c3a3506c..44aee186e 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -23,8 +23,8 @@ import org.mozilla.fenix.Config import org.mozilla.fenix.R import org.mozilla.fenix.components.metrics.MozillaProductDetector import org.mozilla.fenix.ext.getPreferenceKey -import org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataOnQuitType import org.mozilla.fenix.settings.PhoneFeature +import org.mozilla.fenix.settings.deletebrowsingdata.DeleteBrowsingDataOnQuitType import java.security.InvalidParameterException /** @@ -76,6 +76,11 @@ class Settings private constructor( override val preferences: SharedPreferences = appContext.getSharedPreferences(FENIX_PREFERENCES, MODE_PRIVATE) + var adjustCampaignId by stringPreference( + appContext.getPreferenceKey(R.string.pref_key_adjust_campaign), + default = "" + ) + var usePrivateMode by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_private_mode), default = false diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 9fe6d7796..ae726b413 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -104,4 +104,6 @@ pref_key_bounce_quick_action pref_key_reader_mode_notification + + pref_key_adjust_campaign diff --git a/docs/metrics.md b/docs/metrics.md index 24c8a2aa2..fa907a527 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -157,6 +157,7 @@ The following metrics are added to the ping: | Name | Type | Description | Data reviews | Extras | Expiration | | --- | --- | --- | --- | --- | --- | | experiments.metrics.active_experiment |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Records the branch name of the active experiment, if the client is enrolled in the `fenix-test-2019-08-05` experiment. This is intended to validate that the service-experiments library properly matches clients to experiments and can take action based on a multi-branched experiment. This is done by recording the experiment branch name in this string metric which allows the experiment to be transparent and unobtrusive to the user. |[1](https://bugzilla.mozilla.org/show_bug.cgi?id=1543986#c4)||2019-11-01 | +| metrics.campaign |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string containing the Adjust campaign id from which the user installed Fenix |[1](https://github.com/mozilla-mobile/fenix/pull/TODO)||2020-03-01 | | metrics.default_browser |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Is Fenix the default browser? |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673)||2020-03-01 | | metrics.default_moz_browser |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The name of the default browser on device if and only if it's a Mozilla owned product |[1](https://github.com/mozilla-mobile/fenix/pull/1953/), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-03-01 | | metrics.mozilla_products |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |A list of all the Mozilla products installed on device. We currently scan for: Firefox, Firefox Beta, Firefox Aurora, Firefox Nightly, Firefox Fdroid, Firefox Lite, Reference Browser, Reference Browser Debug, Fenix, Focus, and Lockwise. |[1](https://github.com/mozilla-mobile/fenix/pull/1953/), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-03-01 |