[自驾状态启动自驾埋点超时、中途进入应用 上报自驾启动成功]
This commit is contained in:
yangyakun
2023-07-27 19:43:58 +08:00
parent c2bd2f84e4
commit e98bef4e3b
3 changed files with 55 additions and 43 deletions

View File

@@ -29,6 +29,12 @@ object RxUtils {
function.invoke()
}
}
fun createSubscribeOnOwnThread(delay: Long=2000, function: () -> Unit): Disposable? {
return Observable.timer(delay, TimeUnit.MILLISECONDS)
.subscribe {
function.invoke()
}
}
fun isDisposed(disposable: Disposable?):Boolean{
if(disposable!=null){

View File

@@ -928,6 +928,12 @@ public class TaxiModel {
return;
}
if(CallerAutoPilotStatusListenerManager.INSTANCE.getState()
== IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
ToastUtils.showShort("自驾中、请勿重复启动");
return;
}
CallerLogger.INSTANCE.e(M_TAXI + TAG, "isPassStartAutopilotCommand = " +
FunctionBuildConfig.isPassStartAutopilotCommand);

View File

@@ -3,15 +3,16 @@ package com.mogo.och.taxi.utils
import android.text.TextUtils
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.utils.MogoAnalyticUtils.track
import com.mogo.eagle.core.data.app.AppConfigInfo.plateNumber
import com.mogo.commons.utils.MogoAnalyticUtils
import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_TAXI
import com.mogo.eagle.core.utilcode.util.DateTimeUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.och.common.module.utils.RxUtils
import com.mogo.och.taxi.constant.TaxiConst
import io.reactivex.disposables.Disposable
/**
* OCH Taxi埋点工具
@@ -21,22 +22,23 @@ import com.mogo.och.taxi.constant.TaxiConst
object TaxiAnalyticsManager {
/**
* @see TaxiConst.EVENT_KEY_RESTART_AUTOPILOT
* @see TaxiConst.EVENT_KEY_START_SERVICE
*/
private var mStartAutopilotKey: String? = null
private val mStartAutopilotParams = HashMap<String, Any>()
private val startAutopilotRunnable: Runnable = Runnable {
// 15s内未开启上报失败埋点
triggerStartAutopilotFailureEvent("", "15s后app等待超时")
}
var startAutopiloTimeOut: Disposable? = null
fun triggerStartAutopilotFailureEventByAdas(failCode: String, failMsg: String) {
removeWaitingCallback()
RxUtils.disposeSubscribe(startAutopiloTimeOut)
triggerStartAutopilotFailureEvent(failCode, failMsg)
}
private fun removeWaitingCallback() {
if (startAutopilotRunnable != null) {
UiThreadHandler.removeCallbacks(startAutopilotRunnable)
}
private fun clearStartAutopilotParams() {
mStartAutopilotParams.clear()
}
/**
@@ -46,27 +48,22 @@ object TaxiAnalyticsManager {
*/
private fun triggerStartAutopilotFailureEvent(failCode: String, failMsg: String) {
if (mStartAutopilotParams.isEmpty()) return
e(SceneConstant.M_TAXI + "triggerStartAutopilotFailureEvent", failMsg)
CallerLogger.e(M_TAXI + "triggerStartAutopilotFailureEvent", failMsg)
if (CallerAutoPilotStatusListenerManager.getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_CODE] = failCode
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_MSG] = failMsg
}
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_RESULT] =
CallerAutoPilotStatusListenerManager.getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
track(mStartAutopilotKey, mStartAutopilotParams)
MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams)
clearStartAutopilotParams() //清空参数数据,防止误传
}
private fun clearStartAutopilotParams() {
mStartAutopilotParams.clear()
}
fun clearStartAutopilotFailureMSG() {
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_CODE] = ""
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_MSG] = ""
}
/**
*
* ① 自检完成后 启动自驾
* ② 自驾由其他状态转换到自驾中回调
* 触发'开启自动驾驶'埋点流程
* 开启自动驾驶15s内成功则发送成功埋点否则发送失败埋点
* @param restart false点击'开始服务'启动)/true接管后点击'自动驾驶'按钮启动)
@@ -83,28 +80,32 @@ object TaxiAnalyticsManager {
orderNo: String
) {
mStartAutopilotKey = if (restart) TaxiConst.EVENT_KEY_RESTART_AUTOPILOT else TaxiConst.EVENT_KEY_START_SERVICE
val plateNum = plateNumber
val dateTime = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss)
mStartAutopilotParams[TaxiConst.EVENT_PARAM_SN] = MoGoAiCloudClientConfig.getInstance().sn
mStartAutopilotParams[TaxiConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum
mStartAutopilotParams[TaxiConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE
mStartAutopilotParams[TaxiConst.EVENT_PARAM_TIME] = dateTime
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_NAME] = startName
mStartAutopilotParams[TaxiConst.EVENT_PARAM_END_NAME] = endName
mStartAutopilotParams[TaxiConst.EVENT_PARAM_LINE_ID] = lineId
mStartAutopilotParams[TaxiConst.EVENT_PARAM_ORDER_NUMBER] = orderNo
// CallerLogger.INSTANCE.d(M_TAXI + "埋点==","restart = "+restart+", send= "+send);
if (send) {
if (mStartAutopilotParams.isEmpty()) return
// 开启成功,上报埋点
clearStartAutopilotFailureMSG()
removeWaitingCallback()
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_RESULT] = true
track(mStartAutopilotKey, mStartAutopilotParams)
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_CODE] = ""//启动自驾失败code
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_FAILURE_MSG] = "" //启动自驾失败原因
// 取消15s超时
RxUtils.disposeSubscribe(startAutopiloTimeOut)
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_RESULT] = true // 自动驾驶状态
MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams)
clearStartAutopilotParams() //清空参数数据,防止误传
} else {
UiThreadHandler.postDelayed(startAutopilotRunnable, TaxiConst.LOOP_PERIOD_15S)
val plateNum = AppConfigInfo.plateNumber
mStartAutopilotParams[TaxiConst.EVENT_PARAM_SN] = MoGoAiCloudClientConfig.getInstance().sn
mStartAutopilotParams[TaxiConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum
mStartAutopilotParams[TaxiConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE
mStartAutopilotParams[TaxiConst.EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss)
mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_NAME] = startName
mStartAutopilotParams[TaxiConst.EVENT_PARAM_END_NAME] = endName
mStartAutopilotParams[TaxiConst.EVENT_PARAM_LINE_ID] = lineId
mStartAutopilotParams[TaxiConst.EVENT_PARAM_ORDER_NUMBER] = orderNo
startAutopiloTimeOut = RxUtils.createSubscribeOnOwnThread(TaxiConst.LOOP_PERIOD_15S) {
// 15s内未开启上报失败埋点
triggerStartAutopilotFailureEvent("", "15s后app等待超时")
}
}
}
@@ -116,17 +117,16 @@ object TaxiAnalyticsManager {
* @param orderNo
*/
fun triggerUnableStartAPReasonEvent(startName: String, endName: String, orderNo: String, reason: String) {
val plateNum = plateNumber
val dateTime = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss)
val plateNum = AppConfigInfo.plateNumber
val params = HashMap<String, Any>()
params[TaxiConst.EVENT_PARAM_SN] = MoGoAiCloudClientConfig.getInstance().sn
params[TaxiConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum
params[TaxiConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE
params[TaxiConst.EVENT_PARAM_TIME] = dateTime
params[TaxiConst.EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss)
params[TaxiConst.EVENT_PARAM_START_NAME] = startName
params[TaxiConst.EVENT_PARAM_END_NAME] = endName
params[TaxiConst.EVENT_PARAM_ORDER_NUMBER] = orderNo
params[TaxiConst.EVENT_PARAM_UNABLE_START_REASON] = reason
track(TaxiConst.EVENT_KEY_AP_UNABLE_START_REASON, params)
MogoAnalyticUtils.track(TaxiConst.EVENT_KEY_AP_UNABLE_START_REASON, params)
}
}