Commit 2db45ae2 authored by 艾娇平's avatar 艾娇平

添加支持业务层更新PVStart 和 PvEnd信息

parent 4242879f
......@@ -359,12 +359,20 @@ static NSString *sdkVersion = @"110";
[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"];
......@@ -421,9 +429,11 @@ 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];
if ([referrerLink isKindOfClass:[NSArray class]] && referrerLink.count) {
[attributesParams setValue:referrerLink forKey:@"referrer_link"];
......
......@@ -8,6 +8,8 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef void(^PhobosUpdatePVBlock)(void);
@protocol PhobosPVProtocol <NSObject>
/**
......@@ -83,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
......@@ -244,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(updatePVBlock));
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