Commit ec8ac7b0 authored by 井庆林's avatar 井庆林

pull

parents d3ac29ab 0495bdd9
......@@ -42,32 +42,32 @@ NSString *const MockCityId = @"beijing";
Phobos.sharedClient.signingType = PhobosSigningTypeDebug;
Phobos.sharedClient.userId = @"";
NSString *inDate = [PhobosUtil currentTime];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
[dict setObject:[PhobosUtil currentTime] forKey:@"out"];
[dict setObject:inDate forKey:@"in"];
[dict setObject:@"test" forKey:@"page_name"];
[dict setObject:@"" forKey:@"business_id"];
[dict setObject:@"" forKey:@"referrer"];
[dict setObject:@(0) forKey:@"fake"];
[dict setObject:@"" forKey:@"referrer_id"];
[dict setObject:@"" forKey:@"extra_param"];
[dict setObject:@"" forKey:@"referrer_tab_name"];
[dict setObject:@(0) forKey:@"is_push"];
[Phobos track:@"page_view" attributes:dict];
NSArray *array = [GMCache fetchObjectAtDocumentPathWithkey:PhobosCacheKey];
[Phobos track:@"page_view" attributes:dict];
array = [GMCache fetchObjectAtDocumentPathWithkey:PhobosCacheKey];
[dict setObject:[PhobosUtil currentTime] forKey:@"in"];
[dict setObject:[PhobosUtil currentTime] forKey:@"out"];
[Phobos track:@"page_view" attributes:dict];
array = [GMCache fetchObjectAtDocumentPathWithkey:PhobosCacheKey];
[Phobos track:@"test" attributes:dict];
array = [GMCache fetchObjectAtDocumentPathWithkey:PhobosCacheKey];
// NSString *inDate = [PhobosUtil currentTime];
// NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
// [dict setObject:[PhobosUtil currentTime] forKey:@"out"];
// [dict setObject:inDate forKey:@"in"];
// [dict setObject:@"test" forKey:@"page_name"];
// [dict setObject:@"" forKey:@"business_id"];
// [dict setObject:@"" forKey:@"referrer"];
// [dict setObject:@(0) forKey:@"fake"];
// [dict setObject:@"" forKey:@"referrer_id"];
// [dict setObject:@"" forKey:@"extra_param"];
// [dict setObject:@"" forKey:@"referrer_tab_name"];
// [dict setObject:@(0) forKey:@"is_push"];
// [Phobos track:@"page_view" attributes:dict];
// NSArray *array = [GMCache fetchObjectAtDocumentPathWithkey:PhobosCacheKey];
//
// [Phobos track:@"page_view" attributes:dict];
// array = [GMCache fetchObjectAtDocumentPathWithkey:PhobosCacheKey];
//
// [dict setObject:[PhobosUtil currentTime] forKey:@"in"];
// [dict setObject:[PhobosUtil currentTime] forKey:@"out"];
// [Phobos track:@"page_view" attributes:dict];
// array = [GMCache fetchObjectAtDocumentPathWithkey:PhobosCacheKey];
//
// [Phobos track:@"test" attributes:dict];
// array = [GMCache fetchObjectAtDocumentPathWithkey:PhobosCacheKey];
//
}
- (void)didReceiveMemoryWarning
......
......@@ -35,7 +35,11 @@ PODS:
- GMKit/Protocol (1.1.3):
- Masonry (= 1.1.0)
- SDWebImage (= 3.7.6)
<<<<<<< HEAD
- GMPhobos (1.3.4):
=======
- GMPhobos (1.3.6):
>>>>>>> 0495bdd9cf7d4652f1252b323950a64abc9f17ca
- GMCache
- GMKit
- Masonry (1.1.0)
......@@ -51,7 +55,7 @@ SPEC REPOS:
"git@git.wanmeizhensuo.com:gengmeiios/GMSpecs.git":
- GMCache
- GMKit
https://github.com/cocoapods/specs.git:
https://github.com/CocoaPods/Specs.git:
- Masonry
- SDWebImage
- TMCache
......@@ -63,11 +67,15 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
GMCache: 09a3029c96fe130e3a21faef70b3d9d2ce92d639
GMKit: 35f788243cceeddf3e13c5226b3ea0b5e08e2117
<<<<<<< HEAD
GMPhobos: 1ee4b12cccd1df054bf9539357c5fc60a2d64a68
=======
GMPhobos: 6623102d634ce5485e8d3e474da8bdce5891f419
>>>>>>> 0495bdd9cf7d4652f1252b323950a64abc9f17ca
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
SDWebImage: c325cf02c30337336b95beff20a13df489ec0ec9
TMCache: 95ebcc9b3c7e90fb5fd8fc3036cba3aa781c9bed
PODFILE CHECKSUM: ea0fac2144ac80baf8f21576cde49526c19991ad
COCOAPODS: 1.7.4
COCOAPODS: 1.9.0
This diff is collapsed.
......@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = "GMPhobos"
s.version = "1.3.5"
s.version = "1.3.6"
s.summary = "GM statistic data sdk"
s.description = <<-DESC
......
......@@ -15,6 +15,7 @@
#import "PhobosCustomVisibleController.h"
#import "UIDevice+Resolutions.h"
#import <GMCache/GMCache.h>
#import <mach/mach_time.h>
static Phobos *sharedClient = nil;
static NSString *sdkVersion = @"110";
......@@ -135,12 +136,16 @@ static NSString *sdkVersion = @"110";
}
- (UIViewController *)visibleController {
id target = self.getTopController();
if (self.getTopController) {
id target = self.getTopController();
if ([target conformsToProtocol:NSProtocolFromString(@"PhobosCustomVisibleController")]) {
target = [target performSelector:@selector(phobosVisibleController)];
if ([target conformsToProtocol:NSProtocolFromString(@"PhobosCustomVisibleController")]) {
target = [target performSelector:@selector(phobosVisibleController)];
}
return target;
}
return target;
return nil;
}
#pragma mark - notification handler
......@@ -353,12 +358,21 @@ static NSString *sdkVersion = @"110";
[page initReferrerIdIfNil];
[page initReferrerTabName];
page.inTime = [PhobosUtil currentTime];
page.inTimeMillis = [PhobosUtil currentMMTime];
// 业务层更新
if (page.updatePVStartBlock) {
page.updatePVStartBlock();
}
}
- (void)onPVEnd:(UIResponder<PhobosPVProtocol> *)page {
if (![PhobosUtil isNonEmpty:page.pageName] || !page.needLogPV) {
return;
}
// 业务层更新
if (page.updatePVEndBlock) {
page.updatePVEndBlock();
}
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
@try {
[dict setObject:[PhobosUtil currentTime] forKey:@"out"];
......@@ -366,12 +380,18 @@ static NSString *sdkVersion = @"110";
[dict setObject:page.pageName forKey:@"page_name"];
[dict setObject:page.businessId?:@"" forKey:@"business_id"];
[dict setObject:page.referer?:@"" forKey:@"referrer"];
[dict setObject:page.referrerLink ? : @[] forKey:@"referrer_link"];
if ([page.referrerLink isKindOfClass:[NSArray class]] && page.referrerLink.count) {
[dict setObject:page.referrerLink forKey:@"referrer_link"];
} else {
[dict setObject:@[] forKey:@"referrer_link"];
}
[dict setObject:@(0) forKey:@"fake"];
[dict setObject:page.referrerId ? : @"" forKey:@"referrer_id"];
[dict setObject:page.extraParam ? : @"" forKey:@"extra_param"];
[dict setObject:page.referrerTabName ? : @"" forKey:@"referrer_tab_name"];
[dict setObject:page.isPush.intValue ? @(page.isPush.intValue) : @(0) forKey:@"is_push"];
[dict setObject:page.inTimeMillis?:@"" forKey:@"in_time_millis"];
[dict setObject:[PhobosUtil currentMMTime] forKey:@"out_time_millis"];
if (page.inTime.length > 0) {
// 页面显示时间为空时不记录页面pv事件
......@@ -409,11 +429,17 @@ static NSString *sdkVersion = @"110";
*
* @since 0.0.1
*/
- (NSDictionary *)prepareDictionaryForEvent:(NSString *)eventId attributes:(NSDictionary *)attributes{
- (NSDictionary *)prepareDictionaryForEvent:(NSString *)eventId attributes:(NSDictionary *)attributes {
NSArray *referrerLink = sharedClient.visibleController.referrerLink;
if (![eventId isEqualToString:@"page_view"]) {
// 对于埋点没有referrer_link的情况,在这里进行统一添加
if (![attributes.allKeys containsObject:@"referrer_link"]) {
NSMutableDictionary *attributesParams = [NSMutableDictionary dictionaryWithDictionary:attributes];
[attributesParams setValue:referrerLink ? : @[] forKey:@"referrer_link"];
if ([referrerLink isKindOfClass:[NSArray class]] && referrerLink.count) {
[attributesParams setValue:referrerLink forKey:@"referrer_link"];
} else {
[attributesParams setValue:@[] forKey:@"referrer_link"];
}
attributes = attributesParams;
}
[self catchNullForEvent:eventId attributes:attributes];
......@@ -445,12 +471,16 @@ static NSString *sdkVersion = @"110";
if (_signingType == PhobosSigningTypeDebug || _signingType == PhobosSigningTypeRelease) {
[dict setObject:@(0) forKey:@"is_release"];
}
NSString *nano_time = [NSString stringWithFormat:@"%lld",[[NSProcessInfo processInfo] systemUptime]];
[dict setObject:eventId forKey:@"type"];
[dict setObject:appParams forKey:@"app"];
[dict setObject:sdkVersion forKey:@"version"];
[dict setObject:deviceParams forKey:@"device"];
[dict setObject:_userId forKey:@"user_id"];
[dict setObject:currentTime forKey:@"create_at"];
[dict setObject:currentTime forKey:@"create_at"];// 1584513842 当前时间(秒)
[dict setObject:nano_time?:@"" forKey:@"nano_time"];// 1657008897 系统启动后时长(秒)
[dict setObject:@(mach_absolute_time()) forKey:@"absolute_time"];// 148237263697318 系统启动后的 CPU 嘀嗒数(纳秒)
[dict setObject:[PhobosUtil currentMMTime] forKey:@"create_at_millis"];// 1584513842753 当前时间戳(毫秒)
[dict setObject:attributes forKey:@"params"];
[dict setObject:_sessionId forKey:@"app_session_id"];
}
......
......@@ -8,6 +8,8 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef void(^PhobosUpdatePVBlock)(void);
@protocol PhobosPVProtocol <NSObject>
/**
......@@ -42,6 +44,9 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, copy, nonnull) NSString *inTime;
/// 当前VC.view 显示的时候的时间戳(精确到毫秒)
@property (nonatomic, copy, nonnull) NSString *inTimeMillis;
/**
前一个页面的businessId。该属性有可能为空字符串
*/
......@@ -80,6 +85,10 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, copy) NSArray *referrerLink;
/// 业务层更新PVStart信息
@property (nonatomic, copy) PhobosUpdatePVBlock updatePVStartBlock;
/// 业务层更新PVEnd信息
@property (nonatomic, copy) PhobosUpdatePVBlock updatePVEndBlock;
@end
NS_ASSUME_NONNULL_END
......@@ -428,7 +428,7 @@
}
/**
* 获取手机运行时间,从开机到现在
* 获取手机运行时间,从开机到现在(秒)
*/
+ (NSString *)deviceRunTime {
struct timeval boottime;
......
......@@ -152,7 +152,6 @@
objc_setAssociatedObject(self, @selector(inTime), inTime, OBJC_ASSOCIATION_COPY);
}
/**
这个地方inTime的值为nil的情况不做考虑,因为Phobos不会发送。inTime必须在controller viewWillAppear时赋值
*/
......@@ -161,6 +160,15 @@
return inTime;
}
- (void)setInTimeMillis:(NSString *)inTimeMillis {
objc_setAssociatedObject(self, @selector(inTimeMillis), inTimeMillis, OBJC_ASSOCIATION_COPY);
}
- (NSString *)inTimeMillis {
NSString *inTimeMillis = objc_getAssociatedObject(self, @selector(inTimeMillis));
return inTimeMillis;
}
- (void)initReferrerIdIfNil {
// 只有不为空,且是controller的情况下才自动获取
if ([self.referrerId isEqualToString:@""] && [self isKindOfClass:[UIViewController class]]) {
......@@ -236,4 +244,23 @@
return isPush == nil ? @"" : isPush;
}
- (void)setUpdatePVStartBlock:(PhobosUpdatePVBlock)updatePVStartBlock {
objc_setAssociatedObject(self, @selector(updatePVStartBlock), updatePVStartBlock, OBJC_ASSOCIATION_COPY);
}
- (PhobosUpdatePVBlock)updatePVStartBlock {
PhobosUpdatePVBlock updatePVBlock = objc_getAssociatedObject(self, @selector(updatePVStartBlock));
return updatePVBlock;
}
- (void)setUpdatePVEndBlock:(PhobosUpdatePVBlock)updatePVEndBlock {
objc_setAssociatedObject(self, @selector(updatePVEndBlock), updatePVEndBlock, OBJC_ASSOCIATION_COPY);
}
- (PhobosUpdatePVBlock)updatePVEndBlock {
PhobosUpdatePVBlock updatePVBlock = objc_getAssociatedObject(self, @selector(updatePVEndBlock));
return updatePVBlock;
}
@end
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