Commit 7c54df4a authored by Dan Ballard's avatar Dan Ballard Committed by Pier Angelo Vendrame
Browse files

fixup! Bug 40185: [android] Use NimbusDisabled

Bug 43016: Redisable Nimbus
parent 50ad336a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -378,7 +378,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorIn
                ?.also {
                    Events.appOpened.record(Events.AppOpenedExtra(it))
                    // This will record an event in Nimbus' internal event store. Used for behavioral targeting
                    components.nimbus.events.recordEvent("app_opened")
                    // components.nimbus.events.recordEvent("app_opened")

                    if (safeIntent.action.equals(ACTION_OPEN_PRIVATE_TAB) && it == APP_ICON) {
                        AppIcon.newPrivateTabTapped.record(NoExtras())
+0 −2
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@ import mozilla.components.lib.crash.service.MozillaSocorroService
import mozilla.components.support.ktx.android.content.isMainProcess
import mozilla.components.support.utils.BrowsersCache
import mozilla.components.support.utils.RunWhenReadyQueue
import mozilla.components.service.nimbus.NimbusDisabled
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config
import org.mozilla.fenix.HomeActivity
+1 −1
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ internal class TelemetryAccountObserver(
            // User signed-in into an existing FxA account.
            AuthType.Signin -> {
                SyncAuth.signIn.record(NoExtras())
                context.components.nimbus.events.recordEvent("sync_auth.sign_in")
                // context.components.nimbus.events.recordEvent("sync_auth.sign_in")
            }

            // User created a new FxA account.
+31 −3
Original line number Diff line number Diff line
@@ -6,16 +6,21 @@ package org.mozilla.fenix.components

import android.content.Context
import mozilla.components.service.nimbus.NimbusApi
import mozilla.components.service.nimbus.NimbusDisabled
import mozilla.components.service.nimbus.messaging.FxNimbusMessaging
import mozilla.components.service.nimbus.messaging.Message
import mozilla.components.service.nimbus.messaging.MessageMetadataStorage
import mozilla.components.service.nimbus.messaging.NimbusMessagingController
import mozilla.components.service.nimbus.messaging.NimbusMessagingControllerInterface
import mozilla.components.service.nimbus.messaging.NimbusMessagingStorage
import mozilla.components.service.nimbus.messaging.OnDiskMessageMetadataStorage
import org.mozilla.experiments.nimbus.NimbusEventStore
import org.mozilla.experiments.nimbus.NimbusMessagingHelperInterface
import org.mozilla.experiments.nimbus.NullNimbus
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.experiments.createNimbus
import org.mozilla.fenix.messaging.CustomAttributeProvider
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.perf.lazyMonitored

/**
@@ -28,7 +33,14 @@ class NimbusComponents(private val context: Context) {
     * should be mediated through a FML generated class, e.g. [FxNimbus].
     */
    val sdk: NimbusApi by lazyMonitored {
        createNimbus(context, BuildConfig.NIMBUS_ENDPOINT)
        if (BuildConfig.DATA_COLLECTION_DISABLED) {
            NimbusDisabled(context)
        } else {
            createNimbus(context, BuildConfig.NIMBUS_ENDPOINT).also { api ->
                FxNimbus.api = api
            }
        }

    }

    /**
@@ -44,7 +56,8 @@ class NimbusComponents(private val context: Context) {
     * the JEXL helper available from [createJexlHelper].
     */
    val events: NimbusEventStore by lazyMonitored {
        sdk.events
        NullNimbus(context)
        //sdk.events
    }

    /**
@@ -92,10 +105,25 @@ class NimbusComponents(private val context: Context) {
    private val messagingStorage by lazyMonitored {
        NimbusMessagingStorage(
            context = context,
            metadataStorage = OnDiskMessageMetadataStorage(context),
            metadataStorage = NullMessageMetadataStorage(), //OnDiskMessageMetadataStorage(context),
            nimbus = sdk,
            messagingFeature = FxNimbusMessaging.features.messaging,
            attributeProvider = CustomAttributeProvider,
        )
    }
}
// Noop impl of MessageMetadataStorage to replace OnDiskMessageMetadataStorage
class NullMessageMetadataStorage(): MessageMetadataStorage {
    override suspend fun getMetadata(): Map<String, Message.Metadata> {
        var metadataMap: MutableMap<String, Message.Metadata> = hashMapOf()
        return metadataMap
    }

    override suspend fun addMetadata(metadata: Message.Metadata): Message.Metadata {
        return metadata
    }

    override suspend fun updateMetadata(metadata: Message.Metadata) {
        // noop
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ class SaveToPDFMiddleware(
                                source = telemetrySource(isPdf),
                            ),
                        )
                        nimbusEventStore.recordEvent("print_tapped")
                        // nimbusEventStore.recordEvent("print_tapped")
                    } else {
                        Events.saveToPdfTapped.record(
                            Events.SaveToPdfTappedExtra(