Bugfix 1.0.5 (#37)

This commit is contained in:
Sayed Owais Ali
2023-11-03 18:54:19 +05:30
committed by Shivam Goyal
parent 9ac177e82b
commit ccf0957483
7 changed files with 62 additions and 30 deletions

View File

@@ -6,7 +6,7 @@ plugins {
id 'kotlin-parcelize'
}
def VERSION_NAME = "1.0.5"
def VERSION_NAME = "1.0.5.1"
android {
namespace 'com.navi.alfred'

View File

@@ -188,7 +188,7 @@ data class AlfredConfig(
}
fun setMemoryUsageBeforeEventStart() {
this.memoryUsageBeforeEventStart = getMemoryUsage()
this.memoryUsageBeforeEventStart = getMemoryUsagePercentage()
}
fun setStorageUsageBeforeEventStart() {
@@ -201,8 +201,6 @@ data class AlfredConfig(
fun getCpuUsage(): Float = com.navi.alfred.utils.getCpuUsage()
fun getMemoryUsage(): Float = com.navi.alfred.utils.getMemoryUsage()
fun getMemoryUsagePercentage(): Float = com.navi.alfred.utils.getMemoryUsagePercentage()
fun getStorageUsage(): Float {
@@ -325,7 +323,7 @@ data class AlfredConfig(
deviceAttributes = DeviceAttributes(
battery = getBatteryPercentage(),
storage = getStorageUsage(),
memory = getMemoryUsage()
memory = getMemoryUsagePercentage()
)
)
}

View File

@@ -132,6 +132,7 @@ object AlfredManager {
config.setSessionStartRecordingTime()
config.setEventStartRecordingTime()
handleDeviceAttributes()
config.setAlfredEventId()
val startRecordingEvent = buildEvent(
AlfredConstants.START_RECORDING_EVENT,
screenName = screenName,

View File

@@ -1,6 +1,10 @@
package com.navi.alfred.utils
import com.navi.alfred.AlfredManager
import com.navi.alfred.model.Failure
import com.navi.alfred.model.FailureAttributes
import com.navi.alfred.model.FailureRequest
import com.navi.alfred.network.AlfredNetworkRepository
import com.navi.alfred.network.model.CruiseResponse
import com.navi.alfred.utils.AlfredConstants.DEFAULT_CRUISE_CONFIG_URL
@@ -24,6 +28,28 @@ internal suspend fun getCruiseConfig(cruiseApiSuccessful: (response: CruiseRespo
} catch (e: Exception) {
e.log()
}
} else {
val cruiseFailure = Failure(
errorType = AlfredConstants.API_ERROR,
requestUrl = DEFAULT_CRUISE_CONFIG_URL,
requestMethod = AlfredConstants.GET_METHOD,
errorTimestamp = System.currentTimeMillis(),
errorName = AlfredConstants.GET_CRUISE_CONFIG_FAILURE,
errorStatusCode = response.code().toLong(),
errorMessage = response.message()
)
try {
AlfredManager.networkRepository.sendFailure(
AlfredConstants.DEFAULT_SEND_FAILURE_POST_URL,
AlfredManager.config.getApiKey(),
failureRequest = FailureRequest(
failureAttributes = FailureAttributes(),
events = listOf(cruiseFailure)
)
)
} catch (e: Exception) {
e.log()
}
}
}

View File

@@ -101,12 +101,6 @@ internal fun getBatteryPercentage(context: Context): Float {
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY).toFloat()
}
internal fun getMemoryUsage(): Float {
val runtime = Runtime.getRuntime()
val usedMemory = runtime.totalMemory() - runtime.freeMemory()
return usedMemory / (1024f * 1024f)
}
internal fun getMemoryUsagePercentage(): Float {
val runtime = Runtime.getRuntime()
val usedMemory = runtime.totalMemory() - runtime.freeMemory()

View File

@@ -71,9 +71,7 @@ internal suspend fun sendEventsToServer(applicationContext: Context): Boolean {
request
)
return if (
(response.isSuccessful && response.code() == AlfredConstants.CODE_API_SUCCESS) or
(response.code() == AlfredConstants.CODE_API_BAD_REQUEST)
) {
response.isSuccessful && response.code() == AlfredConstants.CODE_API_SUCCESS) {
analyticsDao.deleteEvents(analyticsEvents.map { it.eventId })
true
} else {
@@ -89,7 +87,7 @@ internal suspend fun sendEventsToServer(applicationContext: Context): Boolean {
requestMethod = POST_METHOD,
zipName = zipNamesList,
errorStatusCode = response.code().toLong(),
errorMessage = response.body()?.toString(),
errorMessage = response.message(),
errorName = INGEST_EVENT_FAILURE
)
AlfredDispatcher.addTaskToQueue(
@@ -98,7 +96,12 @@ internal suspend fun sendEventsToServer(applicationContext: Context): Boolean {
context = AlfredManager.applicationContext
)
)
false
if (response.code() == AlfredConstants.CODE_API_BAD_REQUEST) {
analyticsDao.deleteEvents(analyticsEvents.map { it.eventId })
true
} else {
false
}
}
} else {
false
@@ -148,8 +151,7 @@ internal suspend fun sendNegativeCaseToServer(applicationContext: Context): Bool
request
)
return if (
(response.isSuccessful && response.code() == AlfredConstants.CODE_API_SUCCESS) or
(response.code() == AlfredConstants.CODE_API_BAD_REQUEST)
response.isSuccessful && response.code() == AlfredConstants.CODE_API_SUCCESS
) {
negativeCaseDao.deleteNegativeCase(negativeEvents.map { it.negativeCaseId })
true
@@ -159,7 +161,7 @@ internal suspend fun sendNegativeCaseToServer(applicationContext: Context): Bool
requestUrl = DEFAULT_SEND_CRASH_URL,
requestMethod = POST_METHOD,
errorStatusCode = response.code().toLong(),
errorMessage = response.body()?.toString(),
errorMessage = response.message(),
errorName = INGEST_CRASH_FAILURE
)
AlfredDispatcher.addTaskToQueue(
@@ -168,7 +170,12 @@ internal suspend fun sendNegativeCaseToServer(applicationContext: Context): Bool
context = AlfredManager.applicationContext
)
)
false
if (response.code() == AlfredConstants.CODE_API_BAD_REQUEST) {
negativeCaseDao.deleteNegativeCase(negativeEvents.map { it.negativeCaseId })
true
} else {
false
}
}
} else {
false
@@ -345,7 +352,7 @@ internal fun sendAlfredSessionEvent(dumpFlow: Boolean = false, index: Int? = nul
requestMethod = POST_METHOD,
zipName = request.session_upload_event_attributes.eventId?.let { listOf(it) },
errorStatusCode = response.code().toLong(),
errorMessage = response.body()?.toString(),
errorMessage = response.message(),
errorName = INGEST_SESSION_FAILURE
)
AlfredDispatcher.addTaskToQueue(
@@ -386,8 +393,7 @@ internal suspend fun sendIngestMetric(): Boolean {
metricRequestBody = request
)
return if (
(response.isSuccessful && response.code() == AlfredConstants.CODE_API_SUCCESS) or
(response.code() == AlfredConstants.CODE_API_BAD_REQUEST)
response.isSuccessful && response.code() == AlfredConstants.CODE_API_SUCCESS
) {
AlfredManager.apiMetricDao.deleteApiMetric(metricEventList.map { it.id })
true
@@ -397,7 +403,7 @@ internal suspend fun sendIngestMetric(): Boolean {
requestUrl = DEFAULT_INGEST_METRIC_URL,
requestMethod = POST_METHOD,
errorStatusCode = response.code().toLong(),
errorMessage = response.body()?.toString(),
errorMessage = response.message(),
errorName = INGEST_METRIC_FAILURE
)
AlfredDispatcher.addTaskToQueue(
@@ -406,7 +412,12 @@ internal suspend fun sendIngestMetric(): Boolean {
context = AlfredManager.applicationContext
)
)
false
if (response.code() == AlfredConstants.CODE_API_BAD_REQUEST) {
AlfredManager.apiMetricDao.deleteApiMetric(metricEventList.map { it.id })
true
} else {
false
}
}
}
} catch (e: Exception) {
@@ -463,7 +474,8 @@ internal fun buildEvent(
sessionId = AlfredManager.config.getAlfredSessionId(),
screenName = screenName,
moduleName = moduleName,
fragmentList = getFragmentList()
fragmentList = getFragmentList(),
zipName = AlfredManager.config.getAlfredEventId()
)
return AnalyticsEvent(timeStamp, Gson().toJson(eventData))
}
@@ -485,7 +497,8 @@ internal fun buildNegativeCaseEvent(
sessionId = AlfredManager.config.getAlfredSessionId(),
screenName = screenName,
moduleName = moduleName,
fragmentList = getFragmentList()
fragmentList = getFragmentList(),
zipName = AlfredManager.config.getAlfredEventId()
)
return NegativeCase(timeStamp, Gson().toJson(eventData))
}

