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

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Apr 15, 2020
1 parent 71c841f commit 5ee7a2d
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 48 deletions.
24 changes: 19 additions & 5 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,20 @@ history:
expires: "2020-09-01"

tip:
displayed:
type: event
description: >
The tip was displayed
extra_keys:
identifier:
description: "The identifier of the tip displayed"
bugs:
- https://github.com/mozilla-mobile/fenix/issues/9328
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/9836
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
pressed:
type: event
description: >
Expand All @@ -1053,9 +1067,9 @@ tip:
identifier:
description: "The identifier of the tip the action was taken on"
bugs:
- https://github.com/mozilla-mobile/fenix/issues/TODO
- https://github.com/mozilla-mobile/fenix/issues/9328
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/TODO
- https://github.com/mozilla-mobile/fenix/pull/9836
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
Expand All @@ -1065,11 +1079,11 @@ tip:
The tip was closed
extra_keys:
identifier:
description: "The identifier of the tip the action was taken on"
description: "The identifier of the tip closed"
bugs:
- https://github.com/mozilla-mobile/fenix/issues/TODO
- https://github.com/mozilla-mobile/fenix/issues/9328
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/TODO
- https://github.com/mozilla-mobile/fenix/pull/9836
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/mozilla/fenix/FeatureFlags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ object FeatureFlags {
* Enables picture-in-picture feature
*/
val pictureInPicture = Config.channel.isNightlyOrDebug

/**
* Enables tip feature
*/
val tips = Config.channel.isDebug
}
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ private val Event.wrapper: EventWrapper<*>?
is Event.AddonsOpenInToolbarMenu -> EventWrapper<NoExtraKeys>(
{ Addons.openAddonInToolbarMenu.record(it) }
)
is Event.TipDisplayed -> EventWrapper(
{ Tip.displayed.record(it) },
{ Tip.displayedKeys.valueOf(it) }
)
is Event.TipPressed -> EventWrapper(
{ Tip.pressed.record(it) },
{ Tip.pressedKeys.valueOf(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ sealed class Event {
}
}

data class TipDisplayed(val identifier: String) : Event() {
override val extras: Map<Tip.displayedKeys, String>?
get() = hashMapOf(Tip.displayedKeys.identifier to identifier)
}

data class TipPressed(val identifier: String) : Event() {
override val extras: Map<Tip.pressedKeys, String>?
get() = hashMapOf(Tip.pressedKeys.identifier to identifier)
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,10 @@ class HomeFragment : Fragment() {
activity?.window?.setBackgroundDrawableResource(R.drawable.private_home_background_gradient)
}
hideToolbar()
// TODO: How should I handle this?
/*
if (sharedViewModel.shouldScrollToSelectedTab) {
scrollToSelectedTab()
sharedViewModel.shouldScrollToSelectedTab = false
}
*/
}

override fun onPause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ fun TextView.setOnboardingIcon(@DrawableRes id: Int) {
val size = context.resources.getDimensionPixelSize(R.dimen.onboarding_header_icon_height_width)
icon?.setBounds(size)
icon?.setTint(ContextCompat.getColor(context, R.color.onboarding_card_icon))

putCompoundDrawablesRelative(start = icon)
}
62 changes: 26 additions & 36 deletions app/src/main/java/org/mozilla/fenix/home/tips/MigrationTip.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,24 @@ import org.mozilla.fenix.settings.SupportUtils
object MigrationTip {
private lateinit var context: Context

private fun firefoxPreviewMovedTip() : Tip =
private fun firefoxPreviewMovedTip(): Tip =
Tip(
identifier = getIdentifier(),
title = R.string.tip_firefox_preview_moved_header,
description = R.string.tip_firefox_preview_moved_description,
learnMoreButton = R.string.search_suggestions_onboarding_learn_more_link,
learnMoreAction = {
(context.asActivity() as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(SupportUtils.SumoTopic.FENIX_MOVING),
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(
SupportUtils.SumoTopic.FENIX_MOVING
),
newTab = true,
from = BrowserDirection.FromHome
)
},
button = R.string.tip_firefox_preview_moved_button,
shouldDisplay = {
true
//context.settings().shouldDisplayFenixMovingTip()
},
shouldDisplay = { context.settings().shouldDisplayFenixMovingTip() },
didClose = {
// TODO: Telemetry?
context.settings().preferences
.edit()
.putBoolean(context.getString(R.string.pref_key_migrating_tip), false)
Expand All @@ -49,26 +47,24 @@ object MigrationTip {
action = ::getFirefoxMovedButtonAction
)

private fun firefoxPreviewMovedPreviewInstalledTip() : Tip =
private fun firefoxPreviewMovedPreviewInstalledTip(): Tip =
Tip(
identifier = getIdentifier(),
title = R.string.tip_firefox_preview_moved_header_preview_installed,
description = R.string.tip_firefox_preview_moved_description_preview_installed,
learnMoreButton = R.string.search_suggestions_onboarding_learn_more_link,
learnMoreAction = {
(context.asActivity() as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(SupportUtils.SumoTopic.FENIX_MOVING),
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(
SupportUtils.SumoTopic.FENIX_MOVING
),
newTab = true,
from = BrowserDirection.FromHome
)
},
button = R.string.tip_firefox_preview_moved_button_preview_installed,
shouldDisplay = {
true
//context.settings().shouldDisplayFenixMovingTip()
},
shouldDisplay = { context.settings().shouldDisplayFenixMovingTip() },
didClose = {
// TODO: Telemetry?
context.settings().preferences
.edit()
.putBoolean(context.getString(R.string.pref_key_migrating_tip), false)
Expand All @@ -77,26 +73,24 @@ object MigrationTip {
action = ::getFirefoxMovedButtonAction
)

private fun firefoxPreviewMovedPreviewNotInstalledTip() : Tip =
private fun firefoxPreviewMovedPreviewNotInstalledTip(): Tip =
Tip(
identifier = getIdentifier(),
title = R.string.tip_firefox_preview_moved_header_preview_not_installed,
description = R.string.tip_firefox_preview_moved_description_preview_not_installed,
learnMoreButton = R.string.search_suggestions_onboarding_learn_more_link,
learnMoreAction = {
(context.asActivity() as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(SupportUtils.SumoTopic.FENIX_MOVING),
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(
SupportUtils.SumoTopic.FENIX_MOVING
),
newTab = true,
from = BrowserDirection.FromHome
)
},
button = R.string.tip_firefox_preview_moved_button_preview_not_installed,
shouldDisplay = {
true
//context.settings().shouldDisplayFenixMovingTip()
},
shouldDisplay = { context.settings().shouldDisplayFenixMovingTip() },
didClose = {
// TODO: Telemetry?
context.settings().preferences
.edit()
.putBoolean(context.getString(R.string.pref_key_migrating_tip), false)
Expand All @@ -108,21 +102,15 @@ object MigrationTip {
fun get(context: Context): Tip? {
this.context = context
return when (context.packageName) {
MozillaProductDetector.MozillaProducts.FENIX.productName -> firefoxPreviewMovedTip()
MozillaProductDetector.MozillaProducts.FIREFOX_NIGHTLY.productName -> {
getNightlyMigrationTip()
}
MozillaProductDetector.MozillaProducts.FENIX_NIGHTLY.productName -> {
getNightlyMigrationTip()
}
else -> {
null
}
FENIX.productName -> firefoxPreviewMovedTip()
FIREFOX_NIGHTLY.productName -> getNightlyMigrationTip()
FENIX_NIGHTLY.productName -> getNightlyMigrationTip()
else -> null
}
}

private fun getNightlyMigrationTip(): Tip? {
return if (MozillaProductDetector.packageIsInstalled(context, MozillaProductDetector.MozillaProducts.FENIX.productName)) {
return if (MozillaProductDetector.packageIsInstalled(context, FENIX.productName)) {
firefoxPreviewMovedPreviewInstalledTip()
} else {
firefoxPreviewMovedPreviewNotInstalledTip()
Expand All @@ -141,10 +129,12 @@ object MigrationTip {
}

private fun getNightlyMigrationAction() {
return if (MozillaProductDetector.packageIsInstalled(context, MozillaProductDetector.MozillaProducts.FENIX.productName)) {
// TODO: Just launch Firefox Preview?
return if (MozillaProductDetector.packageIsInstalled(context, FENIX.productName)) {
context.startActivity(context.packageManager.getLaunchIntentForPackage(FENIX.productName))
} else {
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(SupportUtils.FIREFOX_NIGHTLY_PLAY_STORE_URL)))
context.startActivity(Intent(
Intent.ACTION_VIEW, Uri.parse(SupportUtils.FIREFOX_NIGHTLY_PLAY_STORE_URL)
))
}
}

Expand All @@ -156,4 +146,4 @@ object MigrationTip {
else -> { -1 }
}
}
}
}
4 changes: 3 additions & 1 deletion app/src/main/java/org/mozilla/fenix/home/tips/TipManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package org.mozilla.fenix.home.tips
import android.content.Context
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes

import org.mozilla.fenix.FeatureFlags

enum class Type {
BUTTON
Expand Down Expand Up @@ -40,6 +40,8 @@ class TipManager(val context: Context) {

// In an ideal world we could populate tips from a server
private fun populateTipList() {
if (!FeatureFlags.tips) { return }

MigrationTip.get(context)?.let { migrationTip ->
tipList.add(migrationTip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class TipViewHolder(
this.tip = tip

view.apply {
context.components.analytics.metrics.track(
Event.TipDisplayed(context.getString(tip.identifier))
)

val appName = context.getString(R.string.app_name)

tip_header_text.text = view.context.getString(tip.title, appName)
Expand Down
24 changes: 22 additions & 2 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ This means you might have to go searching through the dependency tree to get a f
This ping is intended to provide a measure of the activation of mobile products. It's generated when Fenix starts, right after Glean is initialized. It doesn't include the client_id, since it might be reporting an hashed version of the Google Advertising ID.


**Data reviews for this ping:**

- <https://github.com/mozilla-mobile/fenix/pull/1707#issuecomment-486972209>

**Bugs related to this ping:**

- 1538011
- 1501822

The following metrics are added to the ping:

| Name | Type | Description | Data reviews | Extras | Expiration |
Expand Down Expand Up @@ -167,8 +176,9 @@ The following metrics are added to the ping:
| sync_auth.sign_up |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |User registered a new Firefox Account, and was signed into it |[1](https://github.com/mozilla-mobile/fenix/pull/4931#issuecomment-529740300)||2020-09-01 |
| tab.media_pause |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the pause icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266)||2020-09-01 |
| tab.media_play |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the play icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266)||2020-09-01 |
| tip.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip was closed |[1](https://github.com/mozilla-mobile/fenix/pull/TODO)|<ul><li>identifier: The identifier of the tip the action was taken on</li></ul>|2020-09-01 |
| tip.pressed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip's button was pressed |[1](https://github.com/mozilla-mobile/fenix/pull/TODO)|<ul><li>identifier: The identifier of the tip the action was taken on</li></ul>|2020-09-01 |
| tip.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip was closed |[1](https://github.com/mozilla-mobile/fenix/pull/9836)|<ul><li>identifier: The identifier of the tip closed</li></ul>|2020-09-01 |
| tip.displayed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip was displayed |[1](https://github.com/mozilla-mobile/fenix/pull/9836)|<ul><li>identifier: The identifier of the tip displayed</li></ul>|2020-09-01 |
| tip.pressed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip's button was pressed |[1](https://github.com/mozilla-mobile/fenix/pull/9836)|<ul><li>identifier: The identifier of the tip the action was taken on</li></ul>|2020-09-01 |
| toolbar_settings.changed_position |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The user selected a new position for the toolbar |[1](https://github.com/mozilla-mobile/fenix/pull/6608)|<ul><li>position: A string that indicates the new position of the toolbar TOP or BOTTOM</li></ul>|2020-09-01 |
| top_sites.open_in_new_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opens a new tab based on a top site item |[1](https://github.com/mozilla-mobile/fenix/pull/7523)||2020-09-01 |
| top_sites.open_in_private_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opens a new private tab based on a top site item |[1](https://github.com/mozilla-mobile/fenix/pull/7523)||2020-09-01 |
Expand All @@ -187,6 +197,16 @@ The following metrics are added to the ping:
This ping is intended to capture the source of the installation


This ping includes the [client id](https://mozilla.github.io/glean/book/user/pings/index.html#the-client_info-section).

**Data reviews for this ping:**

- <https://github.com/mozilla-mobile/fenix/pull/8074#issuecomment-586512202>

**Bugs related to this ping:**

- <https://github.com/mozilla-mobile/fenix/issues/7295>

The following metrics are added to the ping:

| Name | Type | Description | Data reviews | Extras | Expiration |
Expand Down

0 comments on commit 5ee7a2d

Please sign in to comment.