Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #11392: Rename Installation ping to FirstSession
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Jun 24, 2020
1 parent 621da0c commit d5dfbb7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 29 deletions.
12 changes: 6 additions & 6 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2319,11 +2319,11 @@ pocket:
- [email protected]
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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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.
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions app/pings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ activation:
notification_emails:
- [email protected]

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ 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`() {
val mockedContext: Context = mockk(relaxed = true)
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
Expand All @@ -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()
Expand Down
17 changes: 9 additions & 8 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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).
Expand All @@ -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

Expand Down

0 comments on commit d5dfbb7

Please sign in to comment.