For #1857: Adds telemetry for QR scanner
parent
732b255ce5
commit
9e50b55340
|
@ -633,4 +633,50 @@ activation:
|
||||||
- https://github.com/mozilla-mobile/fenix/pull/1707#issuecomment-486972209
|
- https://github.com/mozilla-mobile/fenix/pull/1707#issuecomment-486972209
|
||||||
notification_emails:
|
notification_emails:
|
||||||
- fenix-core@mozilla.com
|
- fenix-core@mozilla.com
|
||||||
expires: "2019-10-01"
|
expires: "2019-10-01"
|
||||||
|
|
||||||
|
qr_scanner:
|
||||||
|
opened:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
A user opened the QR scanner
|
||||||
|
bugs:
|
||||||
|
- 1857
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/2524#issuecomment-492739967
|
||||||
|
notification_emails:
|
||||||
|
- fenix-core@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
|
prompt_displayed:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
A user scanned a QR code, causing a confirmation prompt to display asking if they want to navigate to the page
|
||||||
|
bugs:
|
||||||
|
- 1857
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/2524#issuecomment-492739967
|
||||||
|
notification_emails:
|
||||||
|
- fenix-core@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
|
navigation_allowed:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
A user tapped "allow" on the prompt, directing the user to the website scanned
|
||||||
|
bugs:
|
||||||
|
- 1857
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/2524#issuecomment-492739967
|
||||||
|
notification_emails:
|
||||||
|
- fenix-core@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
||||||
|
navigation_denied:
|
||||||
|
type: event
|
||||||
|
description: >
|
||||||
|
A user tapped "deny" on the prompt, putting the user back to the scanning view
|
||||||
|
bugs:
|
||||||
|
- 1857
|
||||||
|
data_reviews:
|
||||||
|
- https://github.com/mozilla-mobile/fenix/pull/2524#issuecomment-492739967
|
||||||
|
notification_emails:
|
||||||
|
- fenix-core@mozilla.com
|
||||||
|
expires: "2020-03-01"
|
|
@ -23,6 +23,7 @@ import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.mozilla.fenix.GleanMetrics.QrScanner
|
||||||
|
|
||||||
private class EventWrapper<T : Enum<T>>(
|
private class EventWrapper<T : Enum<T>>(
|
||||||
private val recorder: ((Map<T, String>?) -> Unit),
|
private val recorder: ((Map<T, String>?) -> Unit),
|
||||||
|
@ -159,6 +160,18 @@ private val Event.wrapper
|
||||||
is Event.UriOpened -> EventWrapper<NoExtraKeys>(
|
is Event.UriOpened -> EventWrapper<NoExtraKeys>(
|
||||||
{ Events.totalUriCount.add(1) }
|
{ Events.totalUriCount.add(1) }
|
||||||
)
|
)
|
||||||
|
is Event.QRScannerOpened -> EventWrapper<NoExtraKeys>(
|
||||||
|
{ QrScanner.opened.record(it) }
|
||||||
|
)
|
||||||
|
is Event.QRScannerPromptDisplayed -> EventWrapper<NoExtraKeys>(
|
||||||
|
{ QrScanner.promptDisplayed.record(it) }
|
||||||
|
)
|
||||||
|
is Event.QRScannerNavigationAllowed -> EventWrapper<NoExtraKeys>(
|
||||||
|
{ QrScanner.navigationAllowed.record(it) }
|
||||||
|
)
|
||||||
|
is Event.QRScannerNavigationDenied -> EventWrapper<NoExtraKeys>(
|
||||||
|
{ QrScanner.navigationDenied.record(it) }
|
||||||
|
)
|
||||||
|
|
||||||
// Don't track other events with Glean
|
// Don't track other events with Glean
|
||||||
else -> null
|
else -> null
|
||||||
|
|
|
@ -74,6 +74,10 @@ sealed class Event {
|
||||||
object CustomTabsActionTapped : Event()
|
object CustomTabsActionTapped : Event()
|
||||||
object CustomTabsMenuOpened : Event()
|
object CustomTabsMenuOpened : Event()
|
||||||
object UriOpened : Event()
|
object UriOpened : Event()
|
||||||
|
object QRScannerOpened : Event()
|
||||||
|
object QRScannerPromptDisplayed : Event()
|
||||||
|
object QRScannerNavigationAllowed : Event()
|
||||||
|
object QRScannerNavigationDenied : Event()
|
||||||
|
|
||||||
data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
|
data class PreferenceToggled(val preferenceKey: String, val enabled: Boolean, val context: Context) : Event() {
|
||||||
private val switchPreferenceTelemetryAllowList = listOf(
|
private val switchPreferenceTelemetryAllowList = listOf(
|
||||||
|
|
|
@ -110,6 +110,7 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
requestPermissions(permissions, REQUEST_CODE_CAMERA_PERMISSIONS)
|
requestPermissions(permissions, REQUEST_CODE_CAMERA_PERMISSIONS)
|
||||||
},
|
},
|
||||||
onScanResult = { result ->
|
onScanResult = { result ->
|
||||||
|
search_scan_button.isChecked = false
|
||||||
activity?.let {
|
activity?.let {
|
||||||
AlertDialog.Builder(it).apply {
|
AlertDialog.Builder(it).apply {
|
||||||
val spannable = resources.getSpannable(
|
val spannable = resources.getSpannable(
|
||||||
|
@ -121,9 +122,11 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
)
|
)
|
||||||
setMessage(spannable)
|
setMessage(spannable)
|
||||||
setNegativeButton("DENY") { dialog: DialogInterface, _ ->
|
setNegativeButton("DENY") { dialog: DialogInterface, _ ->
|
||||||
|
requireComponents.analytics.metrics.track(Event.QRScannerNavigationDenied)
|
||||||
dialog.cancel()
|
dialog.cancel()
|
||||||
}
|
}
|
||||||
setPositiveButton("ALLOW") { dialog: DialogInterface, _ ->
|
setPositiveButton("ALLOW") { dialog: DialogInterface, _ ->
|
||||||
|
requireComponents.analytics.metrics.track(Event.QRScannerNavigationAllowed)
|
||||||
(activity as HomeActivity)
|
(activity as HomeActivity)
|
||||||
.openToBrowserAndLoad(
|
.openToBrowserAndLoad(
|
||||||
searchTermOrURL = result,
|
searchTermOrURL = result,
|
||||||
|
@ -131,10 +134,10 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
from = BrowserDirection.FromSearch
|
from = BrowserDirection.FromSearch
|
||||||
)
|
)
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
// TODO add metrics
|
|
||||||
}
|
}
|
||||||
create()
|
create()
|
||||||
}.show()
|
}.show()
|
||||||
|
requireComponents.analytics.metrics.track(Event.QRScannerPromptDisplayed)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
owner = this,
|
owner = this,
|
||||||
|
@ -143,6 +146,7 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
|
|
||||||
view.search_scan_button.setOnClickListener {
|
view.search_scan_button.setOnClickListener {
|
||||||
getManagedEmitter<SearchChange>().onNext(SearchChange.ToolbarClearedFocus)
|
getManagedEmitter<SearchChange>().onNext(SearchChange.ToolbarClearedFocus)
|
||||||
|
requireComponents.analytics.metrics.track(Event.QRScannerOpened)
|
||||||
qrFeature.get()?.scan(R.id.container)
|
qrFeature.get()?.scan(R.id.container)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue