Bug 1833638 - remove client ID duplication code

fenix/115.2.0
Bruno Rosa 1 year ago committed by mergify[bot]
parent 4291ce211e
commit ef95f337f3

@ -1,12 +1,4 @@
---
client-deduplication:
description: A feature to control the sending of the client-deduplication ping.
hasExposure: true
exposureDescription: ""
variables:
enabled:
type: boolean
description: "If true, the ping will be sent."
cookie-banners:
description: Features for cookie banner handling.
hasExposure: true

@ -258,7 +258,6 @@ events:
send_in_pings:
- metrics
- baseline
- client-deduplication
bugs:
- https://github.com/mozilla-mobile/fenix/issues/17089
data_reviews:
@ -1837,7 +1836,6 @@ metrics:
send_in_pings:
- metrics
- baseline
- client-deduplication
bugs:
- https://github.com/mozilla-mobile/fenix/issues/1158
- https://github.com/mozilla-mobile/fenix/issues/6556
@ -2109,7 +2107,6 @@ metrics:
please see `has_open_tabs`.
send_in_pings:
- metrics
- client-deduplication
bugs:
- https://github.com/mozilla-mobile/fenix/issues/11479
data_reviews:
@ -2927,7 +2924,6 @@ search.default_engine:
send_in_pings:
- metrics
- baseline
- client-deduplication
bugs:
- https://github.com/mozilla-mobile/fenix/issues/800
data_reviews:
@ -2957,7 +2953,6 @@ search.default_engine:
send_in_pings:
- metrics
- baseline
- client-deduplication
bugs:
- https://github.com/mozilla-mobile/fenix/issues/800
data_reviews:
@ -3543,8 +3538,6 @@ sync_auth:
notification_emails:
- android-probes@mozilla.com
- cgordon@mozilla.com
send_in_pings:
- client-deduplication
expires: never
metadata:
tags:
@ -6977,7 +6970,6 @@ browser.search:
send_in_pings:
- metrics
- baseline
- client-deduplication
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6558
- https://github.com/mozilla-mobile/fenix/issues/28010
@ -7012,7 +7004,6 @@ browser.search:
send_in_pings:
- metrics
- baseline
- client-deduplication
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6558
- https://github.com/mozilla-mobile/fenix/issues/28010
@ -7038,7 +7029,6 @@ browser.search:
send_in_pings:
- metrics
- baseline
- client-deduplication
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6557
data_reviews:
@ -9452,56 +9442,6 @@ review_prompt:
data_sensitivity:
- interaction
expires: 121
client_deduplication:
valid_advertising_id:
type: boolean
description: |
Whether or not we get a valid advertising ID from the device.
send_in_pings:
- client-deduplication
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1817029
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1813195#c11
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
- fbertsch@mozilla.com
expires: 122
experiment_timeframe:
type: string
description: |
A string we use to identify which run of the experiment this is.
send_in_pings:
- client-deduplication
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1817029
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1813195#c11
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
- fbertsch@mozilla.com
expires: 122
hashed_gaid:
type: string
lifetime: ping
description: |
A hashed and salted version of the Google Advertising ID from the device.
send_in_pings:
- client-deduplication
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1817029
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1813195#c11
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
- fbertsch@mozilla.com
expires: 122
private_browsing_shortcut_cfr:
add_shortcut:

@ -260,21 +260,6 @@ features:
value:
enabled: true
client-deduplication:
description: A feature to control the sending of the client-deduplication ping.
variables:
enabled:
description: If true, the ping will be sent.
type: Boolean
default: false
defaults:
- channel: nightly
value:
enabled: false
- channel: developer
value:
enabled: false
growth-data:
description: A feature measuring campaign growth data
variables:

@ -65,24 +65,6 @@ spoc:
notification_emails:
- android-probes@mozilla.com
client-deduplication:
description: |
Contains data to help identify if client IDs are being regenerated
erroneously.
include_client_id: true
reasons:
active: |
The ping is being sent when the app is coming to the foreground.
inactive: |
The ping is being sent when the app is going to the background.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1817029
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1813195#c11
notification_emails:
- android-probes@mozilla.com
- fbertsch@mozilla.com
cookie-banner-report-site:
description: |
This ping is needed when the cookie banner reducer doesn't work on

