2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

[fenix] For https://github.com/mozilla-mobile/fenix/issues/7295 - Adds more documentation for the installation metrics

This commit is contained in:
Jeff Boek 2020-02-14 14:09:14 -08:00
parent 30c7a2dee8
commit ef35bc2c24
7 changed files with 33 additions and 45 deletions

View File

@ -1796,11 +1796,11 @@ installation:
send_in_pings: send_in_pings:
- installation - installation
description: > description: >
Campaign The name of the campaign that is responsible for this installation.
bugs: bugs:
- https://github.com/mozilla-mobile/fenix/issues/7295 - https://github.com/mozilla-mobile/fenix/issues/7295
data_reviews: data_reviews:
- TODO - https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202
notification_emails: notification_emails:
- fenix-core@mozilla.com - fenix-core@mozilla.com
expires: "2020-09-01" expires: "2020-09-01"
@ -1809,11 +1809,11 @@ installation:
send_in_pings: send_in_pings:
- installation - installation
description: > description: >
Network The name of the Network that sourced this installation.
bugs: bugs:
- https://github.com/mozilla-mobile/fenix/issues/7295 - https://github.com/mozilla-mobile/fenix/issues/7295
data_reviews: data_reviews:
- TODO - https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202
notification_emails: notification_emails:
- fenix-core@mozilla.com - fenix-core@mozilla.com
expires: "2020-09-01" expires: "2020-09-01"
@ -1822,11 +1822,11 @@ installation:
send_in_pings: send_in_pings:
- installation - installation
description: > description: >
AdGroup The name of the AdGroup that was used to source this installation.
bugs: bugs:
- https://github.com/mozilla-mobile/fenix/issues/7295 - https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202
data_reviews: data_reviews:
- TODO - https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586480836
notification_emails: notification_emails:
- fenix-core@mozilla.com - fenix-core@mozilla.com
expires: "2020-09-01" expires: "2020-09-01"
@ -1835,24 +1835,24 @@ installation:
- installation - installation
type: string type: string
description: > description: >
Creative The identifier of the creative material that the user interacted with.
bugs: bugs:
- https://github.com/mozilla-mobile/fenix/issues/7295 - https://github.com/mozilla-mobile/fenix/issues/7295
data_reviews: data_reviews:
- TODO - https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202
notification_emails: notification_emails:
- fenix-core@mozilla.com - fenix-core@mozilla.com
expires: "2020-09-01" expires: "2020-09-01"
timestamp: timestamp:
send_in_pings: send_in_pings:
- installation - installation
type: string type: datetime
description: > description: >
Timestamp The date and time of the installation.
bugs: bugs:
- https://github.com/mozilla-mobile/fenix/issues/7295 - https://github.com/mozilla-mobile/fenix/issues/7295
data_reviews: data_reviews:
- TODO - https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202
notification_emails: notification_emails:
- fenix-core@mozilla.com - fenix-core@mozilla.com
expires: "2020-09-01" expires: "2020-09-01"

View File

@ -21,11 +21,11 @@ activation:
installation: installation:
description: > description: >
Intended for counting user installs. This ping is intended to capture the source of the installation
include_client_id: false include_client_id: false
bugs: bugs:
- https://github.com/mozilla-mobile/fenix/issues/7295 - https://github.com/mozilla-mobile/fenix/issues/7295
data_reviews: data_reviews:
- TODO - https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202
notification_emails: notification_emails:
- fenix-core@mozilla.com - fenix-core@mozilla.com

View File

@ -54,10 +54,7 @@ class AdjustMetricsService(private val application: Application) : MetricsServic
application.applicationContext.settings().adjustCampaignId = application.applicationContext.settings().adjustCampaignId =
it.campaign it.campaign
} }
if (application.applicationContext.settings().adjustInstallTimestamp.isEmpty()) {
application.applicationContext.settings().adjustInstallTimestamp =
System.currentTimeMillis().toString()
}
InstallationPing(application).checkAndSend() InstallationPing(application).checkAndSend()
} }

