Framework文件
- FireflyStatistics.framework ;詳細參見接入iOS
配置鏈接
- 需要(yào / yāo)添加
FireflyStatistics.framework
的(de)鏈接,以(yǐ)及對應的(de)依賴鏈接
頭文件引用
簡單導入
#import <FireflyStatistics/FireflyStatistics.h>
接口
配置appkey和(hé / huò)appsecret
首先向行爲(wéi / wèi)分析平台申請注冊,通過審核後,會爲(wéi / wèi)每一(yī / yì /yí)個(gè)App分配一(yī / yì /yí)個(gè)appkey和(hé / huò)appsecret,其和(hé / huò)AppId綁定
+ (void)startWithAppKey:(NSString *)appKey secret:(NSString *)secret;
是(shì)否在(zài)控制台打印日志
便于(yú)調試階段查看日志
+ (void)setIsLogEnabled:(BOOL)isLogEnabled;
登陸、登出(chū)
+ (void)login:(NSString * _Nonnull)userId;
+ (void)logout;
是(shì)否捕獲崩潰信息
+ (void)setIsCaughtCrashEnabled:(BOOL)isCaughtCrashEnabled;
設置本地(dì / de)低優先級文件最大(dà)條數
+ (void)setMaxNumberLocalFile:(NSInteger)maxNumber;
設置本地(dì / de)指定優先級文件存儲最大(dà)size
+ (void)setMaxFileSize:(int64_t)contentSize priority:(FireflyStatisticsLogPriority)priority;
日志寫入快捷方法
1. FireflyStatisticsLog(NSDictionary *_Nonnull log);
2. FireflyStatisticsLog_priority(FireflyStatisticsLogPriority priority , NSDictionary *_Nonnull log);
3. FireflyStatisticsLog_options(NSString *_Nonnull type, FireflyStatisticsLogPriority priority , NSDictionary *_Nonnull log);
日志寫入
1. + (void)ffsLog:(NSDictionary *_Nonnull)log;
2. + (void)ffsLogPriority:(FireflyStatisticsLogPriority) priority log:(NSDictionary *_Nonnull)log;
3. + (void)ffsLogOptions:(NSString *_Nonnull )type priority:(FireflyStatisticsLogPriority)priority log:(NSDictionary *_Nonnull)log;
頁面時(shí)間統計
頁面的(de)時(shí)間統計函數:
1. FireflyStatisticsStartTracePage(NSString *_Nonnull pageName);
2. FireflyStatisticsEndTracePage(NSString *_Nonnull pageName);
使用
初始化
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[FireflyStatisticsAgent startWithAppKey:@"appkey" secret:@"appSecret"];
[FireflyStatisticsAgent setIsCaughtCrashEnabled:NO];
[FireflyStatisticsAgent setIsLogEnabled:YES];
[FireflyStatisticsAgent setMaxNumberLocalFile:5];
[FireflyStatisticsAgent setMaxFileSize:10000 * 1024 priority:FireflyStatisticsLogPriorityLow];
[FireflyStatisticsAgent setTracePageLogPriority:FireflyStatisticsLogPriorityHigh];
[FireflyStatisticsAgent setNetworkTypeOnSendData:(FireflyStatisticsNetworkTypeWifi)];
[FireflyStatisticsAgent setIsSendDataAfterResignActive:YES];
[FireflyStatisticsAgent checkLocalFileData];
// Override point for customization after application launch.
return YES;
}
寫入日志
FireflyStatisticsLog_options(@"log", FireflyStatisticsLogPriorityHigh, @{@"xcontext":@{@"testkey":@"testValue"}});