From 5810c9d795fe840c254ce050e41d82ed3b9b62af Mon Sep 17 00:00:00 2001 From: Alyssa Yu Date: Thu, 29 Sep 2022 00:20:18 -0700 Subject: [PATCH] fix: fix other location info not auto populate (#79) --- .../android/plugins/AndroidContextPlugin.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt b/android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt index 0ed49eca..2216e4cf 100644 --- a/android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt +++ b/android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt @@ -115,7 +115,13 @@ class AndroidContextPlugin : Plugin { if (trackingOptions.shouldTrackCarrier()) { event.carrier = contextProvider.carrier } - if (trackingOptions.shouldTrackCountry()) { + if (trackingOptions.shouldTrackIpAddress()) { + event.ip ?: let { + // get the ip in server side if there is no event level ip + event.ip = "\$remote" + } + } + if (trackingOptions.shouldTrackCountry() && event.ip !== "\$remote") { event.country = contextProvider.country } if (trackingOptions.shouldTrackLanguage()) { @@ -145,10 +151,6 @@ class AndroidContextPlugin : Plugin { event.partnerId = it } } - event.ip ?: let { - // get the ip in server side if there is no event level ip - event.ip = "\$remote" - } event.plan ?: let { amplitude.configuration.plan ?. let { event.plan = it.clone()