PQEventTrackViewModel.swift 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. //
  2. // PQEventTrackViewModel.swift
  3. // PQSpeed
  4. //
  5. // Created by SanW on 2020/11/3.
  6. // Copyright © 2020 BytesFlow. All rights reserved.
  7. //
  8. import UIKit
  9. // MARK: - 埋点数据上报
  10. /// 埋点数据上报
  11. public class PQEventTrackViewModel: NSObject {
  12. /// 基础埋点上报
  13. /// - Parameters:
  14. /// - logType: 数据库类型
  15. /// - businessType: businessType
  16. /// - objectType: objectType
  17. /// - eventData: eventData
  18. /// - pageSource: 页面场景
  19. /// - extParams: extParams 扩展字段,为json对象
  20. /// - remindmsg: remindmsg 打印提示信息
  21. /// - Returns: <#description#>
  22. public class func baseReportUpload(logType: statisticsLogType = .st_log_type_simpleevent, businessType: businessType?, objectType: objectType?, pageSource: PAGESOURCE?, params: [String: Any]? = nil, eventData: [String: Any]? = nil, extParams: [String: Any]? = nil, remindmsg: String? = "基础") {
  23. DispatchQueue.global().async {
  24. // LogType
  25. var tempParams: [String: Any] = params ?? [:]
  26. tempParams["LogType"] = logType.rawValue
  27. // pageSource
  28. if pageSource != nil {
  29. tempParams["pageSource"] = pageSource?.rawValue
  30. }
  31. // eventData
  32. var tempEventData: [String: Any] = eventData ?? [:]
  33. if objectType != nil {
  34. tempEventData["objectType"] = objectType?.rawValue
  35. }
  36. if businessType != nil {
  37. tempEventData["businessType"] = businessType?.rawValue
  38. }
  39. if tempEventData.keys.count > 0 {
  40. tempParams["eventData"] = dictionaryToJsonString(tempEventData)
  41. }
  42. // extParams
  43. if extParams != nil, (extParams?.keys.count ?? 0) > 0 {
  44. tempParams["extParams"] = dictionaryToJsonString(extParams!)
  45. }
  46. SWNetRequest.postRequestData(url: PQENVUtil.shared.commonapi + staticsFrontendReportUrl, parames: tempParams) { _, _, _, _ in
  47. BFLog(message: "\(remindmsg ?? "基础")埋点数据上报:\(tempParams)")
  48. }
  49. }
  50. }
  51. /// 视频相关上报
  52. /// - Parameters:
  53. /// - reportLogType: 上报库类型
  54. /// - videoData: 视频数据
  55. /// - pageSource: 页面
  56. /// - businessType: <#businessType description#>
  57. /// - objectType: <#objectType description#>
  58. /// - extParams: <#extParams description#>
  59. /// - shareId: <#shareId description#>
  60. /// - videoIds: <#videoIds description#>
  61. /// - playId: <#playId description#>
  62. /// - headVideoId: <#headVideoId description#>
  63. public class func videoRelationReportUpload(reportLogType: reportLogType, videoData: PQVideoListModel?, pageSource: PAGESOURCE? = nil, businessType: businessType?, objectType: objectType? = nil, extParams: [String: Any]? = nil, shareId: String? = nil, videoIds: String? = nil, playId: String? = nil, headVideoId: String? = nil) {
  64. var tempExtParams: [String: Any] = extParams ?? [:]
  65. if videoData?.reCreateVideoData != nil {
  66. tempExtParams["projectId"] = videoData?.reCreateVideoData?.projectId ?? ""
  67. tempExtParams["parentProjectId"] = videoData?.reCreateVideoData?.parentProjectId ?? ""
  68. tempExtParams["rootProjectId"] = videoData?.reCreateVideoData?.rootProjectId ?? ""
  69. tempExtParams["canProduce"] = videoData?.reCreateVideoData?.canReproduce ?? 0
  70. if !tempExtParams.keys.contains("clickedVideoId") {
  71. tempExtParams["videoId"] = videoData?.uniqueId ?? "0"
  72. }
  73. if videoData?.reCreateVideoData?.parentVideoId != nil {
  74. tempExtParams["parentVideoId"] = videoData?.reCreateVideoData?.parentVideoId ?? ""
  75. }
  76. }
  77. if objectType == .ot_reproduce_clickButton || objectType == .ot_reproduce_collectionBar || objectType == .ot_reproduce_collectionClicButton || objectType == .ot_reproduce_sameSourceButton {
  78. PQEventTrackViewModel.baseReportUpload(businessType: businessType, objectType: objectType, pageSource: pageSource != nil ? pageSource! : (videoData?.pageSource ?? .sp_category), extParams: tempExtParams, remindmsg: "再创作上报")
  79. } else {
  80. PQEventTrackViewModel.reportVideoPlayUpload(reportLogType: reportLogType, videoId: videoData?.uniqueId ?? "0", headVideoId: headVideoId ?? videoData?.headVideoId, videoIds: videoIds, pageSource: pageSource != nil ? pageSource! : (videoData?.pageSource ?? .sp_category), playId: playId ?? "", recommendId: videoData?.recommendId, recommendLogVO: videoData?.recommendLogVO, abInfoData: videoData?.abInfoData, measureType: videoData?.measureType, measureId: videoData?.measureId, businessType: businessType, shareId: shareId ?? "", extParams: tempExtParams, objectType: objectType)
  81. }
  82. }
  83. /// 播放相关数据上报
  84. /// - Parameters:
  85. /// - reportLogType: 日志类型
  86. /// - videoId: 视频Id
  87. /// - headVideoId: 当前的相关推荐视频是属于哪个视频的相关推荐,值为那个头部视频的videoId
  88. /// - videoIds: reportLogType_view时传
  89. /// - pageSource: 页面
  90. /// - playId: 播放ID 对于每一次播放操作,生成唯一playid,标示唯一一次播放操作,视频播放中暂停,再继续播放时,不算一次新的播放,不需要生成新的playid。重播视频算一次新的播放,即需要生成新的playid。
  91. /// - recommendId: 推荐链路ID 列表返回
  92. /// - recommendLogVO: 推荐日志对象 列表返回
  93. /// - abInfoData: AB信息 列表返回
  94. /// - measureType:
  95. /// - measureId:
  96. /// - businessType: 操作类型
  97. /// - targetUid: 视频用户ID
  98. /// - Returns: <#description#>
  99. public class func reportVideoPlayUpload(reportLogType: reportLogType, videoId: String, headVideoId: String?, videoIds: String?, pageSource: PAGESOURCE, playId: String, recommendId: String?, recommendLogVO: String?, abInfoData: String?, measureType: Int?, measureId: Int?, businessType: businessType?, targetUid: Int = 0, shareId: String = "", extParams: [String: Any]? = nil, objectType: objectType? = nil) {
  100. DispatchQueue.global().async {
  101. var params: [String: Any] = ["videoId": videoId, "pageSource": pageSource.rawValue, "playId": playId, "targetUid": targetUid]
  102. if measureType != nil {
  103. params["measureType"] = measureType
  104. }
  105. if measureId != nil {
  106. params["measureId"] = measureId
  107. }
  108. if recommendId != nil, !(recommendId?.isEmpty ?? true) {
  109. params["recommendId"] = recommendId
  110. }
  111. if recommendLogVO != nil, !(recommendLogVO?.isEmpty ?? true) {
  112. params["recommendLogVO"] = recommendLogVO
  113. }
  114. if abInfoData != nil, !(abInfoData?.isEmpty ?? true) {
  115. params["abInfoData"] = abInfoData
  116. }
  117. if pageSource.rawValue.contains("speedApp-category") {
  118. params["pageCategoryId"] = 55
  119. }
  120. // eventData
  121. var tempEventData: [String: Any] = Dictionary<String, Any>.init()
  122. if objectType != nil {
  123. tempEventData["objectType"] = objectType?.rawValue
  124. }
  125. if businessType != nil {
  126. tempEventData["businessType"] = businessType?.rawValue
  127. }
  128. // extParams
  129. var tempExtParams: [String: Any] = extParams ?? [:]
  130. if headVideoId != nil, (headVideoId?.count ?? 0) > 0 {
  131. tempExtParams["headVideoId"] = (headVideoId ?? "0")
  132. }
  133. var url: String = PQENVUtil.shared.longvideoapi
  134. switch reportLogType {
  135. case .reportLogType_view:
  136. url = url + videoViewReportUrl
  137. if videoIds != nil, !videoIds!.isEmpty {
  138. params["videoIds"] = videoIds
  139. } else {
  140. params["videoIds"] = videoId
  141. }
  142. params["viewId"] = getUniqueId(desc: "\(videoId)viewId")
  143. case .reportLogType_realPlay:
  144. url = url + videoRealPlayReportUrl
  145. if businessType != nil {
  146. params["actionTriggerType"] = businessType?.rawValue
  147. }
  148. case .reportLogType_play:
  149. url = url + videoPlayReportUrl
  150. case .reportLogType_Action:
  151. url = url + videoActionReportUrl
  152. if businessType != nil, businessType == .bt_videoShareH5 || businessType == .bt_videoShareFriend {
  153. params["shareId"] = shareId
  154. params["rootLaunchShareId"] = shareId
  155. params["parentShareId"] = shareId
  156. params["shareDepth"] = "0"
  157. }
  158. if businessType != nil {
  159. params["businessType"] = businessType?.rawValue
  160. }
  161. case .reportLogType_Frontend:
  162. url = PQENVUtil.shared.commonapi + staticsFrontendReportUrl
  163. params["LogType"] = 30
  164. params["eventData"] = dictionaryToJsonString(["tabIndex": PQSingletoMemoryUtil.shared.selectedTabIndex ?? "categoryTab", "businessType": businessType?.rawValue ?? ""])
  165. }
  166. if tempEventData.keys.count > 0 {
  167. params["eventData"] = dictionaryToJsonString(tempEventData)
  168. }
  169. if tempExtParams.keys.count > 0 {
  170. params["extParams"] = dictionaryToJsonString(tempExtParams)
  171. }
  172. SWNetRequest.postRequestData(url: url, parames: params) { response, _, error, _ in
  173. BFLog(message: "播放相关数据上报:\(String(describing: error)),\(response ?? [:])")
  174. }
  175. }
  176. }
  177. // / 分享上报
  178. // / - Parameters:
  179. // / - isShareVideo: 是否是分享视频
  180. // / - screenType: 分享场景 1-分享视频/用户 2-分享视频到朋友圈 3-分享视频到好友
  181. // / - videoId: 视频Id
  182. // / - pageSource: 页面枚举
  183. // / - recommendId: <#recommendId description#>
  184. // / - recommendLogVO: <#recommendLogVO description#>
  185. // / - abInfoData: <#abInfoData description#>
  186. // / - measureType: <#measureType description#>
  187. // / - measureId: <#measureId description#>
  188. // / - businessType: <#businessType description#>
  189. // / - targetUid: <#targetUid description#>
  190. // / - shareId: <#shareId description#>
  191. 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 = "") {
  192. DispatchQueue.global().async {
  193. var url: String = PQENVUtil.shared.longvideoapi
  194. switch screenType {
  195. case 1:
  196. url = url + userShareReportUrl
  197. case 2:
  198. url = url + userShareH5ReportUrl
  199. case 3:
  200. url = url + userShareFriendReportUrl
  201. default:
  202. break
  203. }
  204. var params: [String: Any] = ["type": isShareVideo ? "1" : "2", "videoId": videoId, "pageSource": pageSource.rawValue, "playId": PQSingletoVideoPlayer.shared.playId, "targetUid": targetUid ?? 0, "shareDepth": "0"]
  205. if measureType != nil {
  206. params["measureType"] = measureType
  207. }
  208. if measureId != nil {
  209. params["measureId"] = measureId
  210. }
  211. params["shareId"] = shareId
  212. params["rootLaunchShareId"] = shareId
  213. params["parentShareId"] = shareId
  214. params["rootShareId"] = shareId
  215. if !BFLoginUserInfo.shared.openId.isEmpty {
  216. params["shareUi"] = BFLoginUserInfo.shared.openId
  217. }
  218. if pageSource.rawValue.contains("speedApp-category") {
  219. params["pageCategoryId"] = 55
  220. }
  221. if isShareVideo {
  222. params["shareObjectId"] = videoId
  223. } else {
  224. params["shareObjectId"] = targetUid
  225. }
  226. if businessType != nil {
  227. params["businessType"] = businessType?.rawValue
  228. }
  229. if recommendId != nil, !(recommendId?.isEmpty ?? true) {
  230. params["recommendId"] = recommendId
  231. }
  232. if recommendLogVO != nil, !(recommendLogVO?.isEmpty ?? true) {
  233. params["recommendLogVO"] = recommendLogVO
  234. }
  235. if abInfoData != nil, !(abInfoData?.isEmpty ?? true) {
  236. params["abInfoData"] = abInfoData
  237. }
  238. SWNetRequest.postRequestData(url: url, parames: params) { response, _, error, _ in
  239. BFLog(message: "用户点击分享数据上报:\(String(describing: error)),\(response ?? [:])")
  240. }
  241. }
  242. }
  243. /// DNS上报
  244. /// - Returns: <#description#>
  245. public class func dnsReportUpload() {
  246. DispatchQueue.global().async {
  247. let speedExtParams = parseDNS(hostUrl: "speed.piaoquantv.com")
  248. let rescdnExtParams = parseDNS(hostUrl: "rescdn.yishihui.com")
  249. if speedExtParams != nil {
  250. PQEventTrackViewModel.baseReportUpload(businessType: .bt_dnsParseCostTime, objectType: nil, pageSource: nil, eventData: ["tabIndex": PQSingletoMemoryUtil.shared.selectedTabIndex ?? "categoryTab"], extParams: speedExtParams, remindmsg: "dnsParse")
  251. }
  252. if rescdnExtParams != nil {
  253. PQEventTrackViewModel.baseReportUpload(businessType: .bt_dnsParseCostTime, objectType: nil, pageSource: nil, eventData: ["tabIndex": PQSingletoMemoryUtil.shared.selectedTabIndex ?? "categoryTab"], extParams: rescdnExtParams, remindmsg: "dnsParse")
  254. }
  255. }
  256. }
  257. /// 冷热启动数据上报
  258. /// - Parameters:
  259. /// - isHotLaunch 是否是热启动
  260. /// - logType: <#logType description#>
  261. /// - eventId: <#eventId description#>
  262. /// - eventData: <#eventData description#>
  263. /// - extParams: <#extParams description#>
  264. /// - pageSource: <#pageSource description#>
  265. /// - Returns: <#description#>
  266. class public func reportStatisticsUpload(isHotLaunch: Bool = false, logType: statisticsLogType, coldLaunchType _: coldLaunchType = .coldLaunchType_userActiveOpen, eventId _: String?, eventData _: String?, pageSource: PAGESOURCE?) {
  267. DispatchQueue.global().async {
  268. var params: [String: Any] = ["LogType": logType.rawValue]
  269. if PQSingletoMemoryUtil.shared.isColdLaunch {
  270. // 1-请求中 2-请求成功 3-请求失败
  271. if PQSingletoMemoryUtil.shared.coldLaunchStatus != 2 {
  272. PQSingletoMemoryUtil.shared.coldLaunchStatus = 1
  273. } else {
  274. return
  275. }
  276. }
  277. params["eventData"] = dictionaryToJsonString(["tabIndex": PQSingletoMemoryUtil.shared.selectedTabIndex ?? "categoryTab"])
  278. // 参数
  279. var extParams: [String: Any] = Dictionary<String, Any>.init()
  280. extParams["downloadChannel"] = channelID
  281. extParams["launchParams"] = PQSingletoMemoryUtil.shared.commandLaunchParams
  282. if pageSource?.rawValue.contains("speedApp-category") ?? false {
  283. params["pageCategoryId"] = 55
  284. }
  285. if PQSingletoMemoryUtil.shared.commandReportParams != nil {
  286. for (key, value) in PQSingletoMemoryUtil.shared.commandReportParams!.reversed() {
  287. extParams[key] = value
  288. }
  289. }
  290. if !isHotLaunch {
  291. extParams["coldLaunchType"] = (PQSingletoMemoryUtil.shared.coldLaunchType ?? .coldLaunchType_userActiveOpen).rawValue
  292. } else {
  293. extParams["hotLaunchType"] = (PQSingletoMemoryUtil.shared.coldLaunchType ?? .coldLaunchType_userActiveOpen).rawValue
  294. }
  295. if pageSource != nil {
  296. params["pageSource"] = pageSource!.rawValue
  297. }
  298. // 是否第一次安装
  299. let firstInstall: String? = getUserDefaults(key: cFirstInstall) as? String
  300. if firstInstall == nil || (firstInstall?.count ?? 0 <= 0) || firstInstall != "1" {
  301. extParams["isFirstLaunch"] = 1
  302. } else {
  303. extParams["isFirstLaunch"] = 0
  304. }
  305. params["extParams"] = dictionaryToJsonString(extParams)
  306. // 是否第一次安装
  307. let firstParams: String? = getUserDefaults(key: cFirstParams) as? String
  308. if (firstInstall == nil || firstInstall?.count ?? 0 <= 0 || firstInstall != "1") && (firstParams != nil && ((firstParams?.count ?? 0) > 0)) {
  309. params = jsonStringToDictionary(firstParams!) ?? Dictionary<String, Any>.init()
  310. }
  311. if firstParams == nil || ((firstParams?.count ?? 0) <= 0) {
  312. saveUserDefaults(key: cFirstParams, value: dictionaryToJsonString(params) ?? "")
  313. }
  314. SWNetRequest.postRequestData(url: PQENVUtil.shared.commonapi + staticsFrontendReportUrl, parames: params) { response, _, error, _ in
  315. BFLog(message: "冷热启动上报:\(String(describing: error)),\(response ?? [:]),params = \(params)")
  316. if PQSingletoMemoryUtil.shared.isColdLaunch {
  317. PQSingletoMemoryUtil.shared.coldLaunchStatus = error == nil ? 2 : 3
  318. }
  319. // 清空启动数据
  320. PQSingletoMemoryUtil.shared.coldLaunchType = nil
  321. if error == nil, firstInstall == nil || firstInstall?.count ?? 0 <= 0 || firstInstall != "1" {
  322. saveUserDefaults(key: cFirstInstall, value: "1")
  323. }
  324. saveUserDefaults(key: cSelectedTabIndex, value: "categoryTab")
  325. }
  326. }
  327. }
  328. /// 推送点击数据上报
  329. /// - Parameters:
  330. /// - pushId: 推送Id
  331. /// - pushTargetType: 1-推送单个视频 2-整体关注有更新 3-关注单个up主有更新(暂废弃) 4-订阅某人有更新
  332. /// - pushBrand: 推送平台 APPLE_TYPE
  333. /// - pushTargetId: pushTargetType == 1 视频ID,pushTargetType == 4 用户ID
  334. /// - bizParam 扩展参数
  335. /// - Returns: <#description#>
  336. public class func reportPushActionUpload(pushId: String, pushTargetType: Int, pushBrand: String = cPushChannel, pushTargetId: String?,bizParam : [String: Any]? = nil) {
  337. DispatchQueue.global().async {
  338. var params: [String: Any] = bizParam ?? Dictionary<String,Any>.init()
  339. if pushTargetId != nil {
  340. params["pushTargetId"] = pushTargetId
  341. }
  342. if pushId.count > 0 {
  343. params["pushId"] = pushId
  344. }
  345. params["pushTargetType"] = pushTargetType
  346. params["pushBrand"] = pushBrand
  347. params["pushReportType"] = "click"
  348. if params.keys.contains("aps"){
  349. params.removeValue(forKey: "aps")
  350. }
  351. SWNetRequest.postRequestData(url: PQENVUtil.shared.longvideoapi + pushActionReportUrl, parames: params) { response, _, error, _ in
  352. BFLog(message: "推送点击数据上报:\(String(describing: error)),\(response ?? [:])")
  353. }
  354. }
  355. }
  356. /// 上报deviceToken
  357. /// - Parameter registerId: 设备id
  358. /// - Parameter deviceToken: <#deviceToken description#>
  359. /// - Returns: <#description#>
  360. public class func reportPushDeviceTokenUpload(registerId: String, deviceToken: String, completeHander: @escaping (_ isSuccess: Bool) -> Void) {
  361. DispatchQueue.global().async {
  362. SWNetRequest.postRequestData(url: PQENVUtil.shared.longvideoapi + pushDeviceTokenReportUrl, parames: ["registerId": registerId, "deviceToken": deviceToken, "brand": cPushChannel]) { response, _, error, _ in
  363. completeHander(error == nil ? true : false)
  364. BFLog(message: "deviceToken数据上报:\(String(describing: error)),\(response ?? [:])")
  365. }
  366. }
  367. }
  368. /// 搜索上报
  369. /// - Parameters:
  370. /// - keyWord: 搜索词
  371. /// - searchType: 1 热搜词搜索 2 历史记录 3 普通搜索
  372. /// - searchNumber: 数量
  373. /// - reportType: 1 into 2 click 3 show
  374. /// - Returns: <#description#>
  375. public class func searchReportUpload(keyWord: String, searchType: Int, searchNumber: Int = 10, reportType: Int = 2) {
  376. DispatchQueue.global().async {
  377. let params: [String: Any] = ["keyWord": keyWord, "searchType": searchType, "searchNumber": searchNumber, "reportType": reportType]
  378. SWNetRequest.postRequestData(url: PQENVUtil.shared.longvideoapi + searchReportUrl, parames: params) { response, _, error, _ in
  379. BFLog(message: "搜索数据上报:\(String(describing: error)),\(response ?? [:])")
  380. }
  381. }
  382. }
  383. /// 发布视频的上报
  384. /// - Parameters:
  385. /// - projectId:项目ID-发布创作的视频时必传,会在进入创作工具页时生成,以app_no_projectdata为前缀
  386. /// - businessType: <#businessType description#>
  387. /// - ossInfo: <#ossInfo description#>
  388. /// - params: <#params description#>
  389. /// - Returns: <#description#>
  390. public class func publishReportUpload(projectId: String?, businessType: businessType, ossInfo: [String: Any], params: [String: Any]) {
  391. DispatchQueue.global().async {
  392. var extParams: [String: Any] = ["ossInfo": dictionaryToJsonString(ossInfo) ?? "", "params": dictionaryToJsonString(params) ?? ""]
  393. if projectId != nil {
  394. extParams["projectId"] = projectId
  395. }
  396. if !extParams.keys.contains("source") {
  397. extParams["source"] = projectId != nil ? "videoCompose" : "videoUpload"
  398. }
  399. PQEventTrackViewModel.baseReportUpload(businessType: businessType, objectType: nil, pageSource: nil, extParams: extParams, remindmsg: "发布视频")
  400. }
  401. }
  402. /// 处理视频创作素材搜索上报
  403. /// - Parameters:
  404. /// - businessType: <#businessType description#>
  405. /// - materialList: <#materialList description#>
  406. /// - Returns: <#description#>
  407. public class func dealWithMaterialSearchReportUpload(businessType: businessType, materialList: [PQEditVisionTrackMaterialsModel]) {
  408. if materialList.count > 0 {
  409. DispatchQueue.global().async {
  410. for item in materialList {
  411. materialReportUpload(material: item, businessType: businessType)
  412. }
  413. }
  414. }
  415. }
  416. /// 视频创作素材搜索上报
  417. /// - Parameters:
  418. /// - material:搜索素材
  419. /// - searchId:搜索ID
  420. /// - businessType: <#businessType description#>
  421. /// - pageSource: <#pageSource description#>
  422. /// - Returns: <#description#>
  423. public class func materialReportUpload(material: PQEditVisionTrackMaterialsModel?, businessType: businessType?, objectType: objectType? = nil) {
  424. DispatchQueue.global().async {
  425. var params: [String: Any] = [:]
  426. var eventData: [String: Any] = [:]
  427. var tempObjectType: objectType? = objectType
  428. if tempObjectType == nil, material != nil {
  429. if material?.type == StickerType.GIF.rawValue {
  430. tempObjectType = .ot_makevideo_gif
  431. } else if material?.type == StickerType.VIDEO.rawValue {
  432. tempObjectType = .ot_makevideo_video
  433. } else if material?.type == StickerType.IMAGE.rawValue {
  434. tempObjectType = .ot_makevideo_jpg
  435. }
  436. }
  437. if material?.searchId != nil {
  438. params["searchId"] = material?.searchId
  439. eventData["searchId"] = material?.searchId
  440. }
  441. if material?.localSearchId != nil {
  442. params["localSearchId"] = material?.localSearchId
  443. eventData["localSearchId"] = material?.localSearchId
  444. }
  445. if material?.sliceId != nil {
  446. params["sliceId"] = material?.sliceId
  447. params["videoId"] = material?.sliceId
  448. }
  449. if material?.sourceType != nil {
  450. params["sourceType"] = material?.sourceType
  451. }
  452. PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_videoCompose, businessType: businessType, objectType: tempObjectType, pageSource: .sp_material_search, params: params, eventData: eventData, remindmsg: "视频创作素材搜索")
  453. }
  454. }
  455. /// 站内消息埋点上报
  456. /// - Parameters:
  457. /// - messageIds: 消息Id,多个用逗号分隔
  458. /// - clickId: 子入口点击ID,标识一次子入口点击动作。子入口内消息列表中的消息点击行为都带有此字段,分享空间消息除外
  459. /// - messageType: 消息类型
  460. /// - messageSubType: 消息子类型
  461. /// - actionType: 动作类型(backendCreate:后端构建;backendReturn:后端返回;frontendPull:前端拉取;view:曝光;click:点击)
  462. /// - objectType: <#objectType description#>
  463. /// - pageSource: <#pageSource description#>
  464. /// - readStatus: 已读状态:1:页面上显示未读 2:页面上显示已读
  465. /// - eventData: 扩展数据,json格式,日志系统里会展开存储
  466. /// - extParams: 扩展字段 json格式
  467. /// - remindmsg: 打印提示信息
  468. /// - Returns: <#description#>
  469. public class func messageReportUpload(messageIds: String?, clickId: String?, messageType: messageType?, messageSubType: messageSubType?, actionType: actionType?, objectType: objectType?, pageSource: PAGESOURCE?, readStatus: Int = 1, eventData: [String: Any]? = nil, extParams: [String: Any]? = nil, remindmsg: String? = "基础") {
  470. DispatchQueue.global().async {
  471. var tempParams: [String: Any] = extParams ?? [:]
  472. if messageType != nil, messageType != .mt_nomal {
  473. tempParams["messageType"] = messageType?.rawValue
  474. }
  475. if messageSubType != nil, messageSubType != .mtsub_nomal {
  476. tempParams["messageSubType"] = messageSubType?.rawValue
  477. }
  478. if actionType != nil {
  479. tempParams["actionType"] = actionType?.rawValue
  480. }
  481. if messageIds != nil {
  482. tempParams["messageIds"] = messageIds
  483. }
  484. tempParams["readStatus"] = readStatus + 1
  485. if pageSource != nil {
  486. tempParams["pageSource"] = pageSource?.rawValue
  487. }
  488. // eventData
  489. var tempEventData: [String: Any] = eventData ?? [:]
  490. if objectType != nil {
  491. tempEventData["objectType"] = objectType?.rawValue
  492. }
  493. if tempEventData.keys.count > 0 {
  494. tempParams["eventData"] = dictionaryToJsonString(tempEventData)
  495. }
  496. // extParams
  497. var tempExtParams: [String: Any] = extParams ?? [:]
  498. if clickId != nil {
  499. tempExtParams["clickId"] = clickId
  500. }
  501. if tempExtParams.keys.count > 0 {
  502. tempParams["extParams"] = dictionaryToJsonString(tempExtParams)
  503. }
  504. SWNetRequest.postRequestData(url: PQENVUtil.shared.longvideoapi + messagePeportUrl, parames: tempParams) { _, _, _, _ in
  505. BFLog(message: "\(remindmsg ?? "基础")埋点数据上报:\(tempParams)")
  506. }
  507. }
  508. }
  509. }