浏览代码

1.添加直播页面信息上报阿里云日志

王鹏鹏 1 年之前
父节点
当前提交
d4dde33b64

+ 5 - 5
home/src/main/java/com/yingyangfly/home/activity/HomeActivity.kt

@@ -820,10 +820,6 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), Vie
                         if (TextUtils.isEmpty(description).not()) {
                             messageBean.description = description
                         }
-                        val messageInfo = GsonUtil.GsonString(messageBean)
-                        if (TextUtils.isEmpty(messageInfo).not()) {
-                            oneLog(messageInfo)
-                        }
                         when (messageBean.businessID) {
                             "A" -> {
                                 purchaseServices(messageBean)
@@ -859,6 +855,10 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), Vie
                                 showTaskDialog(messageBean)
                             }
                         }
+                        val messageInfo = GsonUtil.GsonString(messageBean)
+                        if (TextUtils.isEmpty(messageInfo).not()) {
+                            oneLog(messageInfo)
+                        }
                     }
                 }
             }
@@ -918,7 +918,7 @@ class HomeActivity : BaseMVVMActivity<ActivityHomeBinding, HomeViewModel>(), Vie
         runOnUiThread {
             val log = com.aliyun.sls.android.producer.Log()
             log.putContent(
-                "IM消息内容", messageInfo
+                "首页IM消息内容", messageInfo
             )
             log.putContent("患者id", User.getUserId())
             log.putContent("患者姓名", User.getName())

+ 50 - 8
livebroadcast/src/main/java/com/yingyang/livebroadcast/activity/detail/LiveBroadcastActivity.kt

@@ -32,6 +32,7 @@ import com.yingyangfly.baselib.router.RouterUrlCommon
 import com.yingyangfly.baselib.utils.GsonUtil
 import com.yingyangfly.baselib.utils.LiveEventBusUtil
 import com.yingyangfly.baselib.utils.RxBusCodes
+import com.yingyangfly.baselib.utils.User
 import java.util.*
 
 /**
@@ -97,6 +98,7 @@ class LiveBroadcastActivity :
             initTask()
         } else {
             "播放失败,请重试".toast()
+            reportLog("直播间播放器初始化失败,error code: $result")
         }
     }
 
@@ -107,21 +109,25 @@ class LiveBroadcastActivity :
                 V2TXLiveCode.V2TXLIVE_ERROR_REQUEST_TIMEOUT -> {
                     "直播间请求服务器超时".loge()
                     tipsDialog("请求服务器超时,请您退出直播间重试。")
+                    reportLog("直播间请求服务器超时")
                 }
 
                 V2TXLiveCode.V2TXLIVE_ERROR_DISCONNECTED -> {
                     "直播间连接断开".loge()
                     tipsDialog("直播连接断开,请您退出直播间重试。")
+                    reportLog("直播间连接断开")
                 }
 
                 V2TXLiveCode.V2TXLIVE_WARNING_NETWORK_BUSY -> {
                     "直播间网络状况不佳".loge()
                     "当前直播间网络状况不佳".toast()
+                    reportLog("直播间网络状况不佳")
                 }
 
                 V2TXLiveCode.V2TXLIVE_WARNING_VIDEO_BLOCK -> {
                     "直播间当前视频播放出现卡顿".loge()
                     "当前视频播放出现卡顿".toast()
+                    reportLog("直播间当前视频播放出现卡顿")
                 }
             }
         }
@@ -132,18 +138,21 @@ class LiveBroadcastActivity :
             super.onWarning(player, code, msg, extraInfo)
             when (code) {
                 V2TXLiveCode.V2TXLIVE_ERROR_REQUEST_TIMEOUT -> {
-                    "请求服务器超时".toast()
-                    "直播间请求服务器超时".loge()
+                    "当前直播间请求服务器超时".toast()
+                    "当前直播间请求服务器超时".loge()
+                    reportLog("当前直播间请求服务器超时")
                 }
 
                 V2TXLiveCode.V2TXLIVE_ERROR_DISCONNECTED -> {
-                    "连接断开".toast()
-                    "直播间连接断开".loge()
+                    "当前直播间连接断开".toast()
+                    "当前直播间连接断开".loge()
+                    reportLog("当前直播间连接断开")
                 }
 
                 V2TXLiveCode.V2TXLIVE_WARNING_NETWORK_BUSY -> {
                     "当前直播间网络状况不佳".toast()
-                    "直播间网络状况不佳".loge()
+                    "当前直播间网络状况不佳".loge()
+                    reportLog("当前直播间网络状况不佳")
                 }
             }
         }
@@ -207,8 +216,8 @@ class LiveBroadcastActivity :
      */
     private fun liveIncr() {
         viewModel.liveIncr(liveId, fail = {
-        }, success = {
-        })
+            reportLog("直播统计心跳上报失败,$it")
+        }, success = {})
     }
 
     /**
@@ -259,6 +268,7 @@ class LiveBroadcastActivity :
                                             endLive()
                                         }
                                     }
+                                    oneLog(GsonUtil.GsonString(messageBean))
                                 }
                             }
                         }
@@ -322,6 +332,7 @@ class LiveBroadcastActivity :
     override fun onResume() {
         super.onResume()
         LiveEventBusUtil.send(RxBusCodes.FINISHGAME, "")
+        reportLog("进入直播间")
     }
 
     override fun onDestroy() {
@@ -343,6 +354,7 @@ class LiveBroadcastActivity :
             messageDialog.show(
                 supportFragmentManager, "taskFragment"
             )
+            oneLog("直播结束")
         }
     }
 
@@ -363,7 +375,7 @@ class LiveBroadcastActivity :
     }
 
     /**
-     * 删除图片
+     * 确定取消弹窗
      */
     private fun tipsDialog(content: String) {
         runOnUiThread {
@@ -373,4 +385,34 @@ class LiveBroadcastActivity :
                 }, true).show(supportFragmentManager)
         }
     }
