From 2d65faf2329bd60e705197fd224c26ca2ec6c0ae Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Thu, 25 Jun 2020 10:06:26 -0700 Subject: [PATCH] For #11392: Rename Installation ping to FirstSession (#11869) --- app/metrics.yaml | 12 ++++++------ app/pings.yaml | 5 +++-- .../components/metrics/AdjustMetricsService.kt | 2 +- ...{InstallationPing.kt => FirstSessionPing.kt} | 16 ++++++++-------- .../components/metrics/GleanMetricsService.kt | 2 +- ...ationPingTest.kt => FirstSessionPingTest.kt} | 6 +++--- docs/metrics.md | 17 +++++++++-------- 7 files changed, 31 insertions(+), 29 deletions(-) rename app/src/main/java/org/mozilla/fenix/components/metrics/{InstallationPing.kt => FirstSessionPing.kt} (87%) rename app/src/test/java/org/mozilla/fenix/components/metrics/{InstallationPingTest.kt => FirstSessionPingTest.kt} (90%) diff --git a/app/metrics.yaml b/app/metrics.yaml index 8d1485f44..3cee09206 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -2319,11 +2319,11 @@ pocket: - fenix-core@mozilla.com expires: "2020-09-01" -installation: +first_session: campaign: type: string send_in_pings: - - installation + - first-session description: | The name of the campaign that is responsible for this installation. bugs: @@ -2336,7 +2336,7 @@ installation: network: type: string send_in_pings: - - installation + - first-session description: | The name of the Network that sourced this installation. bugs: @@ -2349,7 +2349,7 @@ installation: adgroup: type: string send_in_pings: - - installation + - first-session description: | The name of the AdGroup that was used to source this installation. bugs: @@ -2361,7 +2361,7 @@ installation: expires: "2020-09-01" creative: send_in_pings: - - installation + - first-session type: string description: | The identifier of the creative material that the user interacted with. @@ -2374,7 +2374,7 @@ installation: expires: "2020-09-01" timestamp: send_in_pings: - - installation + - first-session type: datetime description: | The Glean generated date and time of the installation. This is diff --git a/app/pings.yaml b/app/pings.yaml index 5a392f005..ae1474c71 100644 --- a/app/pings.yaml +++ b/app/pings.yaml @@ -19,9 +19,10 @@ activation: notification_emails: - fenix-core@mozilla.com -installation: +first-session: description: | - This ping is intended to capture the source of the installation + This ping is intended to capture the source of the app install + on the first session. include_client_id: true bugs: - https://github.com/mozilla-mobile/fenix/issues/7295 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 e8dcd5b50..6c75f9785 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 @@ -37,7 +37,7 @@ class AdjustMetricsService(private val application: Application) : MetricsServic true ) - val installationPing = InstallationPing(application) + val installationPing = FirstSessionPing(application) config.setOnAttributionChangedListener { if (!it.network.isNullOrEmpty()) { diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/InstallationPing.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/FirstSessionPing.kt similarity index 87% rename from app/src/main/java/org/mozilla/fenix/components/metrics/InstallationPing.kt rename to app/src/main/java/org/mozilla/fenix/components/metrics/FirstSessionPing.kt index 4196d3621..c85f9a920 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/InstallationPing.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/FirstSessionPing.kt @@ -11,11 +11,11 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import mozilla.components.support.base.log.logger.Logger -import org.mozilla.fenix.GleanMetrics.Installation +import org.mozilla.fenix.GleanMetrics.FirstSession import org.mozilla.fenix.GleanMetrics.Pings import org.mozilla.fenix.ext.settings -class InstallationPing(private val context: Context) { +class FirstSessionPing(private val context: Context) { private val prefs: SharedPreferences by lazy { context.getSharedPreferences( @@ -56,15 +56,15 @@ class InstallationPing(private val context: Context) { internal fun triggerPing() { if (checkMetricsNotEmpty()) { context.settings().also { - Installation.campaign.set(it.adjustCampaignId) - Installation.adgroup.set(it.adjustAdGroup) - Installation.creative.set(it.adjustCreative) - Installation.network.set(it.adjustNetwork) - Installation.timestamp.set() + FirstSession.campaign.set(it.adjustCampaignId) + FirstSession.adgroup.set(it.adjustAdGroup) + FirstSession.creative.set(it.adjustCreative) + FirstSession.network.set(it.adjustNetwork) + FirstSession.timestamp.set() } CoroutineScope(Dispatchers.IO).launch { - Pings.installation.submit() + Pings.firstSession.submit() markAsTriggered() } } 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 1813991e2..1a32a84c8 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 @@ -570,7 +570,7 @@ class GleanMetricsService(private val context: Context) : MetricsService { private var initialized = false private val activationPing = ActivationPing(context) - private val installationPing = InstallationPing(context) + private val installationPing = FirstSessionPing(context) override fun start() { logger.debug("Enabling Glean.") diff --git a/app/src/test/java/org/mozilla/fenix/components/metrics/InstallationPingTest.kt b/app/src/test/java/org/mozilla/fenix/components/metrics/FirstSessionPingTest.kt similarity index 90% rename from app/src/test/java/org/mozilla/fenix/components/metrics/InstallationPingTest.kt rename to app/src/test/java/org/mozilla/fenix/components/metrics/FirstSessionPingTest.kt index 752eeb337..c3e920f2c 100644 --- a/app/src/test/java/org/mozilla/fenix/components/metrics/InstallationPingTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/metrics/FirstSessionPingTest.kt @@ -16,7 +16,7 @@ import org.junit.Test import org.mozilla.fenix.ext.settings import org.mozilla.fenix.utils.Settings -internal class InstallationPingTest { +internal class FirstSessionPingTest { @Test fun `checkAndSend() triggers the ping if it wasn't marked as triggered`() { @@ -24,7 +24,7 @@ internal class InstallationPingTest { val mockedSettings: Settings = mockk(relaxed = true) mockkStatic("org.mozilla.fenix.ext.ContextKt") every { mockedContext.settings() } returns mockedSettings - val mockAp = spyk(InstallationPing(mockedContext), recordPrivateCalls = true) + val mockAp = spyk(FirstSessionPing(mockedContext), recordPrivateCalls = true) every { mockAp.checkMetricsNotEmpty() } returns true every { mockAp.wasAlreadyTriggered() } returns false every { mockAp.markAsTriggered() } just Runs @@ -39,7 +39,7 @@ internal class InstallationPingTest { @Test fun `checkAndSend() doesn't trigger the ping again if it was marked as triggered`() { - val mockAp = spyk(InstallationPing(mockk()), recordPrivateCalls = true) + val mockAp = spyk(FirstSessionPing(mockk()), recordPrivateCalls = true) every { mockAp.wasAlreadyTriggered() } returns true mockAp.checkAndSend() diff --git a/docs/metrics.md b/docs/metrics.md index 4634c84d0..470a7bfa2 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -9,7 +9,7 @@ This means you might have to go searching through the dependency tree to get a f - [activation](#activation) - [events](#events) - - [installation](#installation) + - [first-session](#first-session) - [metrics](#metrics) - [startup-timeline](#startup-timeline) @@ -188,9 +188,10 @@ The following metrics are added to the ping: | user_specified_search_engines.custom_engine_deleted |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user deleted a custom search engine |[1](https://github.com/mozilla-mobile/fenix/pull/6918)||2020-09-01 | | voice_search.tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected the voice search button on the search screen. |[1](https://github.com/mozilla-mobile/fenix/pull/10785)||2020-09-01 | -## installation +## first-session -This ping is intended to capture the source of the installation +This ping is intended to capture the source of the app install +on the first session. This ping includes the [client id](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section). @@ -207,11 +208,11 @@ The following metrics are added to the ping: | Name | Type | Description | Data reviews | Extras | Expiration | | --- | --- | --- | --- | --- | --- | -| installation.adgroup |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The name of the AdGroup that was used to source this installation. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586480836)||2020-09-01 | -| installation.campaign |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The name of the campaign that is responsible for this installation. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 | -| installation.creative |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The identifier of the creative material that the user interacted with. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 | -| installation.network |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The name of the Network that sourced this installation. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 | -| installation.timestamp |[datetime](https://mozilla.github.io/glean/book/user/metrics/datetime.html) |The Glean generated date and time of the installation. This is unique per app install, though the rest of the data in this ping is from Adjust and will remain static across installs. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 | +| first_session.adgroup |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The name of the AdGroup that was used to source this installation. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586480836)||2020-09-01 | +| first_session.campaign |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The name of the campaign that is responsible for this installation. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 | +| first_session.creative |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The identifier of the creative material that the user interacted with. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 | +| first_session.network |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The name of the Network that sourced this installation. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 | +| first_session.timestamp |[datetime](https://mozilla.github.io/glean/book/user/metrics/datetime.html) |The Glean generated date and time of the installation. This is unique per app install, though the rest of the data in this ping is from Adjust and will remain static across installs. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 | ## metrics