Skip to content

Commit

Permalink
RAD-5747 Anonymous config call in trackOnce (#266)
Browse files Browse the repository at this point in the history
* add config call for anonymous before track

* add boolean for track usage

* usage enum not bool

* resume usage

* move config track usage call later in the call stack

* move config track usage call later in the call stack

* use anon val

* bump version

* 3.5.11 version bump

---------

Co-authored-by: Jason R Tibbetts <[email protected]>
Co-authored-by: Nick Patrick <[email protected]>
Co-authored-by: Tim Julien <[email protected]>
  • Loading branch information
4 people committed Feb 11, 2023
1 parent b8343d2 commit 9f9ed5a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: "org.jetbrains.dokka"
apply plugin: 'io.radar.mvnpublish'

ext {
radarVersion = '3.5.10'
radarVersion = '3.5.11'
}

String buildNumber = ".${System.currentTimeMillis()}"
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/main/java/io/radar/sdk/Radar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ object Radar {
val application = this.context as? Application
application?.registerActivityLifecycleCallbacks(RadarActivityLifecycleCallbacks())

this.apiClient.getConfig(object : RadarApiClient.RadarGetConfigApiCallback {
val usage = "initialize"
this.apiClient.getConfig(usage, object : RadarApiClient.RadarGetConfigApiCallback {
override fun onComplete(config: RadarConfig) {
locationManager.updateTrackingFromMeta(config.meta)
RadarSettings.setFeatureSettings(context, config.featureSettings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ internal class RadarActivityLifecycleCallbacks : Application.ActivityLifecycleCa
try {
val updated = RadarSettings.updateSessionId(activity.applicationContext)
if (updated) {
Radar.apiClient.getConfig(object : RadarApiClient.RadarGetConfigApiCallback {
val usage = "resume"
Radar.apiClient.getConfig(usage, object : RadarApiClient.RadarGetConfigApiCallback {
override fun onComplete(config: RadarConfig) {
Radar.locationManager.updateTrackingFromMeta(config.meta)
RadarSettings.setFeatureSettings(activity.applicationContext, config.featureSettings)
Expand Down
10 changes: 9 additions & 1 deletion sdk/src/main/java/io/radar/sdk/RadarApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,17 @@ internal class RadarApiClient(
)
}

internal fun getConfig(callback: RadarGetConfigApiCallback? = null) {
internal fun getConfig(usage: String? = null, callback: RadarGetConfigApiCallback? = null) {
val publishableKey = RadarSettings.getPublishableKey(context) ?: return

val queryParams = StringBuilder()
queryParams.append("installId=${RadarSettings.getInstallId(context)}")
queryParams.append("&sessionId=${RadarSettings.getSessionId(context)}")
queryParams.append("&locationAuthorization=${RadarUtils.getLocationAuthorization(context)}")
queryParams.append("&locationAccuracyAuthorization=${RadarUtils.getLocationAccuracyAuthorization(context)}")
if (usage != null) {
queryParams.append("&usage=${usage}")
}

val host = RadarSettings.getHost(context)
val uri = Uri.parse(host).buildUpon()
Expand Down Expand Up @@ -272,6 +275,11 @@ internal class RadarApiClient(
return
}

if (anonymous) {
val usage = "track"
this.getConfig(usage)
}

val host = RadarSettings.getHost(context)
val uri = Uri.parse(host).buildUpon()
.appendEncodedPath("v1/track")
Expand Down

0 comments on commit 9f9ed5a

Please sign in to comment.