添加了百度统计的相关类

This commit is contained in:
fengshuo
2021-09-27 17:44:09 +08:00
parent 45a5a38a2a
commit 2b6b0e29ce
7 changed files with 208 additions and 1 deletions

View File

@@ -29,6 +29,8 @@ target 'xplan-ios' do
#持久化存储
pod 'SSKeychain'
pod 'Base64'
#统计
pod 'BaiduMobStatCodeless', '~> 5.3.5'
#登录的
pod 'mob_sharesdk'
pod 'mob_sharesdk/ShareSDKPlatforms/QQ'

View File

@@ -14,6 +14,7 @@ PODS:
- AFNetworking/Serialization (4.0.1)
- AFNetworking/UIKit (4.0.1):
- AFNetworking/NSURLSession
- BaiduMobStatCodeless (5.3.5)
- Base64 (1.1.2)
- FFPopup (1.1.5)
- HappyDNS (0.3.17)
@@ -51,6 +52,7 @@ PODS:
DEPENDENCIES:
- AFNetworking
- BaiduMobStatCodeless (~> 5.3.5)
- Base64
- FFPopup
- IAPHelper
@@ -73,6 +75,7 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- AFNetworking
- BaiduMobStatCodeless
- Base64
- FFPopup
- HappyDNS
@@ -93,6 +96,7 @@ SPEC REPOS:
SPEC CHECKSUMS:
AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce
BaiduMobStatCodeless: b3c73335cc1a5d464540111ff08857fc33cae656
Base64: cecfb41a004124895a7bcee567a89bae5a89d49b
FFPopup: a208dcee8db3e54ec4a88fcd6481f6f5d85b7a83
HappyDNS: 848ef73e24f2b0e2752064223ce2dc0dd88900ea
@@ -111,6 +115,6 @@ SPEC CHECKSUMS:
SZTextView: 094dc6acc9beec537685c545d6e3e0d4975174e1
YYText: 5c461d709e24d55a182d1441c41dc639a18a4849
PODFILE CHECKSUM: e15982fef9e57d97997b5e561f9e5bd64d3950fc
PODFILE CHECKSUM: 48063c5a85dfa0437fffd3a123ff709292daa45e
COCOAPODS: 1.10.1

View File

