|
@@ -1,551 +0,0 @@
|
|
|
-//
|
|
|
-// PQEventTrackViewModel.swift
|
|
|
-// PQSpeed
|
|
|
-//
|
|
|
-// Created by SanW on 2020/11/3.
|
|
|
-// Copyright © 2020 BytesFlow. All rights reserved.
|
|
|
-//
|
|
|
-
|
|
|
-import UIKit
|
|
|
-import BFCommonKit
|
|
|
-import BFNetRequestKit
|
|
|
-import BFMediaKit
|
|
|
-
|
|
|
-// 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!)
|
|
|
- }
|
|
|
- BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.commonapi + staticsFrontendReportUrl, parames: tempParams,commonParams: commonParams()) { _, _, _, _ 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: 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 (videoData?.pageSource == .sp_cmunit_joinTopic || pageSource == .sp_cmunit_joinTopic) && "\(tempExtParams["topicId"] ?? "")".count <= 0 {
|
|
|
- tempExtParams["topicId"] = "\(videoData?.topicData?["id"] ?? "")"
|
|
|
- } else if (videoData?.pageSource == .sp_cmunit_follow || pageSource == .sp_cmunit_follow) && "\(tempExtParams["followedUid"] ?? "")".count <= 0 {
|
|
|
- tempExtParams["followedUid"] = "\(videoData?.user?["uid"] ?? "")"
|
|
|
- }
|
|
|
- }
|
|
|
- if videoData is PQVideoListModel {
|
|
|
- if (videoData as? PQVideoListModel)?.reCreateVideoData != nil {
|
|
|
- tempExtParams["projectId"] = (videoData as? PQVideoListModel)?.reCreateVideoData?.projectId ?? ""
|
|
|
- tempExtParams["parentProjectId"] = (videoData as? PQVideoListModel)?.reCreateVideoData?.parentProjectId ?? ""
|
|
|
- tempExtParams["rootProjectId"] = (videoData as? PQVideoListModel)?.reCreateVideoData?.rootProjectId ?? ""
|
|
|
- tempExtParams["canProduce"] = (videoData as? PQVideoListModel)?.reCreateVideoData?.canReproduce ?? 0
|
|
|
- if !tempExtParams.keys.contains("clickedVideoId") {
|
|
|
- tempExtParams["videoId"] = "\(videoData?.id ?? 0)"
|
|
|
- }
|
|
|
- if (videoData as? PQVideoListModel)?.reCreateVideoData?.parentVideoId != nil {
|
|
|
- tempExtParams["parentVideoId"] = (videoData as? PQVideoListModel)?.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?.id ?? 0)", headVideoId: headVideoId ?? videoData?.headVideoId, videoIds: (videoIds == nil ? "\(videoData?.id ?? 0)" : videoIds), pageSource: pageSource != nil ? pageSource! : (videoData?.pageSource ?? .sp_category), playId: playId ?? "", recommendId: videoData?.recommendId, recommendLogVO: videoData?.recommendLogVO,flowPool:videoData?.flowPool, 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?,flowPool: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 flowPool != nil, (flowPool?.count ?? 0) > 0 {
|
|
|
- params["flowPool"] = flowPool
|
|
|
- }
|
|
|
- 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
|
|
|
- }
|
|
|
- tempEventData["pageSource"] = pageSource.rawValue
|
|
|
- // extParams
|
|
|
- var tempExtParams: [String: Any] = extParams ?? [:]
|
|
|
- if headVideoId != nil, (headVideoId?.count ?? 0) > 0 {
|
|
|
- tempExtParams["headVideoId"] = (headVideoId ?? "0")
|
|
|
- }
|
|
|
- if videoId.count > 0 {
|
|
|
- tempExtParams["videoId"] = videoId
|
|
|
- }
|
|
|
- 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"
|
|
|
- params["videoId"] = videoIds
|
|
|
- }
|
|
|
- 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)
|
|
|
- }
|
|
|
- BFNetRequestAdaptor.postRequestData(url: url, parames: params,commonParams: commonParams()) { 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?,flowPool:String?, abInfoData: String?, measureType: Int?, measureId: Int?, businessType: businessType?, targetUid: Int?, shareId: String = "",playId:String?,extParams: [String: Any]? = nil) {
|
|
|
- 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": playId ?? "", "targetUid": targetUid ?? 0, "shareDepth": "0"]
|
|
|
- if extParams != nil {
|
|
|
- params["extParams"] = dictionaryToJsonString(extParams!)
|
|
|
- }
|
|
|
- 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 flowPool != nil, (flowPool?.count ?? 0) > 0 {
|
|
|
- params["flowPool"] = flowPool
|
|
|
- }
|
|
|
- if abInfoData != nil, !(abInfoData?.isEmpty ?? true) {
|
|
|
- params["abInfoData"] = abInfoData
|
|
|
- }
|
|
|
- BFNetRequestAdaptor.postRequestData(url: url, parames: params,commonParams: commonParams()) { 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) ?? "")
|
|
|
- }
|
|
|
- BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.commonapi + staticsFrontendReportUrl, parames: params,commonParams: commonParams()) { 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")
|
|
|
- }
|
|
|
- BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + pushActionReportUrl, parames: params,commonParams: commonParams()) { 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 {
|
|
|
- BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + pushDeviceTokenReportUrl, parames: ["registerId": registerId, "deviceToken": deviceToken, "brand": cPushChannel],commonParams: commonParams()) { 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]
|
|
|
- BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + searchReportUrl, parames: params,commonParams: commonParams()) { 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)
|
|
|
- }
|
|
|
- BFNetRequestAdaptor.postRequestData(url: PQENVUtil.shared.longvideoapi + messagePeportUrl, parames: tempParams,commonParams: commonParams()) { _, _, _, _ in
|
|
|
- BFLog(message: "\(remindmsg ?? "基础")埋点数据上报:\(tempParams)")
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|