TP-57175 | Event whitelisting on Appsflyer and Firebase (#9791)

This commit is contained in:
Balrambhai Sharma
2024-02-16 16:14:53 +05:30
committed by GitHub
parent ba4678a674
commit df26179414
10 changed files with 35 additions and 21 deletions

View File

@@ -108,7 +108,7 @@ class InsuranceTabViewModel @Inject constructor(
is AnalyticsAction -> {
NaviTrackEvent.trackEvent(
uiTronAction.eventName ?: "", uiTronAction.eventProperties
uiTronAction.eventName ?: "", uiTronAction.eventProperties, uiTronAction.isNeededForAppsflyer, uiTronAction.isNeededForFirebase
)
}

View File

@@ -102,7 +102,7 @@ class TrialInsuranceDashboardFragment : BaseFragment(), WidgetCallback, NewBotto
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
NaviTrackEvent.trackEventOnClickStream(NaviAnalytics.TRIAL_INSURANCE_DASHBOARD_INIT)
NaviTrackEvent.trackEvent(NaviAnalytics.TRIAL_INSURANCE_DASHBOARD_INIT)
}
override fun onAttach(context: Context) {
@@ -212,7 +212,9 @@ class TrialInsuranceDashboardFragment : BaseFragment(), WidgetCallback, NewBotto
override fun onClick(naviClickAction: NaviClickAction, widgetId: String?) {
if (naviClickAction is CtaData) {
naviClickAction.analyticsEventProperties?.let { analyticsEvent ->
NaviTrackEvent.trackEvent(analyticsEvent.name ?: "", analyticsEvent.properties)
NaviTrackEvent.trackEvent(
analyticsEvent.name ?: "", analyticsEvent.properties, analyticsEvent.isNeededForAppsflyer.orFalse(), analyticsEvent.isNeededForFirebase.orFalse()
)
}
val bundle = Bundle()
bundle.putParcelable(Constants.PARAMS_EXTRA, naviClickAction)

View File

@@ -127,7 +127,7 @@ class TrialInsuranceDashboardVM @Inject constructor(
is AnalyticsAction -> {
NaviTrackEvent.trackEvent(
uiTronAction.eventName ?: "", uiTronAction.eventProperties
uiTronAction.eventName ?: "", uiTronAction.eventProperties, uiTronAction.isNeededForAppsflyer, uiTronAction.isNeededForFirebase
)
}

View File

@@ -136,12 +136,14 @@ object NaviTrackEvent {
fun trackEvent(
eventName: String,
eventValues: Map<String, String>? = null,
isNeededForAppsflyer: Boolean = true,
isNeededForAppsflyer: Boolean = false,
isNeededForFirebase: Boolean = false
) {
MoengageUtil.trackEvent(eventName, eventValues, applicationContext)
if (isNeededForFirebase) FcmAnalyticsUtil.analytics.trackEvent(eventName, eventValues)
PulseManager.trackEvent(eventName, eventValues)
if (isNeededForAppsflyer)
AppsFlyerUtil.instance.trackEvent(applicationContext, eventName, eventValues)
if (isEventWhiteListedForAppsflyer(eventName)) {
AppsFlyerUtil.instance.trackEvent(applicationContext, eventName, eventValues)
}

View File

@@ -17,7 +17,9 @@ import kotlinx.parcelize.RawValue
data class AnalyticsEvent(
@SerializedName("name") val name: String? = null,
@SerializedName("properties")
var properties: @RawValue MutableMap<String, String>? = mutableMapOf()
var properties: @RawValue MutableMap<String, String>? = mutableMapOf(),
@SerializedName("isNeededForAppsflyer") val isNeededForAppsflyer: Boolean? = null,
@SerializedName("isNeededForFirebase") val isNeededForFirebase: Boolean? = null,
) : Parcelable {
fun addLoadTime(pageLoadTime: Long) {
if (pageLoadTime != -1L) {

View File

@@ -5,6 +5,7 @@ import com.google.gson.Gson
import com.navi.analytics.utils.NaviTrackEvent
import com.navi.base.model.AnalyticsEvent
import com.navi.base.model.CtaData
import com.navi.base.utils.orFalse
import com.navi.common.utils.getNetworkType
import com.navi.insurance.common.models.Action
import com.navi.naviwidgets.models.WidgetViewedData
@@ -40,7 +41,9 @@ constructor() {
sendEvent(
AnalyticsEvent(
name = InsuranceAnalyticsConstants.HI_widget_viewed_event,
properties = mutableMapOf(Pair(screenName, mapValue))
properties = mutableMapOf(Pair(screenName, mapValue)),
isNeededForAppsflyer = true,
isNeededForFirebase = true
),
screenName
)
@@ -48,9 +51,7 @@ constructor() {
fun sendEvent(
analyticsEvent: AnalyticsEvent?,
screen: String? = null,
isNeededForAppsflyer: Boolean = true,
isNeededForFirebase: Boolean = false
screen: String? = null
) {
if (analyticsEvent == null) {
Timber.e("AnalyticsEvent is null")
@@ -70,8 +71,8 @@ constructor() {
NaviInsuranceAnalytics.postAnalyticsEvent(
it,
analyticsEvent.properties,
isNeededForAppsflyer = isNeededForAppsflyer,
isNeededForFirebase = isNeededForFirebase
isNeededForAppsflyer = analyticsEvent.isNeededForAppsflyer.orFalse(),
isNeededForFirebase = analyticsEvent.isNeededForFirebase.orFalse()
)
} ?: run {
Timber.e("Event name is null")

View File

@@ -18,6 +18,7 @@ import com.navi.analytics.moengage.MoengageUtil
import com.navi.analytics.utils.NaviTrackEvent
import com.navi.base.model.AnalyticsEvent
import com.navi.base.utils.BaseUtils
import com.navi.base.utils.orFalse
import com.navi.base.utils.orZero
import com.navi.common.CommonLibManager
import com.navi.insurance.models.request.OfferRequest
@@ -160,7 +161,7 @@ class NaviInsuranceAnalytics private constructor() {
fun postAnalyticsEvent(
eventName: String,
eventProperties: Map<String, String>?,
isNeededForAppsflyer: Boolean = true,
isNeededForAppsflyer: Boolean = false,
isNeededForFirebase: Boolean = false
) {
val updatedEventProperties = mutableMapOf<String, String>()
@@ -2134,7 +2135,9 @@ class NaviInsuranceAnalytics private constructor() {
offerParams.cover?.map { c -> c.coverId }?.joinToString(",").orEmpty()
),
Pair("screen", screenName)
)
),
isNeededForAppsflyer = true,
isNeededForFirebase = true
)
}
}
@@ -2272,7 +2275,9 @@ class NaviInsuranceAnalytics private constructor() {
analyticsEvent.name?.let { eventName ->
postAnalyticsEvent(
eventName,
analyticsEvent.properties?.toImmutableMap()
analyticsEvent.properties?.toImmutableMap(),
analyticsEvent.isNeededForAppsflyer.orFalse(),
analyticsEvent.isNeededForFirebase.orFalse()
)
}
}

View File

@@ -112,7 +112,9 @@ class BenefitExplainerFragment : GiBaseFragment(), WidgetCallback {
benefitID?.let { benefit ->
tabId?.let { tab ->
val analyticsEvent = AnalyticsEvent(
name = NaviInsuranceAnalytics.GI_BENFEXPLAINER_BENEFITPAGE_VIEW
name = NaviInsuranceAnalytics.GI_BENFEXPLAINER_BENEFITPAGE_VIEW,
isNeededForAppsflyer = true,
isNeededForFirebase = true
)
analyticsEvent.properties?.put(NaviInsuranceAnalytics.BENEFIT_ID, benefit)
analyticsEvent.properties?.put(NaviInsuranceAnalytics.WIDGET_ID, tab)

View File

@@ -302,10 +302,10 @@ class FormBasedFragment :
AnalyticsEvent(
name = analyticsScreenName,
properties =
mutableMapOf(Pair(APPLICATION_TYPE_EXTRA, applicationType.orEmpty()))
),
isNeededForAppsflyer = true,
isNeededForFirebase = analyticsScreenName == InsuranceAnalyticsConstants.EXISTING_INSURANCE_KEY
mutableMapOf(Pair(APPLICATION_TYPE_EXTRA, applicationType.orEmpty())),
isNeededForAppsflyer = true,
isNeededForFirebase = analyticsScreenName == InsuranceAnalyticsConstants.EXISTING_INSURANCE_KEY
)
)
}

View File

@@ -288,7 +288,7 @@ class QuoteOfferFragment : BaseFragment(), WidgetCallback, View.OnClickListener
}
}
insuranceAnalyticsHandler.sendEvent(it.metaData?.analyticsEvent, screenName, isNeededForAppsflyer = true, isNeededForFirebase = true)
insuranceAnalyticsHandler.sendEvent(it.metaData?.analyticsEvent?.copy(isNeededForAppsflyer = true, isNeededForFirebase = true), screenName)
it.headerWidget?.let { widgetConfigList ->
if (widgetConfigList.isNotEmpty()) {