@@ -124,6 +124,8 @@
E865963F27015A9C00846EBD /* XPMineUserTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = E865963E27015A9C00846EBD /* XPMineUserTableView.m */; };
E86596432701611A00846EBD /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596412701611A00846EBD /* UIImage+ImageEffects.m */; };
E86596462701612D00846EBD /* UIImageView+Vague.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596452701612D00846EBD /* UIImageView+Vague.m */; };
E86596512701A1C000846EBD /* StatisticsService.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596502701A1C000846EBD /* StatisticsService.m */; };
E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E86596532701A55500846EBD /* StatisticsServiceHelper.m */; };
E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308826E89BE000B90D4F /* LoginPhoneViewController.m */; };
E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872308C26E89DAA00B90D4F /* LoginInputView.m */; };
E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = E872309226E8D31500B90D4F /* LoginVerifCodeView.m */; };
@@ -430,6 +432,10 @@
E86596422701611A00846EBD /* UIImage+ImageEffects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ImageEffects.h"; sourceTree = "<group>"; };
E86596442701612D00846EBD /* UIImageView+Vague.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIImageView+Vague.h"; sourceTree = "<group>"; };
E86596452701612D00846EBD /* UIImageView+Vague.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+Vague.m"; sourceTree = "<group>"; };
E865964F2701A1C000846EBD /* StatisticsService.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatisticsService.h; sourceTree = "<group>"; };
E86596502701A1C000846EBD /* StatisticsService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StatisticsService.m; sourceTree = "<group>"; };
E86596522701A55500846EBD /* StatisticsServiceHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatisticsServiceHelper.h; sourceTree = "<group>"; };
E86596532701A55500846EBD /* StatisticsServiceHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StatisticsServiceHelper.m; sourceTree = "<group>"; };
E872308726E89BE000B90D4F /* LoginPhoneViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginPhoneViewController.h; sourceTree = "<group>"; };
E872308826E89BE000B90D4F /* LoginPhoneViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoginPhoneViewController.m; sourceTree = "<group>"; };
E872308B26E89DAA00B90D4F /* LoginInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginInputView.h; sourceTree = "<group>"; };
@@ -966,6 +972,7 @@
189DD5A726DFA09700AB55B1 /* Tool */ = {
isa = PBXGroup;
children = (
E865964E2701A1A900846EBD /* StatisticsService */,
E89DA66C2700873B008483C1 /* NSObject */,
E89DA6612700590A008483C1 /* IAPHelper */,
E8B846B926FD7BE600A777FE /* UploadImage */,
@@ -1185,6 +1192,17 @@
path = VagueImageView;
sourceTree = "<group>";
};
E865964E2701A1A900846EBD /* StatisticsService */ = {
isa = PBXGroup;
children = (
E865964F2701A1C000846EBD /* StatisticsService.h */,
E86596502701A1C000846EBD /* StatisticsService.m */,
E86596522701A55500846EBD /* StatisticsServiceHelper.h */,
E86596532701A55500846EBD /* StatisticsServiceHelper.m */,
);
path = StatisticsService;
sourceTree = "<group>";
};
E872308A26E89D5100B90D4F /* CustomView */ = {
isa = PBXGroup;
children = (
@@ -1704,6 +1722,7 @@
18E7B22626E8CDCF0064BC9B /* XplanFlutterBoostDelegate.m in Sources */,
E8EEB8F326FC2050007C6EBA /* SDWaitingView.m in Sources */,
E8B846CB26FDD7CD00A777FE /* XPMineRechargeViewController.m in Sources */,
E86596512701A1C000846EBD /* StatisticsService.m in Sources */,
E824544026F58F9400BE8163 /* XPMinePayPwdViewController.m in Sources */,
E8AC723D26F4B6AA007D6E91 /* XPLoginBindPhoneResultViewController.m in Sources */,
189DD73E26E21C3F00AB55B1 /* YYUtility.m in Sources */,
@@ -1780,6 +1799,7 @@
E8E70D7726F2F15100F03460 /* XPMineViewController.m in Sources */,
E8AC722C26F49580007D6E91 /* XPMineNotificaViewController.m in Sources */,
189DD52E26DE255300AB55B1 /* AppDelegate.m in Sources */,
E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */,
E8E70D8C26F2F5A500F03460 /* XPMineMatchCollectionViewCell.m in Sources */,
186A534A26FC6ED900D67B2C /* TTActionSheetConfig.m in Sources */,
E81C279326EB394D0031E639 /* LoginForgetPasswordViewController.m in Sources */,

View File

@@ -0,0 +1,35 @@
//
// StatisticsService.h
// xplan-ios
//
// Created by 冯硕 on 2021/9/27.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface StatisticsService : NSObject
/// 埋点数据 不带参数的
/// @param event key
/// @param describe 描述
+ (void)trackEvent:(NSString *)event eventDescribe:(NSString *)describe;
/// 埋点的 代参数的
/// @param event key
/// @param describe 描述
/// @param attributes 参数
+ (void)trackEvent:(NSString *)event eventDescribe:(NSString *)describe eventAttributes:(nullable NSDictionary *)attributes;
/// 统计时长的 开始
/// @param event key
/// @param describe 描述
+ (void)trackEvent:(NSString *)event eventStart:(NSString *)describe;
/// 统计时长 结束
/// @param event key
/// @param describe 描述
+ (void)trackEvent:(NSString *)event eventEnd:(NSString *)describe;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,59 @@
//
// StatisticsService.m
// xplan-ios
//
// Created by on 2021/9/27.
//
#import "StatisticsService.h"
#import <BaiduMobStatCodeless/BaiduMobStat.h>
@implementation StatisticsService
///
/// @param event key
/// @param describe
+ (void)trackEvent:(NSString *)event eventDescribe:(NSString *)describe {
if (event == nil || event.length == 0) {
return;
}
[self trackEvent:event eventDescribe:describe eventAttributes:nil];
}
///
/// @param event key
/// @param describe
/// @param attributes
+ (void)trackEvent:(NSString *)event eventDescribe:(NSString *)describe eventAttributes:(nullable NSDictionary *)attributes {
if (event == nil || event.length == 0) {
return;
}
[[BaiduMobStat defaultStat] logEvent:event eventLabel:describe attributes:attributes];
}
///
/// @param event key
/// @param describe
+ (void)trackEvent:(NSString *)event eventStart:(NSString *)describe {
if (event == nil || event.length == 0) {
return;
}
[[BaiduMobStat defaultStat] eventStart:event eventLabel:describe];
}
///
/// @param event key
/// @param describe
+ (void)trackEvent:(NSString *)event eventEnd:(NSString *)describe {
if (event == nil || event.length == 0){
return;
}
[[BaiduMobStat defaultStat] eventEnd:event eventLabel:describe];
}
@end

View File

@@ -0,0 +1,36 @@
//
// StatisticsServiceHelper.h
// xplan-ios
//
// Created by 冯硕 on 2021/9/27.
//项目中埋点的数据 尽可能的使用这个类 进行参数的构建 在getTrackEventDescripWithKey 方法中配置相对应的event 和 decribe
/// 在.m中 生成一个key 在.h中 exten 即可
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface StatisticsServiceHelper : NSObject
UIKIT_EXTERN NSString *const StatisticsServiceEventAppLaunch;
/// 埋点事件
/// @param eventKey key
+ (void)trackEventWithKey:(NSString *)eventKey;
/// 埋点事件带参数
/// @param eventKey key
/// @param eventAttributes 参数
+ (void)trackEventWithKey:(NSString *)eventKey eventAttributes:(NSDictionary * _Nullable)eventAttributes;
/// 统计时长 开始
/// @param eventKey key
+ (void)trackEventStartWithKey:(NSString *)eventKey;
/// 统计时长 结束
/// @param eventKey key
+ (void)trackEventEndWithKey:(NSString *)eventKey;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,51 @@
//
// StatisticsServiceHelper.m
// xplan-ios
//
// Created by on 2021/9/27.
//
#import "StatisticsServiceHelper.h"
#import "StatisticsService.h"
@implementation StatisticsServiceHelper
NSString *const StatisticsServiceEventAppLaunch = @"app_launch";
///
/// @param eventKey key
+ (void)trackEventWithKey:(NSString *)eventKey {
[self trackEventWithKey:eventKey eventAttributes:nil];
}
///
/// @param eventKey key
/// @param eventAttributes
+ (void)trackEventWithKey:(NSString *)eventKey eventAttributes:(NSDictionary * _Nullable)eventAttributes {
[StatisticsService trackEvent:eventKey eventDescribe:[self getTrackEventDescripWithKey:eventKey] eventAttributes:eventAttributes];
}
///
/// @param eventKey key
+ (void)trackEventStartWithKey:(NSString *)eventKey {
[StatisticsService trackEvent:eventKey eventStart:[self getTrackEventDescripWithKey:eventKey]];
}
///
/// @param eventKey key
+ (void)trackEventEndWithKey:(NSString *)eventKey {
[StatisticsService trackEvent:eventKey eventEnd:[self getTrackEventDescripWithKey:eventKey]];
}
/// key descrip
+ (NSString *)getTrackEventDescripWithKey:(NSString *)key {
NSDictionary * dic = @{
StatisticsServiceEventAppLaunch:@"应用启动",
};
NSString * decription = [dic objectForKey:StatisticsServiceEventAppLaunch];
return decription;
}
@end