add segment analytics to android
This commit is contained in:
@ -140,6 +140,8 @@ dependencies {
|
||||
|
||||
implementation 'com.google.code.gson:gson:2.8.9'
|
||||
implementation 'com.pspdfkit:pspdfkit:8.4.1'
|
||||
|
||||
implementation 'com.segment.analytics.kotlin:android:1.10.0'
|
||||
}
|
||||
|
||||
apollo {
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
package="app.omnivore.omnivore">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<application
|
||||
android:name=".OmnivoreApplication"
|
||||
|
||||
@ -8,6 +8,8 @@ import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
import com.segment.analytics.kotlin.android.Analytics
|
||||
import com.segment.analytics.kotlin.core.*
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@ -22,4 +24,18 @@ object AppModule {
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideNetworker(datastore: DatastoreRepository) = Networker(datastore)
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideAnalytics(
|
||||
@ApplicationContext app: Context
|
||||
): Analytics {
|
||||
val writeKey = app.getString(R.string.segment_write_key)
|
||||
|
||||
return Analytics(writeKey, app.applicationContext) {
|
||||
trackApplicationLifecycleEvents = true
|
||||
application = app.applicationContext
|
||||
useLifecycleObserver = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package app.omnivore.omnivore.ui.home
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
@ -8,6 +9,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import app.omnivore.omnivore.models.LinkedItem
|
||||
import app.omnivore.omnivore.networking.*
|
||||
import com.pspdfkit.analytics.Analytics
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -16,7 +18,8 @@ import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class HomeViewModel @Inject constructor(
|
||||
private val networker: Networker
|
||||
private val networker: Networker,
|
||||
private val analytics: com.segment.analytics.kotlin.core.Analytics
|
||||
): ViewModel() {
|
||||
private var cursor: String? = null
|
||||
private var items: List<LinkedItem> = listOf()
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="pspdfkit_license_key">unset</string>
|
||||
<string name="segment_write_key">unset</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user