View File

@@ -29,8 +29,8 @@ internal suspend fun getPreSignedUrl(
index: Int? = null,
workManagerFlow: Boolean? = false
) {
AlfredManager.config.setAlfredEventId()
val bucketKey = AlfredManager.config.getAlfredEventId().plus(AlfredConstants.ZIP_FILE_EXTENSION)
AlfredManager.config.setAlfredEventId()
val response =
AlfredManager.networkRepository.getPreSignedUrl(bucketKey, AlfredManager.config.getApiKey())
if (response.isSuccessful && response.code() == AlfredConstants.CODE_API_SUCCESS) {
@@ -52,7 +52,7 @@ internal suspend fun getPreSignedUrl(
requestUrl = DEFAULT_GET_PRE_SIGNED_URL_URL.plus(bucketKey),
requestMethod = GET_METHOD,
errorStatusCode = response.code().toLong(),
errorMessage = response.errorBody()?.string(),
errorMessage = response.message(),
errorName = GET_PRE_SIGNED_URL_FAILURE
)
AlfredDispatcher.addTaskToQueue(
@@ -152,7 +152,7 @@ internal suspend fun uploadFile(
requestUrl = url,
requestMethod = POST_METHOD,
errorStatusCode = uploadResponse.code().toLong(),
errorMessage = uploadResponse.errorBody()?.string(),
errorMessage = uploadResponse.message(),
errorName = UPLOAD_TO_S3_FAILURE
)
AlfredDispatcher.addTaskToQueue(