Parcourir la source

1.修改埋点上报

wenweiwei il y a 3 ans
Parent
commit
8f6aa74d2d

+ 75 - 77
BFFramework/Classes/BFModules/BFUtility/PQSingletoVideoPlayer.swift

@@ -7,8 +7,8 @@
 //  Copyright © 2020 BytesFlow. All rights reserved.
 //
 
-import UIKit
 import BFCommonKit
+import UIKit
 
 public class PQSingletoVideoPlayer: NSObject {
     public static let shared = PQSingletoVideoPlayer()
@@ -31,8 +31,9 @@ public class PQSingletoVideoPlayer: NSObject {
     public var isPlaying: Bool {
         return player.isPlaying()
     }
-    public var autoResumePlayWhenEnterForeground:Bool = true
-    var shouldResumePlayWhenEnterForeground:Bool = false
+
+    public var autoResumePlayWhenEnterForeground: Bool = true
+    var shouldResumePlayWhenEnterForeground: Bool = false
 
     public lazy var player: TXVodPlayer = {
         let player = TXVodPlayer()
@@ -49,7 +50,7 @@ public class PQSingletoVideoPlayer: NSObject {
     /// - Parameters:
     ///   - videoData: <#videoData description#>
     ///   - controllerView: <#controllerView description#>
-    public func configPlyer(videoData: BFVideoItemProtocol, controllerView: UIView, renderMode: TX_Enum_Type_RenderMode = .RENDER_MODE_FILL_SCREEN,isAllList:Bool = false) {
+    public func configPlyer(videoData: BFVideoItemProtocol, controllerView: UIView, renderMode: TX_Enum_Type_RenderMode = .RENDER_MODE_FILL_SCREEN, isAllList: Bool = false) {
 //        if playVideoData?.id == videoData.id {
 //            return
 //        }
@@ -86,7 +87,7 @@ public class PQSingletoVideoPlayer: NSObject {
             PQSingletoMemoryUtil.shared.playCount = PQSingletoMemoryUtil.shared.playCount + 1
         }
     }
-    
+
     public func reRenderView(newView: UIView) {
         player.removeVideoWidget()
         player.setupVideoWidget(newView, insert: 0)
@@ -98,15 +99,15 @@ public class PQSingletoVideoPlayer: NSObject {
             let playDuration = player.currentPlaybackTime() - lastPlaybackTime
             debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
             if playDuration > 0 {
-                var extParams:[String:Any]?
-                if isHomePageAllList {
-                    if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                        extParams = ["topicId":"all"]
-                    } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                        extParams = ["followedUid":"all"]
-                    }
+                var extParams: [String: Any]?
+                if playVideoData?.pageSource == .sp_cmunit_joinTopic {
+                    extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
+                } else if playVideoData?.pageSource == .sp_cmunit_follow {
+                    extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
+                } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
+                    extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
                 }
-                PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource":(playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue,"playDuration":Int64(playDuration * 1000),"playId":playId,"uid":"\(playVideoData?.user?["uid"] ?? "")","videoId":playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
+                PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
                 lastPlaybackTime = player.currentPlaybackTime()
             }
             player.removeVideoWidget()
@@ -143,15 +144,15 @@ public class PQSingletoVideoPlayer: NSObject {
         let playDuration = player.currentPlaybackTime() - lastPlaybackTime
         debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
         if playDuration > 0 {
-            var extParams:[String:Any]?
-            if isHomePageAllList {
-                if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                    extParams = ["topicId":"all"]
-                } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                    extParams = ["followedUid":"all"]
-                }
+            var extParams: [String: Any]?
+            if playVideoData?.pageSource == .sp_cmunit_joinTopic {
+                extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
+            } else if playVideoData?.pageSource == .sp_cmunit_follow {
+                extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
+            } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
+                extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
             }
-            PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource":(playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue,"playDuration":Int64(playDuration * 1000),"playId":playId,"uid":"\(playVideoData?.user?["uid"] ?? "")","videoId":playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
+            PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
             lastPlaybackTime = player.currentPlaybackTime()
         }
     }
@@ -165,15 +166,15 @@ public class PQSingletoVideoPlayer: NSObject {
         let playDuration = player.currentPlaybackTime() - lastPlaybackTime
         debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
         if playDuration > 0 {
-            var extParams:[String:Any]?
-            if isHomePageAllList {
-                if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                    extParams = ["topicId":"all"]
-                } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                    extParams = ["followedUid":"all"]
-                }
+            var extParams: [String: Any]?
+            if playVideoData?.pageSource == .sp_cmunit_joinTopic {
+                extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
+            } else if playVideoData?.pageSource == .sp_cmunit_follow {
+                extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
+            } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
+                extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
             }
-            PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource":(playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue,"playDuration":Int64(playDuration * 1000),"playId":playId,"uid":"\(playVideoData?.user?["uid"] ?? "")","videoId":playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
+            PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
             lastPlaybackTime = player.currentPlaybackTime()
         }
     }
@@ -190,15 +191,15 @@ public class PQSingletoVideoPlayer: NSObject {
         let playDuration = player.currentPlaybackTime() - lastPlaybackTime
         debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
         if playDuration > 0 {
-            var extParams:[String:Any]?
-            if isHomePageAllList {
-                if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                    extParams = ["topicId":"all"]
-                } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                    extParams = ["followedUid":"all"]
-                }
+            var extParams: [String: Any]?
+            if playVideoData?.pageSource == .sp_cmunit_joinTopic {
+                extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
+            } else if playVideoData?.pageSource == .sp_cmunit_follow {
+                extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
+            } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail){
+                extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
             }
-            PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource":(playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue,"playDuration":Int64(playDuration * 1000),"playId":playId,"uid":"\(playVideoData?.user?["uid"] ?? "")","videoId":playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
+            PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
             lastPlaybackTime = player.currentPlaybackTime()
         }
     }
