Commit 9d412b49 authored by pete谢兆麟's avatar pete谢兆麟

埋点SDK接入

parent c85b9d71
......@@ -61,7 +61,8 @@ target 'galaxy' do
#crash统计
pod 'Bugly','2.5.93'
#神策数据分析
pod 'SensorsAnalyticsSDK'
end
......
......@@ -12,6 +12,7 @@
0468D4242B494BEA00CFB916 /* YHCodeResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4232B494BEA00CFB916 /* YHCodeResultViewController.swift */; };
0468D4262B495A5400CFB916 /* YHPickPhoneAddressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4252B495A5400CFB916 /* YHPickPhoneAddressViewController.swift */; };
0468D4282B50D4AF00CFB916 /* YHPrivacyAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4272B50D4AF00CFB916 /* YHPrivacyAlertView.swift */; };
0468D42B2B55019900CFB916 /* YHAnalytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D42A2B55019900CFB916 /* YHAnalytics.swift */; };
04808C062B4686510056D53C /* ATAuthSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 04808C042B4686510056D53C /* ATAuthSDK.bundle */; };
04808C082B4686C10056D53C /* ATAuthSDK_D.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 04808C032B4686510056D53C /* ATAuthSDK_D.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
049A48A82B49417300D0C641 /* YHAboutUsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */; };
......@@ -121,6 +122,7 @@
0468D4232B494BEA00CFB916 /* YHCodeResultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCodeResultViewController.swift; sourceTree = "<group>"; };
0468D4252B495A5400CFB916 /* YHPickPhoneAddressViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPickPhoneAddressViewController.swift; sourceTree = "<group>"; };
0468D4272B50D4AF00CFB916 /* YHPrivacyAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPrivacyAlertView.swift; sourceTree = "<group>"; };
0468D42A2B55019900CFB916 /* YHAnalytics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAnalytics.swift; sourceTree = "<group>"; };
04808C032B4686510056D53C /* ATAuthSDK_D.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ATAuthSDK_D.framework; sourceTree = "<group>"; };
04808C042B4686510056D53C /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = ATAuthSDK.bundle; sourceTree = "<group>"; };
049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsViewController.swift; sourceTree = "<group>"; };
......@@ -226,6 +228,14 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0468D4292B55017400CFB916 /* Analytics */ = {
isa = PBXGroup;
children = (
0468D42A2B55019900CFB916 /* YHAnalytics.swift */,
);
path = Analytics;
sourceTree = "<group>";
};
04808C022B4686510056D53C /* Frameworks */ = {
isa = PBXGroup;
children = (
......@@ -409,6 +419,7 @@
A5ACE8EE2B4564F7002C94D2 /* Tools */ = {
isa = PBXGroup;
children = (
0468D4292B55017400CFB916 /* Analytics */,
04AF58BA2B4FB71C0066011A /* Localized */,
A5ACE8F12B4564F7002C94D2 /* NetWork */,
A5ACE8F72B4564F7002C94D2 /* Extention */,
......@@ -843,6 +854,7 @@
A5ACE9492B4564F7002C94D2 /* BsHUDSuccessView.swift in Sources */,
A5ACE9432B4564F7002C94D2 /* UILable+Extension.swift in Sources */,
A5ACE9382B4564F7002C94D2 /* UIApplication+Extension.swift in Sources */,
0468D42B2B55019900CFB916 /* YHAnalytics.swift in Sources */,
A5ACE93C2B4564F7002C94D2 /* UIColor+Extension.swift in Sources */,
A5C5B2EA2B4ECA4D00A7C5D1 /* YHDavidModel0.swift in Sources */,
A5ACE9572B4564F7002C94D2 /* YHBasicContentView.swift in Sources */,
......
......@@ -30,6 +30,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
//3.其他第三方sdk设置
thirdSetting()
YHAnalytics.analyticsStart(launchOptions: launchOptions)
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if YHAnalytics.handleSchemeUrl(url) ?? false {
return true
}
return true
}
......
......@@ -32,6 +32,16 @@ class YHLoginViewController: YHBaseViewController {
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
YHAnalytics.timeStrat("loginTime")
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
YHAnalytics.timeEnd("loginTime")
}
func setView() {
bgImageView = {
let imageView = UIImageView()
......@@ -194,6 +204,7 @@ class YHLoginViewController: YHBaseViewController {
}
@objc func messageLogin() {
YHAnalytics.track("Login")
if privacyView.isAgree {
let vc = YHVerificationCodeLoginController()
self.navigationController?.pushViewController(vc)
......
......@@ -7,7 +7,6 @@
//
import UIKit
import RxSwift
class YHPrivacyAlertView: UIView {
typealias Block = () -> ()
......
//
// YHAnalytics.swift
// galaxy
//
// Created by EDY on 2024/1/15.
// Copyright © 2024 www.davidhuang.com. All rights reserved.
//
import UIKit
import SensorsAnalyticsSDK
class YHAnalytics {
// 分析初始化
static func analyticsStart(launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
let options = SAConfigOptions.init(serverURL: "url地址,由管理员提供", launchOptions: launchOptions)
//开启全埋点
options.autoTrackEventType = [.eventTypeAppStart, .eventTypeAppEnd, .eventTypeAppClick, .eventTypeAppViewScreen]
#if DEBUG
//开启log
options.enableLog = true
#endif
/**
* 其他配置,如开启可视化全埋点
*/
//初始化SDK
SensorsAnalyticsSDK.start(configOptions: options)
}
//处理数据的Url
static func handleSchemeUrl(_ url: URL) -> Bool? {
return SensorsAnalyticsSDK.sharedInstance()?.handleSchemeUrl(url)
}
// 立即上报
static func flush() {
SensorsAnalyticsSDK.sharedInstance()?.flush()
}
}
// 统计事件,统计时长
extension YHAnalytics {
// 统计事件名
static func track(_ event: String, properties: [AnyHashable : Any]? = [:]) {
SensorsAnalyticsSDK.sharedInstance()?.track(event, withProperties: properties)
}
// 统计时长 开始
static func timeStrat(_ event: String) {
SensorsAnalyticsSDK.sharedInstance()?.trackTimerStart(event)
}
// 统计时长 暂停
static func timePause(_ event: String) {
SensorsAnalyticsSDK.sharedInstance()?.trackTimerPause(event)
}
// 统计时长 继续
static func timeResume(_ event: String) {
SensorsAnalyticsSDK.sharedInstance()?.trackTimerResume(event)
}
// 统计时长 结束
static func timeEnd(_ event: String, properties: [AnyHashable : Any]? = [:]) {
SensorsAnalyticsSDK.sharedInstance()?.trackTimerEnd(event, withProperties: properties)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment