Commit 7dad09d9 authored by 汪洋's avatar 汪洋

Merge branch 'dev' into 'master'

给每一条埋点数据增加一个id。修改sessionid不正确的bug



See merge request !7
parents 1a948f13 3dd061a8
......@@ -25,7 +25,8 @@ static NSString *sdkVersion = @"110";
@property (strong, nonatomic) NSString *channelId;
@property (strong, nonatomic) NSString *appVersion;
@property (strong, nonatomic) NSString *sessionId;
/* 每一条埋点数据的物理ID,自增,生命周期和sessionId相同。特别注意:在sessionOver的时候,要把他置为0 */
@property (assign, nonatomic) NSInteger serialId;
@end
@implementation Phobos
......@@ -40,7 +41,6 @@ static NSString *sdkVersion = @"110";
+ (void)setSharedClient:(Phobos *)client{
sharedClient = client;
[sharedClient handleEventAfterInit];
}
- (instancetype)initWithAppName:(NSString *)appName channelId:(NSString *)channelId{
......@@ -87,9 +87,11 @@ static NSString *sdkVersion = @"110";
}
}
- (void)handleEventAfterInit{
/**
在APP启动、从后台到前台的时候需要记录device_opened埋点
*/
- (void)handleEventDeviceOpened{
WMCacheService *cache = [WMCacheService sharedInstance];
/** 每次打开APP埋点 **/
[Phobos track:@"device_opened" attributes:@{} sendNow:YES];
......@@ -137,6 +139,7 @@ static NSString *sdkVersion = @"110";
* @since 0.0.1
*/
- (void)handleSessionStart{
_serialId = 0;
_sessionId = [[NSUUID UUID] UUIDString];
WMCacheService *cache = [WMCacheService sharedInstance];
[cache storeObjectAtDiskWithkey:PhobosBeginTime object:[PhobosUtil currentTime]];
......@@ -152,6 +155,7 @@ static NSString *sdkVersion = @"110";
- (void)handleAppFinishLaunch:(id)sender{
phobosLog(@"handleAppFinishLaunch");
[self handleSessionStart];
[self handleEventDeviceOpened];
}
/**
......@@ -164,6 +168,7 @@ static NSString *sdkVersion = @"110";
- (void)handleAppInForeground:(id)sender{
phobosLog(@"handleAppInForeground");
[self handleSessionStart];
[self handleEventDeviceOpened];
[self fetchDataAndSend];
[self handlePVEventAppInForeground];
}
......@@ -200,6 +205,8 @@ static NSString *sdkVersion = @"110";
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:usedTime,@"duration",nil];
[Phobos track:@"on_app_session_over" attributes:dict];
[cache removeObjectAtDiskWithkey:PhobosBeginTime];
//当前session结束之后,把id置为0
_serialId = 0;
}
/**
......@@ -345,7 +352,8 @@ static NSString *sdkVersion = @"110";
self.appVersion, @"version",
self.channelId,@"channel",
_userType,@"user_type",
self.currentCityId,@"current_city_id", nil];
self.currentCityId,@"current_city_id",
@(_serialId++), @"serial_id",nil];
[dict setObject:eventId forKey:@"type"];
[dict setObject:appParams forKey:@"app"];
[dict setObject:sdkVersion forKey:@"version"];
......
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