@@ -212,23 +213,20 @@ public class PQSingletoVideoPlayer: NSObject {
     override private init() {
         super.init()
 
-        NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: nil) { notice in
+        NotificationCenter.default.addObserver(forName: UIApplication.didEnterBackgroundNotification, object: nil, queue: nil) { _ in
             if self.isPlaying {
                 self.pausePlayer()
                 self.shouldResumePlayWhenEnterForeground = true
             }
         }
-        NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: nil) { notice in
-            
-            if self.autoResumePlayWhenEnterForeground && self.shouldResumePlayWhenEnterForeground {
+        NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: nil) { _ in
 
+            if self.autoResumePlayWhenEnterForeground, self.shouldResumePlayWhenEnterForeground {
                 self.shouldResumePlayWhenEnterForeground = false
 
                 self.resumePlayer()
-
             }
         }
-
     }
 
     override public func copy() -> Any {
@@ -263,15 +261,15 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                 if !isSemiRealPlay, playVideoData != nil {
                     isSemiRealPlay = true
                     // 播放上报
-                    var extParams:[String:Any]?
+                    var extParams: [String: Any]?
                     if isHomePageAllList {
                         if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                            extParams = ["topicId":"all"]
+                            extParams = ["topicId": "all"]
                         } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                            extParams = ["followedUid":"all"]
+                            extParams = ["followedUid": "all"]
                         }
                     }
-                    PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoSemiRealPlay, objectType: nil, extParams:extParams , shareId: nil, videoIds: nil, playId: playId)
+                    PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoSemiRealPlay, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
                 }
             }
             if player.currentPlaybackTime() >= 20.0 || ((playProgress / duration) >= 0.3) {
@@ -279,12 +277,12 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                 if !isRealPlay, playVideoData != nil {
                     isRealPlay = true
                     // 播放上报
-                    var extParams:[String:Any]?
+                    var extParams: [String: Any]?
                     if isHomePageAllList {
                         if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                            extParams = ["topicId":"all"]
+                            extParams = ["topicId": "all"]
                         } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                            extParams = ["followedUid":"all"]
+                            extParams = ["followedUid": "all"]
                         }
                     }
                     PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_realPlay, videoData: playVideoData, pageSource: nil, businessType: .bt_videoRealPlay, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
