TP-35117 | Alfred/session id screen name fix (#7166)
* TP-32650 | screenName issue fix * TP-000000 | session id validation in events api * TP-00000 | screen name fix for crash and anr events * TP-00000 | added session id empty check * TP-00000 | resolved pr comment * TP-35117 | events api failure handling
This commit is contained in:
committed by
GitHub Enterprise
parent
a046ce17cf
commit
dea9b83903
@@ -44,8 +44,6 @@ import com.naviapp.analytics.utils.NaviAnalytics.Companion.STACK_TRACE
|
||||
import com.naviapp.analytics.utils.NaviSDKHelper
|
||||
import com.naviapp.common.transformer.AppLoadTimerMapper
|
||||
import com.naviapp.registration.SplashActivity
|
||||
import com.naviapp.utils.Constants.ANR_REGEX_1
|
||||
import com.naviapp.utils.Constants.ANR_REGEX_2
|
||||
import com.naviapp.utils.DEV
|
||||
import com.naviapp.utils.isDifferentPackage
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
@@ -96,26 +94,23 @@ open class NaviApplication : SplitCompatApplication(), Application.ActivityLifec
|
||||
return@setANRListener
|
||||
}
|
||||
val className = it.cause?.stackTrace?.get(0)?.className.orEmpty()
|
||||
if (className.contains(ANR_REGEX_1) || className.contains(ANR_REGEX_2)) {
|
||||
val anrEventProperties = mutableMapOf(
|
||||
SCREEN_NAME to className,
|
||||
METHOD_NAME to it.cause?.stackTrace?.get(0)?.methodName.orEmpty(),
|
||||
LINE_NUMBER to it.cause?.stackTrace?.get(0)?.lineNumber.toString(),
|
||||
APP_IN_FOREGROUND to isAppInForeground().toString()
|
||||
val anrEventProperties = mutableMapOf(
|
||||
SCREEN_NAME to (NaviTrackEvent.currentScreenName ?: className),
|
||||
METHOD_NAME to it.cause?.stackTrace?.get(0)?.methodName.orEmpty(),
|
||||
LINE_NUMBER to it.cause?.stackTrace?.get(0)?.lineNumber.toString(),
|
||||
APP_IN_FOREGROUND to isAppInForeground().toString()
|
||||
)
|
||||
NaviTrackEvent.trackEventOnClickStream(
|
||||
GLOBAL_ANR, anrEventProperties
|
||||
)
|
||||
if (isDifferentPackage.not() && (AlfredManager.config.getAlfredStatus() && AlfredManager.config.getAnrEnableStatus())) {
|
||||
anrEventProperties[STACK_TRACE] = it.cause?.stackTrace?.get(0).toString()
|
||||
val anrView =
|
||||
LayoutInflater.from(applicationContext).inflate(R.layout.anr_screen, null)
|
||||
measureInflatedView(anrView)
|
||||
AlfredManager.handleAnrEvent(
|
||||
anrEventProperties, anrView, NaviTrackEvent.currentScreenName ?: className
|
||||
)
|
||||
NaviTrackEvent.trackEventOnClickStream(
|
||||
GLOBAL_ANR, anrEventProperties
|
||||
)
|
||||
if (isDifferentPackage.not()) {
|
||||
if (AlfredManager.config.getAlfredStatus() && AlfredManager.config.getAnrEnableStatus()) {
|
||||
anrEventProperties[STACK_TRACE] = it.cause?.stackTrace?.get(0).toString()
|
||||
val anrView =
|
||||
LayoutInflater.from(applicationContext)
|
||||
.inflate(R.layout.anr_screen, null)
|
||||
measureInflatedView(anrView)
|
||||
AlfredManager.handleAnrEvent(anrEventProperties, anrView, className)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
|
||||
@@ -128,7 +123,8 @@ open class NaviApplication : SplitCompatApplication(), Application.ActivityLifec
|
||||
}
|
||||
try {
|
||||
val crashEventProperties = mutableMapOf(
|
||||
SCREEN_NAME to exception.stackTrace[0]?.className.orEmpty(),
|
||||
SCREEN_NAME to (NaviTrackEvent.currentScreenName
|
||||
?: exception.stackTrace[0]?.className.orEmpty()),
|
||||
METHOD_NAME to exception.stackTrace[0]?.methodName.orEmpty(),
|
||||
LINE_NUMBER to exception.stackTrace[0]?.lineNumber.toString(),
|
||||
APP_IN_FOREGROUND to isAppInForeground().toString()
|
||||
@@ -136,21 +132,19 @@ open class NaviApplication : SplitCompatApplication(), Application.ActivityLifec
|
||||
NaviTrackEvent.trackEventOnClickStream(
|
||||
GLOBAL_APP_CRASH, crashEventProperties
|
||||
)
|
||||
if (isDifferentPackage.not()) {
|
||||
if (AlfredManager.config.getAlfredStatus() && AlfredManager.config.getCrashEnableStatus()) {
|
||||
exception.stackTrace[0]?.let { stackTraceElement ->
|
||||
crashEventProperties[STACK_TRACE] = stackTraceElement.toString()
|
||||
}
|
||||
val crashView =
|
||||
LayoutInflater.from(applicationContext)
|
||||
.inflate(R.layout.crash_screen, null)
|
||||
measureInflatedView(crashView)
|
||||
AlfredManager.handleCrashEvent(
|
||||
crashEventProperties,
|
||||
crashView.rootView,
|
||||
exception.stackTrace[0]?.className.orEmpty()
|
||||
)
|
||||
if (isDifferentPackage.not() && (AlfredManager.config.getAlfredStatus() && AlfredManager.config.getCrashEnableStatus())) {
|
||||
exception.stackTrace[0]?.let { stackTraceElement ->
|
||||
crashEventProperties[STACK_TRACE] = stackTraceElement.toString()
|
||||
}
|
||||
val crashView =
|
||||
LayoutInflater.from(applicationContext).inflate(R.layout.crash_screen, null)
|
||||
measureInflatedView(crashView)
|
||||
AlfredManager.handleCrashEvent(
|
||||
crashEventProperties,
|
||||
crashView.rootView,
|
||||
NaviTrackEvent.currentScreenName
|
||||
?: exception.stackTrace[0]?.className.orEmpty()
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
defaultHandler?.uncaughtException(thread, exception)
|
||||
@@ -163,7 +157,7 @@ open class NaviApplication : SplitCompatApplication(), Application.ActivityLifec
|
||||
}
|
||||
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||
if(activity is SplashActivity){
|
||||
if (activity is SplashActivity) {
|
||||
AppLaunchUtils.resetAppOpenOnLaunch()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.navi.analytics.alfred.network.AlfredRetrofitProvider
|
||||
import com.navi.analytics.alfred.network.model.CruiseResponse
|
||||
import com.navi.analytics.alfred.utils.*
|
||||
import com.navi.analytics.alfred.utils.AlfredConstants.API_METRICS
|
||||
import com.navi.analytics.alfred.utils.AlfredConstants.CODE_API_BAD_REQUEST
|
||||
import com.navi.analytics.alfred.utils.AlfredConstants.CODE_API_SUCCESS
|
||||
import com.navi.analytics.alfred.utils.AlfredConstants.THIRD_PARTY_MODULE
|
||||
import com.navi.analytics.alfred.worker.AddEventTask
|
||||
@@ -558,7 +559,7 @@ object AlfredManager {
|
||||
AlfredConstants.DEFAULT_INGEST_METRIC_URL,
|
||||
metricRequestBody = request
|
||||
)
|
||||
return if (response.isSuccessful && response.code() == CODE_API_SUCCESS) {
|
||||
return if ((response.isSuccessful && response.code() == CODE_API_SUCCESS) or (response.code() == CODE_API_BAD_REQUEST)) {
|
||||
apiMetricDao.deleteApiMetric(metricEventList.map { it.id })
|
||||
true
|
||||
} else {
|
||||
@@ -619,7 +620,7 @@ object AlfredManager {
|
||||
val response = repository.sendEvents(
|
||||
config.getPostUrl(), request
|
||||
)
|
||||
return if (response.isSuccessful && response.code() == CODE_API_SUCCESS) {
|
||||
return if ((response.isSuccessful && response.code() == CODE_API_SUCCESS) or (response.code() == CODE_API_BAD_REQUEST)) {
|
||||
analyticsDao.deleteEvents(analyticsEvents.map { it.eventId })
|
||||
true
|
||||
} else {
|
||||
@@ -876,13 +877,15 @@ object AlfredManager {
|
||||
anrEventProperties: Map<String, String>, anrView: View, screenName: String? = null
|
||||
) {
|
||||
startAnrCrashZipUpload(anrView)
|
||||
coroutineDispatcher.executor.execute {
|
||||
val event = buildEvent(
|
||||
AlfredConstants.ANR_EVENT, anrEventProperties as HashMap<String, String>,
|
||||
screenName = screenName,
|
||||
moduleName = currentModuleName
|
||||
)
|
||||
AlfredDispatcher.addTaskToQueue(AddEventTask(event, this.applicationContext))
|
||||
if (config.getAlfredSessionId().isNotEmpty()) {
|
||||
coroutineDispatcher.executor.execute {
|
||||
val event = buildEvent(
|
||||
AlfredConstants.ANR_EVENT, anrEventProperties as HashMap<String, String>,
|
||||
screenName = screenName,
|
||||
moduleName = currentModuleName
|
||||
)
|
||||
AlfredDispatcher.addTaskToQueue(AddEventTask(event, this.applicationContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -910,14 +913,16 @@ object AlfredManager {
|
||||
screenName: String? = null
|
||||
) {
|
||||
startAnrCrashZipUpload(crashView)
|
||||
coroutineDispatcher.executor.execute {
|
||||
val event = buildEvent(
|
||||
AlfredConstants.CRASH_ANALYTICS_EVENT,
|
||||
crashEventProperties as HashMap<String, String>,
|
||||
screenName = screenName,
|
||||
moduleName = currentModuleName
|
||||
)
|
||||
AlfredDispatcher.addTaskToQueue(AddEventTask(event, applicationContext))
|
||||
if (config.getAlfredSessionId().isNotEmpty()) {
|
||||
coroutineDispatcher.executor.execute {
|
||||
val event = buildEvent(
|
||||
AlfredConstants.CRASH_ANALYTICS_EVENT,
|
||||
crashEventProperties as HashMap<String, String>,
|
||||
screenName = screenName,
|
||||
moduleName = currentModuleName
|
||||
)
|
||||
AlfredDispatcher.addTaskToQueue(AddEventTask(event, applicationContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ package com.navi.analytics.alfred.utils
|
||||
|
||||
object AlfredConstants {
|
||||
const val CODE_API_SUCCESS = 200
|
||||
const val CODE_API_BAD_REQUEST = 400
|
||||
const val UNDERSCORE = "_"
|
||||
const val ADD_EVENT_TASK = "AddEventTask"
|
||||
const val ADD_API_METRIC_TASK = "AddMetricTask"
|
||||
|
||||
Reference in New Issue
Block a user