[3.4.0]
[启动自驾埋点转换到kotlin]
This commit is contained in:
@@ -934,7 +934,7 @@ public class TaxiModel {
|
||||
if (!FunctionBuildConfig.isDemoMode && !OCHAdasAbilityManager.getInstance().getAutopilotAbilityStatus()) {
|
||||
ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() +
|
||||
", 请稍候重试");
|
||||
TaxiAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent(
|
||||
TaxiAnalyticsManager.INSTANCE.triggerUnableStartAPReasonEvent(
|
||||
mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.orderNo,
|
||||
OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason());
|
||||
return;
|
||||
@@ -962,7 +962,7 @@ public class TaxiModel {
|
||||
+ " ,endSiteName=" + mCurrentOCHOrder.endSiteAddr
|
||||
+ "isRestartAutopilot = " + isRestartAutopilot);
|
||||
|
||||
TaxiAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestartAutopilot, false,
|
||||
TaxiAnalyticsManager.INSTANCE.triggerStartAutopilotEvent(isRestartAutopilot, false,
|
||||
mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.lineId, mCurrentOCHOrder.orderNo);
|
||||
|
||||
if (mControllerStatusCallback != null) {
|
||||
@@ -1051,7 +1051,7 @@ public class TaxiModel {
|
||||
private final OchAdasStartFailureCallback mAdasStartFailureListener = new OchAdasStartFailureCallback() {
|
||||
@Override
|
||||
public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) {
|
||||
TaxiAnalyticsManager.getInstance().triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage);
|
||||
TaxiAnalyticsManager.INSTANCE.triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage);
|
||||
if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode) {
|
||||
CallerLogger.INSTANCE.e(M_TAXI + TAG, "mAdasStartFailureListener = " + startFailedMessage);
|
||||
mADASStatusCallback.onStartAdasFailure();
|
||||
@@ -1213,7 +1213,7 @@ public class TaxiModel {
|
||||
}
|
||||
if (mCurrentOCHOrder != null
|
||||
&& TaxiOrderStatusEnum.OnTheWayToEnd.getCode() == mCurrentOCHOrder.orderStatus) {
|
||||
TaxiAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestartAutopilot, true,
|
||||
TaxiAnalyticsManager.INSTANCE.triggerStartAutopilotEvent(isRestartAutopilot, true,
|
||||
mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.lineId, mCurrentOCHOrder.orderNo);
|
||||
if (FunctionBuildConfig.isDemoMode) {
|
||||
// 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后,置true
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
package com.mogo.och.taxi.utils;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
|
||||
import com.mogo.commons.utils.MogoAnalyticUtils;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.DateTimeUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.taxi.constant.TaxiConst;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* OCH Taxi埋点工具
|
||||
*
|
||||
* Created on 2022/3/24
|
||||
*/
|
||||
public class TaxiAnalyticsManager {
|
||||
|
||||
private static final class SingletonHolder {
|
||||
private static final TaxiAnalyticsManager INSTANCE = new TaxiAnalyticsManager();
|
||||
}
|
||||
|
||||
public static TaxiAnalyticsManager getInstance() {
|
||||
return TaxiAnalyticsManager.SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String mStartAutopilotKey;
|
||||
private HashMap<String, Object> mStartAutopilotParams = new HashMap<>();
|
||||
|
||||
private Runnable startAutopilotRunnable = () -> {
|
||||
// 15s内未开启,上报失败埋点
|
||||
triggerStartAutopilotFailureEvent("", "15s后app等待超时");
|
||||
};
|
||||
|
||||
public void triggerStartAutopilotFailureEventByAdas(String failCode, String failMsg){
|
||||
removeWaitingCallback();
|
||||
triggerStartAutopilotFailureEvent(failCode, failMsg);
|
||||
}
|
||||
|
||||
private void removeWaitingCallback() {
|
||||
if (startAutopilotRunnable != null) {
|
||||
UiThreadHandler.removeCallbacks(startAutopilotRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerStartAutopilotFailureEvent(String failCode, String failMsg){
|
||||
if (mStartAutopilotParams.isEmpty()) return;
|
||||
|
||||
CallerLogger.INSTANCE.e(M_TAXI + "triggerStartAutopilotFailureEvent", failMsg);
|
||||
if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() !=
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_START_FAILURE_CODE, failCode);
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_START_FAILURE_MSG,
|
||||
failMsg);
|
||||
}
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_START_RESULT,
|
||||
CallerAutoPilotStatusListenerManager.INSTANCE.getState() ==
|
||||
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING);
|
||||
MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams);
|
||||
|
||||
clearStartAutopilotParams();//清空参数数据,防止误传
|
||||
}
|
||||
|
||||
private void clearStartAutopilotParams(){
|
||||
mStartAutopilotParams.clear();
|
||||
}
|
||||
|
||||
public void clearStartAutopilotFailureMSG(){
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_START_FAILURE_CODE, "");
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_START_FAILURE_MSG, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发'开启自动驾驶'埋点流程
|
||||
* 开启自动驾驶,15s内成功则发送成功埋点,否则发送失败埋点
|
||||
* @param restart false(点击'开始服务'启动)/true(接管后点击'自动驾驶'按钮启动)
|
||||
* @param send 是否直接发送埋点(15s内开启成功则直接发送成功埋点)
|
||||
*/
|
||||
public void triggerStartAutopilotEvent(
|
||||
boolean restart, boolean send, String startName, String endName, long lineId, String orderNo) {
|
||||
mStartAutopilotKey = restart ?
|
||||
TaxiConst.EVENT_KEY_RESTART_AUTOPILOT : TaxiConst.EVENT_KEY_START_SERVICE;
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
String plateNum = AppConfigInfo.INSTANCE.getPlateNumber();
|
||||
String dateTime = DateTimeUtils.getTimeText(
|
||||
System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss);
|
||||
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_SN, sn);
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum);
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_ENV_ONLINE,
|
||||
DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false);
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_TIME, dateTime);
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_START_NAME, startName);
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_END_NAME, endName);
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_LINE_ID, lineId);
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_ORDER_NUMBER, orderNo);
|
||||
|
||||
// CallerLogger.INSTANCE.d(M_TAXI + "埋点==","restart = "+restart+", send= "+send);
|
||||
|
||||
if (send) {
|
||||
if (mStartAutopilotParams.isEmpty()) return;
|
||||
// 开启成功,上报埋点
|
||||
clearStartAutopilotFailureMSG();
|
||||
removeWaitingCallback();
|
||||
mStartAutopilotParams.put(TaxiConst.EVENT_PARAM_START_RESULT, true);
|
||||
MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams);
|
||||
|
||||
clearStartAutopilotParams();//清空参数数据,防止误传
|
||||
} else {
|
||||
UiThreadHandler.postDelayed(startAutopilotRunnable, TaxiConst.LOOP_PERIOD_15S);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发"无法开启自驾已知异常"埋点
|
||||
* @param startName
|
||||
* @param endName
|
||||
* @param orderNo
|
||||
*/
|
||||
public void triggerUnableStartAPReasonEvent(String startName, String endName, String orderNo,
|
||||
String reason) {
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
String plateNum = AppConfigInfo.INSTANCE.getPlateNumber();
|
||||
String dateTime = DateTimeUtils.getTimeText(
|
||||
System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss);
|
||||
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
|
||||
params.put(TaxiConst.EVENT_PARAM_SN, sn);
|
||||
params.put(TaxiConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum);
|
||||
params.put(TaxiConst.EVENT_PARAM_ENV_ONLINE,
|
||||
DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false);
|
||||
params.put(TaxiConst.EVENT_PARAM_TIME, dateTime);
|
||||
params.put(TaxiConst.EVENT_PARAM_START_NAME, startName);
|
||||
params.put(TaxiConst.EVENT_PARAM_END_NAME, endName);
|
||||
params.put(TaxiConst.EVENT_PARAM_ORDER_NUMBER, orderNo);
|
||||
params.put(TaxiConst.EVENT_PARAM_UNABLE_START_REASON, reason);
|
||||
MogoAnalyticUtils.INSTANCE.track(TaxiConst.EVENT_KEY_AP_UNABLE_START_REASON, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
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.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.util.DateTimeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.taxi.constant.TaxiConst
|
||||
|
||||
/**
|
||||
* OCH Taxi埋点工具
|
||||
*
|
||||
* Created on 2022/3/24
|
||||
*/
|
||||
object TaxiAnalyticsManager {
|
||||
|
||||
|
||||
private var mStartAutopilotKey: String? = null
|
||||
private val mStartAutopilotParams = HashMap<String, Any>()
|
||||
private val startAutopilotRunnable: Runnable = Runnable {
|
||||
// 15s内未开启,上报失败埋点
|
||||
triggerStartAutopilotFailureEvent("", "15s后app等待超时")
|
||||
}
|
||||
|
||||
fun triggerStartAutopilotFailureEventByAdas(failCode: String, failMsg: String) {
|
||||
removeWaitingCallback()
|
||||
triggerStartAutopilotFailureEvent(failCode, failMsg)
|
||||
}
|
||||
|
||||
private fun removeWaitingCallback() {
|
||||
if (startAutopilotRunnable != null) {
|
||||
UiThreadHandler.removeCallbacks(startAutopilotRunnable)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ① 15s超时调用
|
||||
* ② 底盘明确给出错误原因
|
||||
* 启动自驾失败写日志
|
||||
*/
|
||||
private fun triggerStartAutopilotFailureEvent(failCode: String, failMsg: String) {
|
||||
if (mStartAutopilotParams.isEmpty()) return
|
||||
e(SceneConstant.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)
|
||||
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(接管后点击'自动驾驶'按钮启动)
|
||||
* @param send 是否直接发送埋点(15s内开启成功则直接发送成功埋点)
|
||||
* true 点击自驾后15s内成功后回调
|
||||
* false 点击开始自驾
|
||||
*/
|
||||
fun triggerStartAutopilotEvent(
|
||||
restart: Boolean,
|
||||
send: Boolean,
|
||||
startName: String,
|
||||
endName: String,
|
||||
lineId: Long,
|
||||
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)
|
||||
clearStartAutopilotParams() //清空参数数据,防止误传
|
||||
} else {
|
||||
UiThreadHandler.postDelayed(startAutopilotRunnable, TaxiConst.LOOP_PERIOD_15S)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发"无法开启自驾已知异常"埋点
|
||||
* App启动
|
||||
* @param startName
|
||||
* @param endName
|
||||
* @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 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_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)
|
||||
}
|
||||
}
|
||||
@@ -449,4 +449,14 @@ public class DateTimeUtils {
|
||||
return strStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 06月07 格式的日期
|
||||
* @return
|
||||
*/
|
||||
public static String getTimeText(String dateFormat) {
|
||||
SimpleDateFormat format = new SimpleDateFormat(dateFormat, Locale.US);
|
||||
String strStart = format.format(new Date());
|
||||
return strStart;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user