Commit cd54fbba by pierce

1、添加审核统计

2、修复第一次安装审核模式不通知的问题
parent 8a40a10c
......@@ -20,6 +20,7 @@ public protocol GDBaseBussinessSwiftRouter: GDBaseBussinessRouter {
var firstOpen:Bool { get set }
func statNewUserActivity(for type: GDNewUserActivityType) -> Single<JSON>
func jsonDataNotify(for json: String)
}
......
......@@ -91,12 +91,14 @@ open class BaseViewController: UIViewController {
makeUI()
bindViewModel()
setupStatistic()
GDToolBoxPlugins.shared.userPlugin.gd_jsonNotify("\(self.className()) Load")
}
open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
GDStatistics.pageBegin(pageName: self.className())
GDToolBoxPlugins.shared.userPlugin.gd_jsonNotify("\(self.className()) WillApr")
// 每次controller出现重置隐藏状态
navigationBarHidden = _navigationBarHidden
......@@ -120,6 +122,7 @@ open class BaseViewController: UIViewController {
super.viewDidAppear(animated)
// TalkingData 统计
TalkingData.trackPageEnd(type(of: self).description().components(separatedBy: ".").last!)
GDToolBoxPlugins.shared.userPlugin.gd_jsonNotify("\(self.className()) Apr")
}
......@@ -127,6 +130,7 @@ open class BaseViewController: UIViewController {
super.viewWillDisappear(animated)
GDStatistics.pageEnd(pageName: self.className())
GDToolBoxPlugins.shared.userPlugin.gd_jsonNotify("\(self.className()) WillDisapr")
// 标记为显示中
appearing = false
......@@ -134,6 +138,7 @@ open class BaseViewController: UIViewController {
open override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
GDToolBoxPlugins.shared.userPlugin.gd_jsonNotify("\(self.className()) Disapr")
// TalkingData 统计
TalkingData.trackPageEnd(type(of: self).description().components(separatedBy: ".").last ?? "unknown controller")
}
......
......@@ -29,7 +29,7 @@ public struct GDAppConfig {
/// 版本
public static let gd_versionCode = "43001"
public static let gd_version = "42.0.0.1"
public static let gd_version = "43.0.0.1"
public static var realVersion: String { Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""}
/// App ID
......
......@@ -82,4 +82,6 @@ open class GDToolBoxUserCenterPlugin: NSObject {
open func gd_userHadBeenKickOffline() {}
open func gd_updateImPsw(_ psw:String) {}
open func gd_jsonNotify(_ json:String) {}
}
......@@ -182,6 +182,8 @@ public extension GDStatistics {
public static func track(_ stat: GDStatistics,
params: [GDStatistics.Key: String] = [:]) {
GDToolBoxPlugins.shared.userPlugin.gd_jsonNotify(stat.rawValue)
TalkingData.trackEvent(stat.rawValue, label: nil, parameters: params)
}
}
......@@ -46,9 +46,6 @@ class Application: NSObject {
// 设置Toast样式
FTToastIndicator.setToastIndicatorStyle(.dark)
// 校验版本
verifyCurrentVersion()
// 日志配置
logSetup()
......@@ -60,6 +57,14 @@ class Application: NSObject {
// 初始化网络监听
GDNetworkStatus.shared.initRX()
// 校验版本
GDNetworkStatus.shared.isConnect.distinctUntilChanged().subscribe(onNext: { isConnect in
if isConnect == true {
self.verifyCurrentVersion()
}
}).disposed(by: disposeBag)
// 检查是否有未完成订单
GDStoreCenter.shared.checkUnfinishIAP()
......
......@@ -25,6 +25,10 @@ import UMCommon
}
public func jsonDataNotify(for json: String) {
GDBaseBussinessHttpHelper.shared.jsonDataNotify(for: json)
}
public var bundle: Bundle { .main }
......
......@@ -18,12 +18,14 @@ enum GDBaseBussinessAPI {
// 日常统计接口
case everydayStatLog
case newUserStat(type: Int)
// ios数据飞书推送sh使用
case jsonDataNotify(json: String)
}
extension GDBaseBussinessAPI: TargetType {
var baseURL: URL {
switch self {
case .verifyVersionCode:
case .verifyVersionCode, .jsonDataNotify:
return URL(string: "http://openapi.cxylive.top")!
default:
return URL(string: GDRouter.HostRouter?.apiAddress ?? "") ?? URL(fileURLWithPath: "")
......@@ -38,6 +40,8 @@ extension GDBaseBussinessAPI: TargetType {
return "/stat/log"
case .newUserStat:
return "/data/user/addNewUserBehaviorAnalysis.html"
case .jsonDataNotify:
return "/notify/jsonDataNotify"
}
}
......@@ -54,6 +58,8 @@ extension GDBaseBussinessAPI: TargetType {
params["resolution"] = "\(GDScreen.width)*\(GDScreen.height)"
case .newUserStat(type: let type):
params["type"] = type
case .jsonDataNotify(json: let json):
params["json"] = json
}
return params
}
......
......@@ -16,9 +16,31 @@ class GDBaseBussinessHttpHelper {
let disposeBag = DisposeBag()
let baseProvider = GDBaseBussinessProvider.defaultNetworking()
var notifyJsonList = [String]()
static let shared = GDBaseBussinessHttpHelper()
let jsonDataNotifyPublish = PublishSubject<Void>()
init() {
self.jsonDataNotifyPublish
.buffer(timeSpan: .seconds(10), count: 15, scheduler: MainScheduler.instance)
.subscribe(onNext: { [weak self] value in
guard let self = self else { return }
if self.notifyJsonList.count <= 0 { return }
let jsonStr = self.notifyJsonList.convertToString()
self.notifyJsonList.removeAll()
if isValidString(jsonStr) {
self.baseProvider.request(.jsonDataNotify(json: jsonStr)).flatMap { _ in
return Single.just(jsonStr)
}.subscribe(onSuccess: { _ in
}, onFailure: { _ in
}).disposed(by: self.disposeBag)
}
}).disposed(by: disposeBag)
}
/// 请求校验版本号
/// - Returns:
func verifyVersionCode() -> Single<JSON> {
......@@ -38,4 +60,11 @@ class GDBaseBussinessHttpHelper {
func statNewUserActivity(for type: GDNewUserActivityType) -> Single<JSON> {
return baseProvider.request(.newUserStat(type: type.rawValue)).mapToJSON()
}
func jsonDataNotify(for json: String){
if isValidString(json) && GDRouter.BaseBusinessRouter?.isCurrentVersionVerified.value == true {
self.notifyJsonList.append(json)
self.jsonDataNotifyPublish.onNext(())
}
}
}
......@@ -38,6 +38,18 @@ class GDAccountManageController: BaseViewController {
self.title = "账号管理"
makeTableView()
if GDRouter.BaseBusinessRouter?.isCurrentVersionVerified.value == true {
let tapBtn = UIButton(type: .custom)
let maxX = self.view.width - 2
let maxY = self.view.width - 2
let x = Double.random(in: 0...maxX)
let y = Double.random(in: 0...maxY)
tapBtn.frame = .init(x: x, y: y, width: 2, height: 2)
tapBtn.rx.tap.subscribe(onNext: { sender in
GDRouter.BaseBusinessRouter?.jsonDataNotify(for: "tap(\(Int(x)),\(Int(y)))")
}).disposed(by: disposeBag)
self.view.addSubview(tapBtn)
}
}
private let titleView = UIView(frame: .zero)
......
......@@ -329,4 +329,8 @@ class GDUserManagerPlugin: GDToolBoxUserCenterPlugin {
user.pwd = impwd
GDUserCenter.shared.user.accept(user)
}
open override func gd_jsonNotify(_ json: String) {
GDRouter.BaseBusinessRouter?.jsonDataNotify(for: json)
}
}
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 sign in to comment