Browse Source

1.add event report

wenweiwei 3 years ago
parent
commit
8c79c53bc4

+ 4 - 0
Introduce.xcodeproj/project.pbxproj

@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		2D80D52B2773528C00D24520 /* INAppConfigUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D80D52A2773528C00D24520 /* INAppConfigUtil.swift */; };
 		415C49D22763022900814766 /* Resources.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 415C49D12763022900814766 /* Resources.bundle */; };
 		41A112792766E12C0093BBF0 /* PQConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = 41A112782766E12C0093BBF0 /* PQConfig.plist */; };
 		4A426DDD275484DF00B3733B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A426DDC275484DF00B3733B /* AppDelegate.swift */; };
@@ -21,6 +22,7 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		2D80D52A2773528C00D24520 /* INAppConfigUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = INAppConfigUtil.swift; sourceTree = "<group>"; };
 		3051DB0957784182F3E1AAD3 /* Pods-Introduce.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Introduce.release.xcconfig"; path = "Target Support Files/Pods-Introduce/Pods-Introduce.release.xcconfig"; sourceTree = "<group>"; };
 		3D67E85C017389B87957100F /* Pods_Introduce.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Introduce.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		415C49D12763022900814766 /* Resources.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Resources.bundle; path = Aarchitecture/Resources.bundle; sourceTree = "<group>"; };
@@ -108,6 +110,7 @@
 				4A426DF92754A47700B3733B /* INPhotoVideosController.swift */,
 				4A426DFB2754A4B200B3733B /* INIntroduceController.swift */,
 				4A426DFD2754A4F600B3733B /* INVideoExportController.swift */,
+				2D80D52A2773528C00D24520 /* INAppConfigUtil.swift */,
 			);
 			path = Record;
 			sourceTree = "<group>";
@@ -272,6 +275,7 @@
 			files = (
 				4A426DFA2754A47700B3733B /* INPhotoVideosController.swift in Sources */,
 				4A426DDD275484DF00B3733B /* AppDelegate.swift in Sources */,
+				2D80D52B2773528C00D24520 /* INAppConfigUtil.swift in Sources */,
 				4A426DF52754A27D00B3733B /* INRecorderController.swift in Sources */,
 				4A426DFE2754A4F600B3733B /* INVideoExportController.swift in Sources */,
 				4A426DFC2754A4B200B3733B /* INIntroduceController.swift in Sources */,

+ 32 - 16
Introduce/Aarchitecture/AppDelegate.swift

@@ -12,21 +12,20 @@ import UIKit
 @main
 class AppDelegate: UIResponder, UIApplicationDelegate {
     var window: UIWindow?
-
-    func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
-        // Override point for customization after application launch.
-        BFConfig.shared.styleColor = .intrGreen
-        BFConfig.shared.statusBarStyle = .light
-        BFConfig.shared.styleBackGroundColor = UIColor.black
-        BFConfig.shared.styleTitleColor = UIColor.white
-        BFConfig.shared.cutViewStyleColor = UIColor.white
-        BFConfig.shared.cutViewTintColor = UIColor.black
-        BFConfig.shared.pointEditNamalBackgroundColor = UIColor.hexColor(hexadecimal: "#1A1A1A")
-        BFMaterialConfig.shared.materialDeleteImage = UIImage.moduleImage(named: "icon_search_delete", moduleName: "BFMaterialKit") ?? UIImage()
-        BFConfig.shared.cutDurationColor = UIColor(red: 238.0 / 255.0, green: 0 / 255.0, blue: 81.0 / 255.0, alpha: 0.1)
-        BFConfig.shared.hiddenMusicMask = false
-        BFConfig.shared.otherTintColor = UIColor.hexColor(hexadecimal: "#333333")
-        BFConfig.shared.statusBarStyle = .light
+    var isEnterBack: Bool = false // 进入后台
+    var notificationUserInfo: [String: Any]?
+    
+    func application(_: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
+        // 初始化配置
+        INAppConfigUtil.pageConfig()
+        if launchOptions?.keys.contains(UIApplication.LaunchOptionsKey.remoteNotification) ?? false {
+            notificationUserInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any]
+            if notificationUserInfo != nil && notificationUserInfo?.keys.contains("type") ?? false {
+                PQSingletoMemoryUtil.shared.coldLaunchType = .coldLaunchType_pushRecall
+            }
+        }
+        // 配置启动项
+        INAppConfigUtil.applicationConfig(launchOptions:launchOptions)
 //        BFMaterialConfig.shared.choseType = .single
         return true
     }
@@ -35,9 +34,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 
     func applicationWillResignActive(_: UIApplication) {}
 
-    func applicationDidEnterBackground(_: UIApplication) {}
+    func applicationDidEnterBackground(_: UIApplication) {
+        // 热启动重新生成SubSesstionId
+        isEnterBack = true
+        PQSingletoMemoryUtil.shared.createSubSesstionId()
+        BFConfig.shared.subSessionId = getUniqueId(desc: "subSessionid")
+    }
 
     func application(_: UIApplication, supportedInterfaceOrientationsFor _: UIWindow?) -> UIInterfaceOrientationMask {
         return UIInterfaceOrientationMask.portrait
     }
+    
+
+    func applicationDidBecomeActive(_: UIApplication) {
+        BFLog(message: "applicationDidBecomeActive")
+        if isEnterBack {
+            // 热启动
+            PQSingletoMemoryUtil.shared.isColdLaunch = false
+            // 热启动上报
+            INAppConfigUtil.appLaunchReportUpload(isHotLaunch: true)
+            isEnterBack = false
+        }
+    }
 }

