Use koin in the analytics module

pull/2064/head
lihenggui 1 year ago
parent dd4a852ec8
commit 015528c5f7

@ -15,7 +15,7 @@
*/
plugins {
alias(libs.plugins.nowinandroid.kmp.library)
alias(libs.plugins.nowinandroid.kotlin.inject)
alias(libs.plugins.nowinandroid.di.koin)
alias(libs.plugins.jetbrains.compose)
alias(libs.plugins.compose)
}

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2023 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest />

@ -17,13 +17,11 @@
package com.google.samples.apps.nowinandroid.core.analytics
import co.touchlab.kermit.Logger
import me.tatarka.inject.annotations.Inject
/**
* An implementation of AnalyticsHelper just writes the events to logcat. Used in builds where no
* analytics events should be sent to a backend.
*/
@Inject
internal class StubAnalyticsHelper : AnalyticsHelper {
override fun logEvent(event: AnalyticsEvent) {
Logger.d { "Received analytics event: $event" }

@ -16,13 +16,10 @@
package com.google.samples.apps.nowinandroid.core.analytics.di
import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper
import com.google.samples.apps.nowinandroid.core.analytics.StubAnalyticsHelper
import me.tatarka.inject.annotations.Component
import me.tatarka.inject.annotations.Provides
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module
@Component
internal abstract class AnalyticsModule {
@Provides
fun providesAnalyticsHelper(): AnalyticsHelper = StubAnalyticsHelper()
val analyticsModule = module {
singleOf(::StubAnalyticsHelper)
}

Loading…
Cancel
Save