diff --git a/OCH/bus/driver/src/main/java/com/mogo/och/bus/constant/BusConst.kt b/OCH/bus/driver/src/main/java/com/mogo/och/bus/constant/BusConst.kt index 658e68a68b..a72a91e2d4 100644 --- a/OCH/bus/driver/src/main/java/com/mogo/och/bus/constant/BusConst.kt +++ b/OCH/bus/driver/src/main/java/com/mogo/och/bus/constant/BusConst.kt @@ -36,25 +36,6 @@ class BusConst { //终点UUID const val BUS_END_MAP_MAKER = "bus_end_map_maker"; - // 埋点key:接管后点击'自动驾驶'按钮启动 - const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_bus_restart_autopilot" - // 埋点key:开始服务开启自动驾驶(成功/失败) - const val EVENT_KEY_START_SERVICE = "event_key_och_bus_start_service" - const val EVENT_PARAM_SN = "sn" - const val EVENT_PARAM_TIME = "time" - const val EVENT_PARAM_START_NAME = "start_name" - const val EVENT_PARAM_END_NAME = "end_name" - const val EVENT_PARAM_LINE_ID = "line_id" - const val EVENT_PARAM_MAP_ORIGINAL_DATA = "map_original_data" // 域控原始状态信息 - const val EVENT_PARAM_AUTOPILOT_STATE = "autopilot_state" //原始的自动驾驶状态 - const val EVENT_PARAM_START_RESULT = "start_autopilot" // true/false - const val EVENT_PARAM_START_FAILURE_CODE = "start_autopilot_failure_code" // 启动自驾失败code - const val EVENT_PARAM_START_FAILURE_MSG = "start_autopilot_failure_msg" // 启动自驾失败原因 - const val EVENT_PARAM_PLATE_NUM = "plate_number" // 车牌号 - const val EVENT_PARAM_ENV_ONLINE = "env_online" // 是否线上环境:true/false - // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 - const val EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_bus_ap_unable_start_reason" - const val EVENT_PARAM_UNABLE_START_REASON = "unable_start_reason"; /** * 订单起终点Marker类型 diff --git a/OCH/bus/driver/src/main/java/com/mogo/och/bus/model/OrderModel.java b/OCH/bus/driver/src/main/java/com/mogo/och/bus/model/OrderModel.java index b22f648ebc..4d52da2627 100644 --- a/OCH/bus/driver/src/main/java/com/mogo/och/bus/model/OrderModel.java +++ b/OCH/bus/driver/src/main/java/com/mogo/och/bus/model/OrderModel.java @@ -25,6 +25,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.util.CoordinateUtils; +import com.mogo.eagle.core.utilcode.util.DateTimeUtils; import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils; import com.mogo.eagle.core.utilcode.util.GsonUtils; import com.mogo.eagle.core.utilcode.util.NetworkUtils; @@ -398,7 +399,7 @@ public class OrderModel { @Override public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) { - BusAnalyticsManager.INSTANCE.triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage); + BusAnalyticsManager.INSTANCE.triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage, System.currentTimeMillis()); if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode){ CallerLogger.e( M_BUS + TAG, "mAdasStartFailureListener = "+startFailedMessage ); mADASStatusCallback.onStartAdasFailure(); @@ -676,6 +677,7 @@ public class OrderModel { */ private void startAutopilot(boolean isRestart, int leaveIndex) { + BusAnalyticsManager.INSTANCE.triggerClickStartAutopilotTime(System.currentTimeMillis()); // 非自驾状态---->预写日志----> 启动自驾 ---> 自驾启动成功 ----> 上报日志 //  自驾状态---->启动自驾 ---> 自驾启动成功 @@ -1254,7 +1256,7 @@ public class OrderModel { BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); BusAnalyticsManager.INSTANCE.triggerStartAutopilotEvent(isRestart, send, - currentStation.getName(), nextStation.getName(), currentLineId); + currentStation.getName(), nextStation.getName(), currentLineId,"",System.currentTimeMillis()); } public void triggerUnableStartAPReasonEvent() { @@ -1264,7 +1266,7 @@ public class OrderModel { BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); BusAnalyticsManager.INSTANCE.triggerUnableStartAPReasonEvent( - currentStation.getName(), nextStation.getName(), currentLineId, + currentStation.getName(), nextStation.getName(), String.valueOf(currentLineId),"", OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason()); } diff --git a/OCH/bus/driver/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java b/OCH/bus/driver/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java index ec6c49c8bd..127ed24d0a 100644 --- a/OCH/bus/driver/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java +++ b/OCH/bus/driver/src/main/java/com/mogo/och/bus/presenter/BusPresenter.java @@ -13,6 +13,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; 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.bus.bean.WriteOffPassenger; import com.mogo.och.bus.callback.IBusADASStatusCallback; diff --git a/OCH/bus/driver/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.kt b/OCH/bus/driver/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.kt index 53b80232ab..b33e4d73d7 100644 --- a/OCH/bus/driver/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.kt +++ b/OCH/bus/driver/src/main/java/com/mogo/och/bus/util/BusAnalyticsManager.kt @@ -1,115 +1,37 @@ package com.mogo.och.bus.util -import android.text.TextUtils -import com.mogo.commons.debug.DebugConfig -import com.mogo.commons.storage.SharedPrefsMgr -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 -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant -import com.mogo.eagle.core.utilcode.util.DateTimeUtils -import com.mogo.och.bus.constant.BusConst -import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager -import com.mogo.och.common.module.utils.RxUtils -import io.reactivex.disposables.Disposable +import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics /** * OCH Bus埋点工具 * * Created on 2022/3/24 */ -object BusAnalyticsManager { +object BusAnalyticsManager: OchAutopilotAnalytics() { - private var mStartAutopilotKey: String? = null - private val mStartAutopilotParams = HashMap() + // 埋点key:接管后点击'自动驾驶'按钮启动 + private const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_bus_restart_autopilot" + // 埋点key:开始服务开启自动驾驶(成功/失败) + private const val EVENT_KEY_START_SERVICE = "event_key_och_bus_start_service" + // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 + private const val EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_bus_ap_unable_start_reason" + // 埋点key:点击启动自驾 + private const val EVENT_KEY_CLICK_START_AUTOPILOT = "event_key_och_bus_click_start_autopilot" - var startAutopiloTimeOut: Disposable? = null - fun triggerStartAutopilotFailureEventByAdas(failCode: String, failMsg: String) { - RxUtils.disposeSubscribe(startAutopiloTimeOut) - triggerStartAutopilotFailureEvent(failCode, failMsg) + override fun getEventKeyStartService(): String { + return EVENT_KEY_START_SERVICE } - private fun clearStartAutopilotParams() { - mStartAutopilotParams.clear() + override fun getEventKeyRestartService(): String { + return EVENT_KEY_RESTART_AUTOPILOT } - private fun triggerStartAutopilotFailureEvent(failCode: String, failMsg: String) { - if (mStartAutopilotParams.isEmpty()) return - CallerLogger.e(SceneConstant.M_BUS + "triggerStartAutopilotFailureEvent", failMsg) - if (CallerAutoPilotStatusListenerManager.getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { - mStartAutopilotParams[BusConst.EVENT_PARAM_START_FAILURE_CODE] = failCode - mStartAutopilotParams[BusConst.EVENT_PARAM_START_FAILURE_MSG] = failMsg - } - - mStartAutopilotParams[BusConst.EVENT_PARAM_MAP_ORIGINAL_DATA] = - OCHAdasAbilityManager.getInstance().originalData - mStartAutopilotParams[BusConst.EVENT_PARAM_AUTOPILOT_STATE] = - CallerAutoPilotStatusListenerManager.getState() - mStartAutopilotParams[BusConst.EVENT_PARAM_START_RESULT] = - CallerAutoPilotStatusListenerManager.getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - - MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams) - clearStartAutopilotParams() //清空参数数据,防止误传 + override fun getEventKeyApUnableStartReason(): String { + return EVENT_KEY_AP_UNABLE_START_REASON } - /** - * 触发'开启自动驾驶'埋点流程 - * 开启自动驾驶,15s内成功则发送成功埋点,否则发送失败埋点 - * @param restart false(点击'滑动出发'启动)/true(接管后点击'自动驾驶'按钮启动) - * @param send 是否直接发送埋点(15s内开启成功则直接发送成功埋点) - */ - fun triggerStartAutopilotEvent( - restart: Boolean, send: Boolean, startName: String, endName: String, lineId: Int - ) { - mStartAutopilotKey = if (restart) BusConst.EVENT_KEY_RESTART_AUTOPILOT else BusConst.EVENT_KEY_START_SERVICE - if (send) { - if (mStartAutopilotParams.isEmpty()) return - // 开启成功,上报埋点 - mStartAutopilotParams[BusConst.EVENT_PARAM_START_FAILURE_CODE] = "" - mStartAutopilotParams[BusConst.EVENT_PARAM_START_FAILURE_MSG] = "" - RxUtils.disposeSubscribe(startAutopiloTimeOut) - mStartAutopilotParams[BusConst.EVENT_PARAM_START_RESULT] = true - MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams) - clearStartAutopilotParams() //清空参数数据,防止误传 - } else { - val plateNum = AppConfigInfo.plateNumber - mStartAutopilotParams[BusConst.EVENT_PARAM_SN] = SharedPrefsMgr.getInstance().sn - mStartAutopilotParams[BusConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum - mStartAutopilotParams[BusConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE - mStartAutopilotParams[BusConst.EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) - mStartAutopilotParams[BusConst.EVENT_PARAM_START_NAME] = startName - mStartAutopilotParams[BusConst.EVENT_PARAM_END_NAME] = endName - mStartAutopilotParams[BusConst.EVENT_PARAM_LINE_ID] = lineId - startAutopiloTimeOut = RxUtils.createSubscribeOnOwnThread(BusConst.LOOP_PERIOD_15S) { - // 15s内未开启,上报失败埋点 - triggerStartAutopilotFailureEvent("", "15s后app等待超时") - } - } - } - - /** - * 触发"无法开启自驾已知异常"埋点 - * @param startName - * @param endName - * @param lineId - */ - fun triggerUnableStartAPReasonEvent( - startName: String, endName: String, lineId: Int, - reason: String - ) { - val plateNum = AppConfigInfo.plateNumber - val params = HashMap() - params[BusConst.EVENT_PARAM_SN] = SharedPrefsMgr.getInstance().sn - params[BusConst.EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum - params[BusConst.EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE - params[BusConst.EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) - params[BusConst.EVENT_PARAM_START_NAME] = startName - params[BusConst.EVENT_PARAM_END_NAME] = endName - params[BusConst.EVENT_PARAM_LINE_ID] = lineId - params[BusConst.EVENT_PARAM_UNABLE_START_REASON] = reason - MogoAnalyticUtils.track(BusConst.EVENT_KEY_AP_UNABLE_START_REASON, params) + override fun getEventKeyClickStartAutopilot(): String { + return EVENT_KEY_CLICK_START_AUTOPILOT } } \ No newline at end of file diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/constant/CharterConst.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/constant/CharterConst.kt index ea0f7f3ac4..8bd7d25eb6 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/constant/CharterConst.kt +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/constant/CharterConst.kt @@ -21,26 +21,6 @@ class CharterConst { // 尝试下发给MEC轨迹最多10次 const val LOOP_SEND_TRAJ_TIMES = 10 - // 埋点key:接管后点击'自动驾驶'按钮启动 - const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_charter_restart_autopilot" - // 埋点key:开始服务开启自动驾驶(成功/失败) - const val EVENT_KEY_START_SERVICE = "event_key_och_charter_start_service" - const val EVENT_PARAM_SN = "sn" - const val EVENT_PARAM_TIME = "time" - const val EVENT_PARAM_START_NAME = "start_name" - const val EVENT_PARAM_END_NAME = "end_name" - const val EVENT_PARAM_LINE_ID = "line_id" - const val EVENT_PARAM_MAP_ORIGINAL_DATA = "map_original_data" // 域控原始状态信息 - const val EVENT_PARAM_AUTOPILOT_STATE = "autopilot_state" //原始的自动驾驶状态 - const val EVENT_PARAM_START_RESULT = "start_autopilot" // true/false - const val EVENT_PARAM_START_FAILURE_CODE = "start_autopilot_failure_code" // 启动自驾失败code - const val EVENT_PARAM_START_FAILURE_MSG = "start_autopilot_failure_msg" // 启动自驾失败原因 - const val EVENT_PARAM_PLATE_NUM = "plate_number" // 车牌号 - const val EVENT_PARAM_ENV_ONLINE = "env_online" // 是否线上环境:true/false - // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 - const val EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_charter_ap_unable_start_reason" - const val EVENT_PARAM_UNABLE_START_REASON = "unable_start_reason" - /** * 订单起终点Marker类型 */ diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/manager/CharterAnalyticsManager.java b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/manager/CharterAnalyticsManager.java index 4a525b3dca..bb98e7d8b2 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/manager/CharterAnalyticsManager.java +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/manager/CharterAnalyticsManager.java @@ -1,28 +1,18 @@ package com.magic.mogo.och.charter.manager; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; +import androidx.annotation.NonNull; +import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics; -import android.text.TextUtils; +public class CharterAnalyticsManager extends OchAutopilotAnalytics { -import com.magic.mogo.och.charter.constant.CharterConst; -import com.mogo.commons.debug.DebugConfig; -import com.mogo.commons.storage.SharedPrefsMgr; -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; -import com.mogo.eagle.core.utilcode.util.DateTimeUtils; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager; - -import java.util.HashMap; - -/** - * @author: wangmingjun - * @date: 2023/3/1 - */ -public class CharterAnalyticsManager { + // 埋点key:接管后点击'自动驾驶'按钮启动 + private static final String EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_charter_restart_autopilot"; + // 埋点key:开始服务开启自动驾驶(成功/失败) + private static final String EVENT_KEY_START_SERVICE = "event_key_och_charter_start_service"; + // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 + private static final String EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_charter_ap_unable_start_reason"; + // 埋点key:点击启动自驾 + private static final String EVENT_KEY_CLICK_START_AUTOPILOT = "event_key_och_charter_click_start_autopilot"; private static final class SingletonHolder { private static final CharterAnalyticsManager INSTANCE = new CharterAnalyticsManager(); @@ -32,120 +22,28 @@ public class CharterAnalyticsManager { return CharterAnalyticsManager.SingletonHolder.INSTANCE; } - private String mStartAutopilotKey; - private HashMap mStartAutopilotParams = new HashMap<>(); - - private Runnable startAutopilotRunnable = () -> { - // 15s内未开启,上报失败埋点 - triggerStartAutopilotFailureEvent("", "15s后app等待超时"); - }; - - public void triggerStartAutopilotFailureEventByAdas(String failCode, String failMsg){ - removeWaitingCallback(); - triggerStartAutopilotFailureEvent(failCode, failMsg); + @NonNull + @Override + public String getEventKeyStartService() { + return EVENT_KEY_START_SERVICE; } - private void triggerStartAutopilotFailureEvent(String failCode, String failMsg){ - if (mStartAutopilotParams.isEmpty()) return; - - CallerLogger.e( M_BUS + "triggerStartAutopilotFailureEvent", failMsg ); - - if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() != - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){ - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_FAILURE_CODE, failCode); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_FAILURE_MSG, failMsg); - } - - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_MAP_ORIGINAL_DATA, - OCHAdasAbilityManager.getInstance().getOriginalData()); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_AUTOPILOT_STATE, - CallerAutoPilotStatusListenerManager.INSTANCE.getState()); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_RESULT - , CallerAutoPilotStatusListenerManager.INSTANCE.getState() == - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); - - MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); - - clearStartAutopilotParams();//清空参数数据,防止误传 + @NonNull + @Override + public String getEventKeyRestartService() { + return EVENT_KEY_RESTART_AUTOPILOT; } - private void removeWaitingCallback() { - if (startAutopilotRunnable != null) { - UiThreadHandler.removeCallbacks(startAutopilotRunnable); - } + @NonNull + @Override + public String getEventKeyApUnableStartReason() { + return EVENT_KEY_AP_UNABLE_START_REASON; } - public void clearStartAutopilotFailureMSG(){ - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_FAILURE_CODE, ""); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_FAILURE_MSG, ""); + @NonNull + @Override + public String getEventKeyClickStartAutopilot() { + return EVENT_KEY_CLICK_START_AUTOPILOT; } - private void clearStartAutopilotParams(){ - mStartAutopilotParams.clear(); - } - - /** - * 触发'开启自动驾驶'埋点流程 - * 开启自动驾驶,15s内成功则发送成功埋点,否则发送失败埋点 - * @param restart false(点击'滑动出发'启动)/true(接管后点击'自动驾驶'按钮启动) - * @param send 是否直接发送埋点(15s内开启成功则直接发送成功埋点) - */ - public void triggerStartAutopilotEvent( - boolean restart, boolean send, String startName, String endName, int lineId) { - mStartAutopilotKey = restart ? - CharterConst.EVENT_KEY_RESTART_AUTOPILOT : CharterConst.EVENT_KEY_START_SERVICE; - String sn = SharedPrefsMgr.getInstance().getSn(); - String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); - String dateTime = DateTimeUtils.getTimeText( - System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); - - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_SN, sn); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_ENV_ONLINE, - DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_TIME, dateTime); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_NAME, startName); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_END_NAME, endName); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_LINE_ID, lineId); - - if (send) { - if (mStartAutopilotParams.isEmpty()) return; - // 开启成功,上报埋点 - clearStartAutopilotFailureMSG(); - removeWaitingCallback(); - mStartAutopilotParams.put(CharterConst.EVENT_PARAM_START_RESULT, true); - MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); - - clearStartAutopilotParams();//清空参数数据,防止误传 - } else { - UiThreadHandler.postDelayed(startAutopilotRunnable, CharterConst.LOOP_PERIOD_15S); - } - } - - /** - * 触发"无法开启自驾已知异常"埋点 - * @param startName - * @param endName - * @param lineId - */ - public void triggerUnableStartAPReasonEvent(String startName, String endName, int lineId, - String reason) { - String sn = SharedPrefsMgr.getInstance().getSn(); - String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); - String dateTime = DateTimeUtils.getTimeText( - System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); - - HashMap params = new HashMap<>(); - - params.put(CharterConst.EVENT_PARAM_SN, sn); - params.put(CharterConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum); - params.put(CharterConst.EVENT_PARAM_ENV_ONLINE, - DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false); - params.put(CharterConst.EVENT_PARAM_TIME, dateTime); - params.put(CharterConst.EVENT_PARAM_START_NAME, startName); - params.put(CharterConst.EVENT_PARAM_END_NAME, endName); - params.put(CharterConst.EVENT_PARAM_LINE_ID, lineId); - params.put(CharterConst.EVENT_PARAM_UNABLE_START_REASON, reason); - MogoAnalyticUtils.INSTANCE.track(CharterConst.EVENT_KEY_AP_UNABLE_START_REASON, params); - } } diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/model/DriverM1Model.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/model/DriverM1Model.kt index b28bcf3789..0c15df4cd3 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/model/DriverM1Model.kt +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/model/DriverM1Model.kt @@ -333,7 +333,7 @@ class DriverM1Model { startFailedMessage: String ) { CharterAnalyticsManager.getInstance() - .triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage) + .triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage,System.currentTimeMillis()) if (mControllerStatusCallback != null) { d(SceneConstant.M_CHARTER_D + TAG, @@ -479,6 +479,9 @@ class DriverM1Model { * @param isRestart */ private fun startAutopilot() { + + CharterAnalyticsManager.getInstance().triggerClickStartAutopilotTime(System.currentTimeMillis()); + //判断轨迹Id是否可用 mCurrentRoute?.let { //根据开关和后台是否发布轨迹启动自驾 @@ -510,6 +513,7 @@ class DriverM1Model { } triggerStartServiceEvent(false, false) + val parameters = initAutopilotControlParameters() if (null == parameters) { d(SceneConstant.M_CHARTER_D + TAG, "行程日志-AutopilotControlParameters is empty.") @@ -550,10 +554,16 @@ class DriverM1Model { return } mCurrentOrder?.lineId?.let { - CharterAnalyticsManager.getInstance().triggerStartAutopilotEvent( - isRestart, send, - mCurrentOrder?.startSiteName, mCurrentOrder?.siteName, it - ) + val startSiteName = mCurrentOrder?.startSiteName + val endSiteName = mCurrentOrder?.siteName + val orderNo = mCurrentOrder?.orderNo + if(startSiteName!=null&&endSiteName!=null) { + + CharterAnalyticsManager.getInstance().triggerStartAutopilotEvent( + isRestart, send, + startSiteName, endSiteName, it, orderNo?:"", System.currentTimeMillis() + ) + } } } @@ -562,10 +572,14 @@ class DriverM1Model { return } mCurrentOrder?.lineId?.let { - CharterAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent( - mCurrentOrder?.startSiteName, mCurrentOrder?.siteName, it, - OCHAdasAbilityManager.getInstance().autopilotUnAbilityReason - ) + val startSiteName = mCurrentOrder?.startSiteName + val endSiteName = mCurrentOrder?.siteName + if (startSiteName != null && endSiteName != null) { + CharterAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent( + startSiteName, endSiteName, it.toString(),"", + OCHAdasAbilityManager.getInstance().autopilotUnAbilityReason + ) + } } } diff --git a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt index 26fd6be7c3..07cdb373c5 100644 --- a/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt +++ b/OCH/charter/driver/src/main/java/com/magic/mogo/och/charter/presenter/DriverM1Presenter.kt @@ -141,7 +141,7 @@ class DriverM1Presenter(view: DriverM1Fragment?) : // // } IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING ->{ - DriverM1Model.get().triggerStartServiceEvent(isRestart = false, send = true) + DriverM1Model.get().triggerStartServiceEvent(false,true) } // IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE ->{ // diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutopilotAnalytics.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutopilotAnalytics.kt new file mode 100644 index 0000000000..af7bc4030d --- /dev/null +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/manager/autopilot/autopilot/OchAutopilotAnalytics.kt @@ -0,0 +1,168 @@ +package com.mogo.och.common.module.manager.autopilot.autopilot + +import android.text.TextUtils +import com.mogo.commons.debug.DebugConfig +import com.mogo.commons.storage.SharedPrefsMgr +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 +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant +import com.mogo.eagle.core.utilcode.util.DateTimeUtils +import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager +import com.mogo.och.common.module.utils.RxUtils +import io.reactivex.disposables.Disposable + +abstract class OchAutopilotAnalytics { + + companion object{ + private const val EVENT_PARAM_AUTOPILOTANALYTICS_GROUP = "start_autopilot_group" + private const val EVENT_PARAM_SN = "sn" + private const val EVENT_PARAM_PLATE_NUM = "plate_number" // 车牌号 + private const val EVENT_PARAM_ENV_ONLINE = "env_online" // 是否线上环境:true/false + private const val EVENT_PARAM_TIME = "time" + private const val EVENT_PARAM_ACCURATE_TIME = "time_accurate" + private const val EVENT_PARAM_START_SUCCESS_TIME = "time_success" + private const val EVENT_PARAM_START_FAIL_TIME = "time_fail" + private const val EVENT_PARAM_CLICK_TIME = "time_click" + private const val EVENT_PARAM_START_NAME = "start_name" + private const val EVENT_PARAM_END_NAME = "end_name" + private const val EVENT_PARAM_LINE_ID = "line_id" + private const val EVENT_PARAM_ORDER_NUMBER = "order_num" + private const val EVENT_PARAM_UNABLE_START_REASON = "unable_start_reason" + private const val EVENT_PARAM_MAP_ORIGINAL_DATA = "map_original_data" // 域控原始状态信息 + private const val EVENT_PARAM_AUTOPILOT_STATE = "autopilot_state" //原始的自动驾驶状态 + private const val EVENT_PARAM_START_RESULT = "start_autopilot" // true/false + private const val EVENT_PARAM_START_FAILURE_CODE = "start_autopilot_failure_code" // 启动自驾失败code + private const val EVENT_PARAM_START_FAILURE_MSG = "start_autopilot_failure_msg" // 启动自驾失败原因 + } + + + private val LOOP_PERIOD_15S = 15 * 1000L + + + private var mStartAutopilotKey: String? = null + private val mStartAutopilotParams = HashMap() + + private var startAutopiloTimeOut: Disposable? = null + + fun triggerStartAutopilotFailureEventByAdas(failCode: String, failMsg: String, startFailDate: Long) { + RxUtils.disposeSubscribe(startAutopiloTimeOut) + triggerStartAutopilotFailureEvent(failCode, failMsg, startFailDate) + } + + private fun clearStartAutopilotParams() { + mStartAutopilotParams.clear() + } + + private fun triggerStartAutopilotFailureEvent(failCode: String, failMsg: String, startFailDate: Long) { + if (mStartAutopilotParams.isEmpty()) return + CallerLogger.e(SceneConstant.M_BUS + "triggerStartAutopilotFailureEvent", failMsg) + if (CallerAutoPilotStatusListenerManager.getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { + mStartAutopilotParams[EVENT_PARAM_START_FAILURE_CODE] = failCode + mStartAutopilotParams[EVENT_PARAM_START_FAILURE_MSG] = failMsg + } + + mStartAutopilotParams[EVENT_PARAM_MAP_ORIGINAL_DATA] = OCHAdasAbilityManager.getInstance().originalData + mStartAutopilotParams[EVENT_PARAM_AUTOPILOT_STATE] = CallerAutoPilotStatusListenerManager.getState() + mStartAutopilotParams[EVENT_PARAM_START_FAIL_TIME] = DateTimeUtils.getTimeText(startFailDate,DateTimeUtils.yyyy_MM_dd_HH_mm_ss_SSS) + mStartAutopilotParams[EVENT_PARAM_START_RESULT] = CallerAutoPilotStatusListenerManager.getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + mStartAutopilotParams[EVENT_PARAM_AUTOPILOTANALYTICS_GROUP] = EVENT_PARAM_AUTOPILOTANALYTICS_GROUP + MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams) + clearStartAutopilotParams() //清空参数数据,防止误传 + } + + /** + * 触发'开启自动驾驶'埋点流程 + * 开启自动驾驶,15s内成功则发送成功埋点,否则发送失败埋点 + * @param restart false(点击'滑动出发'启动)/true(接管后点击'自动驾驶'按钮启动) + * @param send 是否直接发送埋点(15s内开启成功则直接发送成功埋点) + */ + fun triggerStartAutopilotEvent( + restart: Boolean, + send: Boolean, + startName: String, + endName: String, + lineId: Int, + orderId:String?, + triggerDate: Long + ) { + mStartAutopilotKey = if (restart) getEventKeyRestartService() else getEventKeyStartService() + if (send) { + if (mStartAutopilotParams.isEmpty()) return + RxUtils.disposeSubscribe(startAutopiloTimeOut) + // 开启成功,上报埋点 + mStartAutopilotParams[EVENT_PARAM_START_FAILURE_CODE] = "" + mStartAutopilotParams[EVENT_PARAM_START_FAILURE_MSG] = "" + mStartAutopilotParams[EVENT_PARAM_START_RESULT] = true + // 自动驾驶状态变更时间 + mStartAutopilotParams[EVENT_PARAM_START_SUCCESS_TIME] = DateTimeUtils.getTimeText(triggerDate,DateTimeUtils.yyyy_MM_dd_HH_mm_ss_SSS) + mStartAutopilotParams[EVENT_PARAM_AUTOPILOTANALYTICS_GROUP] = EVENT_PARAM_AUTOPILOTANALYTICS_GROUP + MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams) + clearStartAutopilotParams() //清空参数数据,防止误传 + } else { + val plateNum = AppConfigInfo.plateNumber + mStartAutopilotParams[EVENT_PARAM_SN] = SharedPrefsMgr.getInstance().sn + mStartAutopilotParams[EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum + mStartAutopilotParams[EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE + mStartAutopilotParams[EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) + mStartAutopilotParams[EVENT_PARAM_ACCURATE_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss_SSS) + // 外部点击时间 + mStartAutopilotParams[EVENT_PARAM_CLICK_TIME] = DateTimeUtils.getTimeText(triggerDate,DateTimeUtils.yyyy_MM_dd_HH_mm_ss_SSS) + mStartAutopilotParams[EVENT_PARAM_START_NAME] = startName + mStartAutopilotParams[EVENT_PARAM_END_NAME] = endName + mStartAutopilotParams[EVENT_PARAM_LINE_ID] = lineId + mStartAutopilotParams[EVENT_PARAM_ORDER_NUMBER] = orderId?:"" + startAutopiloTimeOut = RxUtils.createSubscribeOnOwnThread(LOOP_PERIOD_15S) { + // 15s内未开启,上报失败埋点 + triggerStartAutopilotFailureEvent("", "15s后app等待超时", System.currentTimeMillis()) + } + } + } + + /** + * 触发"无法开启自驾已知异常"埋点 + * @param startName + * @param endName + * @param lineId + */ + fun triggerUnableStartAPReasonEvent( + startName: String, endName: String, lineId: String, orderNo:String ,reason: String + ) { + val plateNum = AppConfigInfo.plateNumber + val params = HashMap() + params[EVENT_PARAM_SN] = SharedPrefsMgr.getInstance().sn + params[EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum + params[EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE + params[EVENT_PARAM_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss) + params[EVENT_PARAM_ACCURATE_TIME] = DateTimeUtils.getTimeText(DateTimeUtils.yyyy_MM_dd_HH_mm_ss_SSS) + params[EVENT_PARAM_START_NAME] = startName + params[EVENT_PARAM_END_NAME] = endName + params[EVENT_PARAM_LINE_ID] = lineId + params[EVENT_PARAM_ORDER_NUMBER] = orderNo + params[EVENT_PARAM_UNABLE_START_REASON] = reason + params[EVENT_PARAM_AUTOPILOTANALYTICS_GROUP] = EVENT_PARAM_AUTOPILOTANALYTICS_GROUP + MogoAnalyticUtils.track(getEventKeyApUnableStartReason(), params) + } + + /** + * 用户点击启动自驾的时间 + */ + fun triggerClickStartAutopilotTime(triggerDate: Long) { + val plateNum = AppConfigInfo.plateNumber + val params = HashMap() + params[EVENT_PARAM_SN] = SharedPrefsMgr.getInstance().sn + params[EVENT_PARAM_PLATE_NUM] = if (TextUtils.isEmpty(plateNum)) "" else plateNum + params[EVENT_PARAM_ENV_ONLINE] = DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE + params[EVENT_PARAM_CLICK_TIME] = DateTimeUtils.getTimeText(triggerDate,DateTimeUtils.yyyy_MM_dd_HH_mm_ss_SSS) + params[EVENT_PARAM_AUTOPILOTANALYTICS_GROUP] = EVENT_PARAM_AUTOPILOTANALYTICS_GROUP + MogoAnalyticUtils.track(getEventKeyClickStartAutopilot(), params) + } + + abstract fun getEventKeyStartService(): String + abstract fun getEventKeyRestartService(): String + abstract fun getEventKeyApUnableStartReason(): String + abstract fun getEventKeyClickStartAutopilot(): String + +} \ No newline at end of file diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/constant/BusConst.kt b/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/constant/BusConst.kt index 0c68d7b5e0..10fb756a69 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/constant/BusConst.kt +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/constant/BusConst.kt @@ -38,25 +38,6 @@ class BusConst { //终点UUID const val BUS_END_MAP_MAKER = "bus_end_map_maker"; - // 埋点key:接管后点击'自动驾驶'按钮启动 - const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_bus_restart_autopilot" - // 埋点key:开始服务开启自动驾驶(成功/失败) - const val EVENT_KEY_START_SERVICE = "event_key_och_bus_start_service" - const val EVENT_PARAM_SN = "sn" - const val EVENT_PARAM_TIME = "time" - const val EVENT_PARAM_START_NAME = "start_name" - const val EVENT_PARAM_END_NAME = "end_name" - const val EVENT_PARAM_LINE_ID = "line_id" - const val EVENT_PARAM_MAP_ORIGINAL_DATA = "map_original_data" // 域控原始状态信息 - const val EVENT_PARAM_AUTOPILOT_STATE = "autopilot_state" //原始的自动驾驶状态 - const val EVENT_PARAM_START_RESULT = "start_autopilot" // true/false - const val EVENT_PARAM_START_FAILURE_CODE = "start_autopilot_failure_code" // 启动自驾失败code - const val EVENT_PARAM_START_FAILURE_MSG = "start_autopilot_failure_msg" // 启动自驾失败原因 - const val EVENT_PARAM_PLATE_NUM = "plate_number" // 车牌号 - const val EVENT_PARAM_ENV_ONLINE = "env_online" // 是否线上环境:true/false - // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 - const val EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_bus_ap_unable_start_reason" - const val EVENT_PARAM_UNABLE_START_REASON = "unable_start_reason"; /** * 订单起终点Marker类型 diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/model/OrderModel.java b/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/model/OrderModel.java index 301996838f..0e86c5e4a9 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/model/OrderModel.java +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/model/OrderModel.java @@ -21,6 +21,7 @@ import com.mogo.eagle.core.data.BaseData; import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters; import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.map.MogoLocation; +import com.mogo.eagle.core.utilcode.util.DateTimeUtils; import com.mogo.eagle.core.utilcode.util.StringUtils; import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager; import com.mogo.och.common.module.manager.distance.TrajectoryAndDistanceManager; @@ -289,7 +290,7 @@ public class OrderModel { @Override public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) { - BusAnalyticsManager.getInstance().triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage); + BusAnalyticsManager.getInstance().triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage,System.currentTimeMillis()); if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode){ CallerLogger.e( M_BUS + TAG, "mAdasStartFailureListener = "+startFailedMessage ); mADASStatusCallback.onStartAdasFailure(); @@ -626,6 +627,8 @@ public class OrderModel { * @param isRestart */ private void startAutopilot(boolean isRestart, int leaveIndex) { + BusAnalyticsManager.getInstance().triggerClickStartAutopilotTime(System.currentTimeMillis()); + //1、判断轨迹url是否可用 if(busRoutesResult!=null){ //根据开关和后台是否发布轨迹启动自驾 @@ -1196,7 +1199,7 @@ public class OrderModel { BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); BusAnalyticsManager.getInstance().triggerStartAutopilotEvent(isRestart, send, - currentStation.getName(), nextStation.getName(), busRoutesResult.getLineId()); + currentStation.getName(), nextStation.getName(), busRoutesResult.getLineId(),"",System.currentTimeMillis()); } public void triggerUnableStartAPReasonEvent() { @@ -1206,7 +1209,7 @@ public class OrderModel { BusStationBean currentStation = stationList.get(backgroundCurrentStationIndex); BusStationBean nextStation = stationList.get(backgroundCurrentStationIndex + 1); BusAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent( - currentStation.getName(), nextStation.getName(), busRoutesResult.getLineId(), + currentStation.getName(), nextStation.getName(), String.valueOf(busRoutesResult.getLineId()),"", OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason()); } diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/presenter/BusPresenter.java b/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/presenter/BusPresenter.java index 3189c4a116..5e055e533e 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/presenter/BusPresenter.java +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/presenter/BusPresenter.java @@ -15,6 +15,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; 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.common.module.biz.login.LoginStatusEnum; import com.mogo.och.common.module.manager.autopilot.autopilot.ArrivedStation; diff --git a/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/util/BusAnalyticsManager.java b/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/util/BusAnalyticsManager.java index b7a47fc233..5e85fa7ffa 100644 --- a/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/util/BusAnalyticsManager.java +++ b/OCH/shuttle/driver/src/main/java/com/mogo/och/shuttle/util/BusAnalyticsManager.java @@ -1,29 +1,25 @@ package com.mogo.och.shuttle.util; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BUS; -import android.text.TextUtils; +import androidx.annotation.NonNull; -import com.mogo.commons.debug.DebugConfig; -import com.mogo.commons.storage.SharedPrefsMgr; -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.shuttle.constant.BusConst; -import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager; - -import java.util.HashMap; +import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics; /** * OCH Bus埋点工具 - * + *

* Created on 2022/3/24 */ -public class BusAnalyticsManager { +public class BusAnalyticsManager extends OchAutopilotAnalytics { + + // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 + private static final String EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_bus_ap_unable_start_reason"; + // 埋点key:接管后点击'自动驾驶'按钮启动 + private static final String EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_bus_restart_autopilot"; + // 埋点key:开始服务开启自动驾驶(成功/失败) + private static final String EVENT_KEY_START_SERVICE = "event_key_och_bus_start_service"; + // 埋点key:点击启动自驾 + private static final String EVENT_KEY_CLICK_START_AUTOPILOT = "event_key_och_shuttle_click_start_autopilot"; private static final class SingletonHolder { private static final BusAnalyticsManager INSTANCE = new BusAnalyticsManager(); @@ -33,120 +29,28 @@ public class BusAnalyticsManager { return BusAnalyticsManager.SingletonHolder.INSTANCE; } - private String mStartAutopilotKey; - private HashMap mStartAutopilotParams = new HashMap<>(); - - private Runnable startAutopilotRunnable = () -> { - // 15s内未开启,上报失败埋点 - triggerStartAutopilotFailureEvent("", "15s后app等待超时"); - }; - - public void triggerStartAutopilotFailureEventByAdas(String failCode, String failMsg){ - removeWaitingCallback(); - triggerStartAutopilotFailureEvent(failCode, failMsg); + @NonNull + @Override + public String getEventKeyStartService() { + return EVENT_KEY_START_SERVICE; } - private void triggerStartAutopilotFailureEvent(String failCode, String failMsg){ - if (mStartAutopilotParams.isEmpty()) return; - - CallerLogger.e( M_BUS + "triggerStartAutopilotFailureEvent", failMsg ); - - if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() != - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){ - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_CODE, failCode); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_MSG, failMsg); - } - - mStartAutopilotParams.put(BusConst.EVENT_PARAM_MAP_ORIGINAL_DATA, - OCHAdasAbilityManager.getInstance().getOriginalData()); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_AUTOPILOT_STATE, - CallerAutoPilotStatusListenerManager.INSTANCE.getState()); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT - , CallerAutoPilotStatusListenerManager.INSTANCE.getState() == - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); - - MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); - - clearStartAutopilotParams();//清空参数数据,防止误传 + @NonNull + @Override + public String getEventKeyRestartService() { + return EVENT_KEY_RESTART_AUTOPILOT; } - private void removeWaitingCallback() { - if (startAutopilotRunnable != null) { - UiThreadHandler.removeCallbacks(startAutopilotRunnable); - } + @NonNull + @Override + public String getEventKeyApUnableStartReason() { + return EVENT_KEY_AP_UNABLE_START_REASON; } - public void clearStartAutopilotFailureMSG(){ - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_CODE, ""); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_FAILURE_MSG, ""); + @NonNull + @Override + public String getEventKeyClickStartAutopilot() { + return EVENT_KEY_CLICK_START_AUTOPILOT; } - private void clearStartAutopilotParams(){ - mStartAutopilotParams.clear(); - } - - /** - * 触发'开启自动驾驶'埋点流程 - * 开启自动驾驶,15s内成功则发送成功埋点,否则发送失败埋点 - * @param restart false(点击'滑动出发'启动)/true(接管后点击'自动驾驶'按钮启动) - * @param send 是否直接发送埋点(15s内开启成功则直接发送成功埋点) - */ - public void triggerStartAutopilotEvent( - boolean restart, boolean send, String startName, String endName, int lineId) { - mStartAutopilotKey = restart ? - BusConst.EVENT_KEY_RESTART_AUTOPILOT : BusConst.EVENT_KEY_START_SERVICE; - String sn = SharedPrefsMgr.getInstance().getSn(); - String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); - String dateTime = DateTimeUtils.getTimeText( - System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); - - mStartAutopilotParams.put(BusConst.EVENT_PARAM_SN, sn); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_ENV_ONLINE, - DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_TIME, dateTime); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_NAME, startName); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_END_NAME, endName); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_LINE_ID, lineId); - - if (send) { - if (mStartAutopilotParams.isEmpty()) return; - // 开启成功,上报埋点 - clearStartAutopilotFailureMSG(); - removeWaitingCallback(); - mStartAutopilotParams.put(BusConst.EVENT_PARAM_START_RESULT, true); - MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); - - clearStartAutopilotParams();//清空参数数据,防止误传 - } else { - UiThreadHandler.postDelayed(startAutopilotRunnable, BusConst.LOOP_PERIOD_15S); - } - } - - /** - * 触发"无法开启自驾已知异常"埋点 - * @param startName - * @param endName - * @param lineId - */ - public void triggerUnableStartAPReasonEvent(String startName, String endName, int lineId, - String reason) { - String sn = SharedPrefsMgr.getInstance().getSn(); - String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); - String dateTime = DateTimeUtils.getTimeText( - System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); - - HashMap params = new HashMap<>(); - - params.put(BusConst.EVENT_PARAM_SN, sn); - params.put(BusConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum); - params.put(BusConst.EVENT_PARAM_ENV_ONLINE, - DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false); - params.put(BusConst.EVENT_PARAM_TIME, dateTime); - params.put(BusConst.EVENT_PARAM_START_NAME, startName); - params.put(BusConst.EVENT_PARAM_END_NAME, endName); - params.put(BusConst.EVENT_PARAM_LINE_ID, lineId); - params.put(BusConst.EVENT_PARAM_UNABLE_START_REASON, reason); - MogoAnalyticUtils.INSTANCE.track(BusConst.EVENT_KEY_AP_UNABLE_START_REASON, params); - } } diff --git a/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/constant/TaxiConst.kt b/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/constant/TaxiConst.kt index 6640864139..4b748b74a3 100644 --- a/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/constant/TaxiConst.kt +++ b/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/constant/TaxiConst.kt @@ -16,8 +16,7 @@ class TaxiConst { // 上报心跳轮询ms const val LOOP_PERIOD_60S = 60 * 1000L - // 开始服务启动自动驾驶等待时间(埋点上传) - const val LOOP_PERIOD_15S = 15 * 1000L + // 轮询查询进行中/待服务订单的间隔时间 2秒 const val LOOP_PERIOD_2S = 2 * 1000L // 轮询查询新到预约单 1秒 @@ -41,27 +40,6 @@ class TaxiConst { const val DEMO_USER = "V" const val TEST_USER = "内测" - // 埋点key:接管后点击'自动驾驶'按钮启动 - const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_taxi_restart_autopilot" - // 埋点key:开始服务开启自动驾驶(成功/失败) - const val EVENT_KEY_START_SERVICE = "event_key_och_taxi_start_service" - const val EVENT_PARAM_SN = "sn" - const val EVENT_PARAM_TIME = "time" - const val EVENT_PARAM_START_NAME = "start_name" - const val EVENT_PARAM_END_NAME = "end_name" - const val EVENT_PARAM_LINE_ID = "line_id" - const val EVENT_PARAM_ORDER_NUMBER = "order_num" - const val EVENT_PARAM_MAP_ORIGINAL_DATA = "map_original_data" // 域控原始状态信息 - const val EVENT_PARAM_AUTOPILOT_STATE = "autopilot_state" //原始的自动驾驶状态 - const val EVENT_PARAM_START_RESULT = "start_autopilot" // true/false - const val EVENT_PARAM_START_FAILURE_CODE = "start_autopilot_failure_code" // 启动自驾失败code - const val EVENT_PARAM_START_FAILURE_MSG = "start_autopilot_failure_msg" // 启动自驾失败原因 - const val EVENT_PARAM_PLATE_NUM = "plate_number" // 车牌号 - const val EVENT_PARAM_ENV_ONLINE = "env_online" // 是否线上环境:true/false - // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 - const val EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_taxi_ap_unable_start_reason" - const val EVENT_PARAM_UNABLE_START_REASON = "unable_start_reason"; - // 实时计算当前剩余里程和时间 间隔 2秒 const val LOOP_CALCULATEROUTE_2S = 2 * 1000L diff --git a/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/model/TaxiModel.java b/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/model/TaxiModel.java index 78a130c6dc..a0a733feaa 100644 --- a/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/model/TaxiModel.java +++ b/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/model/TaxiModel.java @@ -34,6 +34,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListener import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.commons.storage.SharedPrefsMgr; import com.mogo.eagle.core.utilcode.util.CoordinateUtils; +import com.mogo.eagle.core.utilcode.util.DateTimeUtils; import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils; import com.mogo.eagle.core.utilcode.util.NetworkUtils; import com.mogo.eagle.core.utilcode.util.StringUtils; @@ -916,6 +917,9 @@ public class TaxiModel { ) public void startAutoPilot() { + TaxiAnalyticsManager.INSTANCE.triggerClickStartAutopilotTime(System.currentTimeMillis()); + + if (!checkCurrentOCHOrder()) { CallerLogger.e(M_TAXI + TAG, "no order or order is empty."); ToastUtils.showShort("当前订单不存在或异常!"); @@ -958,7 +962,8 @@ public class TaxiModel { ToastUtils.showLong(OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason() + ", 请稍候重试"); TaxiAnalyticsManager.INSTANCE.triggerUnableStartAPReasonEvent( - mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.orderNo, + mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, + String.valueOf(mCurrentOCHOrder.lineId),mCurrentOCHOrder.orderNo, OCHAdasAbilityManager.getInstance().getAutopilotUnAbilityReason()); return; } @@ -992,7 +997,9 @@ public class TaxiModel { + "isRestartAutopilot = " + isRestartAutopilot); TaxiAnalyticsManager.INSTANCE.triggerStartAutopilotEvent(isRestartAutopilot, false, - mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.lineId, mCurrentOCHOrder.orderNo); + mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, + (int) mCurrentOCHOrder.lineId, + mCurrentOCHOrder.orderNo,System.currentTimeMillis()); if (mControllerStatusCallback != null) { mControllerStatusCallback.startOpenAutopilot(); @@ -1085,7 +1092,7 @@ public class TaxiModel { @Override public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) { - TaxiAnalyticsManager.INSTANCE.triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage); + TaxiAnalyticsManager.INSTANCE.triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage,System.currentTimeMillis()); if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode) { CallerLogger.e(M_TAXI + TAG, "mAdasStartFailureListener = " + startFailedMessage); mADASStatusCallback.onStartAdasFailure(); @@ -1229,7 +1236,8 @@ public class TaxiModel { if (mCurrentOCHOrder != null && TaxiOrderStatusEnum.OnTheWayToEnd.getCode() == mCurrentOCHOrder.orderStatus) { TaxiAnalyticsManager.INSTANCE.triggerStartAutopilotEvent(isRestartAutopilot, true, - mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, mCurrentOCHOrder.lineId, mCurrentOCHOrder.orderNo); + mCurrentOCHOrder.startSiteAddr, mCurrentOCHOrder.endSiteAddr, + (int) mCurrentOCHOrder.lineId, mCurrentOCHOrder.orderNo,System.currentTimeMillis()); if (FunctionBuildConfig.isDemoMode) { // 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后,置true FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true; diff --git a/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/utils/TaxiAnalyticsManager.kt b/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/utils/TaxiAnalyticsManager.kt index cfb0a1c10b..eb3eff008b 100644 --- a/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/utils/TaxiAnalyticsManager.kt +++ b/OCH/taxi/driver/src/main/java/com/mogo/och/taxi/utils/TaxiAnalyticsManager.kt @@ -1,139 +1,40 @@ package com.mogo.och.taxi.utils -import android.text.TextUtils -import com.mogo.commons.debug.DebugConfig -import com.mogo.commons.storage.SharedPrefsMgr -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 -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_TAXI -import com.mogo.eagle.core.utilcode.util.DateTimeUtils -import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager -import com.mogo.och.common.module.utils.RxUtils -import com.mogo.och.taxi.constant.TaxiConst -import io.reactivex.disposables.Disposable +import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics /** * OCH Taxi埋点工具 * * Created on 2022/3/24 */ -object TaxiAnalyticsManager { +object TaxiAnalyticsManager : OchAutopilotAnalytics() { + + // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 + const val EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_taxi_ap_unable_start_reason" + + // 埋点key:接管后点击'自动驾驶'按钮启动 + const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_och_taxi_restart_autopilot" + + // 埋点key:开始服务开启自动驾驶(成功/失败) + const val EVENT_KEY_START_SERVICE = "event_key_och_taxi_start_service" + + // 埋点key:点击启动自驾 + private const val EVENT_KEY_CLICK_START_AUTOPILOT = "event_key_och_taxi_click_start_autopilot" - /** - * @see TaxiConst.EVENT_KEY_RESTART_AUTOPILOT - * @see TaxiConst.EVENT_KEY_START_SERVICE - */ - private var mStartAutopilotKey: String? = null - private val mStartAutopilotParams = HashMap() - - var startAutopiloTimeOut: Disposable? = null - - - fun triggerStartAutopilotFailureEventByAdas(failCode: String, failMsg: String) { - RxUtils.disposeSubscribe(startAutopiloTimeOut) - triggerStartAutopilotFailureEvent(failCode, failMsg) + override fun getEventKeyStartService(): String { + return EVENT_KEY_START_SERVICE } - private fun clearStartAutopilotParams() { - mStartAutopilotParams.clear() + override fun getEventKeyRestartService(): String { + return EVENT_KEY_RESTART_AUTOPILOT } - /** - * ① 15s超时调用 - * ② 底盘明确给出错误原因 - * 启动自驾失败写日志 - */ - private fun triggerStartAutopilotFailureEvent(failCode: String, failMsg: String) { - if (mStartAutopilotParams.isEmpty()) return - 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_MAP_ORIGINAL_DATA] = - OCHAdasAbilityManager.getInstance().originalData - mStartAutopilotParams[TaxiConst.EVENT_PARAM_AUTOPILOT_STATE] = - CallerAutoPilotStatusListenerManager.getState() - mStartAutopilotParams[TaxiConst.EVENT_PARAM_START_RESULT] = - CallerAutoPilotStatusListenerManager.getState() == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING - - MogoAnalyticUtils.track(mStartAutopilotKey, mStartAutopilotParams) - clearStartAutopilotParams() //清空参数数据,防止误传 + override fun getEventKeyApUnableStartReason(): String { + return EVENT_KEY_AP_UNABLE_START_REASON } - - /** - * - * ① 自检完成后 启动自驾 - * ② 自驾由其他状态转换到自驾中回调 - * 触发'开启自动驾驶'埋点流程 - * 开启自动驾驶,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 - -// CallerLogger.d(M_TAXI + "埋点==","restart = "+restart+", send= "+send); - if (send) { - if (mStartAutopilotParams.isEmpty()) return - // 开启成功,上报埋点 - 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 { - val plateNum = AppConfigInfo.plateNumber - mStartAutopilotParams[TaxiConst.EVENT_PARAM_SN] = SharedPrefsMgr.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等待超时") - } - } - } - - /** - * 触发"无法开启自驾已知异常"埋点 - * App启动 - * @param startName - * @param endName - * @param orderNo - */ - fun triggerUnableStartAPReasonEvent(startName: String, endName: String, orderNo: String, reason: String) { - val plateNum = AppConfigInfo.plateNumber - val params = HashMap() - params[TaxiConst.EVENT_PARAM_SN] = SharedPrefsMgr.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] = 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 - MogoAnalyticUtils.track(TaxiConst.EVENT_KEY_AP_UNABLE_START_REASON, params) + override fun getEventKeyClickStartAutopilot(): String { + return EVENT_KEY_CLICK_START_AUTOPILOT } } \ No newline at end of file diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/constant/TaxiUnmannedConst.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/constant/TaxiUnmannedConst.kt index 48d36f3046..0359e52cad 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/constant/TaxiUnmannedConst.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/constant/TaxiUnmannedConst.kt @@ -52,29 +52,6 @@ class TaxiUnmannedConst { const val DEMO_USER = "V" const val TEST_USER = "内测" - // 埋点key:接管后点击'自动驾驶'按钮启动 - const val EVENT_KEY_RESTART_AUTOPILOT = "event_key_unmanned_taxi_restart_autopilot" - - // 埋点key:开始服务开启自动驾驶(成功/失败) - const val EVENT_KEY_START_SERVICE = "event_key_unmanned_taxi_start_service" - const val EVENT_PARAM_SN = "sn" - const val EVENT_PARAM_TIME = "time" - const val EVENT_PARAM_START_NAME = "start_name" - const val EVENT_PARAM_END_NAME = "end_name" - const val EVENT_PARAM_LINE_ID = "line_id" - const val EVENT_PARAM_ORDER_NUMBER = "order_num" - const val EVENT_PARAM_MAP_ORIGINAL_DATA = "map_original_data" // 域控原始状态信息 - const val EVENT_PARAM_AUTOPILOT_STATE = "autopilot_state" //原始的自动驾驶状态 - const val EVENT_PARAM_START_RESULT = "start_autopilot" // true/false - const val EVENT_PARAM_START_FAILURE_CODE = "start_autopilot_failure_code" // 启动自驾失败code - const val EVENT_PARAM_START_FAILURE_MSG = "start_autopilot_failure_msg" // 启动自驾失败原因 - const val EVENT_PARAM_PLATE_NUM = "plate_number" // 车牌号 - const val EVENT_PARAM_ENV_ONLINE = "env_online" // 是否线上环境:true/false - - // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 - const val EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_taxi_ap_unable_start_reason" - const val EVENT_PARAM_UNABLE_START_REASON = "unable_start_reason"; - // 实时计算当前剩余里程和时间 间隔 2秒 const val LOOP_CALCULATEROUTE_2S = 2 * 1000L diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt index 0dc86aa9f7..c732001b8f 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt @@ -33,6 +33,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.eagle.core.utilcode.util.CoordinateUtils +import com.mogo.eagle.core.utilcode.util.DateTimeUtils import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils import com.mogo.eagle.core.utilcode.util.NetworkUtils import com.mogo.eagle.core.utilcode.util.StringUtils @@ -301,8 +302,9 @@ object TaxiTaskModel { true, mCurrentTaskWithOrder!!.order!!.orderStartSite!!.siteName, mCurrentTaskWithOrder!!.order!!.orderEndSite!!.siteName, - mCurrentTaskWithOrder!!.lineId, - mCurrentTaskWithOrder!!.order!!.orderNo + mCurrentTaskWithOrder!!.lineId.toInt(), + mCurrentTaskWithOrder!!.order!!.orderNo, + System.currentTimeMillis() ) setBeautificationMode(true) } @@ -474,8 +476,7 @@ object TaxiTaskModel { startFailedMessage: String ) { DebugView.printErrorMsg("[启自驾] 执行失败,code=$startFailedCode, msg=$startFailedMessage") - TaxiAnalyticsManager.getInstance() - .triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage) + TaxiAnalyticsManager.getInstance().triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage,System.currentTimeMillis()) if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode) { e( TAG, @@ -1206,6 +1207,9 @@ object TaxiTaskModel { } fun startAutoPilot() { + + TaxiAnalyticsManager.getInstance().triggerClickStartAutopilotTime(System.currentTimeMillis()); + DebugView.printInfoMsg("[启自驾] startAutoPilot") if (!checkCurrentTaskCondition()) { e(TAG, "no order or order is empty.") @@ -1260,10 +1264,12 @@ object TaxiTaskModel { ", 请稍候重试" ) DebugView.printErrorMsg("[启自驾] ${OCHAdasAbilityManager.getInstance().autopilotUnAbilityReason}") + val orderNo = mCurrentTaskWithOrder?.order?.orderNo TaxiAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent( mCurrentTaskWithOrder!!.startSite!!.siteName, mCurrentTaskWithOrder!!.endSite!!.siteName, mCurrentTaskWithOrder!!.lineId.toString(), // todo 这里原来传的是订单号, 现在是任务没有订单号,传了路线id + orderNo?:"", OCHAdasAbilityManager.getInstance().autopilotUnAbilityReason ) return @@ -1292,8 +1298,9 @@ object TaxiTaskModel { false, mCurrentTaskWithOrder!!.startSite!!.siteName, mCurrentTaskWithOrder!!.endSite!!.siteName, - mCurrentTaskWithOrder!!.lineId, - if (mCurrentTaskWithOrder!!.order != null) mCurrentTaskWithOrder!!.order!!.orderNo else "" + mCurrentTaskWithOrder!!.lineId.toInt(), + if (mCurrentTaskWithOrder!!.order != null) mCurrentTaskWithOrder!!.order!!.orderNo else "", + System.currentTimeMillis() ) mControllerStatusCallback?.startOpenAutopilot() } diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/utils/TaxiAnalyticsManager.java b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/utils/TaxiAnalyticsManager.java index a893501332..ae3f585f36 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/utils/TaxiAnalyticsManager.java +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/utils/TaxiAnalyticsManager.java @@ -1,28 +1,24 @@ package com.mogo.och.unmanned.taxi.utils; -import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI; -import android.text.TextUtils; +import androidx.annotation.NonNull; -import com.mogo.commons.debug.DebugConfig; -import com.mogo.commons.storage.SharedPrefsMgr; -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.common.module.manager.autopilot.OCHAdasAbilityManager; -import com.mogo.och.unmanned.taxi.constant.TaxiUnmannedConst; - -import java.util.HashMap; +import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics; /** * OCH Taxi埋点工具 - * + *

* Created on 2022/3/24 */ -public class TaxiAnalyticsManager { +public class TaxiAnalyticsManager extends OchAutopilotAnalytics { + + // 埋点key:开启自动驾驶前已识别的异常,会导致无法开启自驾 + private static final String EVENT_KEY_AP_UNABLE_START_REASON = "event_key_och_taxi_ap_unable_start_reason"; + // 埋点key:点击启动自驾 + private static final String EVENT_KEY_CLICK_START_AUTOPILOT = "event_key_och_shuttle_click_start_autopilot"; + // 埋点key:接管后点击'自动驾驶'按钮启动 + private static final String EVENT_KEY_RESTART_AUTOPILOT = "event_key_unmanned_taxi_restart_autopilot"; + // 埋点key:开始服务开启自动驾驶(成功/失败) + private static final String EVENT_KEY_START_SERVICE = "event_key_unmanned_taxi_start_service"; private static final class SingletonHolder { private static final TaxiAnalyticsManager INSTANCE = new TaxiAnalyticsManager(); @@ -32,123 +28,29 @@ public class TaxiAnalyticsManager { return SingletonHolder.INSTANCE; } - - - private String mStartAutopilotKey; - private HashMap mStartAutopilotParams = new HashMap<>(); - - private Runnable startAutopilotRunnable = () -> { - // 15s内未开启,上报失败埋点 - triggerStartAutopilotFailureEvent("", "15s后app等待超时"); - }; - - public void triggerStartAutopilotFailureEventByAdas(String failCode, String failMsg){ - removeWaitingCallback(); - triggerStartAutopilotFailureEvent(failCode, failMsg); + @NonNull + @Override + public String getEventKeyStartService() { + return EVENT_KEY_START_SERVICE; } - private void removeWaitingCallback() { - if (startAutopilotRunnable != null) { - UiThreadHandler.removeCallbacks(startAutopilotRunnable); - } + @NonNull + @Override + public String getEventKeyRestartService() { + return EVENT_KEY_RESTART_AUTOPILOT; } - private void triggerStartAutopilotFailureEvent(String failCode, String failMsg){ - if (mStartAutopilotParams.isEmpty()) return; - - CallerLogger.e(M_TAXI + "triggerStartAutopilotFailureEvent", failMsg); - if (CallerAutoPilotStatusListenerManager.INSTANCE.getState() != - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){ - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_START_FAILURE_CODE, failCode); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_START_FAILURE_MSG, - failMsg); - } - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_MAP_ORIGINAL_DATA, - OCHAdasAbilityManager.getInstance().getOriginalData()); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_AUTOPILOT_STATE, - CallerAutoPilotStatusListenerManager.INSTANCE.getState()); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_START_RESULT, - CallerAutoPilotStatusListenerManager.INSTANCE.getState() == - IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING); - MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); - - clearStartAutopilotParams();//清空参数数据,防止误传 + @NonNull + @Override + public String getEventKeyApUnableStartReason() { + return EVENT_KEY_AP_UNABLE_START_REASON; } - private void clearStartAutopilotParams(){ - mStartAutopilotParams.clear(); + @NonNull + @Override + public String getEventKeyClickStartAutopilot() { + return EVENT_KEY_CLICK_START_AUTOPILOT; } - public void clearStartAutopilotFailureMSG(){ - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_START_FAILURE_CODE, ""); - mStartAutopilotParams.put(TaxiUnmannedConst.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 ? - TaxiUnmannedConst.EVENT_KEY_RESTART_AUTOPILOT : TaxiUnmannedConst.EVENT_KEY_START_SERVICE; - String sn = SharedPrefsMgr.getInstance().getSn(); - String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); - String dateTime = DateTimeUtils.getTimeText( - System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); - - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_SN, sn); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_ENV_ONLINE, - DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_TIME, dateTime); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_START_NAME, startName); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_END_NAME, endName); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_LINE_ID, lineId); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_ORDER_NUMBER, orderNo); - -// CallerLogger.d(M_TAXI + "埋点==","restart = "+restart+", send= "+send); - - if (send) { - if (mStartAutopilotParams.isEmpty()) return; - // 开启成功,上报埋点 - clearStartAutopilotFailureMSG(); - removeWaitingCallback(); - mStartAutopilotParams.put(TaxiUnmannedConst.EVENT_PARAM_START_RESULT, true); - MogoAnalyticUtils.INSTANCE.track(mStartAutopilotKey, mStartAutopilotParams); - - clearStartAutopilotParams();//清空参数数据,防止误传 - } else { - UiThreadHandler.postDelayed(startAutopilotRunnable, TaxiUnmannedConst.LOOP_PERIOD_15S); - } - } - - /** - * 触发"无法开启自驾已知异常"埋点 - * @param startName - * @param endName - * @param orderNo - */ - public void triggerUnableStartAPReasonEvent(String startName, String endName, String orderNo, - String reason) { - String sn = SharedPrefsMgr.getInstance().getSn(); - String plateNum = AppConfigInfo.INSTANCE.getPlateNumber(); - String dateTime = DateTimeUtils.getTimeText( - System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); - - HashMap params = new HashMap<>(); - - params.put(TaxiUnmannedConst.EVENT_PARAM_SN, sn); - params.put(TaxiUnmannedConst.EVENT_PARAM_PLATE_NUM, TextUtils.isEmpty(plateNum) ? "" : plateNum); - params.put(TaxiUnmannedConst.EVENT_PARAM_ENV_ONLINE, - DebugConfig.getNetMode() == DebugConfig.NET_MODE_RELEASE ? true : false); - params.put(TaxiUnmannedConst.EVENT_PARAM_TIME, dateTime); - params.put(TaxiUnmannedConst.EVENT_PARAM_START_NAME, startName); - params.put(TaxiUnmannedConst.EVENT_PARAM_END_NAME, endName); - params.put(TaxiUnmannedConst.EVENT_PARAM_ORDER_NUMBER, orderNo); - params.put(TaxiUnmannedConst.EVENT_PARAM_UNABLE_START_REASON, reason); - MogoAnalyticUtils.INSTANCE.track(TaxiUnmannedConst.EVENT_KEY_AP_UNABLE_START_REASON, params); - } } diff --git a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/DateTimeUtils.java b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/DateTimeUtils.java index 9c2f240976..d430f373a6 100644 --- a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/DateTimeUtils.java +++ b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/DateTimeUtils.java @@ -30,6 +30,7 @@ public class DateTimeUtils { public static final String yyyy_MM_dd = "yyyy-MM-dd"; public static final String yyyy_MM = "yyyy-MM"; public static final String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss"; + public static final String yyyy_MM_dd_HH_mm_ss_SSS = "yyyy-MM-dd HH:mm:ss:SSS"; public static final String yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm"; public static final String yyyyMMddHHmmss = "yyyyMMddHHmmss"; public static final String HH_mm = "HH:mm";