From 9f9ed5a98bdd9016f80e443ca6fa1a0f9e10caf4 Mon Sep 17 00:00:00 2001 From: David Goodfellow <61531269+david-goodfellow@users.noreply.github.com> Date: Sat, 11 Feb 2023 15:20:16 -0500 Subject: [PATCH] RAD-5747 Anonymous config call in `trackOnce` (#266) * 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 <708510+jrtibbetts@users.noreply.github.com> Co-authored-by: Nick Patrick Co-authored-by: Tim Julien --- sdk/build.gradle | 2 +- sdk/src/main/java/io/radar/sdk/Radar.kt | 3 ++- .../io/radar/sdk/RadarActivityLifecycleCallbacks.kt | 3 ++- sdk/src/main/java/io/radar/sdk/RadarApiClient.kt | 10 +++++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index bf70ab74..880bdfd9 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -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()}" diff --git a/sdk/src/main/java/io/radar/sdk/Radar.kt b/sdk/src/main/java/io/radar/sdk/Radar.kt index ba0682a8..23623236 100644 --- a/sdk/src/main/java/io/radar/sdk/Radar.kt +++ b/sdk/src/main/java/io/radar/sdk/Radar.kt @@ -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) diff --git a/sdk/src/main/java/io/radar/sdk/RadarActivityLifecycleCallbacks.kt b/sdk/src/main/java/io/radar/sdk/RadarActivityLifecycleCallbacks.kt index 50a9f428..0771f731 100644 --- a/sdk/src/main/java/io/radar/sdk/RadarActivityLifecycleCallbacks.kt +++ b/sdk/src/main/java/io/radar/sdk/RadarActivityLifecycleCallbacks.kt @@ -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) diff --git a/sdk/src/main/java/io/radar/sdk/RadarApiClient.kt b/sdk/src/main/java/io/radar/sdk/RadarApiClient.kt index 63280fa6..85089ed0 100644 --- a/sdk/src/main/java/io/radar/sdk/RadarApiClient.kt +++ b/sdk/src/main/java/io/radar/sdk/RadarApiClient.kt @@ -94,7 +94,7 @@ 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() @@ -102,6 +102,9 @@ internal class RadarApiClient( 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() @@ -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")