@@ -299,12 +297,12 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
             if !isPlayBegin, playVideoData != nil {
                 isPlayBegin = true
                 // 播放上报
-                var extParams:[String:Any]?
+                var extParams: [String: Any]?
                 if isHomePageAllList {
                     if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                        extParams = ["topicId":"all"]
+                        extParams = ["topicId": "all"]
                     } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                        extParams = ["followedUid":"all"]
+                        extParams = ["followedUid": "all"]
                     }
                 }
                 PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccess, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
@@ -322,22 +320,22 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
             if !isFirstFrame, playVideoData != nil {
                 isFirstFrame = true
                 // 播放上报
-                var extParams:[String:Any]?
+                var extParams: [String: Any]?
                 if isHomePageAllList {
                     if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                        extParams = ["topicId":"all"]
+                        extParams = ["topicId": "all"]
                     } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                        extParams = ["followedUid":"all"]
+                        extParams = ["followedUid": "all"]
                     }
                 }
                 PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_play, videoData: playVideoData, pageSource: nil, businessType: nil, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
                 let duration = Int((Date().timeIntervalSince1970 * 1000) - loadingTime)
                 BFLog(message: "加载时长:\(duration)")
                 // 加载时间上报
-                var timeExtParams:[String:Any] = ["duration": duration, "proxyEnable": "0", "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0"]
+                var timeExtParams: [String: Any] = ["duration": duration, "proxyEnable": "0", "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0"]
                 if extParams != nil {
-                    timeExtParams.merge(extParams!) { keyValue, param in
-                        return keyValue
+                    timeExtParams.merge(extParams!) { keyValue, _ in
+                        keyValue
                     }
                 }
                 PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Frontend, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlaySuccessTime, objectType: nil, extParams: timeExtParams, shareId: nil, videoIds: nil, playId: playId)
@@ -352,12 +350,12 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
             if !isPlayEnd, playVideoData != nil {
                 isPlayEnd = true
                 // 播放结束上报
-                var extParams:[String:Any]?
+                var extParams: [String: Any]?
                 if isHomePageAllList {
                     if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                        extParams = ["topicId":"all"]
+                        extParams = ["topicId": "all"]
                     } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                        extParams = ["followedUid":"all"]
+                        extParams = ["followedUid": "all"]
                     }
                 }
                 PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayEnd, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
