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

Commit

Permalink
For #2267: Fixes telemetry for reader view (#4328)
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz authored and boek committed Aug 1, 2019
1 parent 2e7a618 commit 97f7d5b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 30 deletions.
22 changes: 11 additions & 11 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,6 @@ quick_action_sheet:
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
read_tapped:
type: event
description: >
A user tapped the read button
bugs:
- 1195
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1362#issuecomment-479668466
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"

metrics:
default_browser:
Expand Down Expand Up @@ -930,6 +919,17 @@ reader_mode:
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
closed:
type: event
description: >
A user closed reader mode
bugs:
- 2267
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/4328
notification_emails:
- fenix-core@mozilla.com
expires: "2020-03-01"
appearance:
type: event
description: >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.mozilla.fenix.GleanMetrics.QuickActionSheet
import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.GleanMetrics.Collections
import org.mozilla.fenix.GleanMetrics.ReaderMode
import org.mozilla.fenix.GleanMetrics.SyncAccount
import org.mozilla.fenix.GleanMetrics.SyncAuth

Expand Down Expand Up @@ -121,9 +122,6 @@ private val Event.wrapper
is Event.QuickActionSheetDownloadTapped -> EventWrapper<NoExtraKeys>(
{ QuickActionSheet.downloadTapped.record(it) }
)
is Event.QuickActionSheetReadTapped -> EventWrapper<NoExtraKeys>(
{ QuickActionSheet.readTapped.record(it) }
)
is Event.OpenedBookmarkInNewTab -> EventWrapper<NoExtraKeys>(
{ BookmarksManagement.openInNewTab.record(it) }
)
Expand Down Expand Up @@ -265,6 +263,12 @@ private val Event.wrapper
is Event.CollectionTabSelectOpened -> EventWrapper<NoExtraKeys>(
{ Collections.tabSelectOpened.record(it) }
)
is Event.ReaderModeOpened -> EventWrapper<NoExtraKeys>(
{ ReaderMode.opened.record(it) }
)
is Event.ReaderModeAppearanceOpened -> EventWrapper<NoExtraKeys>(
{ ReaderMode.appearance.record(it) }
)
is Event.CollectionTabLongPressed -> EventWrapper<NoExtraKeys>(
{ Collections.longPress.record(it) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ sealed class Event {
object QuickActionSheetShareTapped : Event()
object QuickActionSheetBookmarkTapped : Event()
object QuickActionSheetDownloadTapped : Event()
object QuickActionSheetReadTapped : Event()
object CustomTabsClosed : Event()
object CustomTabsActionTapped : Event()
object CustomTabsMenuOpened : Event()
Expand All @@ -100,6 +99,7 @@ sealed class Event {
object HistoryAllItemsRemoved : Event()
object ReaderModeAvailable : Event()
object ReaderModeOpened : Event()
object ReaderModeClosed : Event()
object ReaderModeAppearanceOpened : Event()
object CollectionRenamed : Event()
object CollectionTabRestored : Event()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ class BrowserInteractor(
}

override fun onQuickActionSheetReadPressed() {
context.metrics.track(Event.QuickActionSheetReadTapped)
val enabled = currentSession.readerMode

if (enabled) {
context.metrics.track(Event.QuickActionSheetClosed)
readerModeController.hideReaderView()
} else {
context.metrics.track(Event.QuickActionSheetOpened)
readerModeController.showReaderView()
}
store.dispatch(QuickActionSheetAction.ReaderActiveStateChange(!enabled))
Expand All @@ -65,7 +67,7 @@ class BrowserInteractor(
}

override fun onQuickActionSheetAppearancePressed() {
// TODO telemetry: https://github.com/mozilla-mobile/fenix/issues/2267
context.metrics.track(Event.ReaderModeAppearanceOpened)
readerModeController.showControls()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ class BrowserInteractorTest {
every { context.metrics } returns metrics
every { context.components.core.sessionManager.selectedSession } returns session
every { session.readerMode } returns false
every { metrics.track(Event.QuickActionSheetReadTapped) } just Runs
every { metrics.track(Event.QuickActionSheetOpened) } just Runs

interactor.onQuickActionSheetReadPressed()

verify { metrics.track(Event.QuickActionSheetReadTapped) }
verify { metrics.track(Event.QuickActionSheetOpened) }
verify { readerModeController.showReaderView() }
}

Expand All @@ -209,11 +209,11 @@ class BrowserInteractorTest {
every { context.metrics } returns metrics
every { context.components.core.sessionManager.selectedSession } returns session
every { session.readerMode } returns true
every { metrics.track(Event.QuickActionSheetReadTapped) } just Runs
every { metrics.track(Event.QuickActionSheetClosed) } just Runs

interactor.onQuickActionSheetReadPressed()

verify { metrics.track(Event.QuickActionSheetReadTapped) }
verify { metrics.track(Event.QuickActionSheetClosed) }
verify { readerModeController.hideReaderView() }
}

Expand All @@ -240,8 +240,12 @@ class BrowserInteractorTest {
@Test
fun onQuickActionSheetAppearancePressed() {
val context: Context = mockk()
val metrics: MetricController = mockk()
val readerModeController: ReaderModeController = mockk(relaxed = true)

every { context.metrics } returns metrics
every { metrics.track(Event.ReaderModeAppearanceOpened) } just Runs

val interactor = BrowserInteractor(
context,
mockk(),
Expand All @@ -253,6 +257,9 @@ class BrowserInteractorTest {

interactor.onQuickActionSheetAppearancePressed()

verify { readerModeController.showControls() }
verify {
metrics.track(Event.ReaderModeAppearanceOpened)
readerModeController.showControls()
}
}
}
16 changes: 8 additions & 8 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,6 @@ tracking_protection</td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>read_tapped</td>
<td>event</td>
<td>A user tapped the read button</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/1362#issuecomment-479668466">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
</table>
</pre>

Expand Down Expand Up @@ -789,6 +781,14 @@ tracking_protection</td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>opened</td>
<td>event</td>
<td>A user closed reader mode</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4328">link</a></td>
<td></td>
<td>2020-03-01</td>
</tr>
<tr>
<td>appearance</td>
<td>event</td>
Expand Down

0 comments on commit 97f7d5b

Please sign in to comment.