123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 |
- //
- // PQEventTrackViewModel.swift
- // PQSpeed
- //
- // Created by SanW on 2020/11/3.
- // Copyright © 2020 BytesFlow. All rights reserved.
- //
- import UIKit
- // MARK: - 埋点数据上报
- /// 埋点数据上报
- public class PQEventTrackViewModel: NSObject {
- /// 基础埋点上报
- /// - Parameters:
- /// - logType: 数据库类型
- /// - businessType: businessType
- /// - objectType: objectType
- /// - eventData: eventData
- /// - pageSource: 页面场景
- /// - extParams: extParams 扩展字段,为json对象
- /// - remindmsg: remindmsg 打印提示信息
- /// - Returns: <#description#>
- 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? = "基础") {
- DispatchQueue.global().async {
- // LogType
- var tempParams: [String: Any] = params ?? [:]
- tempParams["LogType"] = logType.rawValue
- // pageSource
- if pageSource != nil {
- tempParams["pageSource"] = pageSource?.rawValue
- }
- // eventData
- var tempEventData: [String: Any] = eventData ?? [:]
- if objectType != nil {
- tempEventData["objectType"] = objectType?.rawValue
- }
- if businessType != nil {
- tempEventData["businessType"] = businessType?.rawValue
- }
- if tempEventData.keys.count > 0 {
- tempParams["eventData"] = dictionaryToJsonString(tempEventData)
- }
- // extParams
- if extParams != nil, (extParams?.keys.count ?? 0) > 0 {
- tempParams["extParams"] = dictionaryToJsonString(extParams!)
- }
- SWNetRequest.postRequestData(url: PQENVUtil.shared.commonapi + staticsFrontendReportUrl, parames: tempParams) { _, _, _, _ in
- BFLog(message: "\(remindmsg ?? "基础")埋点数据上报:\(tempParams)")
- }
- }
- }
- /// 视频相关上报
- /// - Parameters:
- /// - reportLogType: 上报库类型
- /// - videoData: 视频数据
- /// - pageSource: 页面
- /// - businessType: <#businessType description#>
- /// - objectType: <#objectType description#>
- /// - extParams: <#extParams description#>
- /// - shareId: <#shareId description#>
- /// - videoIds: <#videoIds description#>
- /// - playId: <#playId description#>
- /// - headVideoId: <#headVideoId description#>
- 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) {
- var tempExtParams: [String: Any] = extParams ?? [:]
- if videoData?.reCreateVideoData != nil {
- tempExtParams["projectId"] = videoData?.reCreateVideoData?.projectId ?? ""
- tempExtParams["parentProjectId"] = videoData?.reCreateVideoData?.parentProjectId ?? ""
- tempExtParams["rootProjectId"] = videoData?.reCreateVideoData?.rootProjectId ?? ""
- tempExtParams["canProduce"] = videoData?.reCreateVideoData?.canReproduce ?? 0
- if !tempExtParams.keys.contains("clickedVideoId") {
- tempExtParams["videoId"] = videoData?.uniqueId ?? "0"
- }
- if videoData?.reCreateVideoData?.parentVideoId != nil {
- tempExtParams["parentVideoId"] = videoData?.reCreateVideoData?.parentVideoId ?? ""
- }
- }
- if objectType == .ot_reproduce_clickButton || objectType == .ot_reproduce_collectionBar || objectType == .ot_reproduce_collectionClicButton || objectType == .ot_reproduce_sameSourceButton {
- PQEventTrackViewModel.baseReportUpload(businessType: businessType, objectType: objectType, pageSource: pageSource != nil ? pageSource! : (videoData?.pageSource ?? .sp_category), extParams: tempExtParams, remindmsg: "再创作上报")
- } else {
- 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)
- }
- }
- /// 播放相关数据上报
- /// - Parameters:
- /// - reportLogType: 日志类型
- /// - videoId: 视频Id
- /// - headVideoId: 当前的相关推荐视频是属于哪个视频的相关推荐,值为那个头部视频的videoId
- /// - videoIds: reportLogType_view时传
- /// - pageSource: 页面
- /// - playId: 播放ID 对于每一次播放操作,生成唯一playid,标示唯一一次播放操作,视频播放中暂停,再继续播放时,不算一次新的播放,不需要生成新的playid。重播视频算一次新的播放,即需要生成新的playid。
- /// - recommendId: 推荐链路ID 列表返回
- /// - recommendLogVO: 推荐日志对象 列表返回
- /// - abInfoData: AB信息 列表返回
- /// - measureType:
- /// - measureId:
- /// - businessType: 操作类型
- /// - targetUid: 视频用户ID
- /// - Returns: <#description#>
- 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) {
- DispatchQueue.global().async {
- var params: [String: Any] = ["videoId": videoId, "pageSource": pageSource.rawValue, "playId": playId, "targetUid": targetUid]
- if measureType != nil {
- params["measureType"] = measureType
- }
- if measureId != nil {
- params["measureId"] = measureId
- }
- if recommendId != nil, !(recommendId?.isEmpty ?? true) {
- params["recommendId"] = recommendId
- }
- if recommendLogVO != nil, !(recommendLogVO?.isEmpty ?? true) {
- params["recommendLogVO"] = recommendLogVO
- }
- if abInfoData != nil, !(abInfoData?.isEmpty ?? true) {
- params["abInfoData"] = abInfoData
- }
- if pageSource.rawValue.contains("speedApp-category") {
- params["pageCategoryId"] = 55
- }
- // eventData
- var tempEventData: [String: Any] = Dictionary<String, Any>.init()
- if objectType != nil {
- tempEventData["objectType"] = objectType?.rawValue
- }
- if businessType != nil {
- tempEventData["businessType"] = businessType?.rawValue
- }
- // extParams
- var tempExtParams: [String: Any] = extParams ?? [:]
- if headVideoId != nil, (headVideoId?.count ?? 0) > 0 {
- tempExtParams["headVideoId"] = (headVideoId ?? "0")
- }
- var url: String = PQENVUtil.shared.longvideoapi
- switch reportLogType {
- case .reportLogType_view:
- url = url + videoViewReportUrl
- if videoIds != nil, !videoIds!.isEmpty {
- params["videoIds"] = videoIds
- } else {
- params["videoIds"] = videoId
- }
- params["viewId"] = getUniqueId(desc: "\(videoId)viewId")
- case .reportLogType_realPlay:
- url = url + videoRealPlayReportUrl
- if businessType != nil {
- params["actionTriggerType"] = businessType?.rawValue
- }
- case .reportLogType_play:
- url = url + videoPlayReportUrl
- case .reportLogType_Action:
- url = url + videoActionReportUrl
- if businessType != nil, businessType == .bt_videoShareH5 || businessType == .bt_videoShareFriend {
- params["shareId"] = shareId
- params["rootLaunchShareId"] = shareId
- params["parentShareId"] = shareId
- params["shareDepth"] = "0"
- }
- if businessType != nil {
- params["businessType"] = businessType?.rawValue
- }
- case .reportLogType_Frontend:
- url = PQENVUtil.shared.commonapi + staticsFrontendReportUrl
- params["LogType"] = 30
- params["eventData"] = dictionaryToJsonString(["tabIndex": PQSingletoMemoryUtil.shared.selectedTabIndex ?? "categoryTab", "businessType": businessType?.rawValue ?? ""])
- }
- if tempEventData.keys.count > 0 {
- params["eventData"] = dictionaryToJsonString(tempEventData)
- }
- if tempExtParams.keys.count > 0 {
- params["extParams"] = dictionaryToJsonString(tempExtParams)
- }
- SWNetRequest.postRequestData(url: url, parames: params) { response, _, error, _ in
- BFLog(message: "播放相关数据上报:\(String(describing: error)),\(response ?? [:])")
- }
- }
- }
- // / 分享上报
- // / - Parameters:
- // / - isShareVideo: 是否是分享视频
- // / - screenType: 分享场景 1-分享视频/用户 2-分享视频到朋友圈 3-分享视频到好友
- // / - videoId: 视频Id
- // / - pageSource: 页面枚举
- // / - recommendId: <#recommendId description#>
- // / - recommendLogVO: <#recommendLogVO description#>
- // / - abInfoData: <#abInfoData description#>
- // / - measureType: <#measureType description#>
- // / - measureId: <#measureId description#>
- // / - 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 = "") {
- DispatchQueue.global().async {
- var url: String = PQENVUtil.shared.longvideoapi
- switch screenType {
- case 1:
- url = url + userShareReportUrl
- case 2:
- url = url + userShareH5ReportUrl
- case 3:
- url = url + userShareFriendReportUrl
- default:
- break
- }
- var params: [String: Any] = ["type": isShareVideo ? "1" : "2", "videoId": videoId, "pageSource": pageSource.rawValue, "playId": PQSingletoVideoPlayer.shared.playId, "targetUid": targetUid ?? 0, "shareDepth": "0"]
- if measureType != nil {
- params["measureType"] = measureType
- }
- if measureId != nil {
- params["measureId"] = measureId
- }
- params["shareId"] = shareId
- params["rootLaunchShareId"] = shareId
- params["parentShareId"] = shareId
- params["rootShareId"] = shareId
- if !BFLoginUserInfo.shared.openId.isEmpty {
- params["shareUi"] = BFLoginUserInfo.shared.openId
- }
- if pageSource.rawValue.contains("speedApp-category") {
- params["pageCategoryId"] = 55
- }
- if isShareVideo {
- params["shareObjectId"] = videoId
- } else {
- params["shareObjectId"] = targetUid
- }
- if businessType != nil {
- params["businessType"] = businessType?.rawValue
- }
- if recommendId != nil, !(recommendId?.isEmpty ?? true) {
- params["recommendId"] = recommendId
- }
- if recommendLogVO != nil, !(recommendLogVO?.isEmpty ?? true) {
- params["recommendLogVO"] = recommendLogVO
- }
- if abInfoData != nil, !(abInfoData?.isEmpty ?? true) {
- params["abInfoData"] = abInfoData
- }
- SWNetRequest.postRequestData(url: url, parames: params) { response, _, error, _ in
- BFLog(message: "用户点击分享数据上报:\(String(describing: error)),\(response ?? [:])")
- }
- }
- }
- /// DNS上报
- /// - Returns: <#description#>
- public class func dnsReportUpload() {
- DispatchQueue.global().async {
- let speedExtParams = parseDNS(hostUrl: "speed.piaoquantv.com")
- let rescdnExtParams = parseDNS(hostUrl: "rescdn.yishihui.com")
- if speedExtParams != nil {
- PQEventTrackViewModel.baseReportUpload(businessType: .bt_dnsParseCostTime, objectType: nil, pageSource: nil, eventData: ["tabIndex": PQSingletoMemoryUtil.shared.selectedTabIndex ?? "categoryTab"], extParams: speedExtParams, remindmsg: "dnsParse")
- }
- if rescdnExtParams != nil {
- PQEventTrackViewModel.baseReportUpload(businessType: .bt_dnsParseCostTime, objectType: nil, pageSource: nil, eventData: ["tabIndex": PQSingletoMemoryUtil.shared.selectedTabIndex ?? "categoryTab"], extParams: rescdnExtParams, remindmsg: "dnsParse")
- }
- }
- }
- /// 冷热启动数据上报
- /// - Parameters:
- /// - isHotLaunch 是否是热启动
- /// - logType: <#logType description#>
- /// - eventId: <#eventId description#>
- /// - eventData: <#eventData description#>
- /// - extParams: <#extParams description#>
- /// - pageSource: <#pageSource description#>
- /// - Returns: <#description#>
- class public func reportStatisticsUpload(isHotLaunch: Bool = false, logType: statisticsLogType, coldLaunchType _: coldLaunchType = .coldLaunchType_userActiveOpen, eventId _: String?, eventData _: String?, pageSource: PAGESOURCE?) {
- DispatchQueue.global().async {
- var params: [String: Any] = ["LogType": logType.rawValue]
- if PQSingletoMemoryUtil.shared.isColdLaunch {
- // 1-请求中 2-请求成功 3-请求失败
- if PQSingletoMemoryUtil.shared.coldLaunchStatus != 2 {
- PQSingletoMemoryUtil.shared.coldLaunchStatus = 1
- } else {
- return
- }
- }
- params["eventData"] = dictionaryToJsonString(["tabIndex": PQSingletoMemoryUtil.shared.selectedTabIndex ?? "categoryTab"])
- // 参数
- var extParams: [String: Any] = Dictionary<String, Any>.init()
- extParams["downloadChannel"] = channelID
- extParams["launchParams"] = PQSingletoMemoryUtil.shared.commandLaunchParams
- if pageSource?.rawValue.contains("speedApp-category") ?? false {
- params["pageCategoryId"] = 55
- }
- if PQSingletoMemoryUtil.shared.commandReportParams != nil {
- for (key, value) in PQSingletoMemoryUtil.shared.commandReportParams!.reversed() {
- extParams[key] = value
- }
- }
- if !isHotLaunch {
- extParams["coldLaunchType"] = (PQSingletoMemoryUtil.shared.coldLaunchType ?? .coldLaunchType_userActiveOpen).rawValue
- } else {
- extParams["hotLaunchType"] = (PQSingletoMemoryUtil.shared.coldLaunchType ?? .coldLaunchType_userActiveOpen).rawValue
- }
- if pageSource != nil {
- params["pageSource"] = pageSource!.rawValue
- }
- // 是否第一次安装
- let firstInstall: String? = getUserDefaults(key: cFirstInstall) as? String
- if firstInstall == nil || (firstInstall?.count ?? 0 <= 0) || firstInstall != "1" {
- extParams["isFirstLaunch"] = 1
- } else {
- extParams["isFirstLaunch"] = 0
- }
- params["extParams"] = dictionaryToJsonString(extParams)
- // 是否第一次安装
- let firstParams: String? = getUserDefaults(key: cFirstParams) as? String
- if (firstInstall == nil || firstInstall?.count ?? 0 <= 0 || firstInstall != "1") && (firstParams != nil && ((firstParams?.count ?? 0) > 0)) {
- params = jsonStringToDictionary(firstParams!) ?? Dictionary<String, Any>.init()
- }
- if firstParams == nil || ((firstParams?.count ?? 0) <= 0) {
- saveUserDefaults(key: cFirstParams, value: dictionaryToJsonString(params) ?? "")
- }
- SWNetRequest.postRequestData(url: PQENVUtil.shared.commonapi + staticsFrontendReportUrl, parames: params) { response, _, error, _ in
- BFLog(message: "冷热启动上报:\(String(describing: error)),\(response ?? [:]),params = \(params)")
- if PQSingletoMemoryUtil.shared.isColdLaunch {
- PQSingletoMemoryUtil.shared.coldLaunchStatus = error == nil ? 2 : 3
- }
- // 清空启动数据
- PQSingletoMemoryUtil.shared.coldLaunchType = nil
- if error == nil, firstInstall == nil || firstInstall?.count ?? 0 <= 0 || firstInstall != "1" {
- saveUserDefaults(key: cFirstInstall, value: "1")
- }
- saveUserDefaults(key: cSelectedTabIndex, value: "categoryTab")
- }
- }
- }
- /// 推送点击数据上报
- /// - Parameters:
- /// - pushId: 推送Id
- /// - pushTargetType: 1-推送单个视频 2-整体关注有更新 3-关注单个up主有更新(暂废弃) 4-订阅某人有更新
- /// - pushBrand: 推送平台 APPLE_TYPE
- /// - pushTargetId: pushTargetType == 1 视频ID,pushTargetType == 4 用户ID
- /// - bizParam 扩展参数
- /// - Returns: <#description#>
- public class func reportPushActionUpload(pushId: String, pushTargetType: Int, pushBrand: String = cPushChannel, pushTargetId: String?,bizParam : [String: Any]? = nil) {
- DispatchQueue.global().async {
- var params: [String: Any] = bizParam ?? Dictionary<String,Any>.init()
- if pushTargetId != nil {
- params["pushTargetId"] = pushTargetId
- }
- if pushId.count > 0 {
- params["pushId"] = pushId
- }
- params["pushTargetType"] = pushTargetType
- params["pushBrand"] = pushBrand
- params["pushReportType"] = "click"
- if params.keys.contains("aps"){
- params.removeValue(forKey: "aps")
- }
- SWNetRequest.postRequestData(url: PQENVUtil.shared.longvideoapi + pushActionReportUrl, parames: params) { response, _, error, _ in
- BFLog(message: "推送点击数据上报:\(String(describing: error)),\(response ?? [:])")
- }
- }
- }
- /// 上报deviceToken
- /// - Parameter registerId: 设备id
- /// - Parameter deviceToken: <#deviceToken description#>
- /// - Returns: <#description#>
- public class func reportPushDeviceTokenUpload(registerId: String, deviceToken: String, completeHander: @escaping (_ isSuccess: Bool) -> Void) {
- DispatchQueue.global().async {
- SWNetRequest.postRequestData(url: PQENVUtil.shared.longvideoapi + pushDeviceTokenReportUrl, parames: ["registerId": registerId, "deviceToken": deviceToken, "brand": cPushChannel]) { response, _, error, _ in
- completeHander(error == nil ? true : false)
- BFLog(message: "deviceToken数据上报:\(String(describing: error)),\(response ?? [:])")
- }
- }
- }
- /// 搜索上报
- /// - Parameters:
- /// - keyWord: 搜索词
- /// - searchType: 1 热搜词搜索 2 历史记录 3 普通搜索
- /// - searchNumber: 数量
- /// - reportType: 1 into 2 click 3 show
- /// - Returns: <#description#>
- public class func searchReportUpload(keyWord: String, searchType: Int, searchNumber: Int = 10, reportType: Int = 2) {
- DispatchQueue.global().async {
- let params: [String: Any] = ["keyWord": keyWord, "searchType": searchType, "searchNumber": searchNumber, "reportType": reportType]
- SWNetRequest.postRequestData(url: PQENVUtil.shared.longvideoapi + searchReportUrl, parames: params) { response, _, error, _ in
- BFLog(message: "搜索数据上报:\(String(describing: error)),\(response ?? [:])")
- }
- }
- }
- /// 发布视频的上报
- /// - Parameters:
- /// - projectId:项目ID-发布创作的视频时必传,会在进入创作工具页时生成,以app_no_projectdata为前缀
- /// - businessType: <#businessType description#>
- /// - ossInfo: <#ossInfo description#>
- /// - params: <#params description#>
- /// - Returns: <#description#>
- public class func publishReportUpload(projectId: String?, businessType: businessType, ossInfo: [String: Any], params: [String: Any]) {
- DispatchQueue.global().async {
- var extParams: [String: Any] = ["ossInfo": dictionaryToJsonString(ossInfo) ?? "", "params": dictionaryToJsonString(params) ?? ""]
- if projectId != nil {
- extParams["projectId"] = projectId
- }
- if !extParams.keys.contains("source") {
- extParams["source"] = projectId != nil ? "videoCompose" : "videoUpload"
- }
- PQEventTrackViewModel.baseReportUpload(businessType: businessType, objectType: nil, pageSource: nil, extParams: extParams, remindmsg: "发布视频")
- }
- }
- /// 处理视频创作素材搜索上报
- /// - Parameters:
- /// - businessType: <#businessType description#>
- /// - materialList: <#materialList description#>
- /// - Returns: <#description#>
- public class func dealWithMaterialSearchReportUpload(businessType: businessType, materialList: [PQEditVisionTrackMaterialsModel]) {
- if materialList.count > 0 {
- DispatchQueue.global().async {
- for item in materialList {
- materialReportUpload(material: item, businessType: businessType)
- }
- }
- }
- }
- /// 视频创作素材搜索上报
- /// - Parameters:
- /// - material:搜索素材
- /// - searchId:搜索ID
- /// - businessType: <#businessType description#>
- /// - pageSource: <#pageSource description#>
- /// - Returns: <#description#>
- public class func materialReportUpload(material: PQEditVisionTrackMaterialsModel?, businessType: businessType?, objectType: objectType? = nil) {
- DispatchQueue.global().async {
- var params: [String: Any] = [:]
- var eventData: [String: Any] = [:]
- var tempObjectType: objectType? = objectType
- if tempObjectType == nil, material != nil {
- if material?.type == StickerType.GIF.rawValue {
- tempObjectType = .ot_makevideo_gif
- } else if material?.type == StickerType.VIDEO.rawValue {
- tempObjectType = .ot_makevideo_video
- } else if material?.type == StickerType.IMAGE.rawValue {
- tempObjectType = .ot_makevideo_jpg
- }
- }
- if material?.searchId != nil {
- params["searchId"] = material?.searchId
- eventData["searchId"] = material?.searchId
- }
- if material?.localSearchId != nil {
- params["localSearchId"] = material?.localSearchId
- eventData["localSearchId"] = material?.localSearchId
- }
- if material?.sliceId != nil {
- params["sliceId"] = material?.sliceId
- params["videoId"] = material?.sliceId
- }
- if material?.sourceType != nil {
- params["sourceType"] = material?.sourceType
- }
- PQEventTrackViewModel.baseReportUpload(logType: .st_log_type_videoCompose, businessType: businessType, objectType: tempObjectType, pageSource: .sp_material_search, params: params, eventData: eventData, remindmsg: "视频创作素材搜索")
- }
- }
- /// 站内消息埋点上报
- /// - Parameters:
- /// - messageIds: 消息Id,多个用逗号分隔
- /// - clickId: 子入口点击ID,标识一次子入口点击动作。子入口内消息列表中的消息点击行为都带有此字段,分享空间消息除外
- /// - messageType: 消息类型
- /// - messageSubType: 消息子类型
- /// - actionType: 动作类型(backendCreate:后端构建;backendReturn:后端返回;frontendPull:前端拉取;view:曝光;click:点击)
- /// - objectType: <#objectType description#>
- /// - pageSource: <#pageSource description#>
- /// - readStatus: 已读状态:1:页面上显示未读 2:页面上显示已读
- /// - eventData: 扩展数据,json格式,日志系统里会展开存储
- /// - extParams: 扩展字段 json格式
- /// - remindmsg: 打印提示信息
- /// - Returns: <#description#>
- 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? = "基础") {
- DispatchQueue.global().async {
- var tempParams: [String: Any] = extParams ?? [:]
- if messageType != nil, messageType != .mt_nomal {
- tempParams["messageType"] = messageType?.rawValue
- }
- if messageSubType != nil, messageSubType != .mtsub_nomal {
- tempParams["messageSubType"] = messageSubType?.rawValue
- }
- if actionType != nil {
- tempParams["actionType"] = actionType?.rawValue
- }
- if messageIds != nil {
- tempParams["messageIds"] = messageIds
- }
- tempParams["readStatus"] = readStatus + 1
- if pageSource != nil {
- tempParams["pageSource"] = pageSource?.rawValue
- }
- // eventData
- var tempEventData: [String: Any] = eventData ?? [:]
- if objectType != nil {
- tempEventData["objectType"] = objectType?.rawValue
- }
- if tempEventData.keys.count > 0 {
- tempParams["eventData"] = dictionaryToJsonString(tempEventData)
- }
- // extParams
- var tempExtParams: [String: Any] = extParams ?? [:]
- if clickId != nil {
- tempExtParams["clickId"] = clickId
- }
- if tempExtParams.keys.count > 0 {
- tempParams["extParams"] = dictionaryToJsonString(tempExtParams)
- }
- SWNetRequest.postRequestData(url: PQENVUtil.shared.longvideoapi + messagePeportUrl, parames: tempParams) { _, _, _, _ in
- BFLog(message: "\(remindmsg ?? "基础")埋点数据上报:\(tempParams)")
- }
- }
- }
- }
|