diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/OchBusConst.kt b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/OchBusConst.kt index a85ea7ae3f..ceb9969047 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/OchBusConst.kt +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/constant/OchBusConst.kt @@ -38,6 +38,8 @@ class OchBusConst { // 上报心跳轮询ms const val LOOP_PERIOD_60S = 60 * 1000L + // 开始服务启动自动驾驶等待时间(埋点上传) + const val LOOP_PERIOD_15S = 15 * 1000L const val LOOP_PERIOD_1S = 1 * 1000L const val LOOP_DELAY = 100L @@ -45,5 +47,14 @@ class OchBusConst { const val BUS_START_MAP_MAKER = "bus_start_map_maker"; //终点UUID const val BUS_END_MAP_MAKER = "bus_end_map_maker"; + + // 埋点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_START_RESULT = "start_autopilot" // true/false } } \ No newline at end of file diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusOrderModel.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusOrderModel.java index 556b70ce1a..ea97ad4f27 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusOrderModel.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusOrderModel.java @@ -39,6 +39,7 @@ import com.mogo.och.bus.callback.SlidePannelHideCallback; import com.mogo.och.bus.constant.OchBusConst; import com.mogo.och.bus.net.OCHBusServiceManager; import com.mogo.och.bus.net.OCHServiceCallback; +import com.mogo.och.bus.util.OchBusAnalyticsUtil; import com.mogo.och.bus.util.PinYinUtil; import com.mogo.service.IMogoServiceApis; import com.mogo.service.statusmanager.IMogoStatusChangedListener; @@ -445,6 +446,9 @@ public class OchBusOrderModel { CallerLogger.INSTANCE.d( M_BUS + TAG, "开启自动驾驶====" + currentAutopilot.toString() +" startLatLon="+currentStation.getName()+",endLatLon="+nextStation.getName()); CallerAutoPilotManager.INSTANCE.startAutoPilot(currentAutopilot); + + triggerStartServiceEvent(false); + if (mControllerStatusCallback != null) { mControllerStatusCallback.startOpenAutopilot(); } @@ -841,4 +845,14 @@ public class OchBusOrderModel { OchBusModelLoopManager.getInstance().stopHeartbeatLoop(); } } + + public void triggerStartServiceEvent(boolean send) { + if (stationList == null || currentStationIndex >= stationList.size()) { + return; + } + OchBusStation currentStation = stationList.get( currentStationIndex -1); + OchBusStation nextStation = stationList.get( currentStationIndex); + OchBusAnalyticsUtil.triggerStartServiceEvent(send, + currentStation.getName(), nextStation.getName(), currentLineId); + } } diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java index 00664fb7d5..3a01e43818 100644 --- a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java @@ -194,6 +194,7 @@ public class OchBusPresenter extends Presenter currentAutopilotStatus = IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING; // 改变UI自动驾驶状态 mView.onAutopilotStatusChanged(currentAutopilotStatus, isAnimateRunning); + OchBusOrderModel.getInstance().triggerStartServiceEvent(true); } isAnimateRunning = false; break; diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/OchBusAnalyticsUtil.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/OchBusAnalyticsUtil.java new file mode 100644 index 0000000000..a2b88c8f2c --- /dev/null +++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/util/OchBusAnalyticsUtil.java @@ -0,0 +1,55 @@ +package com.mogo.och.bus.util; + +import com.mogo.cloud.passport.MoGoAiCloudClientConfig; +import com.mogo.eagle.core.function.call.analytics.AnalyticsManager; +import com.mogo.eagle.core.utilcode.util.DateTimeUtils; +import com.mogo.eagle.core.utilcode.util.UiThreadHandler; +import com.mogo.och.bus.constant.OchBusConst; + +import java.util.HashMap; +import java.util.Map; + +/** + * OCH Bus埋点工具 + * + * Created on 2022/3/24 + */ +public class OchBusAnalyticsUtil { + + /** + * 触发'滑动出发'埋点流程: + * 滑动出发(开启自动驾驶)后,15s内成功则发送成功埋点,否则发送失败埋点 + * @param send 是否直接发送埋点(15s内开启成功则直接发送成功埋点) + */ + public static void triggerStartServiceEvent( + boolean send, String startName, String endName, int lineId) { + + String sn = MoGoAiCloudClientConfig.getInstance().getSn(); + String dateTime = DateTimeUtils.getTimeText( + System.currentTimeMillis(), DateTimeUtils.yyyy_MM_dd_HH_mm_ss); + + Map params = new HashMap<>(); + params.put(OchBusConst.EVENT_PARAM_SN, sn); + params.put(OchBusConst.EVENT_PARAM_TIME, dateTime); + params.put(OchBusConst.EVENT_PARAM_START_NAME, startName); + params.put(OchBusConst.EVENT_PARAM_END_NAME, endName); + params.put(OchBusConst.EVENT_PARAM_LINE_ID, lineId); + + Runnable runnable = () -> { + // 15s内未开启,上报失败埋点 + params.put(OchBusConst.EVENT_PARAM_START_RESULT, false); + AnalyticsManager.INSTANCE.track(OchBusConst.EVENT_KEY_START_SERVICE, params); + }; + + if (send) { + // 开启成功,上报埋点 + if (runnable != null && UiThreadHandler.getsUiHandler().hasCallbacks(runnable)) { + UiThreadHandler.removeCallbacks(runnable); + } + params.put(OchBusConst.EVENT_PARAM_START_RESULT, true); + AnalyticsManager.INSTANCE.track(OchBusConst.EVENT_KEY_START_SERVICE, params); + } else { + UiThreadHandler.postDelayed(runnable, OchBusConst.LOOP_PERIOD_15S); + } + } +}