View File

@ -54,13 +54,15 @@ class InstallationPing(private val context: Context) {
*/ */
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun triggerPing() { internal fun triggerPing() {
if (checkMetricsNotEmpty() if (checkMetricsNotEmpty()) {
) { context.settings().also {
Installation.campaign.set(context.settings().adjustCampaignId) Installation.campaign.set(it.adjustCampaignId)
Installation.adgroup.set(context.settings().adjustAdGroup) Installation.adgroup.set(it.adjustAdGroup)
Installation.creative.set(context.settings().adjustCreative) Installation.creative.set(it.adjustCreative)
Installation.network.set(context.settings().adjustNetwork) Installation.network.set(it.adjustNetwork)
Installation.timestamp.set(context.settings().adjustInstallTimestamp) Installation.timestamp.set()
}
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
Pings.installation.submit() Pings.installation.submit()
markAsTriggered() markAsTriggered()

View File

@ -110,11 +110,6 @@ class Settings private constructor(
default = "" default = ""
) )
var adjustInstallTimestamp by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_adjust_install_timestamp),
default = ""
)
var openLinksInAPrivateTab by booleanPreference( var openLinksInAPrivateTab by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_open_links_in_a_private_tab), appContext.getPreferenceKey(R.string.pref_key_open_links_in_a_private_tab),
default = false default = false

View File

@ -12,20 +12,14 @@ import io.mockk.mockk
import io.mockk.mockkStatic import io.mockk.mockkStatic
import io.mockk.spyk import io.mockk.spyk
import io.mockk.verify import io.mockk.verify
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runBlockingTest
import org.junit.Test import org.junit.Test
import org.mozilla.fenix.TestApplication
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.utils.Settings
import org.robolectric.annotation.Config
@ExperimentalCoroutinesApi
@Config(application = TestApplication::class)
internal class InstallationPingTest { internal class InstallationPingTest {
@Test @Test
fun `checkAndSend() triggers the ping if it wasn't marked as triggered`() = runBlockingTest { fun `checkAndSend() triggers the ping if it wasn't marked as triggered`() {
val mockedContext: Context = mockk(relaxed = true) val mockedContext: Context = mockk(relaxed = true)
val mockedSettings: Settings = mockk(relaxed = true) val mockedSettings: Settings = mockk(relaxed = true)
mockkStatic("org.mozilla.fenix.ext.ContextKt") mockkStatic("org.mozilla.fenix.ext.ContextKt")
@ -40,7 +34,7 @@ internal class InstallationPingTest {
verify(exactly = 1) { mockAp.triggerPing() } verify(exactly = 1) { mockAp.triggerPing() }
// Marking the ping as triggered happens in a co-routine off the main thread, // Marking the ping as triggered happens in a co-routine off the main thread,
// so wait a bit for it. // so wait a bit for it.
verify(exactly = 1) { mockAp.markAsTriggered() } verify(timeout = 5000, exactly = 1) { mockAp.markAsTriggered() }
} }
@Test @Test

View File

@ -171,17 +171,17 @@ 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 | | 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 |
## installation ## installation
Intended for counting user installs. This ping is intended to capture the source of the installation
The following metrics are added to the ping: The following metrics are added to the ping:
| Name | Type | Description | Data reviews | Extras | Expiration | | Name | Type | Description | Data reviews | Extras | Expiration |
| --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- |
| installation.adgroup |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |AdGroup |[1](TODO)||2020-09-01 | | 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) |Campaign |[1](TODO)||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) |Creative |[1](TODO)||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) |Network |[1](TODO)||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 |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |Timestamp |[1](TODO)||2020-09-01 | | installation.timestamp |[datetime](https://mozilla.github.io/glean/book/user/metrics/datetime.html) |The date and time of the installation. |[1](https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202)||2020-09-01 |
## metrics ## metrics
This is a built-in ping that is assembled out of the box by the Glean SDK. This is a built-in ping that is assembled out of the box by the Glean SDK.