diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/debug/DebugView.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/debug/DebugView.kt index ba02fa0954..527fc424a5 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/debug/DebugView.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/taxi/ui/debug/DebugView.kt @@ -13,7 +13,10 @@ import android.view.LayoutInflater import android.view.View import android.widget.LinearLayout import android.widget.TextView +import androidx.lifecycle.ProcessLifecycleOwner +import androidx.lifecycle.lifecycleScope import androidx.localbroadcastmanager.content.LocalBroadcastManager +import com.mogo.commons.utils.MogoAnalyticUtils import com.mogo.eagle.core.function.main.MainMoGoApplication import com.mogo.eagle.core.network.utils.GsonUtil import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d @@ -43,6 +46,8 @@ import kotlinx.android.synthetic.main.taxi_debug_order.view.orderStartSiteInfo import kotlinx.android.synthetic.main.taxi_debug_order.view.orderStatus import kotlinx.android.synthetic.main.taxi_debug_order.view.taskEndSite import kotlinx.android.synthetic.main.taxi_debug_order.view.taskStartSite +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch public class DebugView @JvmOverloads constructor( @@ -50,20 +55,25 @@ public class DebugView @JvmOverloads constructor( ) : LinearLayout(context, attrs, defStyleAttr, defStyleRes), ITaxiTaskWithOrderCallback { companion object { const val TAG = "DebugView" + private const val ANALYTICS_EVENT_TYPE_DRIVER_UNMANNED_OPERATION_PROCESS_KEY_NODE_LOG = + "och.driver.unmanned.operation.process.key.node.log" const val BROADCAST_ACTION = "com.mogo.och.driver.debugview.show" const val BROADCAST_DATA_SHOW = "isShow" private var logHistoryTextView: TextView? = null fun printInfoMsg(msg: String) { printMsg("Info $msg", MainMoGoApplication.getApp().getColor(R.color.background_info)) + trackEvent("Info", msg) } fun printWarnMsg(msg: String) { printMsg("Warn $msg", MainMoGoApplication.getApp().getColor(R.color.background_warn)) + trackEvent("Warn", msg) } fun printErrorMsg(msg: String) { printMsg("Error $msg", MainMoGoApplication.getApp().getColor(R.color.background_error)) + trackEvent("Error", msg) } private fun printMsg(msg: String, textColor: Int) { @@ -86,6 +96,18 @@ public class DebugView @JvmOverloads constructor( } } + /** + * 上报埋点 + */ + private fun trackEvent(level: String, msg: String) { + ProcessLifecycleOwner.get().lifecycleScope.launch(Dispatchers.IO) { + val map: MutableMap = HashMap() + map["level"] = level + map["msg"] = msg + MogoAnalyticUtils.track(ANALYTICS_EVENT_TYPE_DRIVER_UNMANNED_OPERATION_PROCESS_KEY_NODE_LOG, map) + } + } + private fun currentDateTimeString(): String { return DateTimeUtil.formatCalendarToString( DateTimeUtil.formatLongToCalendar(System.currentTimeMillis()),