Pinned messages analytics : introduce LocalAnalyticsService so we can easily inject it in views

This commit is contained in:
ganfra
2024-09-20 18:28:25 +02:00
parent d5a6b9f7ba
commit e1f88a9232
7 changed files with 45 additions and 2 deletions

View 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)
}

View File

@@ -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()
}

View File

@@ -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,