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
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Jul 27, 2019
1 parent e6487ba commit bb0f5a2
Show file tree
Hide file tree
Showing 6 changed files with 42 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,15 @@ private val Event.wrapper
is Event.CollectionTabSelectOpened -> EventWrapper<NoExtraKeys>(
{ Collections.tabSelectOpened.record(it) }
)
is Event.ReaderModeOpened -> EventWrapper<NoExtraKeys>(
{ ReaderMode.opened.record(it) }
)
is Event.ReaderModeClosed -> EventWrapper<NoExtraKeys>(
{ ReaderMode.closed.record(it) }
)
is Event.ReaderModeAppearanceOpened -> EventWrapper<NoExtraKeys>(
{ ReaderMode.appearance.record(it) }
)

// Don't track other events with Glean
else -> null
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 @@ -60,11 +60,12 @@ class QuickActionInteractor(

@CallSuper
override fun onReadPressed() {
context.metrics.track(Event.QuickActionSheetReadTapped)
val enabled = selectedSession?.readerMode ?: false
if (enabled) {
context.metrics.track(Event.QuickActionSheetClosed)
readerModeController.hideReaderView()
} else {
context.metrics.track(Event.QuickActionSheetOpened)
readerModeController.showReaderView()
}
quickActionStore.dispatch(QuickActionSheetAction.ReaderActiveStateChange(!enabled))
Expand All @@ -83,7 +84,7 @@ class QuickActionInteractor(

@CallSuper
override fun onAppearancePressed() {
// 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 @@ -185,11 +185,11 @@ class QuickActionInteractorTest {
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.onReadPressed()

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

Expand All @@ -213,27 +213,31 @@ class QuickActionInteractorTest {
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.onReadPressed()

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

@Test
fun onAppearancePressed() {
val context: Context = mockk()
val metrics: MetricController = mockk()
val readerModeController: ReaderModeController = mockk(relaxed = true)
val quickActionSheetStore: QuickActionSheetStore = mockk(relaxed = true)

val interactor = QuickActionInteractor(
context,
readerModeController,
mockk(),
quickActionSheetStore,
mockk(),
mockk(),
mockk()
)
every { context.metrics } returns metrics
every { metrics.track(Event.ReaderModeAppearanceOpened) } just Runs

interactor.onAppearancePressed()

Expand Down
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 bb0f5a2

Please sign in to comment.