diff --git a/Modules/V2Adapter/GrowingAutoTrackKit.m b/Modules/V2Adapter/GrowingAutoTrackKit.m index c1e4dd485..d63de585a 100644 --- a/Modules/V2Adapter/GrowingAutoTrackKit.m +++ b/Modules/V2Adapter/GrowingAutoTrackKit.m @@ -95,7 +95,7 @@ - (void)growingImpTrack:(NSString *)eventId withNumber:(NSNumber *)number { } - (void)growingImpTrack:(NSString *)eventId withVariable:(NSDictionary *)variable { - variable = [GrowingV2Adapter fit3xDictionary:variable]; + variable = [GrowingV2Adapter fitAttributes:variable]; [self growingTrackImpression:eventId attributes:variable]; } diff --git a/Modules/V2AdapterTrackOnly/GrowingCoreKit.m b/Modules/V2AdapterTrackOnly/GrowingCoreKit.m index c156416f2..21a48e9ed 100644 --- a/Modules/V2AdapterTrackOnly/GrowingCoreKit.m +++ b/Modules/V2AdapterTrackOnly/GrowingCoreKit.m @@ -101,7 +101,7 @@ + (void)track:(NSString *)eventId withNumber:(NSNumber *)number { } + (void)track:(NSString *)eventId withVariable:(NSDictionary *)variable { - variable = [GrowingV2Adapter fit3xDictionary:variable]; + variable = [GrowingV2Adapter fitAttributes:variable]; id tracker = growing_getTracker(); if (!tracker) { return; @@ -145,7 +145,7 @@ + (void)clearUserId { } + (void)setPeopleVariable:(NSDictionary *)variable { - variable = [GrowingV2Adapter fit3xDictionary:variable]; + variable = [GrowingV2Adapter fitAttributes:variable]; id tracker = growing_getTracker(); if (!tracker) { return; diff --git a/Modules/V2AdapterTrackOnly/GrowingV2Adapter.m b/Modules/V2AdapterTrackOnly/GrowingV2Adapter.m index 5d8cb36e0..67b73510e 100644 --- a/Modules/V2AdapterTrackOnly/GrowingV2Adapter.m +++ b/Modules/V2AdapterTrackOnly/GrowingV2Adapter.m @@ -69,16 +69,23 @@ + (void)upgrade { [[GrowingPersistenceDataProvider sharedInstance] setString:@"1" forKey:kGrowingUserdefault_2xto3x]; } -+ (NSDictionary *)fit3xDictionary:(NSDictionary *)variable { - NSMutableDictionary *mutDic = [NSMutableDictionary dictionaryWithDictionary:variable]; ++ (NSDictionary *)fitAttributes:(NSDictionary *)variable { + NSMutableDictionary *dic = [NSMutableDictionary dictionary]; for (NSString *key in variable.allKeys) { id obj = variable[key]; - if ([obj isKindOfClass:[NSNumber class]]) { + if ([obj isKindOfClass:[NSString class]]) { + [dic setObject:obj forKey:key]; + } else if ([obj isKindOfClass:[NSNumber class]]) { NSString *value = ((NSNumber *)obj).stringValue; - [mutDic setValue:value forKey:key]; + [dic setValue:value forKey:key]; + } else if ([obj isKindOfClass:[NSNull class]]) { + [dic setObject:@"" forKey:key]; + } else { + NSString *value = [obj description]; + [dic setObject:value forKey:key]; } } - return mutDic; + return [dic copy]; } @end diff --git a/Modules/V2AdapterTrackOnly/Public/GrowingV2Adapter.h b/Modules/V2AdapterTrackOnly/Public/GrowingV2Adapter.h index f71bc288a..9e3c14664 100644 --- a/Modules/V2AdapterTrackOnly/Public/GrowingV2Adapter.h +++ b/Modules/V2AdapterTrackOnly/Public/GrowingV2Adapter.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN // 需要在初始化前调用, 将userId以及deviceId从v2版本迁移到v3版本中 + (void)upgrade; -+ (NSDictionary *)fit3xDictionary:(NSDictionary *)variable; ++ (NSDictionary *)fitAttributes:(NSDictionary *)variable; @end