iOS集成SDK
SDK名称
ZZCAnalyticsSDK-iOS
版本说明
当前版本:v1.0
SDK下载
集成/安装SDK
第一步:把SDK代码Core拖到项目中。
第二步:在App启动的时候,添加SDK初始化相关代码。
#import "ZZCAnalyticsSDK.h"
// 大数据
[ZZCAnalyticsSDK sharedInstanceWithServerURL:@"https://za.xxx.com/za"
andDebugMode:SensorsAnalyticsDebugOff];
[[ZZCAnalyticsSDK sharedInstance] enableLog:NO];
// 设置项目所属产品线
[[ZZCAnalyticsSDK sharedInstance] setProduct:@"xxx"];
// 设置项目名
[[ZZCAnalyticsSDK sharedInstance] setProject:@"xxx"];
// 日志触发上传条数
[ZZCAnalyticsSDK sharedInstance].flushBulkSize = 1;
// 日志定时触发时间间隔
[ZZCAnalyticsSDK sharedInstance].flushInterval = 60 * 1000;
[[ZZCAnalyticsSDK sharedInstance] enableAutoTrack:SensorsAnalyticsEventTypeAppStart | SensorsAnalyticsEventTypeAppEnd];
[ZZCAnalyticsSDK sharedInstance].flushBeforeEnterBackground = YES;
事件/埋点
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZZCGAAnalytics : NSObject
/// 点击事件
/// @param path obj_path,必传,用|拼接
/// @param objectType obj_type,必传,英文
/// @param params 自定义参数,可选,需要大数据中心支持的key
+ (void)trackClickEventPath:(NSString * _Nonnull)path objectType:(NSString *_Nonnull)objectType params:(NSDictionary * _Nullable)params;
/// 展示事件
/// @param path obj_path,必传,用|拼接
/// @param objectType obj_type,必传,英文
/// @param params 自定义参数,可选,需要大数据中心支持的key
+ (void)trackShowEventPath:(NSString * _Nonnull)path objectType:(NSString *_Nonnull)objectType params:(NSDictionary * _Nullable)params;
/// 技术、性能埋点
/// @param path obj_path,必传,用|拼接
/// @param objectType obj_type,必传,英文
/// @param params 自定义参数,可选,需要大数据中心支持的key【detail1、detail2、detail3.....】
+ (void)trackPerfEventPath:(NSString * _Nonnull)path objectType:(NSString *_Nonnull)objectType params:(NSDictionary * _Nullable)params;
/// 点击事件
/// @param path obj_path,必传,用|拼接
/// @param objectType obj_type,必传,英文
/// @param params 自定义参数,可选,需要大数据中心支持的key
+ (void)trackClickEventPath:(NSString * _Nonnull)path objectType:(NSString *_Nonnull)objectType objectId:(NSString *_Nullable)objectId params:(NSDictionary * _Nullable)params;
/// 展示事件
/// @param path obj_path,必传,用|拼接
/// @param objectType obj_type,必传,英文
/// @param params 自定义参数,可选,需要大数据中心支持的key
+ (void)trackShowEventPath:(NSString * _Nonnull)path objectType:(NSString *_Nonnull)objectType objectId:(NSString *_Nullable)objectId params:(NSDictionary * _Nullable)params;
/// 技术、性能埋点
/// @param path obj_path,必传,用|拼接
/// @param objectType obj_type,必传,英文
/// @param params 自定义参数,可选,需要大数据中心支持的key【detail1、detail2、detail3.....】
+ (void)trackPerfEventPath:(NSString * _Nonnull)path objectType:(NSString *_Nonnull)objectType objectId:(NSString *_Nullable)objectId params:(NSDictionary * _Nullable)params;
@end
NS_ASSUME_NONNULL_END
#import "ZZCGAAnalytics.h"
#import "ZZCAnalytics.h"
@implementation ZZCGAAnalytics
+ (void)trackClickEventPath:(NSString *)path objectType:(NSString *)objectType params:(NSDictionary *)params{
[[self class] trackClickEventPath:path objectType:objectType objectId:nil params:params];
}
+ (void)trackShowEventPath:(NSString *)path objectType:(NSString *)objectType params:(NSDictionary *)params{
[[self class] trackShowEventPath:path objectType:objectType objectId:nil params:params];
}
+ (void)trackPerfEventPath:(NSString *)path objectType:(NSString *)objectType params:(NSDictionary *)params{
[[self class] trackPerfEventPath:path objectType:objectType objectId:nil params:params];
}
+ (void)trackClickEventPath:(NSString *)path objectType:(NSString *)objectType objectId:(NSString *)objectId params:(NSDictionary *)params{
if (path.length == 0 || objectType.length == 0) {
return;
}
#ifdef DEBUG
NSLog(@"埋点event:click;埋点obj_path:%@;埋点obj_type:%@",path, objectType);
#endif
[[ZZCAnalytics analytics] sendEvent:^(ZZCAnalyticsEventMaker *maker) {
maker.event.eventName(@"click").objType(objectType).objPath(path).objId(objectId).parameters(params ? params : nil);
}];
}
+ (void)trackShowEventPath:(NSString *)path objectType:(NSString *)objectType objectId:(NSString *)objectId params:(NSDictionary *)params{
if (path.length == 0 || objectType.length == 0) {
return;
}
#ifdef DEBUG
NSLog(@"埋点event:show;埋点obj_path:%@;埋点obj_type:%@",path, objectType);
#endif
[[ZZCAnalytics analytics] sendEvent:^(ZZCAnalyticsEventMaker *maker) {
maker.event.eventName(@"show").objType(objectType).objPath(path).objId(objectId).parameters(params ? params : nil);
}];
}
+ (void)trackPerfEventPath:(NSString *)path objectType:(NSString *)objectType objectId:(NSString *)objectId params:(NSDictionary *)params{
if (path.length == 0 || objectType.length == 0) {
return;
}
#ifdef DEBUG
NSLog(@"埋点event:Perf;埋点obj_path:%@;埋点obj_type:%@",path, objectType);
#endif
[[ZZCAnalytics analytics] sendEvent:^(ZZCAnalyticsEventMaker *maker) {
maker.event.eventName(@"performance").objType(objectType).objPath(path).objId(objectId).parameters(params ? params : nil);
}];
}
@end
/*
* trackClickEventPath:事件类型(click,show等)
* objectType:业务模块
* objectId:数据埋点标识
* params:字典(业务数据埋点)
*/
[ZZCGAAnalytics trackClickEventPath:eventName objectType:@"home_page" objectId:@"home_page_click" params:nil];
其它
SDK预留系统字段说明 | |||
---|---|---|---|
字段名称 | 类型 | 显示名 | 说明 |
$app_version | 字符串 | 应用版本 | 应用的版本 |
$lib | 字符串 | SDK类型 | 例如 Android |
$lib_version | 字符串 | SDK版本 | |
$manufacturer | 字符串 | 设备制造商 | 例如 Xiaomi |
$model | 字符串 | 设备型号 | 例如 Redmi 4X |
$os | 字符串 | 操作系统 | 例如 Android |
$os_version | 字符串 | 操作系统版本 | 例如 6.0.1 |
$screen_height | 数值 | 屏幕高度 | 例如 1280 |
$screen_width | 数值 | 屏幕宽度 | 例如 720 |
$wifi | BOOL | 是否wifi | |
$carrier | 字符串 | 运营商名称 | 例如 中国联通 |
$network_type | 字符串 | 网络类型 | 例如 4G |
$is_first_day | 布尔值 | 是否首日访问 | |
$device_id | 字符串 | 设备ID | 获取值为 AndroidID |