+ 66 - 0
Introduce/Record/INAppConfigUtil.swift

@@ -0,0 +1,66 @@
+//
+//  INAppConfigUtil.swift
+//  Introduce
+//
+//  Created by SanW on 2021/12/22.
+//  Copyright © 2021 BytesFlow. All rights reserved.
+//
+
+import BFAnalyzeKit
+import BFCommonKit
+import BFMaterialKit
+import UIKit
+
+/// <#Description#>
+class INAppConfigUtil: NSObject {
+    class func pageConfig() {
+        BFConfig.shared.appType = "20"
+        BFConfig.shared.appId = "1599191466"
+        BFConfig.shared.styleColor = .intrGreen
+        BFConfig.shared.statusBarStyle = .light
+        BFConfig.shared.styleBackGroundColor = UIColor.black
+        BFConfig.shared.styleTitleColor = UIColor.white
+        BFConfig.shared.cutViewStyleColor = UIColor.white
+        BFConfig.shared.cutViewTintColor = UIColor.black
+        BFConfig.shared.pointEditNamalBackgroundColor = UIColor.hexColor(hexadecimal: "#1A1A1A")
+        BFMaterialConfig.shared.materialDeleteImage = UIImage.moduleImage(named: "icon_search_delete", moduleName: "BFMaterialKit") ?? UIImage()
+        BFConfig.shared.cutDurationColor = UIColor(red: 238.0 / 255.0, green: 0 / 255.0, blue: 81.0 / 255.0, alpha: 0.1)
+        BFConfig.shared.hiddenMusicMask = false
+        BFConfig.shared.otherTintColor = UIColor.hexColor(hexadecimal: "#333333")
+        BFConfig.shared.statusBarStyle = .light
+    }
+
+    class func applicationConfig(launchOptions _: [UIApplication.LaunchOptionsKey: Any]?) {
+//        // 初始化友盟
+//        CMUMApiUtil.registerUM(umAppkey: "6114dfeb1fee2e303c1fa189")
+//        // 初始化Bugly
+//        CMBuglyUtil.registerBugly(appID: "87b0f37276", deviceId: getMachineCode())
+//        // 注册推送
+//        CMUMApiUtil.registerUMPush(launchOptions: launchOptions) { granted, _ in
+//            debugPrint("注册推送:\(granted ? "成功" : "失败")")
+//        }
+//        // 处理口令
+//        PQBoardCommandUtil.dealWithPasteboardData()
+        // 冷热启动上报
+        appLaunchReportUpload()
+    }
+
+    // 冷热启动上报
+    class func appLaunchReportUpload(isHotLaunch: Bool = false) {
+        // 冷启动
+        PQSingletoMemoryUtil.shared.isColdLaunch = true
+        // 是否第一次安装
+        var isFirstLaunch: Int = 1
+        let firstInstall: String? = getUserDefaults(key: cFirstInstall) as? String
+        if firstInstall == nil || (firstInstall?.count ?? 0 <= 0) || firstInstall != "1" {
+            isFirstLaunch = 1
+        } else {
+            isFirstLaunch = 0
+        }
+        // 冷启动上报
+        BFEventTrackAdaptor.appLaunchReportUpload(isFirstLaunch: isFirstLaunch, firstParams: nil, isHotLaunch: isHotLaunch, launchType: PQSingletoMemoryUtil.shared.coldLaunchType?.rawValue ?? "userActiveOpen", commonParams: commonParams())
+        // 清空启动数据
+        PQSingletoMemoryUtil.shared.coldLaunchType = nil
+        saveUserDefaults(key: cFirstInstall, value: "1")
+    }
+}

+ 8 - 0
Introduce/Record/INIntroduceController.swift

@@ -11,6 +11,7 @@ import BFUIKit
 import Foundation
 import Photos
 import UIKit
