[启动自驾流程埋点修改]
This commit is contained in:
yangyakun
2024-05-29 17:34:41 +08:00
parent 2dcd4958d2
commit ffd5aee781
20 changed files with 357 additions and 728 deletions

View File

@@ -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类型

View File

@@ -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());
}

View File

@@ -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;

View File

@@ -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埋点工具
*
* <p>
* 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<String, Object> 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<String, Object> 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);
}
}