@@ -365,15 +363,15 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
             let playDuration = player.currentPlaybackTime() - lastPlaybackTime
             debugPrint("当前播放时长:\(player.currentPlaybackTime()),lastPlaybackTime:\(lastPlaybackTime),playDuration:\(playDuration)")
             if playDuration > 0 {
-                var extParams:[String:Any]?
-                if isHomePageAllList {
-                    if playVideoData?.pageSource == .sp_cmunit_joinTopic {
-                        extParams = ["topicId":"all"]
-                    } else if playVideoData?.pageSource == .sp_cmunit_follow {
-                        extParams = ["followedUid":"all"]
-                    }
+                var extParams: [String: Any]?
+                if playVideoData?.pageSource == .sp_cmunit_joinTopic {
+                    extParams = ["topicId": isHomePageAllList ? "all" : "\(playVideoData?.topicData?["id"] ?? "")"]
+                } else if playVideoData?.pageSource == .sp_cmunit_follow {
+                    extParams = ["followedUid": isHomePageAllList ? "all" : "\(playVideoData?.user?["uid"] ?? "")"]
+                } else if (playVideoData?.pageSource == .sp_cmunit_newTopicDetail || playVideoData?.pageSource == .sp_cmunit_hotTopicDetail) {
+                    extParams = ["topicId": "\(playVideoData?.topicData?["id"] ?? "")"]
                 }
-                PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction,businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource":(playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue,"playDuration":Int64(playDuration * 1000),"playId":playId,"uid":"\(playVideoData?.user?["uid"] ?? "")","videoId":playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
+                PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_pLayaction, businessType: .bt_videoPlayDuration, objectType: nil, pageSource: playVideoData?.pageSource ?? .sp_cmunit_recommend, eventData: ["pageSource": (playVideoData?.pageSource ?? .sp_cmunit_recommend).rawValue, "playDuration": Int64(playDuration * 1000), "playId": playId, "uid": "\(playVideoData?.user?["uid"] ?? "")", "videoId": playVideoData?.id ?? 0], extParams: extParams, remindmsg: "播放时长统计")
                 lastPlaybackTime = player.currentPlaybackTime()
             }
         case PLAY_ERR_NET_DISCONNECT.rawValue, -2301: // 重连失败