+import BFAnalyzeKit
 
 class INIntroduceController: BFBaseViewController {
     var stripSwithView: BFStripSwithView?
@@ -71,8 +72,15 @@ class INIntroduceController: BFBaseViewController {
             stripSwithView?.center.y = backButton?.center.y ?? 0
             stripSwithView?.itemClickHandle = { [weak self] _, index in
                 self?.recordScreenVC.updateContentOffset(index: index)
+                if (self?.assets?.count ?? 0) > index {
+                    // 曝光上报
+                    BFEventTrackAdaptor.baseReportUpload(businessType: .bt_pageView, objectType: self?.assets?[index].mediaType == .video ? .ot_video: .ot_image, pageSource: .sp_speekPage, commonParams: commonParams())
+                }
             }
             navHeadImageView?.addSubview(stripSwithView!)
+        } else if assets != nil,(assets?.count ?? 0) > 0 {
+            // 曝光上报
+            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_pageView, objectType: assets?.first?.mediaType == .video ? .ot_video: .ot_image, pageSource: .sp_speekPage, commonParams: commonParams())
         }
     }
 

+ 5 - 0
Introduce/Record/INRecorderController.swift

@@ -12,6 +12,7 @@ import Foundation
 import UIKit
 import TYAttributedLabel
 import BFCommonKit
+import BFAnalyzeKit
 
 public let cUserProtocol = "https://weapppiccdn.yishihui.com/resources/agreements/videoservice.html?type=15"
 /** 隐私政策 */
@@ -98,6 +99,8 @@ class INRecorderController: BFBaseViewController {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         hiddenNavigation()
+        // 曝光上报
+        BFEventTrackAdaptor.baseReportUpload(businessType: .bt_pageView, objectType: nil, pageSource: .sp_homePage, commonParams: commonParams())
     }
 
     override func viewDidLoad() {
@@ -194,6 +197,8 @@ class INRecorderController: BFBaseViewController {
             let vc = INPhotoVideosController()
             vc.hidesBottomBarWhenPushed = true
             navigationController?.pushViewController(vc, animated: true)
+            // 按钮点击
+            BFEventTrackAdaptor.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_addVideo, pageSource: .sp_homePage, commonParams: commonParams())
         }
     }
 }

+ 6 - 1
Podfile

@@ -27,7 +27,8 @@ target 'Introduce' do
   pod 'BFLogger',              :git => 'https://git.yishihui.com/iOS/BFLogger.git'
   pod 'BFMediaKit',            :git => 'https://git.yishihui.com/iOS/BFMediaKit.git'
   pod 'BFRecordScreenKit',     :git => 'https://git.yishihui.com/iOS/BFRecordScreenKit.git'
-
+  pod 'BFAnalyzeKit',          :git => 'https://git.yishihui.com/iOS/BFAnalyzeKit.git'
+  
 ## ak:Pods-for-testing
 #  pod 'BFCommonKit',           :path => '/Users/ak/Desktop/TZFrameworks/BFCommonKit/'
 #  pod 'BFNetRequestKit',       :path => '/Users/ak/Desktop/TZFrameworks/BFNetRequestKit/'
@@ -36,6 +37,7 @@ target 'Introduce' do
 #  pod 'BFLogger',              :path => '/Users/ak/Desktop/TZFrameworks/BFLogger/'
 #  pod 'BFMediaKit',            :path => '/Users/ak/Desktop/TZFrameworks/BFMediaKit/'
 #  pod 'BFRecordScreenKit',     :path => '/Users/ak/Desktop/TZFrameworks/BFRecordScreenKit/'
+#  pod 'BFAnalyzeKit',          :path => '/Users/ak/Desktop/TZFrameworks/BFAnalyzeKit/'
 
 ## zq:Pods-for-testing
 #  pod 'BFCommonKit',           :path => '../BFCommonKit/'
@@ -45,6 +47,7 @@ target 'Introduce' do
 #  pod 'BFLogger',              :path => '../BFLogger/'
 #  pod 'BFMediaKit',            :path => '../BFMediaKit/'
 #  pod 'BFRecordScreenKit',     :path => '../BFRecordScreenKit/'
+#  pod 'BFAnalyzeKit',          :path => '../BFAnalyzeKit/'
 
 ## ww:Pods-for-testing
 #  pod 'BFCommonKit',           :path => '../../BFCommonKit/Trunk'
@@ -54,6 +57,8 @@ target 'Introduce' do
 #  pod 'BFLogger',              :path => '../../BFLogger/Trunk'
 #  pod 'BFMediaKit',            :path => '../../BFMediaKit/Trunk'
 #  pod 'BFRecordScreenKit',     :path => '../../BFRecordScreenKit/Trunk'
+#  pod 'BFAnalyzeKit',          :path => '../../BFAnalyzeKit/Trunk'
+
 
   
   post_install do |installer|