NTP-8036-Removed Moengage init for tracking (#13183)
This commit is contained in:
@@ -19,7 +19,6 @@ import com.google.android.gms.tasks.OnCompleteListener
|
||||
import com.google.firebase.messaging.FirebaseMessaging
|
||||
import com.moengage.push.amp.plus.MiPushHelper
|
||||
import com.navi.analytics.utils.NaviTrackEvent
|
||||
import com.navi.base.AppServiceManager
|
||||
import com.navi.base.sharedpref.CommonPrefConstants
|
||||
import com.navi.base.sharedpref.PreferenceManager
|
||||
import com.navi.base.utils.BaseUtils.areNotificationsEnabled
|
||||
@@ -221,12 +220,6 @@ object NotificationHandler {
|
||||
com.navi.common.utils.Constants.FCM_TOKEN_STORED,
|
||||
mapOf(com.navi.common.utils.Constants.FCM_TOKEN to token)
|
||||
)
|
||||
if (isUserLoggedIn()) {
|
||||
NaviTrackEvent.moengageUtil.passPushToken(
|
||||
AppServiceManager.application.applicationContext,
|
||||
token
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.log()
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.google.firebase.messaging.FirebaseMessagingService
|
||||
import com.google.firebase.messaging.RemoteMessage
|
||||
import com.navi.analytics.utils.NaviTrackEvent
|
||||
import com.navi.base.sharedpref.PreferenceManager
|
||||
import com.navi.base.utils.BaseUtils
|
||||
import com.navi.base.utils.BaseUtils.areNotificationsEnabled
|
||||
import com.navi.base.utils.isNotNull
|
||||
import com.navi.base.utils.isNotNullAndNotEmpty
|
||||
@@ -132,15 +131,6 @@ class NaviFirebaseMessagingService : FirebaseMessagingService() {
|
||||
}
|
||||
|
||||
private fun handleNotificationForSuperApp(remoteMessage: RemoteMessage, context: Context) {
|
||||
try {
|
||||
if (NaviTrackEvent.moengageUtil.isFromMoEngagePlatform(remoteMessage.data)) {
|
||||
NaviTrackEvent.moengageUtil.passPushPayload(context, remoteMessage.data)
|
||||
return
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.log()
|
||||
}
|
||||
|
||||
if (remoteMessage.data.isNotEmpty()) {
|
||||
handleSilentNotification(remoteMessage, context)
|
||||
}
|
||||
@@ -462,9 +452,6 @@ class NaviFirebaseMessagingService : FirebaseMessagingService() {
|
||||
com.navi.common.utils.Constants.FCM_TOKEN_STORED,
|
||||
mapOf(com.navi.common.utils.Constants.FCM_TOKEN to token)
|
||||
)
|
||||
if (BaseUtils.isUserLoggedIn()) {
|
||||
NaviTrackEvent.moengageUtil.passPushToken(applicationContext, token)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.log()
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import androidx.lifecycle.repeatOnLifecycle
|
||||
import com.google.android.gms.auth.api.phone.SmsRetriever
|
||||
import com.navi.amc.common.taskProcessor.AmcTaskManager
|
||||
import com.navi.analytics.firebase.FcmAnalyticsUtil
|
||||
import com.navi.analytics.utils.NaviTrackEvent
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.USER_EXTERNAL_ID
|
||||
import com.navi.base.sharedpref.PreferenceManager
|
||||
import com.navi.base.utils.BaseUtils
|
||||
@@ -491,9 +490,6 @@ class RegistrationActivity :
|
||||
)
|
||||
}
|
||||
NaviApplication.instance.naviPayManager.get().onAppLogin(loginResponse.externalCustomerId)
|
||||
loginResponse.phoneNumber.let {
|
||||
BaseUtils.savePhoneNumber(it.orEmpty())
|
||||
NaviTrackEvent.setUserAttributes(phoneNumber = it)
|
||||
}
|
||||
loginResponse.phoneNumber.let { BaseUtils.savePhoneNumber(it.orEmpty()) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.navi.amc.utils.AmcAnalytics.SELECTED_EMAIL
|
||||
import com.navi.amc.utils.Constant
|
||||
import com.navi.amc.utils.Constant.EMAIL
|
||||
import com.navi.amc.utils.orValue
|
||||
import com.navi.analytics.utils.NaviTrackEvent
|
||||
import com.navi.base.model.ActionData
|
||||
import com.navi.base.model.CtaData
|
||||
import com.navi.base.model.NaviClickAction
|
||||
@@ -133,7 +132,6 @@ class PersonalDetailsFragment :
|
||||
apiPollScheduler?.stopApiPoll()
|
||||
if (FirebaseStatusType.SUCCESS == response.status) {
|
||||
BaseUtils.saveEmail(viewModel.email)
|
||||
NaviTrackEvent.setUserAttributes(email = viewModel.email)
|
||||
fragmentInterchangeListener?.navigateToNextScreen(
|
||||
viewModel.dataItems.value?.footer?.nextCta
|
||||
)
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright © 2020-2023 by Navi Technologies Limited
|
||||
* * All rights reserved. Strictly confidential
|
||||
*
|
||||
*/
|
||||
|
||||
package com.navi.analytics.moengage
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.moe.pushlibrary.MoEHelper
|
||||
import com.moengage.core.DataCenter
|
||||
import com.moengage.core.MoEngage
|
||||
import com.moengage.core.Properties
|
||||
import com.moengage.core.config.FcmConfig
|
||||
import com.moengage.core.config.InAppConfig
|
||||
import com.moengage.core.config.LogConfig
|
||||
import com.moengage.core.config.NotificationConfig
|
||||
import com.moengage.firebase.MoEFireBaseHelper
|
||||
import com.moengage.inapp.MoEInAppHelper
|
||||
import com.moengage.pushbase.MoEPushHelper
|
||||
import com.navi.analytics.BuildConfig
|
||||
import com.navi.analytics.model.MoengageData
|
||||
import com.navi.analytics.model.UserLocation
|
||||
import java.lang.ref.WeakReference
|
||||
import timber.log.Timber
|
||||
|
||||
object MoengageUtil {
|
||||
fun init(
|
||||
appContext: Application,
|
||||
moengageData: MoengageData,
|
||||
inAppOptOutScreens: MutableSet<Class<*>>
|
||||
) {
|
||||
try {
|
||||
val moEngage =
|
||||
MoEngage.Builder(appContext, moengageData.moengageKey)
|
||||
.setDataCenter(DataCenter.DATA_CENTER_3)
|
||||
.configureNotificationMetaData(
|
||||
NotificationConfig(moengageData.smallIconId, moengageData.largeIconId)
|
||||
)
|
||||
.configureLogs(LogConfig())
|
||||
.configureFcm(FcmConfig(isRegistrationEnabled = true))
|
||||
.configureInApps(InAppConfig(inAppOptOutScreens))
|
||||
.build()
|
||||
MoEngage.initialiseDefaultInstance(moEngage)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun trackScreenName(
|
||||
screenName: String,
|
||||
eventValues: Map<String, Any>? = null,
|
||||
context: Context
|
||||
) {
|
||||
trackEvent(screenName, eventValues, context)
|
||||
}
|
||||
|
||||
fun trackEvent(eventName: String, eventValues: Map<String, Any>? = null, context: Context) {
|
||||
try {
|
||||
val properties = Properties()
|
||||
eventValues?.let { events ->
|
||||
for ((key, value) in events) {
|
||||
properties.addAttribute(key, value)
|
||||
}
|
||||
}
|
||||
MoEHelper.getInstance(context).trackEvent(eventName, properties)
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d("NAVI_MO_EVENT", eventName + " : " + eventValues.toString())
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun setUserId(id: String, context: Context) {
|
||||
try {
|
||||
MoEHelper.getInstance(context).setUniqueId(id) // Pass Unique user id
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun showInApp(context: WeakReference<Context>) {
|
||||
try {
|
||||
context.get()?.let { MoEInAppHelper.getInstance().showInApp(it) }
|
||||
} catch (e: Exception) {}
|
||||
}
|
||||
|
||||
fun logoutUser(context: Context) {
|
||||
try {
|
||||
MoEHelper.getInstance(context).logoutUser()
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun setUserAttributes(
|
||||
context: Context,
|
||||
name: String?,
|
||||
phoneNumber: String?,
|
||||
email: String?,
|
||||
maritalStatus: String?,
|
||||
pinCode: String?,
|
||||
employmentType: String?,
|
||||
companyName: String?,
|
||||
monthlyIncomeAmount: Double?,
|
||||
gender: String?
|
||||
) {
|
||||
try {
|
||||
val helper = MoEHelper.getInstance(context)
|
||||
if (!name.isNullOrBlank()) helper.setFirstName(name.orEmpty())
|
||||
if (!phoneNumber.isNullOrBlank()) helper.setNumber(phoneNumber.orEmpty())
|
||||
if (!email.isNullOrBlank()) helper.setEmail(email.orEmpty())
|
||||
if (!maritalStatus.isNullOrBlank())
|
||||
helper.setUserAttribute(MARITAL_STATUS, maritalStatus.orEmpty())
|
||||
if (!pinCode.isNullOrBlank()) helper.setUserAttribute(PIN_CODE, pinCode.orEmpty())
|
||||
if (!employmentType.isNullOrBlank())
|
||||
helper.setUserAttribute(EMPLYOMENT_TYPE, employmentType.orEmpty())
|
||||
if (!companyName.isNullOrBlank())
|
||||
helper.setUserAttribute(COMPANY_NAME, companyName.orEmpty())
|
||||
if (monthlyIncomeAmount != null)
|
||||
helper.setUserAttribute(MONTHLY_INCOME, monthlyIncomeAmount)
|
||||
if (gender.isNullOrBlank().not()) helper.setUserAttribute(GENDER, gender.orEmpty())
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun setLatLongAttribute(location: UserLocation?, context: Context) {
|
||||
try {
|
||||
location?.let {
|
||||
val helper = MoEHelper.getInstance(context)
|
||||
if (!location.latitude.isNullOrBlank() && !location.latitude.isNullOrBlank())
|
||||
helper.setUserLocation(
|
||||
location.latitude.orEmpty().toDouble(),
|
||||
location.longitude.orEmpty().toDouble()
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
}
|
||||
}
|
||||
|
||||
fun passPushToken(context: Context, newToken: String) {
|
||||
MoEFireBaseHelper.getInstance().passPushToken(context, newToken)
|
||||
}
|
||||
|
||||
fun isFromMoEngagePlatform(gcmPayLoad: Map<String, String>): Boolean {
|
||||
return MoEPushHelper.getInstance().isFromMoEngagePlatform(gcmPayLoad)
|
||||
}
|
||||
|
||||
fun isSilentPush(gcmPayLoad: Map<String, String>): Boolean {
|
||||
return MoEPushHelper.getInstance().isSilentPush(gcmPayLoad)
|
||||
}
|
||||
|
||||
fun passPushPayload(applicationContext: Context, gcmPayLoad: MutableMap<String, String>) {
|
||||
return MoEFireBaseHelper.getInstance().passPushPayload(applicationContext, gcmPayLoad)
|
||||
}
|
||||
|
||||
private const val MARITAL_STATUS = "marital_status"
|
||||
private const val PIN_CODE = "pin_code"
|
||||
private const val EMPLYOMENT_TYPE = "employment_type"
|
||||
private const val COMPANY_NAME = "company_name"
|
||||
private const val MONTHLY_INCOME = "monthly_income"
|
||||
private const val GENDER = "gender"
|
||||
}
|
||||
@@ -17,8 +17,6 @@ import com.navi.analytics.BuildConfig
|
||||
import com.navi.analytics.appsflyer.AppsFlyerUtil
|
||||
import com.navi.analytics.firebase.FcmAnalyticsUtil
|
||||
import com.navi.analytics.model.AnalyticsConfiguration
|
||||
import com.navi.analytics.model.UserLocation
|
||||
import com.navi.analytics.moengage.MoengageUtil
|
||||
import com.navi.analytics.utils.NaviAnalyticsHelper.isEventWhiteListedForAppsflyer
|
||||
import com.navi.base.model.AnalyticsEvent
|
||||
import com.navi.base.model.CtaData
|
||||
@@ -40,11 +38,6 @@ object NaviTrackEvent {
|
||||
private lateinit var inAppOptOutScreens: MutableSet<Class<*>>
|
||||
private lateinit var appContext: Application
|
||||
|
||||
val moengageUtil by lazy {
|
||||
MoengageUtil.init(appContext, analyticsConfiguration.moengageData, inAppOptOutScreens)
|
||||
MoengageUtil
|
||||
}
|
||||
|
||||
fun appInit(
|
||||
appContext: Application,
|
||||
analyticsConfiguration: AnalyticsConfiguration,
|
||||
@@ -107,7 +100,6 @@ object NaviTrackEvent {
|
||||
isNeededForFirebase: Boolean = true
|
||||
) {
|
||||
screenName?.apply {
|
||||
moengageUtil.trackScreenName(this, context = applicationContext)
|
||||
if (isNeededForFirebase) FcmAnalyticsUtil.analytics.trackScreenOpen(this)
|
||||
PulseManager.trackEvent(screenName)
|
||||
if (isEventWhiteListedForAppsflyer(this)) {
|
||||
@@ -123,7 +115,6 @@ object NaviTrackEvent {
|
||||
isNeededForFirebase: Boolean = true
|
||||
) {
|
||||
screenName?.apply {
|
||||
moengageUtil.trackEvent(this, eventValues, context = applicationContext)
|
||||
if (isNeededForFirebase) FcmAnalyticsUtil.analytics.trackEvent(this, eventValues)
|
||||
PulseManager.trackEvent(this, eventValues)
|
||||
if (isEventWhiteListedForAppsflyer(this)) {
|
||||
@@ -163,7 +154,6 @@ object NaviTrackEvent {
|
||||
isNeededForAppsflyer: Boolean = false,
|
||||
isNeededForFirebase: Boolean = false
|
||||
) {
|
||||
moengageUtil.trackEvent(eventName, eventValues, applicationContext)
|
||||
if (isNeededForFirebase) FcmAnalyticsUtil.analytics.trackEvent(eventName, eventValues)
|
||||
PulseManager.trackEvent(eventName, eventValues)
|
||||
if (isNeededForAppsflyer || isEventWhiteListedForAppsflyer(eventName)) {
|
||||
@@ -178,7 +168,6 @@ object NaviTrackEvent {
|
||||
}
|
||||
|
||||
fun trackEventOnAllThirdParty(eventName: String, eventValues: Map<String, String>? = null) {
|
||||
moengageUtil.trackEvent(eventName, eventValues, applicationContext)
|
||||
if (isEventWhiteListedForAppsflyer(eventName)) {
|
||||
AppsFlyerUtil.instance.trackEvent(applicationContext, eventName, eventValues)
|
||||
}
|
||||
@@ -186,7 +175,6 @@ object NaviTrackEvent {
|
||||
}
|
||||
|
||||
fun setUserId(id: String) {
|
||||
moengageUtil.setUserId(id, applicationContext)
|
||||
FcmAnalyticsUtil.analytics.setUserId(id)
|
||||
AppsFlyerUtil.instance.setCustomerId(id)
|
||||
PulseManager.setUserId(id)
|
||||
@@ -197,36 +185,7 @@ object NaviTrackEvent {
|
||||
PulseManager.setSessionId(sessionId)
|
||||
}
|
||||
|
||||
fun setUserAttributes(
|
||||
name: String? = null,
|
||||
phoneNumber: String? = null,
|
||||
email: String? = null,
|
||||
maritalStatus: String? = null,
|
||||
pinCode: String? = null,
|
||||
employmentType: String? = null,
|
||||
companyName: String? = null,
|
||||
monthlyIncomeAmount: Double? = null,
|
||||
gender: String? = null
|
||||
) {
|
||||
moengageUtil.setUserAttributes(
|
||||
applicationContext,
|
||||
name,
|
||||
phoneNumber,
|
||||
email,
|
||||
maritalStatus,
|
||||
pinCode,
|
||||
employmentType,
|
||||
companyName,
|
||||
monthlyIncomeAmount,
|
||||
gender
|
||||
)
|
||||
}
|
||||
|
||||
fun setLatLongAttribute(location: UserLocation?) =
|
||||
moengageUtil.setLatLongAttribute(location, applicationContext)
|
||||
|
||||
fun logoutUser() {
|
||||
moengageUtil.logoutUser(applicationContext)
|
||||
PulseManager.setUserId(null)
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,6 @@ class NaviLocationManager(
|
||||
) {
|
||||
val response = LocationRepository().postLocation(location)
|
||||
analyticsTracker.onLocationPostEndTime()
|
||||
NaviTrackEvent.setLatLongAttribute(location)
|
||||
response.error?.let {
|
||||
_locationPollingData.postValue(null)
|
||||
Timber.e(
|
||||
|
||||
@@ -96,7 +96,6 @@ import com.navi.common.viewmodel.BaseVM
|
||||
import com.navi.common.viewmodel.FeedbackVM
|
||||
import com.navi.naviwidgets.models.LottieFieldData
|
||||
import com.navi.uitron.UiTronSdkManager
|
||||
import java.lang.ref.WeakReference
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -537,7 +536,6 @@ abstract class BaseActivity :
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
NaviTrackEvent.moengageUtil.showInApp(WeakReference(this))
|
||||
latencyMapper = LatencyMapper(screenName)
|
||||
lifecycle.addObserver(latencyMapper)
|
||||
try {
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.navi.common.ui.activity.BaseActivity
|
||||
import com.navi.common.utils.*
|
||||
import com.navi.common.viewmodel.BaseVM
|
||||
import com.navi.naviwidgets.models.LottieFieldData
|
||||
import java.lang.ref.WeakReference
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
@@ -215,7 +214,6 @@ abstract class BaseFragment : NaviCoreFragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
context?.let { NaviTrackEvent.moengageUtil.showInApp(WeakReference(it)) }
|
||||
if (arguments == null) {
|
||||
arguments = Bundle()
|
||||
}
|
||||
|
||||
@@ -150,10 +150,6 @@ class NaviInsuranceAnalytics private constructor() {
|
||||
UserLocation::class.java
|
||||
)
|
||||
userLocation?.let {
|
||||
NaviTrackEvent.moengageUtil.setLatLongAttribute(
|
||||
UserLocation(latitude = it.latitude, longitude = it.longitude),
|
||||
context
|
||||
)
|
||||
firebaseAnalytics.setUserProperty("latitude", userLocation.latitude)
|
||||
firebaseAnalytics.setUserProperty("longitude", userLocation.longitude)
|
||||
}
|
||||
|
||||
@@ -62,15 +62,7 @@ import com.navi.insurance.health.viewmodel.BaseVM
|
||||
import com.navi.insurance.util.ERROR_MESSAGE
|
||||
import com.navi.insurance.util.getGlobalErrorType
|
||||
import com.navi.uitron.UiTronSdkManager
|
||||
import java.lang.ref.WeakReference
|
||||
import kotlin.collections.MutableMap
|
||||
import kotlin.collections.first
|
||||
import kotlin.collections.isNotEmpty
|
||||
import kotlin.collections.last
|
||||
import kotlin.collections.mapOf
|
||||
import kotlin.collections.mutableMapOf
|
||||
import kotlin.collections.set
|
||||
import kotlin.collections.toMap
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -217,11 +209,6 @@ abstract class BaseActivity : NaviCoreActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
NaviTrackEvent.moengageUtil.showInApp(WeakReference(this))
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
biometricPromptUtils.checkAndShowBiometricPrompt(
|
||||
|
||||
@@ -36,7 +36,6 @@ import com.navi.insurance.health.activity.BaseActivity
|
||||
import com.navi.insurance.util.Constants
|
||||
import com.navi.insurance.util.getGlobalErrorType
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
@AndroidEntryPoint
|
||||
abstract class BaseFragment : NaviCoreFragment() {
|
||||
@@ -79,7 +78,6 @@ abstract class BaseFragment : NaviCoreFragment() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
context?.let { NaviTrackEvent.moengageUtil.showInApp(WeakReference(it)) }
|
||||
if (arguments == null) {
|
||||
arguments = Bundle()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user