diff --git a/GrowingAutotracker/GrowingAutotracker.h b/GrowingAutotracker/GrowingAutotracker.h index 826e4c03..e25e7cf6 100644 --- a/GrowingAutotracker/GrowingAutotracker.h +++ b/GrowingAutotracker/GrowingAutotracker.h @@ -136,9 +136,9 @@ NS_ASSUME_NONNULL_BEGIN + (void)clearGeneralProps; /// 设置埋点动态通用属性 -/// @param dynamicGeneralPropsBlock 动态通用属性,其优先级大于通用属性 -+ (void)registerDynamicGeneralPropsBlock:(NSDictionary * (^_Nullable)(void))dynamicGeneralPropsBlock - NS_SWIFT_NAME(registerDynamicGeneralProps(_:)); +/// @param generator 动态通用属性,其优先级大于通用属性 ++ (void)setDynamicGeneralPropsGenerator:(NSDictionary * (^_Nullable)(void))generator + NS_SWIFT_NAME(setDynamicGeneralProps(_:)); ///------------------------------- #pragma mark Autotrack Event diff --git a/GrowingAutotracker/GrowingAutotracker.m b/GrowingAutotracker/GrowingAutotracker.m index 4ada08f5..98a9cd46 100644 --- a/GrowingAutotracker/GrowingAutotracker.m +++ b/GrowingAutotracker/GrowingAutotracker.m @@ -84,8 +84,8 @@ + (void)clearGeneralProps { [[GrowingGeneralProps sharedInstance] clearGeneralProps]; } -+ (void)registerDynamicGeneralPropsBlock:(NSDictionary * (^_Nullable)(void))dynamicGeneralPropsBlock { - [[GrowingGeneralProps sharedInstance] registerDynamicGeneralPropsBlock:dynamicGeneralPropsBlock]; ++ (void)setDynamicGeneralPropsGenerator:(NSDictionary * (^_Nullable)(void))generator { + [[GrowingGeneralProps sharedInstance] setDynamicGeneralPropsGenerator:generator]; } @end diff --git a/GrowingTracker/GrowingTracker.h b/GrowingTracker/GrowingTracker.h index 6543d395..a2fdca60 100644 --- a/GrowingTracker/GrowingTracker.h +++ b/GrowingTracker/GrowingTracker.h @@ -129,9 +129,9 @@ NS_ASSUME_NONNULL_BEGIN + (void)clearGeneralProps; /// 设置埋点动态通用属性 -/// @param dynamicGeneralPropsBlock 动态通用属性,其优先级大于通用属性 -+ (void)registerDynamicGeneralPropsBlock:(NSDictionary * (^_Nullable)(void))dynamicGeneralPropsBlock - NS_SWIFT_NAME(registerDynamicGeneralProps(_:)); +/// @param generator 动态通用属性,其优先级大于通用属性 ++ (void)setDynamicGeneralPropsGenerator:(NSDictionary * (^_Nullable)(void))generator + NS_SWIFT_NAME(setDynamicGeneralProps(_:)); ///------------------------------- #pragma mark Unavailable diff --git a/GrowingTracker/GrowingTracker.m b/GrowingTracker/GrowingTracker.m index 2e2bdc49..7108b6ac 100644 --- a/GrowingTracker/GrowingTracker.m +++ b/GrowingTracker/GrowingTracker.m @@ -84,8 +84,8 @@ + (void)clearGeneralProps { [[GrowingGeneralProps sharedInstance] clearGeneralProps]; } -+ (void)registerDynamicGeneralPropsBlock:(NSDictionary * (^_Nullable)(void))dynamicGeneralPropsBlock { - [[GrowingGeneralProps sharedInstance] registerDynamicGeneralPropsBlock:dynamicGeneralPropsBlock]; ++ (void)setDynamicGeneralPropsGenerator:(NSDictionary * (^_Nullable)(void))generator { + [[GrowingGeneralProps sharedInstance] setDynamicGeneralPropsGenerator:generator]; } @end diff --git a/GrowingTrackerCore/Event/GrowingGeneralProps.h b/GrowingTrackerCore/Event/GrowingGeneralProps.h index 372a7843..d00a4cc6 100644 --- a/GrowingTrackerCore/Event/GrowingGeneralProps.h +++ b/GrowingTrackerCore/Event/GrowingGeneralProps.h @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)clearGeneralProps; -- (void)registerDynamicGeneralPropsBlock:(NSDictionary * (^_Nullable)(void))dynamicGeneralPropsBlock; +- (void)setDynamicGeneralPropsGenerator:(NSDictionary * (^_Nullable)(void))generator; - (void)buildDynamicGeneralProps; diff --git a/GrowingTrackerCore/Event/GrowingGeneralProps.m b/GrowingTrackerCore/Event/GrowingGeneralProps.m index 3387a194..3e2e1d56 100644 --- a/GrowingTrackerCore/Event/GrowingGeneralProps.m +++ b/GrowingTrackerCore/Event/GrowingGeneralProps.m @@ -25,7 +25,7 @@ @interface GrowingGeneralProps () @property (nonatomic, strong) NSMutableDictionary *internalProps; @property (atomic, copy) NSDictionary *dynamicProps; -@property (nonatomic, copy) NSDictionary * (^dynamicPropsBlock)(void); +@property (nonatomic, copy) NSDictionary * (^dynamicPropsGenerator)(void); @end @@ -50,7 +50,7 @@ + (instancetype)sharedInstance { } - (NSDictionary *)getGeneralProps { - if (!self.dynamicProps && self.dynamicPropsBlock) { + if (!self.dynamicProps && self.dynamicPropsGenerator) { // 动态属性未build [self buildDynamicGeneralProps]; } @@ -95,9 +95,9 @@ - (void)clearGeneralProps { }); } -- (void)registerDynamicGeneralPropsBlock:(NSDictionary * (^_Nullable)(void))dynamicGeneralPropsBlock { +- (void)setDynamicGeneralPropsGenerator:(NSDictionary * (^_Nullable)(void))generator { GROWING_RW_LOCK_WRITE(lock, ^{ - self.dynamicPropsBlock = dynamicGeneralPropsBlock; + self.dynamicPropsGenerator = generator; }); } @@ -106,8 +106,8 @@ - (void)buildDynamicGeneralProps { // 目前有:首次初始化SDK、setLoginUserId、setDataCollectionEnabled(皆对应VISIT事件) // 其他非必要的场景则在事件创建过程中调用,也就是在GrowingThread GROWING_RW_LOCK_READ(lock, self.dynamicProps, ^{ - if (self.dynamicPropsBlock) { - NSDictionary *dynamicProps = self.dynamicPropsBlock(); + if (self.dynamicPropsGenerator) { + NSDictionary *dynamicProps = self.dynamicPropsGenerator(); if (dynamicProps && [dynamicProps isKindOfClass:[NSDictionary class]]) { return (NSDictionary *)[dynamicProps copy]; } diff --git a/SwiftPM-Wrap/GrowingAutotracker/Exports.swift b/SwiftPM-Wrap/GrowingAutotracker/Exports.swift index 8ebc914f..6c33d0c4 100644 --- a/SwiftPM-Wrap/GrowingAutotracker/Exports.swift +++ b/SwiftPM-Wrap/GrowingAutotracker/Exports.swift @@ -126,8 +126,8 @@ public struct Autotracker { GrowingAutotracker.clearGeneralProps() } - public static func registerDynamicGeneralProps(_ closure: (() -> [String: Any])?) { - GrowingAutotracker.registerDynamicGeneralProps(closure) + public static func setDynamicGeneralProps(_ closure: (() -> [String: Any])?) { + GrowingAutotracker.setDynamicGeneralProps(closure) } public static func autotrackPage(_ viewController: UIViewController, diff --git a/SwiftPM-Wrap/GrowingTracker/Exports.swift b/SwiftPM-Wrap/GrowingTracker/Exports.swift index 6d57f2b1..16322a58 100644 --- a/SwiftPM-Wrap/GrowingTracker/Exports.swift +++ b/SwiftPM-Wrap/GrowingTracker/Exports.swift @@ -118,7 +118,7 @@ public struct Tracker { GrowingTracker.clearGeneralProps() } - public static func registerDynamicGeneralProps(_ closure: (() -> [String: Any])?) { - GrowingTracker.registerDynamicGeneralProps(closure) + public static func setDynamicGeneralProps(_ closure: (() -> [String: Any])?) { + GrowingTracker.setDynamicGeneralProps(closure) } }