2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-03 23:15:31 +00:00

Bug 1821726 - Part 2: Add juno onboarding telemetry

This commit is contained in:
rahulsainani 2023-04-05 09:38:08 +02:00 committed by mergify[bot]
parent 864951772a
commit 632b1eedb8
4 changed files with 617 additions and 10 deletions

View File

@ -967,6 +967,361 @@ onboarding:
tags:
- Notifications
- Onboarding
set_to_default_card:
type: event
description: |
User viewed juno onboarding set to default card.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
sign_in_card:
type: event
description: |
User viewed juno onboarding sign in card.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
turn_on_notifications_card:
type: event
description: |
User viewed juno onboarding notification permission card.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
set_to_default:
type: event
description: |
User tapped on set to default button in juno onboarding.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
skip_default:
type: event
description: |
User tapped on skip set to default button in juno onboarding.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
sign_in:
type: event
description: |
User tapped on sign in button in juno onboarding.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
skip_sign_in:
type: event
description: |
User tapped on skip sign in button in juno onboarding.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
turn_on_notifications:
type: event
description: |
User tapped on turn on notifications button in juno onboarding.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
skip_turn_on_notifications:
type: event
description: |
User tapped on skip turn on notification button in juno onboarding.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
privacy_policy:
type: event
description: |
User tapped on privacy policy link in juno onboarding.
extra_keys:
element_type:
type: string
description: |
Type of element that was viewed.
action:
type: string
description: |
Type of action taken by the user.
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
completed:
type: event
description: |
User completed the juno onboarding.
extra_keys:
sequence_position:
type: string
description: |
Position of the onboarding card in the onboarding flow.
sequence_id:
type: string
description: |
Identifier for the sequence.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1821726
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/1554
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 126
metadata:
tags:
- Onboarding
search_shortcuts:
selected:

View File