@@ -383,7 +381,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
             if !isPlayerError, playVideoData != nil {
                 isPlayerError = true
                 // 播放失败
-                var extParams:[String:Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
+                var extParams: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
                 if isHomePageAllList {
                     if playVideoData?.pageSource == .sp_cmunit_joinTopic {
                         extParams["topicId"] = "all"
@@ -400,7 +398,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
             if !isPlayerError, playVideoData != nil {
                 isPlayerError = true
                 // 播放失败
-                var extParams:[String:Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": false, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
+                var extParams: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": false, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
                 if isHomePageAllList {
                     if playVideoData?.pageSource == .sp_cmunit_joinTopic {
                         extParams["topicId"] = "all"
@@ -408,7 +406,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
                         extParams["followedUid"] = "all"
                     }
                 }
-                PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams:extParams , shareId: nil, videoIds: nil, playId: playId)
+                PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayError, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
             }
         case PLAY_ERR_HEVC_DECODE_FAIL.rawValue, PLAY_ERR_HLS_KEY.rawValue, PLAY_ERR_GET_PLAYINFO_FAIL.rawValue, PLAY_WARNING_VIDEO_DECODE_FAIL.rawValue, PLAY_WARNING_AUDIO_DECODE_FAIL.rawValue: // H265解码失败,HLS解码key获取失败,获取点播文件信息失败,当前视频解码失败,当前音频解码失败
             if playStatusBloc != nil {
@@ -417,7 +415,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
             if !isPlayerError, playVideoData != nil {
                 isPlayerError = true
                 // 播放失败
-                var extParams:[String:Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": false, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
+                var extParams: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": false, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
                 if isHomePageAllList {
                     if playVideoData?.pageSource == .sp_cmunit_joinTopic {
                         extParams["topicId"] = "all"
@@ -431,7 +429,7 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
             if playStatusBloc != nil {
                 playStatusBloc!(.PQVIDEO_PLAY_STATUS_RECONNECT)
             }
-            var extParams:[String:Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
+            var extParams: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
             if isHomePageAllList {
                 if playVideoData?.pageSource == .sp_cmunit_joinTopic {
                     extParams["topicId"] = "all"
@@ -442,8 +440,8 @@ extension PQSingletoVideoPlayer: TXVodPlayListener {
             PQEventTrackViewModel.videoRelationReportUpload(reportLogType: .reportLogType_Action, videoData: playVideoData, pageSource: nil, businessType: .bt_videoPlayException, objectType: nil, extParams: extParams, shareId: nil, videoIds: nil, playId: playId)
         case PLAY_WARNING_RECV_DATA_LAG.rawValue, PLAY_WARNING_VIDEO_PLAY_LAG.rawValue: // 网络来包不稳:可能是下行带宽不足 | 当前视频播放出现卡顿(用户直观感受)
             // 播放失败
-            var extParams1:[String:Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event, "position": player.currentPlaybackTime()]
-            var extParams2:[String:Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
+            var extParams1: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event, "position": player.currentPlaybackTime()]
+            var extParams2: [String: Any] = ["pageSource": playVideoData!.pageSource.rawValue, "networkType": networkStatus(), "extra": "0", "hasRetry": true, "url": playVideoData?.videoPath ?? "", "videoId": playVideoData?.uniqueId ?? "0", "what": event]
             if isHomePageAllList {
                 if playVideoData?.pageSource == .sp_cmunit_joinTopic {
                     extParams1["topicId"] = "all"

+ 6 - 3
BFFramework/Classes/EventTrack/ViewModel/PQEventTrackViewModel.swift

@@ -69,9 +69,9 @@ public class PQEventTrackViewModel: NSObject {
     public class func videoRelationReportUpload(reportLogType: reportLogType, videoData: BFVideoItemProtocol?, pageSource: PAGESOURCE? = nil, businessType: businessType?, objectType: objectType? = nil, extParams: [String: Any]? = nil, shareId: String? = nil, videoIds: String? = nil, playId: String? = nil, headVideoId: String? = nil) {
         var tempExtParams: [String: Any] = extParams ?? [:]
         if videoData?.topicData != nil {
-            if pageSource == .sp_cmunit_joinTopic && !tempExtParams.keys.contains("topicId") && "\(tempExtParams["topicId"] ?? "")".count <= 0 {
+            if (videoData?.pageSource == .sp_cmunit_joinTopic || pageSource == .sp_cmunit_joinTopic) && "\(tempExtParams["topicId"] ?? "")".count <= 0 {
                 tempExtParams["topicId"] = "\(videoData?.topicData?["id"] ?? "")"
-            } else if pageSource == .sp_cmunit_follow && !tempExtParams.keys.contains("followedUid") && "\(tempExtParams["followedUid"] ?? "")".count <= 0 {
+            } else if (videoData?.pageSource == .sp_cmunit_follow || pageSource == .sp_cmunit_follow) && "\(tempExtParams["followedUid"] ?? "")".count <= 0 {
                 tempExtParams["followedUid"] = "\(videoData?.user?["uid"] ?? "")"
             }
         }
@@ -211,7 +211,7 @@ public class PQEventTrackViewModel: NSObject {
 //    /   - businessType: <#businessType description#>
 //    /   - targetUid: <#targetUid description#>
 //    /   - shareId: <#shareId description#>
-    public class func shareReportUpload(isShareVideo: Bool = true, screenType: Int = 1, videoId: String, pageSource: PAGESOURCE, recommendId: String?, recommendLogVO: String?, abInfoData: String?, measureType: Int?, measureId: Int?, businessType: businessType?, targetUid: Int?, shareId: String = "") {
+    public class func shareReportUpload(isShareVideo: Bool = true, screenType: Int = 1, videoId: String, pageSource: PAGESOURCE, recommendId: String?, recommendLogVO: String?, abInfoData: String?, measureType: Int?, measureId: Int?, businessType: businessType?, targetUid: Int?, shareId: String = "",extParams: [String: Any]? = nil) {
         DispatchQueue.global().async {
             var url: String = PQENVUtil.shared.longvideoapi
             switch screenType {
@@ -225,6 +225,9 @@ public class PQEventTrackViewModel: NSObject {
                 break
             }
             var params: [String: Any] = ["type": isShareVideo ? "1" : "2", "videoId": videoId, "pageSource": pageSource.rawValue, "playId": PQSingletoVideoPlayer.shared.playId, "targetUid": targetUid ?? 0, "shareDepth": "0"]
+            if extParams != nil {
+                params["extParams"] = dictionaryToJsonString(extParams!)
+            }
             if measureType != nil {
                 params["measureType"] = measureType
             }