For #26224 - TCP CFR telemetry

pull/543/head
Mugurell 2 years ago committed by mergify[bot]
parent f4b823b43b
commit 67a55fe089

@ -4575,6 +4575,73 @@ tracking_protection:
- android-probes@mozilla.com
expires: 111
metadata:
tags:
- TrackingProtection
tcp_cfr_shown:
type: event
description: |
The Total Cookie Protection CFR was shown to the user.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/26224
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/26226#issuecomment-1204007332
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 119
metadata:
tags:
- TrackingProtection
tcp_cfr_implicit_dismissal:
type: event
description: |
The Total Cookie Protection CFR was dismissed by the user by interacting
with the outside of the popup.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/26224
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/26226#issuecomment-1204007332
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 119
metadata:
tags:
- TrackingProtection
tcp_cfr_explicit_dismissal:
type: event
description: |
The Total Cookie Protection CFR was dismissed by the user by clicking on
the "X" button to close the popup.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/26224
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/26226#issuecomment-1204007332
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 119
metadata:
tags:
- TrackingProtection
tcp_sumo_link_clicked:
type: event
description: |
A user clicked the link in the Total Cookie Protection CFR to open a new
SUMO tab detailing the Total Cookie Protection feature.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/26224
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/26226#issuecomment-1204007332
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 119
metadata:
tags:
- TrackingProtection

@ -20,6 +20,8 @@ import mozilla.components.browser.state.selector.findCustomTabOrSelectedTab
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.browser.toolbar.BrowserToolbar
import mozilla.components.lib.state.ext.flowScoped
import mozilla.components.service.glean.private.NoExtras
import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.cfr.CFRPopup
import org.mozilla.fenix.compose.cfr.CFRPopup.PopupAlignment.INDICATOR_CENTERED_IN_ANCHOR
@ -103,6 +105,12 @@ class BrowserToolbarCFRPresenter(
},
popupVerticalOffset = CFR_TO_ANCHOR_VERTICAL_PADDING.dp
),
onDismiss = {
when (it) {
true -> TrackingProtection.tcpCfrExplicitDismissal.record(NoExtras())
false -> TrackingProtection.tcpCfrImplicitDismissal.record(NoExtras())
}
}
) {
Text(
text = context.getString(R.string.tcp_cfr_learn_more),
@ -114,6 +122,7 @@ class BrowserToolbarCFRPresenter(
TOTAL_COOKIE_PROTECTION
)
)
TrackingProtection.tcpSumoLinkClicked.record(NoExtras())
tcpCfrPopup?.dismiss()
},
style = FirefoxTheme.typography.body2.copy(
@ -124,6 +133,7 @@ class BrowserToolbarCFRPresenter(
settings.shouldShowTotalCookieProtectionCFR = false
tcpCfrPopup = this
show()
TrackingProtection.tcpCfrShown.record(NoExtras())
}
}
}

@ -24,6 +24,7 @@ import mozilla.components.browser.state.state.createTab
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.browser.toolbar.BrowserToolbar
import mozilla.components.support.test.ext.joinBlocking
import mozilla.components.support.test.robolectric.testContext
import mozilla.components.support.test.rule.MainCoroutineRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@ -35,10 +36,17 @@ import org.junit.Test
import org.mozilla.fenix.R
import org.mozilla.fenix.compose.cfr.CFRPopup
import org.mozilla.fenix.utils.Settings
import mozilla.telemetry.glean.testing.GleanTestRule
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class)
class BrowserToolbarCFRPresenterTest {
@get:Rule
val coroutinesTestRule = MainCoroutineRule()
@get:Rule
val gleanTestRule = GleanTestRule(testContext)
@Test
fun `GIVEN the TCP CFR should be shown for a custom tab WHEN the custom tab is fully loaded THEN the TCP CFR is shown`() {
@ -194,6 +202,36 @@ class BrowserToolbarCFRPresenterTest {
}
}
@Test
fun `WHEN the TCP CFR is shown THEN log telemetry`() {
val presenter = createPresenter(
anchor = mockk(relaxed = true),
)
assertNull(TrackingProtection.tcpCfrShown.testGetValue())
presenter.showTcpCfr()
assertNotNull(TrackingProtection.tcpCfrShown.testGetValue())
}
@Test
fun `WHEN the TCP CFR is dismissed THEN log telemetry`() {
val presenter = createPresenter(
anchor = mockk(relaxed = true)
)
presenter.showTcpCfr()
assertNull(TrackingProtection.tcpCfrExplicitDismissal.testGetValue())
presenter.tcpCfrPopup!!.onDismiss.invoke(true)
assertNotNull(TrackingProtection.tcpCfrExplicitDismissal.testGetValue())
assertNull(TrackingProtection.tcpCfrImplicitDismissal.testGetValue())
presenter.tcpCfrPopup!!.onDismiss.invoke(false)
assertNotNull(TrackingProtection.tcpCfrImplicitDismissal.testGetValue())
}
/**
* Creates and return a [spyk] of a [BrowserToolbarCFRPresenter] that can handle actually showing CFRs.
*/

Loading…
Cancel
Save