+
+    /**
+     * 阿里云日志上报
+     */
+    private fun oneLog(messageInfo: String) {
+        runOnUiThread {
+            val log = com.aliyun.sls.android.producer.Log()
+            log.putContent(
+                "直播间IM消息内容", messageInfo
+            )
+            log.putContent("患者id", User.getUserId())
+            log.putContent("患者姓名", User.getName())
+            sendLog(log)
+        }
+    }
+
+    /**
+     * 阿里云日志上报
+     */
+    private fun reportLog(msg: String) {
+        runOnUiThread {
+            val log = com.aliyun.sls.android.producer.Log()
+            log.putContent(
+                "直播间页面日志", msg
+            )
+            log.putContent("患者id", User.getUserId())
+            log.putContent("患者姓名", User.getName())
+            sendLog(log)
+        }
+    }
 }

+ 41 - 27
livebroadcast/src/main/java/com/yingyang/livebroadcast/activity/list/LiveBroadcastListActivity.kt

@@ -21,6 +21,7 @@ import com.yingyangfly.baselib.utils.GsonUtil
 import com.yingyangfly.baselib.utils.JumpUtil
 import com.yingyangfly.baselib.utils.LiveEventBusUtil
 import com.yingyangfly.baselib.utils.RxBusCodes
+import com.yingyangfly.baselib.utils.User
 
 /**
  * 直播列表
@@ -55,27 +56,25 @@ class LiveBroadcastListActivity :
             rvLiveBroadcast.layoutManager = gridLayoutManager
             rvLiveBroadcast.adapter = liveBroadcastAdapter
             liveBroadcastAdapter.setData(liveBroadcastList)
-            liveBroadcastAdapter.onLiveBroadcastImageClickListener =
-                { url, method, title, id ->
-                    when (method) {
-                        "预约直播" -> {
-                            appointmentLive(id)
-                        }
-                        "直播中" -> {
-                            initPermission(url, id, title)
-                        }
-                        "直播回放" -> {
-                            ARouter.getInstance().build(RouterUrlCommon.videoPlayer)
-                                .withString("url", url)
-                                .withString("title", title)
-                                .withTransition(
-                                    R.anim.leftin,
-                                    R.anim.leftout
-                                ).navigation(mContext)
-                        }
+            liveBroadcastAdapter.onLiveBroadcastImageClickListener = { url, method, title, id ->
+                when (method) {
+                    "预约直播" -> {
+                        appointmentLive(id)
                     }
 
+                    "直播中" -> {
+                        initPermission(url, id, title)
+                    }
+
+                    "直播回放" -> {
+                        ARouter.getInstance().build(RouterUrlCommon.videoPlayer)
+                            .withString("url", url).withString("title", title).withTransition(
+                                R.anim.leftin, R.anim.leftout
+                            ).navigation(mContext)
+                    }
                 }
+
+            }
             radioLive.setOnCheckedChangeListener { group, checkedId ->
                 liveBroadcastAdapter.clearData()
                 liveBroadcastAdapter.showEmptyView = false
@@ -85,11 +84,13 @@ class LiveBroadcastListActivity :
                         liveBroadcastAdapter.setType("预约直播")
                         loadData(isRefresh = true, showLoading = true)
                     }
+
                     R.id.rdb_live -> {
                         method = "2"
                         liveBroadcastAdapter.setType("直播中")
                         loadData(isRefresh = true, showLoading = true)
                     }
+
                     else -> {
                         method = "3"
                         liveBroadcastAdapter.setType("直播回放")
@@ -100,9 +101,7 @@ class LiveBroadcastListActivity :
         }
         liveBroadcastAdapter.jumpDetailsActivityClickListener = {
             JumpUtil.jumpActivityWithUrl(
-                RouterUrlCommon.liveDetails,
-                GsonUtil.GsonString(it),
-                mContext
+                RouterUrlCommon.liveDetails, GsonUtil.GsonString(it), mContext
             )
         }
     }
@@ -207,6 +206,7 @@ class LiveBroadcastListActivity :
     override fun onResume() {
         super.onResume()
         loadData(isRefresh = true, showLoading = true)
+        reportLog("进入直播列表")
     }
 
     /**
@@ -226,6 +226,7 @@ class LiveBroadcastListActivity :
                     v.startAnimation(getScaleAnimation())
                 }
             }
+
             MotionEvent.ACTION_UP -> {
                 v.startAnimation(getEndAnimation())
                 if (v.id == R.id.layoutHome) {
@@ -233,6 +234,7 @@ class LiveBroadcastListActivity :
                     finish()
                 }
             }
+
             MotionEvent.ACTION_CANCEL -> {
                 if (v.id == R.id.layoutHome) {
                     v.startAnimation(getEndAnimation())
@@ -246,11 +248,23 @@ class LiveBroadcastListActivity :
      * 跳转直播页面
      */
     private fun getUserSign(url: String, id: String, title: String) {
-        ARouter.getInstance().build(RouterUrlCommon.liveBroadcast)
-            .withString("url", url)
-            .withString("liveId", id)
-            .withString("title", title)
-            .withTransition(R.anim.leftin, R.anim.leftout)
-            .navigation(mContext)
+        ARouter.getInstance().build(RouterUrlCommon.liveBroadcast).withString("url", url)
+            .withString("liveId", id).withString("title", title)
+            .withTransition(R.anim.leftin, R.anim.leftout).navigation(mContext)
+    }
+
+    /**
+     * 阿里云日志上报
+     */
+    private fun reportLog(msg: String) {
+        runOnUiThread {
+            val log = com.aliyun.sls.android.producer.Log()
+            log.putContent(
+                "直播列表页面日志", msg
+            )
+            log.putContent("患者id", User.getUserId())
+            log.putContent("患者姓名", User.getName())
+            sendLog(log)
+        }
     }
 }