revert some code and fix merge

pull/543/head
akliuxingyuan 1 year ago
parent 6ec7bb2bf6
commit f4a01279ad

@ -22,7 +22,6 @@ import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ReleaseChannel import org.mozilla.fenix.ReleaseChannel
import org.mozilla.fenix.components.metrics.AdjustMetricsService import org.mozilla.fenix.components.metrics.AdjustMetricsService
import org.mozilla.fenix.components.metrics.DefaultMetricsStorage
import org.mozilla.fenix.components.metrics.GleanMetricsService import org.mozilla.fenix.components.metrics.GleanMetricsService
import org.mozilla.fenix.components.metrics.MetricController import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.experiments.createNimbus import org.mozilla.fenix.experiments.createNimbus
@ -32,7 +31,6 @@ import org.mozilla.fenix.gleanplumb.NimbusMessagingStorage
import org.mozilla.fenix.gleanplumb.OnDiskMessageMetadataStorage import org.mozilla.fenix.gleanplumb.OnDiskMessageMetadataStorage
import org.mozilla.fenix.nimbus.FxNimbus import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.perf.lazyMonitored import org.mozilla.fenix.perf.lazyMonitored
import org.mozilla.fenix.utils.BrowsersCache
import org.mozilla.geckoview.BuildConfig.MOZ_APP_BUILDID import org.mozilla.geckoview.BuildConfig.MOZ_APP_BUILDID
import org.mozilla.geckoview.BuildConfig.MOZ_APP_VENDOR import org.mozilla.geckoview.BuildConfig.MOZ_APP_VENDOR
import org.mozilla.geckoview.BuildConfig.MOZ_APP_VERSION import org.mozilla.geckoview.BuildConfig.MOZ_APP_VERSION
@ -121,15 +119,7 @@ class Analytics(
MetricController.create( MetricController.create(
listOf( listOf(
GleanMetricsService(context), GleanMetricsService(context),
AdjustMetricsService( AdjustMetricsService(context as Application),
application = context as Application,
storage = DefaultMetricsStorage(
context = context,
settings = context.settings(),
checkDefaultBrowser = { BrowsersCache.all(context).isDefaultBrowser },
),
crashReporter = crashReporter,
),
), ),
isDataTelemetryEnabled = { context.settings().isTelemetryEnabled }, isDataTelemetryEnabled = { context.settings().isTelemetryEnabled },
isMarketingDataTelemetryEnabled = { context.settings().isMarketingTelemetryEnabled }, isMarketingDataTelemetryEnabled = { context.settings().isMarketingTelemetryEnabled },

@ -102,32 +102,12 @@ class Components(private val context: Context) {
} }
val addonCollectionProvider by lazyMonitored { val addonCollectionProvider by lazyMonitored {
// Check if we have a customized (overridden) AMO collection (supported in Nightly & Beta) PagedAddonCollectionProvider(
if (FeatureFlags.customExtensionCollectionFeature && context.settings().amoCollectionOverrideConfigured()) { context,
AddonCollectionProvider( core.client,
context, serverURL = BuildConfig.AMO_SERVER_URL,
core.client, maxCacheAgeInMinutes = AMO_COLLECTION_MAX_CACHE_AGE,
collectionUser = context.settings().overrideAmoUser, )
collectionName = context.settings().overrideAmoCollection,
)
}
// Use build config otherwise
else if (!BuildConfig.AMO_COLLECTION_USER.isNullOrEmpty() &&
!BuildConfig.AMO_COLLECTION_NAME.isNullOrEmpty()
) {
AddonCollectionProvider(
context,
core.client,
serverURL = BuildConfig.AMO_SERVER_URL,
collectionUser = BuildConfig.AMO_COLLECTION_USER,
collectionName = BuildConfig.AMO_COLLECTION_NAME,
maxCacheAgeInMinutes = AMO_COLLECTION_MAX_CACHE_AGE,
)
}
// Fall back to defaults
else {
AddonCollectionProvider(context, core.client, maxCacheAgeInMinutes = AMO_COLLECTION_MAX_CACHE_AGE)
}
} }
@Suppress("MagicNumber") @Suppress("MagicNumber")

@ -10,23 +10,12 @@ import android.os.Bundle
import android.util.Log import android.util.Log
import com.adjust.sdk.Adjust import com.adjust.sdk.Adjust
import com.adjust.sdk.AdjustConfig import com.adjust.sdk.AdjustConfig
import com.adjust.sdk.AdjustEvent
import com.adjust.sdk.LogLevel import com.adjust.sdk.LogLevel
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import mozilla.components.lib.crash.CrashReporter
import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.Config import org.mozilla.fenix.Config
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
class AdjustMetricsService( class AdjustMetricsService(private val application: Application) : MetricsService {
private val application: Application,
private val storage: MetricsStorage,
private val crashReporter: CrashReporter,
private val dispatcher: CoroutineDispatcher = Dispatchers.IO,
) : MetricsService {
override val type = MetricServiceType.Marketing override val type = MetricServiceType.Marketing
override fun start() { override fun start() {
@ -81,22 +70,9 @@ class AdjustMetricsService(
Adjust.gdprForgetMe(application.applicationContext) Adjust.gdprForgetMe(application.applicationContext)
} }
@Suppress("TooGenericExceptionCaught") // We're not currently sending events directly to Adjust
override fun track(event: Event) { override fun track(event: Event) { /* noop */ }
CoroutineScope(dispatcher).launch { override fun shouldTrack(event: Event): Boolean = false
try {
if (event is Event.GrowthData && storage.shouldTrack(event)) {
Adjust.trackEvent(AdjustEvent(event.tokenName))
storage.updateSentState(event)
}
} catch (e: Exception) {
crashReporter.submitCaughtException(e)
}
}
}
override fun shouldTrack(event: Event): Boolean =
event is Event.GrowthData
companion object { companion object {
private const val LOGTAG = "AdjustMetricsService" private const val LOGTAG = "AdjustMetricsService"

Loading…
Cancel
Save