NTP-1234 | Broke down NaviApplication class to follow SOLID pattern more closely (#11996)
Co-authored-by: Sohan Reddy Atukula <sohan.reddy@navi.com> Co-authored-by: Ayushman Sharma <ayushman.sharma@navi.com> Co-authored-by: Hardik Chaudhary <hardik.chaudhary@navi.com> Co-authored-by: Shaurya Rehan <shaurya.rehan@navi.com> Co-authored-by: Aditya Narayan Malik <aditya.narayan@navi.com> Co-authored-by: Mehul Garg <mehul.garg@navi.com> Co-authored-by: mohit-rajput <mohit.rajput@navi.com> Co-authored-by: Naman Khurmi <naman.khurmi@navi.com> Co-authored-by: nikhil kumar <nikhil.kumar@navi.com> Co-authored-by: Sayed Owais Ali <sayed.owais@navi.com> Co-authored-by: Ankit Yadav <ankit.yadav@navi.com>
This commit is contained in:
@@ -34,6 +34,14 @@ object NaviTrackEvent {
|
||||
private var startTs: Long = 0L
|
||||
private var previousScreenName: String? = null
|
||||
var currentScreenName: String? = null
|
||||
private lateinit var analyticsConfiguration: AnalyticsConfiguration
|
||||
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,
|
||||
@@ -42,7 +50,9 @@ object NaviTrackEvent {
|
||||
) {
|
||||
applicationContext = appContext
|
||||
FcmAnalyticsUtil.analytics.init()
|
||||
MoengageUtil.init(appContext, analyticsConfiguration.moengageData, inAppOptOutScreens)
|
||||
this.analyticsConfiguration = analyticsConfiguration
|
||||
this.inAppOptOutScreens = inAppOptOutScreens
|
||||
this.appContext = appContext
|
||||
val pulseConfig =
|
||||
PulseSDKConfig.Configuration.Builder()
|
||||
.setAppName(analyticsConfiguration.appInfo.appName)
|
||||
@@ -52,6 +62,7 @@ object NaviTrackEvent {
|
||||
.setEventBatchSize(analyticsConfiguration.pulseConfig.eventBatchSize)
|
||||
.setEventInterval(analyticsConfiguration.pulseConfig.eventInterval)
|
||||
.build()
|
||||
|
||||
if (analyticsConfiguration.disableAlfred.not()) {
|
||||
val alfredConfig =
|
||||
AlfredConfig(
|
||||
@@ -94,7 +105,7 @@ object NaviTrackEvent {
|
||||
isNeededForFirebase: Boolean = true
|
||||
) {
|
||||
screenName?.apply {
|
||||
MoengageUtil.trackScreenName(this, context = applicationContext)
|
||||
moengageUtil.trackScreenName(this, context = applicationContext)
|
||||
if (isNeededForFirebase) FcmAnalyticsUtil.analytics.trackScreenOpen(this)
|
||||
PulseManager.trackEvent(screenName)
|
||||
if (isEventWhiteListedForAppsflyer(this)) {
|
||||
@@ -110,7 +121,7 @@ object NaviTrackEvent {
|
||||
isNeededForFirebase: Boolean = true
|
||||
) {
|
||||
screenName?.apply {
|
||||
MoengageUtil.trackEvent(this, eventValues, context = applicationContext)
|
||||
moengageUtil.trackEvent(this, eventValues, context = applicationContext)
|
||||
if (isNeededForFirebase) FcmAnalyticsUtil.analytics.trackEvent(this, eventValues)
|
||||
PulseManager.trackEvent(this, eventValues)
|
||||
if (isEventWhiteListedForAppsflyer(this)) {
|
||||
@@ -149,7 +160,7 @@ object NaviTrackEvent {
|
||||
isNeededForAppsflyer: Boolean = false,
|
||||
isNeededForFirebase: Boolean = false
|
||||
) {
|
||||
MoengageUtil.trackEvent(eventName, eventValues, applicationContext)
|
||||
moengageUtil.trackEvent(eventName, eventValues, applicationContext)
|
||||
if (isNeededForFirebase) FcmAnalyticsUtil.analytics.trackEvent(eventName, eventValues)
|
||||
PulseManager.trackEvent(eventName, eventValues)
|
||||
if (isNeededForAppsflyer || isEventWhiteListedForAppsflyer(eventName)) {
|
||||
@@ -164,7 +175,7 @@ object NaviTrackEvent {
|
||||
}
|
||||
|
||||
fun trackEventOnAllThirdParty(eventName: String, eventValues: Map<String, String>? = null) {
|
||||
MoengageUtil.trackEvent(eventName, eventValues, applicationContext)
|
||||
moengageUtil.trackEvent(eventName, eventValues, applicationContext)
|
||||
if (isEventWhiteListedForAppsflyer(eventName)) {
|
||||
AppsFlyerUtil.instance.trackEvent(applicationContext, eventName, eventValues)
|
||||
}
|
||||
@@ -172,7 +183,7 @@ object NaviTrackEvent {
|
||||
}
|
||||
|
||||
fun setUserId(id: String) {
|
||||
MoengageUtil.setUserId(id, applicationContext)
|
||||
moengageUtil.setUserId(id, applicationContext)
|
||||
FcmAnalyticsUtil.analytics.setUserId(id)
|
||||
AppsFlyerUtil.instance.setCustomerId(id)
|
||||
PulseManager.setUserId(id)
|
||||
@@ -194,7 +205,7 @@ object NaviTrackEvent {
|
||||
monthlyIncomeAmount: Double? = null,
|
||||
gender: String? = null
|
||||
) {
|
||||
MoengageUtil.setUserAttributes(
|
||||
moengageUtil.setUserAttributes(
|
||||
applicationContext,
|
||||
name,
|
||||
phoneNumber,
|
||||
@@ -209,10 +220,10 @@ object NaviTrackEvent {
|
||||
}
|
||||
|
||||
fun setLatLongAttribute(location: UserLocation?) =
|
||||
MoengageUtil.setLatLongAttribute(location, applicationContext)
|
||||
moengageUtil.setLatLongAttribute(location, applicationContext)
|
||||
|
||||
fun logoutUser() {
|
||||
MoengageUtil.logoutUser(applicationContext)
|
||||
moengageUtil.logoutUser(applicationContext)
|
||||
PulseManager.setUserId(null)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user