Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow android configuration values to be updated #68

Merged
merged 1 commit into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions android/src/main/java/com/amplitude/android/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ open class Configuration @JvmOverloads constructor(
override var serverUrl: String? = null,
override var plan: Plan? = null,
override var ingestionMetadata: IngestionMetadata? = null,
val useAdvertisingIdForDeviceId: Boolean = false,
val useAppSetIdForDeviceId: Boolean = false,
val newDeviceIdPerInstall: Boolean = false,
var useAdvertisingIdForDeviceId: Boolean = false,
var useAppSetIdForDeviceId: Boolean = false,
var newDeviceIdPerInstall: Boolean = false,
val trackingOptions: TrackingOptions = TrackingOptions(),
val enableCoppaControl: Boolean = false,
val locationListening: Boolean = true,
val flushEventsOnClose: Boolean = true,
val minTimeBetweenSessionsMillis: Long = MIN_TIME_BETWEEN_SESSIONS_MILLIS,
val trackingSessionEvents: Boolean = true
var enableCoppaControl: Boolean = false,
var locationListening: Boolean = true,
var flushEventsOnClose: Boolean = true,
var minTimeBetweenSessionsMillis: Long = MIN_TIME_BETWEEN_SESSIONS_MILLIS,
var trackingSessionEvents: Boolean = true
) : Configuration(apiKey, flushQueueSize, flushIntervalMillis, instanceName, optOut, storageProvider, loggerProvider, minIdLength, partnerId, callback, flushMaxRetries, useBatch, serverZone, serverUrl, plan, ingestionMetadata) {
companion object {
const val MIN_TIME_BETWEEN_SESSIONS_MILLIS: Long = 300000
Expand Down
34 changes: 34 additions & 0 deletions android/src/test/java/com/amplitude/android/ConfigurationTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.amplitude.android

import android.app.Application
import android.content.Context
import com.amplitude.android.plugins.AndroidLifecyclePlugin
import io.mockk.mockk
import io.mockk.mockkStatic
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test

class ConfigurationTest {
private var context: Context? = null

@BeforeEach
fun setUp() {
context = mockk<Application>(relaxed = true)
mockkStatic(AndroidLifecyclePlugin::class)
}

@Test
fun configuration_init_isValid() {
val configuration = Configuration("test-apikey", context!!)
Assertions.assertTrue(configuration.isValid())
}

@Test
fun configuration_allows_propertyUpdate() {
val configuration = Configuration("test-apikey", context!!)
Assertions.assertTrue(configuration.trackingSessionEvents)
configuration.trackingSessionEvents = false
Assertions.assertFalse(configuration.trackingSessionEvents)
}
}