TP-12345 | updated with release 3.3.22
This commit is contained in:
@@ -655,33 +655,22 @@ object AlfredManager {
|
||||
}
|
||||
}
|
||||
|
||||
fun saveApiLog(request: Request, response: Response, startTime: Long, endTime: Long) {
|
||||
coroutineDispatcher.executor.execute {
|
||||
if (config.getAlfredSessionId().isNotEmpty()) {
|
||||
var bytesSent = 0L
|
||||
var byteReceived = 0L
|
||||
if (request.body != null) {
|
||||
val buffer = Buffer()
|
||||
request.body?.writeTo(buffer)
|
||||
bytesSent = buffer.size
|
||||
}
|
||||
try {
|
||||
if (response.body != null) {
|
||||
val responseBody = response.body
|
||||
val source = responseBody?.source()
|
||||
source?.request(Long.MAX_VALUE)
|
||||
val buffer = source?.buffer
|
||||
byteReceived = buffer?.size ?: 0
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
byteReceived = -1
|
||||
e.log()
|
||||
}
|
||||
var errorMessage: String? = null
|
||||
fun saveApiLog(
|
||||
byteReceived: Long,
|
||||
byteSent: Long,
|
||||
request: Request,
|
||||
response: Response,
|
||||
startTime: Long,
|
||||
endTime: Long
|
||||
) {
|
||||
if (config.getAlfredSessionId().isNotEmpty()) {
|
||||
coroutineDispatcher.executor.execute {
|
||||
val duration: Long = endTime - startTime
|
||||
val errorType: String? = null
|
||||
if (response.code != CODE_API_SUCCESS) {
|
||||
errorMessage = response.message
|
||||
val errorMessage: String? = if (response.code != CODE_API_SUCCESS) {
|
||||
response.message
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val attributes = hashMapOf<String, Any>().apply {
|
||||
this[AlfredConstants.URL] = request.url.toString()
|
||||
@@ -693,7 +682,7 @@ object AlfredManager {
|
||||
this[AlfredConstants.END_TIME] = endTime
|
||||
this[AlfredConstants.DURATION_IN_MS] = duration.toDouble()
|
||||
this[AlfredConstants.BYTES_RECEIVED] = byteReceived
|
||||
this[AlfredConstants.BYTES_SENT] = bytesSent
|
||||
this[AlfredConstants.BYTES_SENT] = byteSent
|
||||
}
|
||||
val appPerformanceEvent = buildAppPerformanceEvent(
|
||||
AlfredConstants.API_METRIC_EVENT_NAME, API_METRICS, attributes
|
||||
@@ -777,20 +766,25 @@ object AlfredManager {
|
||||
if (config.getAlfredStatus() && config.getEnableRecordingStatus()) {
|
||||
if (config.getAlfredSessionId().isNotEmpty()) {
|
||||
coroutineDispatcher.executor.execute {
|
||||
if (currentTouchEvent?.action == ACTION_DOWN) {
|
||||
previousTouchEvent.action = currentTouchEvent.action
|
||||
previousTouchEvent.positionX = currentTouchEvent.rawX
|
||||
previousTouchEvent.positionY = currentTouchEvent.rawY
|
||||
}
|
||||
if (currentTouchEvent?.action == ACTION_UP) {
|
||||
val touchEventData = getTouchEvent(currentTouchEvent, previousTouchEvent)
|
||||
val event = buildEvent(
|
||||
touchEventData.first,
|
||||
touchEventData.second,
|
||||
screenName = screenName,
|
||||
moduleName = moduleName
|
||||
)
|
||||
AlfredDispatcher.addTaskToQueue(AddEventTask(event, applicationContext))
|
||||
try {
|
||||
if (currentTouchEvent?.action == ACTION_DOWN) {
|
||||
previousTouchEvent.action = currentTouchEvent.action
|
||||
previousTouchEvent.positionX = currentTouchEvent.rawX
|
||||
previousTouchEvent.positionY = currentTouchEvent.rawY
|
||||
}
|
||||
if (currentTouchEvent?.action == ACTION_UP) {
|
||||
val touchEventData =
|
||||
getTouchEvent(currentTouchEvent, previousTouchEvent)
|
||||
val event = buildEvent(
|
||||
touchEventData.first,
|
||||
touchEventData.second,
|
||||
screenName = screenName,
|
||||
moduleName = moduleName
|
||||
)
|
||||
AlfredDispatcher.addTaskToQueue(AddEventTask(event, applicationContext))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.log()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,8 +252,9 @@ fun getTouchEvent(
|
||||
currentTouchEvent: MotionEvent?, previousTouchEvent: NaviMotionEvent?
|
||||
): Pair<String, HashMap<String, String>> {
|
||||
val properties = HashMap<String, String>()
|
||||
val eventName = if (difference(currentTouchEvent?.rawX, previousTouchEvent?.positionX) && difference(
|
||||
currentTouchEvent?.rawY, previousTouchEvent?.positionY
|
||||
val pointerIndex = currentTouchEvent?.actionIndex ?: 0
|
||||
val eventName = if (difference(currentTouchEvent?.getX(pointerIndex), previousTouchEvent?.positionX) && difference(
|
||||
currentTouchEvent?.getY(pointerIndex), previousTouchEvent?.positionY
|
||||
)
|
||||
) {
|
||||
properties[AlfredConstants.START_X] = previousTouchEvent?.positionX.toString()
|
||||
@@ -270,7 +271,11 @@ fun getTouchEvent(
|
||||
}
|
||||
|
||||
fun difference(value1: Float? = 0F, value2: Float? = 0F, threshold: Int = 100): Boolean {
|
||||
return abs(subtractExact(value1?.toInt().orZero(), value2?.toInt().orZero())) <= threshold
|
||||
return try {
|
||||
abs(subtractExact(value1?.toInt().orZero(), value2?.toInt().orZero())) <= threshold
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@@ -290,7 +295,7 @@ fun getNetworkType(context: Context): String {
|
||||
else -> "Unknown" + AlfredConstants.UNDERSCORE + mTelephonyManager.networkType
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
e.log()
|
||||
}
|
||||
return "Unknown"
|
||||
}
|
||||
@@ -299,6 +304,7 @@ fun getCarrierName(context: Context): String? {
|
||||
return try {
|
||||
(context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).networkOperatorName
|
||||
} catch (e: Exception) {
|
||||
e.log()
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user