Skip to content

Commit 8bd35fb

Browse files
added syncAfterSetUser feature setting (#445)
* added syncAfterSetUser feature setting * fixed unit tests * reverted whitespace changes * simplified trackOnce calls * bumped version number * bumped version number
1 parent 3d2ed07 commit 8bd35fb

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

sdk/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ apply plugin: "org.jetbrains.dokka"
1010
apply plugin: 'io.radar.mvnpublish'
1111

1212
ext {
13-
radarVersion = '3.21.4'
13+
radarVersion = '3.21.6'
1414
}
1515

1616
String buildNumber = ".${System.currentTimeMillis()}"

sdk/src/main/java/io/radar/sdk/Radar.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,10 @@ object Radar {
624624
}
625625

626626
RadarSettings.setUserId(context, userId)
627+
628+
if (RadarSettings.getSdkConfiguration(context).syncAfterSetUser) {
629+
trackOnce()
630+
}
627631
}
628632

629633
/**
@@ -688,6 +692,10 @@ object Radar {
688692
}
689693

690694
RadarSettings.setMetadata(context, metadata)
695+
696+
if (RadarSettings.getSdkConfiguration(context).syncAfterSetUser) {
697+
trackOnce()
698+
}
691699
}
692700

693701
/**

sdk/src/main/java/io/radar/sdk/model/RadarSdkConfiguration.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ internal data class RadarSdkConfiguration(
2323
val useOpenedAppConversion: Boolean = false,
2424
val useForegroundLocationUpdatedAtMsDiff: Boolean = false,
2525
val locationManagerTimeout: Int = 0,
26+
val syncAfterSetUser: Boolean = false,
2627
) {
2728
companion object {
2829
private const val MAX_CONCURRENT_JOBS = "maxConcurrentJobs"
@@ -39,6 +40,7 @@ internal data class RadarSdkConfiguration(
3940
private const val USE_OPENED_APP_CONVERSION = "useOpenedAppConversion"
4041
private const val USE_FOREGROUND_LOCATION_UPDATED_AT_MS_DIFF = "useForegroundLocationUpdatedAtMsDiff"
4142
private const val LOCATION_MANAGER_TIMEOUT = "locationManagerTimeout"
43+
private const val SYNC_AFTER_SET_USER = "syncAfterSetUser"
4244

4345
fun fromJson(json: JSONObject?): RadarSdkConfiguration {
4446
// set json as empty object if json is null, which uses fallback values
@@ -58,6 +60,7 @@ internal data class RadarSdkConfiguration(
5860
config.optBoolean(USE_OPENED_APP_CONVERSION, true),
5961
config.optBoolean(USE_FOREGROUND_LOCATION_UPDATED_AT_MS_DIFF, false),
6062
config.optInt(LOCATION_MANAGER_TIMEOUT, 0),
63+
config.optBoolean(SYNC_AFTER_SET_USER, false),
6164
)
6265
}
6366

@@ -89,6 +92,7 @@ internal data class RadarSdkConfiguration(
8992
putOpt(USE_OPENED_APP_CONVERSION, useOpenedAppConversion)
9093
putOpt(USE_FOREGROUND_LOCATION_UPDATED_AT_MS_DIFF, useForegroundLocationUpdatedAtMsDiff)
9194
putOpt(LOCATION_MANAGER_TIMEOUT, locationManagerTimeout)
95+
putOpt(SYNC_AFTER_SET_USER, syncAfterSetUser)
9296
}
9397
}
9498
}

sdk/src/test/java/io/radar/sdk/model/RadarSdkConfigurationTest.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class RadarSdkConfigurationTest {
3131
private var useOpenedAppConversion = false
3232
private var useForegroundLocationUpdatedAtMsDiff = false
3333
private var locationManagerTimeout = 123456
34+
private var syncAfterSetUser = false
3435

3536
@Before
3637
fun setUp() {
@@ -50,7 +51,8 @@ class RadarSdkConfigurationTest {
5051
"useLocationMetadata":$useLocationMetadata,
5152
"useOpenedAppConversion":$useOpenedAppConversion,
5253
"useForegroundLocationUpdatedAtMsDiff":$useForegroundLocationUpdatedAtMsDiff,
53-
"locationManagerTimeout":$locationManagerTimeout
54+
"locationManagerTimeout":$locationManagerTimeout,
55+
"syncAfterSetUser":$syncAfterSetUser,
5456
}""".trimIndent()
5557
}
5658

@@ -71,7 +73,8 @@ class RadarSdkConfigurationTest {
7173
useLocationMetadata,
7274
useOpenedAppConversion,
7375
useForegroundLocationUpdatedAtMsDiff,
74-
locationManagerTimeout
76+
locationManagerTimeout,
77+
syncAfterSetUser,
7578
).toJson().toString()
7679
)
7780
}
@@ -92,6 +95,7 @@ class RadarSdkConfigurationTest {
9295
assertEquals(useOpenedAppConversion, settings.useOpenedAppConversion)
9396
assertEquals(useForegroundLocationUpdatedAtMsDiff, settings.useForegroundLocationUpdatedAtMsDiff)
9497
assertEquals(locationManagerTimeout, settings.locationManagerTimeout)
98+
assertEquals(syncAfterSetUser, settings.syncAfterSetUser)
9599
}
96100

97101
@Test

0 commit comments

Comments
 (0)