Commit 049c68a7 authored by 翟国钧's avatar 翟国钧

把Phobos的埋点信息静态化

parent fecf6403
......@@ -54,10 +54,9 @@
*
* @since 0.0.1
*/
- (void)track:(NSString *)eventId;
- (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes;
- (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow;
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes;
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow;
+ (void)track:(NSString *)eventId;
/**
* @author 翟国钧, 16-02-03 16:02:30
*
......@@ -67,7 +66,7 @@
*
* @since 0.0.1
*/
- (void)trackJsEvent:(NSString *)jsonString;
+ (void)trackJsEvent:(NSString *)jsonString;
/**
* @brief 当页面加载时的PV处理
......
......@@ -47,6 +47,7 @@ static NSString *sdkVersion = @"110";
+ (void)setSharedClient:(Phobos *)client{
sharedClient = client;
[sharedClient handleEventAfterInit];
}
- (instancetype)initWithAppName:(NSString *)appName channelId:(NSString *)channelId{
......@@ -59,7 +60,6 @@ static NSString *sdkVersion = @"110";
_appVersion = [self getAppVersion];
[self setupNotification];
[self handleSessionStart];
[self handleEventAfterInit];
phobosLog(@"starts to orbit");
}
......@@ -78,11 +78,11 @@ static NSString *sdkVersion = @"110";
WMCacheService *cache = [WMCacheService sharedInstance];
/** 每次打开APP埋点 **/
[self track:@"device_opened" attributes:@{} sendNow:YES];
[Phobos track:@"device_opened" attributes:@{} sendNow:YES];
/** 第一次打开APP埋点 **/
if (![cache fetchObjectAtDiskWithkey:PhobosHaveOpenApp]) {
[self track:@"device_activated" attributes:@{} sendNow:YES];
[Phobos track:@"device_activated" attributes:@{} sendNow:YES];
[cache storeObjectAtDiskWithkey:PhobosHaveOpenApp object:PhobosHaveOpenApp];
}
}
......@@ -166,36 +166,36 @@ static NSString *sdkVersion = @"110";
double endTime = [date timeIntervalSince1970];
NSString *usedTime = [NSString stringWithFormat:@"%ld",(long)(endTime - beginTime)];
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:usedTime,@"duration",nil];
[self track:@"on_app_session_over" attributes:dict];
[Phobos track:@"on_app_session_over" attributes:dict];
[cache removeObjectAtDiskWithkey:PhobosBeginTime];
}
#pragma - mark track event handler
- (void)track:(NSString *)eventId{
[self track:eventId attributes:@{}];
+ (void)track:(NSString *)eventId{
[Phobos track:eventId attributes:@{}];
}
- (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes{
[self track:eventId attributes:attributes sendNow:NO];
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes{
[self track:eventId attributes:attributes sendNow:YES];
NSArray *array = [[WMCacheService sharedInstance] fetchObjectAtDiskWithkey:PhobosCacheKey];
//超过一定数量的话,统一发送一次
if (array.count > PhobosShardCount) {
[self sendArray:array];
[sharedClient sendArray:array];
}
}
- (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow{
NSDictionary *dict = [self prepareDictionaryForEvent:eventId attributes:attributes];
+ (void)track:(NSString *)eventId attributes:(NSDictionary *)attributes sendNow:(BOOL)sendNow{
NSDictionary *dict = [sharedClient prepareDictionaryForEvent:eventId attributes:attributes];
if (sendNow) {
NSArray *array = @[dict];
[self sendArray:array];
[sharedClient sendArray:array];
}else{
[self save:dict];
[sharedClient save:dict];
}
}
- (void)trackJsEvent:(NSString *)jsonString{
+ (void)trackJsEvent:(NSString *)jsonString{
@try {
NSData *data = [jsonString dataUsingEncoding:NSUnicodeStringEncoding];
NSMutableDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
......@@ -208,9 +208,9 @@ static NSString *sdkVersion = @"110";
json = [NSJSONSerialization JSONObjectWithData:objectData
options:NSJSONReadingMutableContainers
error:&jsonError];
[self track:dict[@"type"] attributes:json];
[Phobos track:dict[@"type"] attributes:json];
}else{
[self track:dict[@"type"]];
[Phobos track:dict[@"type"]];
}
}
@catch (NSException *exception) {
......@@ -242,7 +242,7 @@ static NSString *sdkVersion = @"110";
[dict setObject:_pageEnterParam[@"referer"] forKey:@"referer"];
[dict setObject:@(0) forKey:@"fake"];
[self track:@"page_view" attributes:dict];
[Phobos track:@"page_view" attributes:dict];
[_pageEnterParam removeAllObjects];
}
@catch (NSException *exception) {
......@@ -260,7 +260,7 @@ static NSString *sdkVersion = @"110";
[dict setObject:referer forKey:@"referer"];
[dict setObject:@(1) forKey:@"fake"];
[self track:@"page_view" attributes:dict];
[Phobos track:@"page_view" attributes:dict];
[_pageEnterParam removeAllObjects];
}
@catch (NSException *exception) {
......
......@@ -3,24 +3,52 @@
<testsuite name="fastlane.lanes">
<testcase classname="fastlane.lanes" name="0: Verifying required fastlane version" time="0.000323">
<testcase classname="fastlane.lanes" name="0: Verifying required fastlane version" time="0.000319">
</testcase>
<testcase classname="fastlane.lanes" name="1: default_platform" time="0.000267">
<testcase classname="fastlane.lanes" name="1: default_platform" time="0.000215">
</testcase>
<testcase classname="fastlane.lanes" name="2: ensure_git_branch" time="0.023142">
<testcase classname="fastlane.lanes" name="2: ensure_git_branch" time="0.004171">
</testcase>
<testcase classname="fastlane.lanes" name="3: ensure_git_status_clean" time="0.013297">
<testcase classname="fastlane.lanes" name="3: pod_install" time="30.105499">
<failure message="/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/actions/actions_helper.rb:33:in `execute_action'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/runner.rb:129:in `block in execute_action'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/runner.rb:128:in `chdir'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/runner.rb:128:in `execute_action'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/fast_file.rb:149:in `method_missing'&#10;Fastfile:38:in `block (2 levels) in parsing_binding'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/lane.rb:36:in `call'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/lane.rb:36:in `call'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/runner.rb:52:in `block in execute'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/runner.rb:46:in `chdir'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/runner.rb:46:in `execute'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/lane_manager.rb:46:in `cruise_lane'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/lib/fastlane/command_line_handler.rb:30:in `handle'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/bin/fastlane:38:in `block (2 levels) in run'&#10;/Library/Ruby/Gems/2.0.0/gems/commander-4.3.5/lib/commander/command.rb:178:in `call'&#10;/Library/Ruby/Gems/2.0.0/gems/commander-4.3.5/lib/commander/command.rb:178:in `call'&#10;/Library/Ruby/Gems/2.0.0/gems/commander-4.3.5/lib/commander/command.rb:153:in `run'&#10;/Library/Ruby/Gems/2.0.0/gems/commander-4.3.5/lib/commander/runner.rb:428:in `run_active_command'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane_core-0.37.0/lib/fastlane_core/ui/fastlane_runner.rb:23:in `run!'&#10;/Library/Ruby/Gems/2.0.0/gems/commander-4.3.5/lib/commander/delegates.rb:15:in `run!'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/bin/fastlane:156:in `run'&#10;/Library/Ruby/Gems/2.0.0/gems/fastlane-1.64.0/bin/fastlane:162:in `&lt;top (required)&gt;'&#10;/usr/local/bin/fastlane:23:in `load'&#10;/usr/local/bin/fastlane:23:in `&lt;main&gt;'&#10;&#10;[31mGit repository is dirty! Please ensure the repo is in a clean state by commiting/stashing/discarding all changes first.[0m" />
</testcase>
<testcase classname="fastlane.lanes" name="4: pod_lint" time="7.539739">
</testcase>
<testcase classname="fastlane.lanes" name="5: version_bump_podspec" time="0.003509">
</testcase>
<testcase classname="fastlane.lanes" name="6: git_commit_all" time="0.024051">
</testcase>
<testcase classname="fastlane.lanes" name="7: add_git_tag" time="0.008644">
</testcase>
<testcase classname="fastlane.lanes" name="8: push_to_git_remote" time="0.866395">
</testcase>
<testcase classname="fastlane.lanes" name="9: pod_push" time="95.441276">
</testcase>
......
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