@ -29,6 +29,7 @@ import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.onboarding.view.JunoOnboardingPageType
import org.mozilla.fenix.onboarding.view.JunoOnboardingScreen
import org.mozilla.fenix.onboarding.view.telemetrySequenceId
import org.mozilla.fenix.settings.SupportUtils
import org.mozilla.fenix.theme.FirefoxTheme
@ -39,6 +40,7 @@ class JunoOnboardingFragment : Fragment() {
private val fenixOnboarding by lazy { FenixOnboarding(requireContext()) }
private val onboardingPageTypeList by lazy { onboardingPageTypeList(requireContext()) }
private val telemetryRecorder by lazy { JunoOnboardingTelemetryRecorder() }
@SuppressLint("SourceLockedOrientationActivity")
override fun onCreate(savedInstanceState: Bundle?) {
@ -76,30 +78,83 @@ class JunoOnboardingFragment : Fragment() {
val context = LocalContext.current
JunoOnboardingScreen(
onboardingPageTypeList = onboardingPageTypeList,
onMakeFirefoxDefaultClick = { activity?.openSetDefaultBrowserOption(useCustomTab = true) },
onMakeFirefoxDefaultClick = {
activity?.openSetDefaultBrowserOption(useCustomTab = true)
telemetryRecorder.onSetToDefaultClick(
sequenceId = onboardingPageTypeList.telemetrySequenceId(),
pageType = JunoOnboardingPageType.DEFAULT_BROWSER,
)
},
onSkipDefaultClick = {
telemetryRecorder.onSkipSetToDefaultClick(
onboardingPageTypeList.telemetrySequenceId(),
JunoOnboardingPageType.DEFAULT_BROWSER,
)
},
onPrivacyPolicyClick = { url ->
startActivity(SupportUtils.createSandboxCustomTabIntent(context = context, url = url))
startActivity(
SupportUtils.createSandboxCustomTabIntent(
context = context,
url = url,
),
)
telemetryRecorder.onPrivacyPolicyClick(
onboardingPageTypeList.telemetrySequenceId(),
JunoOnboardingPageType.DEFAULT_BROWSER,
)
},
onSignInButtonClick = {
findNavController().nav(
id = R.id.junoOnboardingFragment,
directions = JunoOnboardingFragmentDirections.actionGlobalTurnOnSync(),
)
telemetryRecorder.onSyncSignInClick(
sequenceId = onboardingPageTypeList.telemetrySequenceId(),
pageType = JunoOnboardingPageType.SYNC_SIGN_IN,
)
},
onSkipSignInClick = {
telemetryRecorder.onSkipSignInClick(
onboardingPageTypeList.telemetrySequenceId(),
JunoOnboardingPageType.SYNC_SIGN_IN,
)
},
onNotificationPermissionButtonClick = {
requireComponents.notificationsDelegate.requestNotificationPermission()
telemetryRecorder.onNotificationPermissionClick(
sequenceId = onboardingPageTypeList.telemetrySequenceId(),
pageType = JunoOnboardingPageType.NOTIFICATION_PERMISSION,
)
},
onSkipNotificationClick = {
telemetryRecorder.onSkipTurnOnNotificationsClick(
onboardingPageTypeList.telemetrySequenceId(),
JunoOnboardingPageType.NOTIFICATION_PERMISSION,
)
},
onFinish = { pageType ->
onFinish(onboardingPageTypeList.telemetrySequenceId(), pageType)
},
onImpression = { pageType ->
telemetryRecorder.onImpression(
onboardingPageTypeList.telemetrySequenceId(),
pageType,
)
},
onFinish = { onFinish() },
)
}
private fun onFinish() {
private fun onFinish(sequenceId: String, pageType: JunoOnboardingPageType) {
context?.settings()?.isJunoOnboardingShown = true
fenixOnboarding.finish()
findNavController().nav(
id = R.id.junoOnboardingFragment,
directions = JunoOnboardingFragmentDirections.actionOnboardingHome(),
)
telemetryRecorder.onOnboardingComplete(
sequenceId = sequenceId,
pageType = pageType,
)
}
private fun onboardingPageTypeList(context: Context): List<JunoOnboardingPageType> =

View File

@ -0,0 +1,197 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.onboarding
import org.mozilla.fenix.GleanMetrics.Onboarding
import org.mozilla.fenix.onboarding.view.JunoOnboardingPageType
/**
* Abstraction responsible for recording telemetry events for JunoOnboarding.
*/
class JunoOnboardingTelemetryRecorder {
/**
* Records "onboarding_completed" telemetry event.
* @param sequenceId The identifier of the onboarding sequence shown to the user.
* @param pageType The page on which the completed event occurred.
*/
fun onOnboardingComplete(sequenceId: String, pageType: JunoOnboardingPageType) {
Onboarding.completed.record(
Onboarding.CompletedExtra(
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
/**
* Records impression events for a given [JunoOnboardingPageType].
* @param sequenceId The identifier of the onboarding sequence shown to the user.
* @param pageType The page for which the impression occurred.
*/
fun onImpression(sequenceId: String, pageType: JunoOnboardingPageType) {
when (pageType) {
JunoOnboardingPageType.DEFAULT_BROWSER -> {
Onboarding.setToDefaultCard.record(
Onboarding.SetToDefaultCardExtra(
action = ACTION_IMPRESSION,
elementType = ET_ONBOARDING_CARD,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
JunoOnboardingPageType.SYNC_SIGN_IN -> {
Onboarding.signInCard.record(
Onboarding.SignInCardExtra(
action = ACTION_IMPRESSION,
elementType = ET_ONBOARDING_CARD,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
JunoOnboardingPageType.NOTIFICATION_PERMISSION -> {
Onboarding.turnOnNotificationsCard.record(
Onboarding.TurnOnNotificationsCardExtra(
action = ACTION_IMPRESSION,
elementType = ET_ONBOARDING_CARD,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
}
}
/**
* Records set to default click event.
* @param sequenceId The identifier of the onboarding sequence shown to the user.
* @param pageType The page for which the impression occurred.
*/
fun onSetToDefaultClick(sequenceId: String, pageType: JunoOnboardingPageType) {
Onboarding.setToDefault.record(
Onboarding.SetToDefaultExtra(
action = ACTION_CLICK,
elementType = ET_PRIMARY_BUTTON,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
/**
* Records sync sign in click event.
* @param sequenceId The identifier of the onboarding sequence shown to the user.
* @param pageType The page for which the impression occurred.
*/
fun onSyncSignInClick(sequenceId: String, pageType: JunoOnboardingPageType) {
Onboarding.signIn.record(
Onboarding.SignInExtra(
action = ACTION_CLICK,
elementType = ET_PRIMARY_BUTTON,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
/**
* Records notification permission click event.
* @param sequenceId The identifier of the onboarding sequence shown to the user.
* @param pageType The page for which the impression occurred.
*/
fun onNotificationPermissionClick(sequenceId: String, pageType: JunoOnboardingPageType) {
Onboarding.turnOnNotifications.record(
Onboarding.TurnOnNotificationsExtra(
action = ACTION_CLICK,
elementType = ET_PRIMARY_BUTTON,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
/**
* Records skip set to default click event.
* @param sequenceId The identifier of the onboarding sequence shown to the user.
* @param pageType The page for which the impression occurred.
*/
fun onSkipSetToDefaultClick(
sequenceId: String,
pageType: JunoOnboardingPageType,
) {
Onboarding.skipDefault.record(
Onboarding.SkipDefaultExtra(
action = ACTION_CLICK,
elementType = ET_SECONDARY_BUTTON,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
/**
* Records skip sign in click event.
* @param sequenceId The identifier of the onboarding sequence shown to the user.
* @param pageType The page for which the impression occurred.
*/
fun onSkipSignInClick(
sequenceId: String,
pageType: JunoOnboardingPageType,
) {
Onboarding.skipSignIn.record(
Onboarding.SkipSignInExtra(
action = ACTION_CLICK,
elementType = ET_SECONDARY_BUTTON,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
/**
* Records skip notification permission click event.
* @param sequenceId The identifier of the onboarding sequence shown to the user.
* @param pageType The page for which the impression occurred.
*/
fun onSkipTurnOnNotificationsClick(
sequenceId: String,
pageType: JunoOnboardingPageType,
) {
Onboarding.skipTurnOnNotifications.record(
Onboarding.SkipTurnOnNotificationsExtra(
action = ACTION_CLICK,
elementType = ET_SECONDARY_BUTTON,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
/**
* Records privacy policy link text click event.
* @param sequenceId The identifier of the onboarding sequence shown to the user.
* @param pageType The page on which the link click event occurred.
*/
fun onPrivacyPolicyClick(sequenceId: String, pageType: JunoOnboardingPageType) {
Onboarding.privacyPolicy.record(
Onboarding.PrivacyPolicyExtra(
action = ACTION_CLICK,
elementType = ET_SECONDARY_BUTTON,
sequenceId = sequenceId,
sequencePosition = pageType.sequencePosition,
),
)
}
companion object {
private const val ACTION_IMPRESSION = "impression"
private const val ACTION_CLICK = "click"
private const val ET_ONBOARDING_CARD = "onboarding_card"
private const val ET_PRIMARY_BUTTON = "primary_button"
private const val ET_SECONDARY_BUTTON = "secondary_button"
}
}

View File

@ -53,14 +53,14 @@ import org.mozilla.fenix.theme.FirefoxTheme
fun JunoOnboardingScreen(
onboardingPageTypeList: List<JunoOnboardingPageType>,
onMakeFirefoxDefaultClick: () -> Unit,
onSkipDefaultClick: () -> Unit = {},
onSkipDefaultClick: () -> Unit,
onPrivacyPolicyClick: (url: String) -> Unit,
onSignInButtonClick: () -> Unit,
onSkipSignInClick: () -> Unit = {},
onSkipSignInClick: () -> Unit,
onNotificationPermissionButtonClick: () -> Unit,
onSkipNotificationClick: () -> Unit = {},
onFinish: () -> Unit,
onImpression: (pageType: JunoOnboardingPageType) -> Unit = {},
onSkipNotificationClick: () -> Unit,
onFinish: (pageType: JunoOnboardingPageType) -> Unit,
onImpression: (pageType: JunoOnboardingPageType) -> Unit,
) {
val coroutineScope = rememberCoroutineScope()
val pagerState = rememberPagerState()
@ -75,7 +75,7 @@ fun JunoOnboardingScreen(
val scrollToNextPageOrDismiss: () -> Unit = {
if (pagerState.currentPage == pagerState.pageCount - 1) {
onFinish()
onFinish(onboardingPageTypeList[pagerState.currentPage])
} else {
coroutineScope.launch {
pagerState.animateScrollToPage(pagerState.currentPage + 1)