Skip to content

Commit

Permalink
For mozilla-mobile#26224 - metrics.yaml cleanup of unneeded newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugurell committed Aug 4, 2022
1 parent 7732e16 commit 1bfb5f1
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 4 deletions.
71 changes: 67 additions & 4 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2496,7 +2496,6 @@ bookmarks_management:
- android-probes@mozilla.com
- erichards@mozilla.com
expires: never

metadata:
tags:
- Bookmarks
Expand Down Expand Up @@ -4555,7 +4554,73 @@ tracking_protection:
notification_emails:
- 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:
- ???????
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:
- ???????
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:
- ?????????
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:
- ??????
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 119
metadata:
tags:
- TrackingProtection
Expand Down Expand Up @@ -5965,7 +6030,6 @@ addons:
notification_emails:
- android-probes@mozilla.com
expires: 116

metadata:
tags:
- WebExtensions
Expand Down Expand Up @@ -6926,7 +6990,6 @@ awesomebar:
- android-probes@mozilla.com
- erichards@mozilla.com
expires: never

metadata:
tags:
- Search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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.CFRPopupProperties
Expand Down Expand Up @@ -94,6 +96,12 @@ class CFRPresenter(
CFRPopup.IndicatorDirection.DOWN
},
),
onDismiss = {
when (it) {
true -> TrackingProtection.tcpCfrExplicitDismissal.record(NoExtras())
false -> TrackingProtection.tcpCfrImplicitDismissal.record(NoExtras())
}
}
) {
Text(
text = context.getString(R.string.tcp_cfr_learn_more),
Expand All @@ -105,6 +113,7 @@ class CFRPresenter(
TOTAL_COOKIE_PROTECTION
)
)
TrackingProtection.tcpSumoLinkClicked.record(NoExtras())
tcpCfr?.dismiss()
},
style = FirefoxTheme.typography.body2.copy(
Expand All @@ -115,6 +124,7 @@ class CFRPresenter(
settings.shouldShowTotalCookieProtectionCFR = false
tcpCfr = this
show()
TrackingProtection.tcpCfrShown.record(NoExtras())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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
Expand All @@ -33,10 +34,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 CFRPresenterTest {
@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`() {
Expand Down Expand Up @@ -257,4 +265,60 @@ class CFRPresenterTest {
assertFalse(cfr.properties.overlapAnchor)
assertEquals(CFRPopup.DEFAULT_INDICATOR_START_OFFSET.dp, cfr.properties.indicatorArrowStartOffset)
}

@Test
fun `WHEN the TCP CFR is shown THEN log telemetry`() {
val context: Context = mockk {
every { getString(R.string.tcp_cfr_message) } returns "Test"
}
val anchor: View = mockk(relaxed = true)
val toolbar: BrowserToolbar = mockk {
every { findViewById<View>(R.id.mozac_browser_toolbar_security_indicator) } returns anchor
}
val settings: Settings = mockk(relaxed = true) {
every { toolbarPosition } returns ToolbarPosition.BOTTOM
}
val presenter = CFRPresenter(
context = context,
store = mockk(),
settings = settings,
toolbar = toolbar,
)

assertNull(TrackingProtection.tcpCfrShown.testGetValue())

presenter.showTcpCfr()

assertNotNull(TrackingProtection.tcpCfrShown.testGetValue())
}

@Test
fun `WHEN the TCP CFR is dismissed THEN log telemetry`() {
val context: Context = mockk {
every { getString(R.string.tcp_cfr_message) } returns "Test"
}
val anchor: View = mockk(relaxed = true)
val toolbar: BrowserToolbar = mockk {
every { findViewById<View>(R.id.mozac_browser_toolbar_security_indicator) } returns anchor
}
val settings: Settings = mockk(relaxed = true) {
every { toolbarPosition } returns ToolbarPosition.BOTTOM
}
val presenter = CFRPresenter(
context = context,
store = mockk(),
settings = settings,
toolbar = toolbar,
)

presenter.showTcpCfr()

assertNull(TrackingProtection.tcpCfrExplicitDismissal.testGetValue())
presenter.tcpCfr!!.onDismiss.invoke(true)
assertNotNull(TrackingProtection.tcpCfrExplicitDismissal.testGetValue())

assertNull(TrackingProtection.tcpCfrImplicitDismissal.testGetValue())
presenter.tcpCfr!!.onDismiss.invoke(false)
assertNotNull(TrackingProtection.tcpCfrImplicitDismissal.testGetValue())
}
}

0 comments on commit 1bfb5f1

Please sign in to comment.