TP-57934 | Added events for location (#10151)
This commit is contained in:
@@ -725,4 +725,17 @@ object InsuranceAnalyticsConstants {
|
||||
const val LOCATION_PERMISSION_NOT_GRANTED = "location_permission_not_granted"
|
||||
|
||||
const val HI_GET_HOSPITAL_PAGE_API_ERROR = "HI_getHospitalPageApiError"
|
||||
|
||||
// Fetch Location Events
|
||||
const val POSTAL_CODE_FAILURE = "hi_fetch_postal_code_from_location_failure"
|
||||
const val POSTAL_CODE_SUCCESS = "hi_fetch_postal_code_from_location_success"
|
||||
const val LOCATION_FROM_COORDINATES_FAILURE = "hi_fetch_location_from_coordinates_failure"
|
||||
const val LOCATION_FROM_COORDINATES_SUCCESS = "hi_fetch_location_from_coordinates_success"
|
||||
const val SAVED_USER_LOCATION_FAILURE = "hi_fetch_saved_user_location_failure"
|
||||
const val SAVED_USER_LOCATION_SUCCESS = "hi_fetch_saved_user_location_success"
|
||||
|
||||
//Fetch Location Event Properties
|
||||
const val TIMEOUT = "timeout"
|
||||
const val NO_ADDRESS_FOUND = "no_address_found"
|
||||
const val NO_POSTAL_CODE_FOUND = "no_postal_code_found"
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.navi.base.utils.orFalse
|
||||
import com.navi.base.utils.orZero
|
||||
import com.navi.base.utils.toDoubleWithSafe
|
||||
import com.navi.common.CommonLibManager
|
||||
import com.navi.insurance.analytics.InsuranceAnalyticsConstants
|
||||
import com.navi.insurance.analytics.NaviInsuranceAnalytics
|
||||
import com.navi.insurance.models.UserLocation
|
||||
import com.navi.insurance.sharedpref.NaviPreferenceManager
|
||||
@@ -166,8 +167,16 @@ class NaviLocationManager(private val context: Context) : Application.ActivityLi
|
||||
1
|
||||
) as List<Address>
|
||||
} catch (e: Exception) {
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
InsuranceAnalyticsConstants.LOCATION_FROM_COORDINATES_FAILURE,
|
||||
null
|
||||
)
|
||||
return null
|
||||
}
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
InsuranceAnalyticsConstants.LOCATION_FROM_COORDINATES_SUCCESS,
|
||||
null
|
||||
)
|
||||
return addresses
|
||||
}
|
||||
|
||||
@@ -187,6 +196,11 @@ class NaviLocationManager(private val context: Context) : Application.ActivityLi
|
||||
if (!calledBack) {
|
||||
callback(null, null, null)
|
||||
calledBack = true
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
InsuranceAnalyticsConstants.POSTAL_CODE_FAILURE, mapOf(
|
||||
"type" to InsuranceAnalyticsConstants.TIMEOUT,
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
timeout
|
||||
@@ -207,6 +221,11 @@ class NaviLocationManager(private val context: Context) : Application.ActivityLi
|
||||
userLocation.longitude!!.toDouble()
|
||||
)
|
||||
calledBack = true
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
InsuranceAnalyticsConstants.POSTAL_CODE_FAILURE, mapOf(
|
||||
"type" to InsuranceAnalyticsConstants.NO_ADDRESS_FOUND,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
return@launch
|
||||
@@ -225,6 +244,9 @@ class NaviLocationManager(private val context: Context) : Application.ActivityLi
|
||||
if (!calledBack) {
|
||||
callback(address.postalCode, null, null)
|
||||
calledBack = true
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
InsuranceAnalyticsConstants.POSTAL_CODE_SUCCESS, null
|
||||
)
|
||||
}
|
||||
}
|
||||
return@launch
|
||||
@@ -234,6 +256,11 @@ class NaviLocationManager(private val context: Context) : Application.ActivityLi
|
||||
if (!calledBack) {
|
||||
callback(null, null, null)
|
||||
calledBack = true
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
InsuranceAnalyticsConstants.POSTAL_CODE_FAILURE, mapOf(
|
||||
"type" to InsuranceAnalyticsConstants.NO_POSTAL_CODE_FOUND,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,12 +483,7 @@ fun getSavedUserLocation(
|
||||
naviLocationManager: NaviLocationManager, viewModel: NewHospitalsVM?
|
||||
): UserLocation? {
|
||||
var userLocation = CommonUtils.getUserLocation()
|
||||
if (userLocation?.latitude != null && userLocation.longitude != null) {
|
||||
UserLocation(
|
||||
latitude = userLocation.latitude.toString(),
|
||||
longitude = userLocation.longitude.toString()
|
||||
)
|
||||
} else {
|
||||
if (userLocation?.latitude == null || userLocation.longitude == null) {
|
||||
naviLocationManager.getLastLocation {
|
||||
it?.let {
|
||||
viewModel?.saveUserLocation(
|
||||
|
||||
@@ -14,6 +14,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import com.navi.base.utils.isNotNullAndNotEmpty
|
||||
import com.navi.common.utils.CommonUtils
|
||||
import com.navi.insurance.analytics.InsuranceAnalyticsConstants
|
||||
import com.navi.insurance.location.NaviLocationManager
|
||||
import com.navi.insurance.models.UserLocation
|
||||
import com.navi.insurance.pre.purchase.journey.PreQuotePatchData
|
||||
@@ -26,6 +27,7 @@ import com.navi.insurance.util.Constants.ANIMATION_DELAY
|
||||
import com.navi.naviwidgets.models.GenericWidgetDataInfo
|
||||
import com.navi.naviwidgets.models.PincodeInputData
|
||||
import kotlinx.coroutines.delay
|
||||
import com.navi.insurance.analytics.NaviInsuranceAnalytics
|
||||
|
||||
|
||||
@Composable
|
||||
@@ -103,13 +105,15 @@ private fun formatPincodeRequestData(pincodeData: PincodeInputData?): PreQuotePa
|
||||
|
||||
fun getSavedUserLocation(): UserLocation? {
|
||||
val commonUtilLocation = CommonUtils.getUserLocation()
|
||||
return if (commonUtilLocation?.latitude != null && commonUtilLocation.longitude != null) {
|
||||
UserLocation(
|
||||
if (commonUtilLocation?.latitude != null && commonUtilLocation.longitude != null) {
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(InsuranceAnalyticsConstants.SAVED_USER_LOCATION_SUCCESS, null)
|
||||
return UserLocation(
|
||||
latitude = commonUtilLocation.latitude,
|
||||
longitude = commonUtilLocation.longitude
|
||||
)
|
||||
} else {
|
||||
null
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(InsuranceAnalyticsConstants.SAVED_USER_LOCATION_FAILURE, null)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user