Bugfix 1.0.5 (#38)

This commit is contained in:
Sayed Owais Ali
2023-11-03 20:32:13 +05:30
committed by Shivam Goyal
parent ccf0957483
commit 7feab8cf12
3 changed files with 17 additions and 8 deletions

View File

@@ -12,7 +12,7 @@ data class Failure(
@SerializedName("error_type") val errorType: String? = "",
@SerializedName("request_url") val requestUrl: String? = "",
@SerializedName("request_method") val requestMethod: String? = "",
@SerializedName("client_ts") val clientTs: Long? = AlfredManager.config.getEventTimeStamp(),
@SerializedName("client_ts") val clientTs: Long? = null,
@SerializedName("error_timestamp") val errorTimestamp: Long? = System.currentTimeMillis(),
@SerializedName("zip_name") val zipName: List<String>? = null,
@SerializedName("error_name") val errorName: String? = "",

View File

@@ -88,7 +88,8 @@ internal suspend fun sendEventsToServer(applicationContext: Context): Boolean {
zipName = zipNamesList,
errorStatusCode = response.code().toLong(),
errorMessage = response.message(),
errorName = INGEST_EVENT_FAILURE
errorName = INGEST_EVENT_FAILURE,
clientTs = request.baseAttribute?.clientTs
)
AlfredDispatcher.addTaskToQueue(
AddFailureTask(
@@ -353,7 +354,8 @@ internal fun sendAlfredSessionEvent(dumpFlow: Boolean = false, index: Int? = nul
zipName = request.session_upload_event_attributes.eventId?.let { listOf(it) },
errorStatusCode = response.code().toLong(),
errorMessage = response.message(),
errorName = INGEST_SESSION_FAILURE
errorName = INGEST_SESSION_FAILURE,
clientTs = request.base_attribute.clientTs
)
AlfredDispatcher.addTaskToQueue(
AddFailureTask(
@@ -511,7 +513,8 @@ internal fun buildFailureEvent(
zipName: List<String>? = null,
errorStatusCode: Long,
errorMessage: String? = "",
errorName: String? = null
errorName: String? = null,
clientTs: Long? = null
): FailureEvent {
val timeStamp = System.currentTimeMillis()
val eventData =
@@ -522,7 +525,8 @@ internal fun buildFailureEvent(
zipName = zipName,
errorStatusCode = errorStatusCode,
errorMessage = errorMessage,
errorName = errorName
errorName = errorName,
clientTs = clientTs
)
return FailureEvent(timeStamp, Gson().toJson(eventData))
}

View File

@@ -29,7 +29,8 @@ internal suspend fun getPreSignedUrl(
index: Int? = null,
workManagerFlow: Boolean? = false
) {
val bucketKey = AlfredManager.config.getAlfredEventId().plus(AlfredConstants.ZIP_FILE_EXTENSION)
val zipNameForFailure = AlfredManager.config.getAlfredEventId()
val bucketKey = zipNameForFailure.plus(AlfredConstants.ZIP_FILE_EXTENSION)
AlfredManager.config.setAlfredEventId()
val response =
AlfredManager.networkRepository.getPreSignedUrl(bucketKey, AlfredManager.config.getApiKey())
@@ -42,7 +43,8 @@ internal suspend fun getPreSignedUrl(
dumpFlow,
index,
zipFileName,
workManagerFlow = workManagerFlow
workManagerFlow = workManagerFlow,
zipNameForFailure = zipNameForFailure
)
}
}
@@ -51,6 +53,7 @@ internal suspend fun getPreSignedUrl(
errorType = API_ERROR,
requestUrl = DEFAULT_GET_PRE_SIGNED_URL_URL.plus(bucketKey),
requestMethod = GET_METHOD,
zipName = listOf(zipNameForFailure),
errorStatusCode = response.code().toLong(),
errorMessage = response.message(),
errorName = GET_PRE_SIGNED_URL_FAILURE
@@ -139,7 +142,8 @@ internal suspend fun uploadFile(
dumpFlow: Boolean = false,
index: Int? = null,
zipFileName: String,
workManagerFlow: Boolean? = false
workManagerFlow: Boolean? = false,
zipNameForFailure: String? = ""
) {
val requestBody = uploadFile.asRequestBody("application/zip".toMediaTypeOrNull())
val uploadResponse = AlfredManager.networkRepository.uploadZipToS3(url, requestBody)
@@ -151,6 +155,7 @@ internal suspend fun uploadFile(
errorType = ZIP_ERROR,
requestUrl = url,
requestMethod = POST_METHOD,
zipName = listOf(zipNameForFailure?: ""),
errorStatusCode = uploadResponse.code().toLong(),
errorMessage = uploadResponse.message(),
errorName = UPLOAD_TO_S3_FAILURE