Skip to content

Commit

Permalink
fix: rename registerDynamicGeneralPropsBlock to setDynamicGeneralProp…
Browse files Browse the repository at this point in the history
…sGenerator
  • Loading branch information
YoloMao committed Apr 22, 2024
1 parent 5e697dd commit 7c8d86e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions GrowingAutotracker/GrowingAutotracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)clearGeneralProps;

/// 设置埋点动态通用属性
/// @param dynamicGeneralPropsBlock 动态通用属性,其优先级大于通用属性
+ (void)registerDynamicGeneralPropsBlock:(NSDictionary<NSString *, id> * (^_Nullable)(void))dynamicGeneralPropsBlock
NS_SWIFT_NAME(registerDynamicGeneralProps(_:));
/// @param generator 动态通用属性,其优先级大于通用属性
+ (void)setDynamicGeneralPropsGenerator:(NSDictionary<NSString *, id> * (^_Nullable)(void))generator
NS_SWIFT_NAME(setDynamicGeneralProps(_:));

///-------------------------------
#pragma mark Autotrack Event
Expand Down
4 changes: 2 additions & 2 deletions GrowingAutotracker/GrowingAutotracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ + (void)clearGeneralProps {
[[GrowingGeneralProps sharedInstance] clearGeneralProps];
}

+ (void)registerDynamicGeneralPropsBlock:(NSDictionary<NSString *, id> * (^_Nullable)(void))dynamicGeneralPropsBlock {
[[GrowingGeneralProps sharedInstance] registerDynamicGeneralPropsBlock:dynamicGeneralPropsBlock];
+ (void)setDynamicGeneralPropsGenerator:(NSDictionary<NSString *, id> * (^_Nullable)(void))generator {
[[GrowingGeneralProps sharedInstance] setDynamicGeneralPropsGenerator:generator];
}

@end
Expand Down
6 changes: 3 additions & 3 deletions GrowingTracker/GrowingTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)clearGeneralProps;

/// 设置埋点动态通用属性
/// @param dynamicGeneralPropsBlock 动态通用属性,其优先级大于通用属性
+ (void)registerDynamicGeneralPropsBlock:(NSDictionary<NSString *, id> * (^_Nullable)(void))dynamicGeneralPropsBlock
NS_SWIFT_NAME(registerDynamicGeneralProps(_:));
/// @param generator 动态通用属性,其优先级大于通用属性
+ (void)setDynamicGeneralPropsGenerator:(NSDictionary<NSString *, id> * (^_Nullable)(void))generator
NS_SWIFT_NAME(setDynamicGeneralProps(_:));

///-------------------------------
#pragma mark Unavailable
Expand Down
4 changes: 2 additions & 2 deletions GrowingTracker/GrowingTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ + (void)clearGeneralProps {
[[GrowingGeneralProps sharedInstance] clearGeneralProps];
}

+ (void)registerDynamicGeneralPropsBlock:(NSDictionary<NSString *, id> * (^_Nullable)(void))dynamicGeneralPropsBlock {
[[GrowingGeneralProps sharedInstance] registerDynamicGeneralPropsBlock:dynamicGeneralPropsBlock];
+ (void)setDynamicGeneralPropsGenerator:(NSDictionary<NSString *, id> * (^_Nullable)(void))generator {
[[GrowingGeneralProps sharedInstance] setDynamicGeneralPropsGenerator:generator];
}

@end
Expand Down
2 changes: 1 addition & 1 deletion GrowingTrackerCore/Event/GrowingGeneralProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN

- (void)clearGeneralProps;

- (void)registerDynamicGeneralPropsBlock:(NSDictionary<NSString *, id> * (^_Nullable)(void))dynamicGeneralPropsBlock;
- (void)setDynamicGeneralPropsGenerator:(NSDictionary<NSString *, id> * (^_Nullable)(void))generator;

- (void)buildDynamicGeneralProps;

Expand Down
12 changes: 6 additions & 6 deletions GrowingTrackerCore/Event/GrowingGeneralProps.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ @interface GrowingGeneralProps ()

@property (nonatomic, strong) NSMutableDictionary<NSString *, id> *internalProps;
@property (atomic, copy) NSDictionary<NSString *, id> *dynamicProps;
@property (nonatomic, copy) NSDictionary<NSString *, id> * (^dynamicPropsBlock)(void);
@property (nonatomic, copy) NSDictionary<NSString *, id> * (^dynamicPropsGenerator)(void);

@end

Expand All @@ -50,7 +50,7 @@ + (instancetype)sharedInstance {
}

- (NSDictionary<NSString *, id> *)getGeneralProps {
if (!self.dynamicProps && self.dynamicPropsBlock) {
if (!self.dynamicProps && self.dynamicPropsGenerator) {
// 动态属性未build
[self buildDynamicGeneralProps];
}
Expand Down Expand Up @@ -95,9 +95,9 @@ - (void)clearGeneralProps {
});
}

- (void)registerDynamicGeneralPropsBlock:(NSDictionary<NSString *, id> * (^_Nullable)(void))dynamicGeneralPropsBlock {
- (void)setDynamicGeneralPropsGenerator:(NSDictionary<NSString *, id> * (^_Nullable)(void))generator {
GROWING_RW_LOCK_WRITE(lock, ^{
self.dynamicPropsBlock = dynamicGeneralPropsBlock;
self.dynamicPropsGenerator = generator;
});
}

Expand All @@ -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];
}
Expand Down
4 changes: 2 additions & 2 deletions SwiftPM-Wrap/GrowingAutotracker/Exports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions SwiftPM-Wrap/GrowingTracker/Exports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 7c8d86e

Please sign in to comment.