Pinned messages analytics : introduce LocalAnalyticsService so we can easily inject it in views
This commit is contained in:
@@ -34,6 +34,7 @@ import io.element.android.libraries.architecture.bindings
|
||||
import io.element.android.libraries.core.log.logger.LoggerTag
|
||||
import io.element.android.libraries.designsystem.theme.ElementThemeApp
|
||||
import io.element.android.libraries.designsystem.utils.snackbar.LocalSnackbarDispatcher
|
||||
import io.element.android.services.analytics.compose.LocalAnalyticsService
|
||||
import io.element.android.x.di.AppBindings
|
||||
import io.element.android.x.intent.SafeUriHandler
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -64,6 +65,7 @@ class MainActivity : NodeActivity() {
|
||||
CompositionLocalProvider(
|
||||
LocalSnackbarDispatcher provides appBindings.snackbarDispatcher(),
|
||||
LocalUriHandler provides SafeUriHandler(this),
|
||||
LocalAnalyticsService provides appBindings.analyticsService(),
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
|
||||
@@ -16,6 +16,7 @@ import io.element.android.libraries.designsystem.utils.snackbar.SnackbarDispatch
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import io.element.android.libraries.matrix.api.tracing.TracingService
|
||||
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
||||
import io.element.android.services.analytics.api.AnalyticsService
|
||||
|
||||
@ContributesTo(AppScope::class)
|
||||
interface AppBindings {
|
||||
@@ -32,4 +33,6 @@ interface AppBindings {
|
||||
fun migrationEntryPoint(): MigrationEntryPoint
|
||||
|
||||
fun lockScreenEntryPoint(): LockScreenEntryPoint
|
||||
|
||||
fun analyticsService(): AnalyticsService
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ dependencies {
|
||||
implementation(projects.libraries.uiUtils)
|
||||
implementation(projects.libraries.testtags)
|
||||
implementation(projects.features.networkmonitor.api)
|
||||
implementation(projects.services.analytics.api)
|
||||
implementation(projects.services.analytics.compose)
|
||||
implementation(projects.services.toolbox.api)
|
||||
implementation(libs.coil.compose)
|
||||
implementation(libs.datetime)
|
||||
|
||||
@@ -114,6 +114,7 @@ fun DependencyHandlerScope.allServicesImpl() {
|
||||
// For analytics configuration, either use noop, or use the impl, with at least one analyticsproviders implementation
|
||||
// implementation(project(":services:analytics:noop"))
|
||||
implementation(project(":services:analytics:impl"))
|
||||
implementation(project(":services:analytics:compose"))
|
||||
implementation(project(":services:analyticsproviders:posthog"))
|
||||
implementation(project(":services:analyticsproviders:sentry"))
|
||||
|
||||
|
||||
18
services/analytics/compose/build.gradle.kts
Normal file
18
services/analytics/compose/build.gradle.kts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2023, 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
plugins {
|
||||
id("io.element.android-compose-library")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "io.element.android.services.analytics.compose"
|
||||
|
||||
}
|
||||
dependencies {
|
||||
api(projects.services.analytics.api)
|
||||
implementation(projects.services.analytics.noop)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.services.analytics.compose
|
||||
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import io.element.android.services.analytics.api.AnalyticsService
|
||||
import io.element.android.services.analytics.noop.NoopAnalyticsService
|
||||
|
||||
/**
|
||||
* Global key to access the [AnalyticsService] in the composition tree.
|
||||
*/
|
||||
val LocalAnalyticsService = staticCompositionLocalOf<AnalyticsService> {
|
||||
NoopAnalyticsService()
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicBoolean
|
||||
import javax.inject.Inject
|
||||
|
||||
@SingleIn(AppScope::class)
|
||||
@ContributesBinding(AppScope::class, boundType = AnalyticsService::class)
|
||||
@ContributesBinding(AppScope::class, boundType = AnalyticsService::class, priority = ContributesBinding.Priority.HIGHEST)
|
||||
class DefaultAnalyticsService @Inject constructor(
|
||||
private val analyticsProviders: Set<@JvmSuppressWildcards AnalyticsProvider>,
|
||||
private val analyticsStore: AnalyticsStore,
|
||||
|
||||
Reference in New Issue
Block a user