@ -76,7 +76,6 @@ import org.mozilla.fenix.components.Core
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.components.metrics.MetricServiceType
import org.mozilla.fenix.components.metrics.MozillaProductDetector
import org.mozilla.fenix.components.metrics.clientdeduplication.ClientDeduplicationLifecycleObserver
import org.mozilla.fenix.experiments.maybeFetchExperiments
import org.mozilla.fenix.ext.areNotificationsEnabledSafe
import org.mozilla.fenix.ext.containsQueryParameters
@ -203,12 +202,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
GlobalScope.launch(Dispatchers.IO) {
setStartupMetrics(store, settings())
}
ProcessLifecycleOwner.get().lifecycle.addObserver(
ClientDeduplicationLifecycleObserver(
this.applicationContext,
),
)
}
@VisibleForTesting

@ -1,43 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.components.metrics.clientdeduplication
import android.content.Context
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import org.mozilla.fenix.nimbus.FxNimbus
/**
* This observer allows us to mimic roughly the same schedule as the Glean SDK baseline ping.
* https://github.com/mozilla/glean/blob/main/glean-core/android/src/main/java/mozilla/telemetry/glean/scheduler/GleanLifecycleObserver.kt
*/
class ClientDeduplicationLifecycleObserver(context: Context) : LifecycleEventObserver {
private val clientDeduplicationPing = ClientDeduplicationPing(context)
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
// The ping will only be sent whenever the Nimbus feature is enabled.
if (FxNimbus.features.clientDeduplication.value().enabled) {
when (event) {
Lifecycle.Event.ON_STOP -> {
clientDeduplicationPing.triggerPing(active = false)
}
Lifecycle.Event.ON_START -> {
// We use ON_START here because we don't want to incorrectly count metrics in
// ON_RESUME as pause/resume can happen when interacting with things like the
// navigation shade which could lead to incorrectly recording the start of a
// duration, etc.
//
// https://developer.android.com/reference/android/app/Activity.html#onStart()
clientDeduplicationPing.triggerPing(active = true)
}
else -> {
// For other lifecycle events, do nothing
}
}
}
}
}

@ -1,49 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.components.metrics.clientdeduplication
import android.content.Context
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.mozilla.fenix.GleanMetrics.ClientDeduplication
import org.mozilla.fenix.GleanMetrics.Pings
import org.mozilla.fenix.components.metrics.MetricsUtils.getHashedIdentifier
/**
* Class to help construct and send the `clientDeduplication` ping.
*/
class ClientDeduplicationPing(private val context: Context) {
private val customHashingSalt = "bug-1813195-02-2023"
/**
* Fills the metrics and triggers the 'clientDeduplication' ping.
*/
internal fun triggerPing(active: Boolean) {
CoroutineScope(Dispatchers.IO).launch {
val hashedId = getHashedIdentifier(context, customHashingSalt)
// Record the metrics.
if (hashedId != null) {
// We have a valid, hashed Google Advertising ID.
ClientDeduplication.hashedGaid.set(hashedId)
ClientDeduplication.validAdvertisingId.set(true)
} else {
ClientDeduplication.validAdvertisingId.set(false)
}
ClientDeduplication.experimentTimeframe.set(customHashingSalt)
// Set the reason based on if the app is foregrounded or backgrounded.
val reason = if (active) {
Pings.clientDeduplicationReasonCodes.active
} else {
Pings.clientDeduplicationReasonCodes.inactive
}
// Submit the ping.
Pings.clientDeduplication.submit(reason)
}
}
}

@ -1,41 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.components.metrics.clientdeduplication
import mozilla.components.service.glean.testing.GleanTestRule
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.ClientDeduplication
import org.mozilla.fenix.GleanMetrics.Pings
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
// For gleanTestRule
@RunWith(FenixRobolectricTestRunner::class)
internal class ClientDeduplicationPingTest {
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
@Test
fun `The clientDeduplication ping is sent`() {
// Record test data.
ClientDeduplication.validAdvertisingId.set(true)
// Instruct the ping API to validate the ping data.
var validatorRun = false
Pings.clientDeduplication.testBeforeNextSubmit { reason ->
assertEquals(Pings.clientDeduplicationReasonCodes.active, reason)
assertEquals(true, ClientDeduplication.validAdvertisingId.testGetValue())
validatorRun = true
}
Pings.clientDeduplication.submit(Pings.clientDeduplicationReasonCodes.active)
// Verify that the validator ran.
assertTrue(validatorRun)
}
}
Loading…
Cancel
Save