diff --git a/SensorsAnalyticsSDK.podspec b/SensorsAnalyticsSDK.podspec index 647c65ed..f314cf85 100644 --- a/SensorsAnalyticsSDK.podspec +++ b/SensorsAnalyticsSDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SensorsAnalyticsSDK" - s.version = "4.5.0" + s.version = "4.5.1" s.summary = "The official iOS SDK of Sensors Analytics." s.homepage = "http://www.sensorsdata.cn" s.source = { :git => 'https://github.com/sensorsdata/sa-sdk-ios.git', :tag => "v#{s.version}" } diff --git a/SensorsAnalyticsSDK.xcodeproj/project.pbxproj b/SensorsAnalyticsSDK.xcodeproj/project.pbxproj index 4f91d8b6..8aeb85fd 100644 --- a/SensorsAnalyticsSDK.xcodeproj/project.pbxproj +++ b/SensorsAnalyticsSDK.xcodeproj/project.pbxproj @@ -491,6 +491,8 @@ F286963328A34FFC00276F78 /* SAExposureManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F286963128A34FFC00276F78 /* SAExposureManager.m */; }; F28997D7273B6D66005E7D5E /* SAGesturePlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = F28997D5273B6D66005E7D5E /* SAGesturePlugin.h */; }; F28997D8273B6D66005E7D5E /* SAGesturePlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = F28997D6273B6D66005E7D5E /* SAGesturePlugin.m */; }; + F296FF042935A3DF00C40C48 /* NSObject+SAToString.h in Headers */ = {isa = PBXBuildFile; fileRef = F296FF022935A3DF00C40C48 /* NSObject+SAToString.h */; }; + F296FF052935A3DF00C40C48 /* NSObject+SAToString.m in Sources */ = {isa = PBXBuildFile; fileRef = F296FF032935A3DF00C40C48 /* NSObject+SAToString.m */; }; F2B643F62832302F00544BD2 /* SensorsAnalyticsSDK+SAAppExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = F2B643F42832302F00544BD2 /* SensorsAnalyticsSDK+SAAppExtension.h */; settings = {ATTRIBUTES = (Public, ); }; }; F2B643F72832302F00544BD2 /* SensorsAnalyticsSDK+SAAppExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = F2B643F52832302F00544BD2 /* SensorsAnalyticsSDK+SAAppExtension.m */; }; F2C877B828A65849002BDA2C /* SAExposureData+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = F2C877B628A65849002BDA2C /* SAExposureData+Private.h */; }; @@ -1059,6 +1061,8 @@ F286963128A34FFC00276F78 /* SAExposureManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SAExposureManager.m; sourceTree = ""; }; F28997D5273B6D66005E7D5E /* SAGesturePlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SAGesturePlugin.h; sourceTree = ""; }; F28997D6273B6D66005E7D5E /* SAGesturePlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SAGesturePlugin.m; sourceTree = ""; }; + F296FF022935A3DF00C40C48 /* NSObject+SAToString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSObject+SAToString.h"; sourceTree = ""; }; + F296FF032935A3DF00C40C48 /* NSObject+SAToString.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSObject+SAToString.m"; sourceTree = ""; }; F2B643F42832302F00544BD2 /* SensorsAnalyticsSDK+SAAppExtension.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SensorsAnalyticsSDK+SAAppExtension.h"; sourceTree = ""; }; F2B643F52832302F00544BD2 /* SensorsAnalyticsSDK+SAAppExtension.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SensorsAnalyticsSDK+SAAppExtension.m"; sourceTree = ""; }; F2C877B628A65849002BDA2C /* SAExposureData+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SAExposureData+Private.h"; sourceTree = ""; }; @@ -1579,6 +1583,8 @@ 45BD80CD26F0B49700DCC759 /* SAThreadSafeDictionary.m */, F21C226528F7B0E500847823 /* NSDictionary+SACopyProperties.h */, F21C226628F7B0E500847823 /* NSDictionary+SACopyProperties.m */, + F296FF022935A3DF00C40C48 /* NSObject+SAToString.h */, + F296FF032935A3DF00C40C48 /* NSObject+SAToString.m */, ); path = Utils; sourceTree = ""; @@ -2481,6 +2487,7 @@ F26FDDD8270312C400E1DF32 /* SAConfigOptions+AppPush.h in Headers */, A82E8951267D918100475757 /* SAEncryptProtocol.h in Headers */, 45A56560263C174300C9C41B /* SAIDFAHelper.h in Headers */, + F296FF042935A3DF00C40C48 /* NSObject+SAToString.h in Headers */, A82E8953267D918100475757 /* SAECCEncryptor.h in Headers */, 4D958B1A2823D99E0086A71C /* SAFirstDayPropertyPlugin.h in Headers */, A8356DDB2656459A00FD64AA /* UIViewController+SAAutoTrack.h in Headers */, @@ -2801,6 +2808,7 @@ 4D2D53BB2591EB3A00805141 /* SAWeakPropertyContainer.m in Sources */, 8876235326E739300067F0B4 /* SAPresetPropertyPlugin.m in Sources */, F200096228BE10B5003C5113 /* UIViewController+SAInternalProperties.m in Sources */, + F296FF052935A3DF00C40C48 /* NSObject+SAToString.m in Sources */, F211742226E9A72C00D65E19 /* SAApplication.m in Sources */, 88ED6BD127BE2ECB00888FBC /* SAFlowManager.m in Sources */, A8356DD72656459A00FD64AA /* SAAppClickTracker.m in Sources */, @@ -3078,6 +3086,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -3111,6 +3120,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/SensorsAnalyticsSDK/Core/Builder/EventObject/SAPropertyValidator.m b/SensorsAnalyticsSDK/Core/Builder/EventObject/SAPropertyValidator.m index 6c7436d7..58e74233 100644 --- a/SensorsAnalyticsSDK/Core/Builder/EventObject/SAPropertyValidator.m +++ b/SensorsAnalyticsSDK/Core/Builder/EventObject/SAPropertyValidator.m @@ -27,6 +27,7 @@ #import "SADateFormatter.h" #import "SensorsAnalyticsSDK+Private.h" #import "SALog.h" +#import "NSObject+SAToString.h" @implementation NSString (SAProperty) @@ -65,11 +66,11 @@ @implementation NSSet (SAProperty) - (id)sensorsdata_propertyValueWithKey:(NSString *)key error:(NSError *__autoreleasing _Nullable *)error { NSMutableSet *result = [NSMutableSet set]; for (id element in self) { - if (![element isKindOfClass:NSString.class]) { - *error = SAPropertyError(10002, @"%@ value of NSSet, NSArray must be NSString. got: %@ %@", self, [element class], element); - return nil; + if (![element conformsToProtocol:@protocol(SAPropertyValueProtocol)]) { + continue; } id sensorsValue = [(id )element sensorsdata_propertyValueWithKey:key error:error]; + sensorsValue = [sensorsValue sensorsdata_toString]; if (sensorsValue) { [result addObject:sensorsValue]; } @@ -84,11 +85,11 @@ @implementation NSArray (SAProperty) - (id)sensorsdata_propertyValueWithKey:(NSString *)key error:(NSError *__autoreleasing _Nullable *)error { NSMutableArray *result = [NSMutableArray array]; for (id element in self) { - if (![element isKindOfClass:NSString.class]) { - *error = SAPropertyError(10003, @"%@ value of NSSet, NSArray must be NSString. got: %@ %@", self, [element class], element); - return nil; + if (![element conformsToProtocol:@protocol(SAPropertyValueProtocol)]) { + continue; } id sensorsValue = [(id )element sensorsdata_propertyValueWithKey:key error:error]; + sensorsValue = [sensorsValue sensorsdata_toString]; if (sensorsValue) { [result addObject:sensorsValue]; } diff --git a/SensorsAnalyticsSDK/Core/HookDelegate/SADelegateProxyObject.h b/SensorsAnalyticsSDK/Core/HookDelegate/SADelegateProxyObject.h index 992ba4e2..11ba7160 100644 --- a/SensorsAnalyticsSDK/Core/HookDelegate/SADelegateProxyObject.h +++ b/SensorsAnalyticsSDK/Core/HookDelegate/SADelegateProxyObject.h @@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong) Class delegateProxy; /// 当前代理对象已 hook 的方法集合 -@property (nonatomic, copy) NSMutableSet *selectors; +@property (nonatomic, strong) NSMutableSet *selectors; - (instancetype)initWithDelegate:(id)delegate proxy:(id)proxy; diff --git a/SensorsAnalyticsSDK/Core/SALimitKeyManager.m b/SensorsAnalyticsSDK/Core/SALimitKeyManager.m index 04164a5d..00a04254 100644 --- a/SensorsAnalyticsSDK/Core/SALimitKeyManager.m +++ b/SensorsAnalyticsSDK/Core/SALimitKeyManager.m @@ -27,7 +27,7 @@ @interface SALimitKeyManager () -@property (nonatomic, copy) NSMutableDictionary *keys; +@property (nonatomic, strong) NSMutableDictionary *keys; @end diff --git a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m index f269c8ec..3e61f4be 100755 --- a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m +++ b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m @@ -64,7 +64,7 @@ #import "SALimitKeyManager.h" #import "NSDictionary+SACopyProperties.h" -#define VERSION @"4.5.0" +#define VERSION @"4.5.1" void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag; diff --git a/SensorsAnalyticsSDK/Core/Utils/NSObject+SAToString.h b/SensorsAnalyticsSDK/Core/Utils/NSObject+SAToString.h new file mode 100644 index 00000000..48e4f5be --- /dev/null +++ b/SensorsAnalyticsSDK/Core/Utils/NSObject+SAToString.h @@ -0,0 +1,31 @@ +// +// NSObject+SAToString.h +// SensorsAnalyticsSDK +// +// Created by 陈玉国 on 2022/11/29. +// Copyright © 2015-2022 Sensors Data Co., Ltd. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSObject (SAToString) + +- (NSString *)sensorsdata_toString; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SensorsAnalyticsSDK/Core/Utils/NSObject+SAToString.m b/SensorsAnalyticsSDK/Core/Utils/NSObject+SAToString.m new file mode 100644 index 00000000..af35f1d9 --- /dev/null +++ b/SensorsAnalyticsSDK/Core/Utils/NSObject+SAToString.m @@ -0,0 +1,41 @@ +// +// NSObject+SAToString.m +// SensorsAnalyticsSDK +// +// Created by 陈玉国 on 2022/11/29. +// Copyright © 2015-2022 Sensors Data Co., Ltd. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#if ! __has_feature(objc_arc) +#error This file must be compiled with ARC. Either turn on ARC for the project or use -fobjc-arc flag on this file. +#endif + +#import "NSObject+SAToString.h" +#import "SADateFormatter.h" + +@implementation NSObject (SAToString) + +- (NSString *)sensorsdata_toString { + if ([self isKindOfClass:[NSString class]]) { + return (NSString *)self; + } + if ([self isKindOfClass:[NSDate class]]) { + NSDateFormatter *dateFormatter = [SADateFormatter dateFormatterFromString:kSAEventDateFormatter]; + return [dateFormatter stringFromDate:(NSDate *)self]; + } + return self.description; +} + +@end