Unverified Commit 9df13ae1 authored by jhugman's avatar jhugman Committed by GitHub
Browse files

For #11655: add leanplum event for installing an addon (#12136) r=elise

* For #11655: add leanplum event for installing an addon

* Add link to data-review request in PR

* Addressed CI comments
parent 31248b83
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -29,8 +29,10 @@ import mozilla.components.feature.addons.ui.AddonsManagerAdapterDelegate
import mozilla.components.feature.addons.ui.PermissionsDialogFragment
import mozilla.components.feature.addons.ui.translatedName
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getRootView
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.theme.ThemeManager
@@ -192,11 +194,13 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management),
                onPositiveButtonClicked = onPositiveButtonClicked
            )
            dialog.show(parentFragmentManager, PERMISSIONS_DIALOG_FRAGMENT_TAG)
            requireContext().components.analytics.metrics.track(Event.AddonInstalled(addon.id))
        }
    }

    private fun showInstallationDialog(addon: Addon) {
        if (!isInstallationInProgress && !hasExistingAddonInstallationDialogFragment()) {
            requireComponents.analytics.metrics.track(Event.AddonInstalled(addon.id))
            val addonCollectionProvider = requireContext().components.addonCollectionProvider

            val dialog = AddonInstallationDialogFragment.newInstance(
+1 −0
Original line number Diff line number Diff line
@@ -650,6 +650,7 @@ private val Event.wrapper: EventWrapper<*>?
        is Event.ClearedPrivateData -> null
        is Event.DismissedOnboarding -> null
        is Event.FennecToFenixMigrated -> null
        is Event.AddonInstalled -> null
    }

class GleanMetricsService(private val context: Context) : MetricsService {
+2 −1
Original line number Diff line number Diff line
@@ -38,9 +38,10 @@ private val Event.name: String?
        is Event.ClearedPrivateData -> "E_Cleared_Private_Data"
        is Event.DismissedOnboarding -> "E_Dismissed_Onboarding"
        is Event.FennecToFenixMigrated -> "E_Fennec_To_Fenix_Migrated"
        is Event.AddonInstalled -> "E_Addon_Installed"

        // Do not track other events in Leanplum
        else -> ""
        else -> null
    }

class LeanplumMetricsService(private val application: Application) : MetricsService {
+2 −0
Original line number Diff line number Diff line
@@ -465,6 +465,8 @@ sealed class Event {
    }

    object CrashReporterOpened : Event()
    data class AddonInstalled(val addonId: String) : Event()

    data class CrashReporterClosed(val crashSubmitted: Boolean) : Event() {
        override val extras: Map<CrashReporter.closedKeys, String>?
            get() = mapOf(CrashReporter.closedKeys.crashSubmitted to crashSubmitted.toString())
+5 −0
Original line number Diff line number Diff line
@@ -231,6 +231,11 @@ Here is the list of current Events sent, which can be found here in the code bas
    <td>The user has just migrated from Fennec to Fenix.</td>
    <td><a href="https://github.com/mozilla-mobile/fenix/pull/8208#issuecomment-584040440">#8208</a></td>
  </tr>
  <tr>
    <td>`E_Addon_Installed`</td>
    <td>The user has installed an addon from the addon management page.</td>
    <td><a href="https://github.com/mozilla-mobile/fenix/pull/12136#issuecomment-651922547">#12136</a></td>
  </tr>
</table>

Deep links