diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 93de2f6a..2a34f555 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -513,7 +513,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -566,7 +566,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -583,7 +583,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 75FYWDWHL5; INFOPLIST_FILE = "$(SRCROOT)/SensorsData/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -603,7 +603,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 75FYWDWHL5; INFOPLIST_FILE = "$(SRCROOT)/SensorsData/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -622,7 +622,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 75FYWDWHL5; INFOPLIST_FILE = SensorsDataSwift/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -644,7 +644,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 75FYWDWHL5; INFOPLIST_FILE = SensorsDataSwift/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/SensorsAnalyticsSDK.podspec b/SensorsAnalyticsSDK.podspec index 6e2f0c35..c0dd47e7 100644 --- a/SensorsAnalyticsSDK.podspec +++ b/SensorsAnalyticsSDK.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| s.name = "SensorsAnalyticsSDK" - s.version = "4.5.6" + s.version = "4.5.7" 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}" } s.license = { :type => "Apache License, Version 2.0" } s.author = { "Yuhan ZOU" => "zouyuhan@sensorsdata.cn" } - s.ios.deployment_target = '8.0' + s.ios.deployment_target = '9.0' s.osx.deployment_target = '10.10' s.default_subspec = 'Core' s.frameworks = 'Foundation', 'SystemConfiguration' @@ -47,7 +47,7 @@ Pod::Spec.new do |s| # 全埋点 s.subspec 'AutoTrack' do |g| - g.ios.deployment_target = '8.0' + g.ios.deployment_target = '9.0' g.dependency 'SensorsAnalyticsSDK/Common' g.source_files = "SensorsAnalyticsSDK/AutoTrack/**/*.{h,m}" g.public_header_files = 'SensorsAnalyticsSDK/AutoTrack/SensorsAnalyticsSDK+SAAutoTrack.h', 'SensorsAnalyticsSDK/AutoTrack/SAConfigOptions+AutoTrack.h' @@ -56,7 +56,7 @@ Pod::Spec.new do |s| # 可视化相关功能,包含可视化全埋点和点击图 s.subspec 'Visualized' do |f| - f.ios.deployment_target = '8.0' + f.ios.deployment_target = '9.0' f.dependency 'SensorsAnalyticsSDK/AutoTrack' f.source_files = "SensorsAnalyticsSDK/Visualized/**/*.{h,m}" f.public_header_files = 'SensorsAnalyticsSDK/Visualized/SensorsAnalyticsSDK+Visualized.h', 'SensorsAnalyticsSDK/Visualized/SAConfigOptions+Visualized.h' @@ -64,7 +64,7 @@ Pod::Spec.new do |s| # 开启 GPS 定位采集 s.subspec 'Location' do |f| - f.ios.deployment_target = '8.0' + f.ios.deployment_target = '9.0' f.frameworks = 'CoreLocation' f.dependency 'SensorsAnalyticsSDK/Core' f.source_files = "SensorsAnalyticsSDK/Location/**/*.{h,m}" @@ -73,7 +73,7 @@ Pod::Spec.new do |s| # 开启设备方向采集 s.subspec 'DeviceOrientation' do |f| - f.ios.deployment_target = '8.0' + f.ios.deployment_target = '9.0' f.dependency 'SensorsAnalyticsSDK/Core' f.source_files = 'SensorsAnalyticsSDK/DeviceOrientation/**/*.{h,m}' f.public_header_files = 'SensorsAnalyticsSDK/DeviceOrientation/SensorsAnalyticsSDK+DeviceOrientation.h' @@ -82,7 +82,7 @@ Pod::Spec.new do |s| # 推送点击 s.subspec 'AppPush' do |f| - f.ios.deployment_target = '8.0' + f.ios.deployment_target = '9.0' f.dependency 'SensorsAnalyticsSDK/Core' f.source_files = "SensorsAnalyticsSDK/AppPush/**/*.{h,m}" f.public_header_files = 'SensorsAnalyticsSDK/AppPush/SAConfigOptions+AppPush.h' @@ -90,7 +90,7 @@ Pod::Spec.new do |s| # 使用崩溃事件采集 s.subspec 'Exception' do |e| - e.ios.deployment_target = '8.0' + e.ios.deployment_target = '9.0' e.dependency 'SensorsAnalyticsSDK/Common' e.source_files = "SensorsAnalyticsSDK/Exception/**/*.{h,m}" e.public_header_files = 'SensorsAnalyticsSDK/Exception/SAConfigOptions+Exception.h' @@ -98,7 +98,7 @@ Pod::Spec.new do |s| # 基于 UA,使用 UIWebView 或者 WKWebView 进行打通 s.subspec 'WebView' do |w| - w.ios.deployment_target = '8.0' + w.ios.deployment_target = '9.0' w.dependency 'SensorsAnalyticsSDK/Core' w.source_files = "SensorsAnalyticsSDK/WebView/**/*.{h,m}" w.public_header_files = 'SensorsAnalyticsSDK/WebView/SensorsAnalyticsSDK+WebView.h' @@ -106,7 +106,7 @@ Pod::Spec.new do |s| # 基于 UA,使用 WKWebView 进行打通 s.subspec 'WKWebView' do |w| - w.ios.deployment_target = '8.0' + w.ios.deployment_target = '9.0' w.dependency 'SensorsAnalyticsSDK/Core' w.source_files = "SensorsAnalyticsSDK/WKWebView/**/*.{h,m}" w.public_header_files = 'SensorsAnalyticsSDK/WKWebView/SensorsAnalyticsSDK+WKWebView.h' @@ -119,14 +119,14 @@ Pod::Spec.new do |s| end s.subspec 'DeprecatedCellClick' do |d| - d.ios.deployment_target = '8.0' + d.ios.deployment_target = '9.0' d.dependency 'SensorsAnalyticsSDK/Core' d.source_files = 'CellClick_HookDelegate_Deprecated/*.{h,m}' d.project_header_files = 'CellClick_HookDelegate_Deprecated/*.h' end s.subspec 'Exposure' do |h| - h.ios.deployment_target = '8.0' + h.ios.deployment_target = '9.0' h.dependency 'SensorsAnalyticsSDK/Common' h.source_files = 'SensorsAnalyticsSDK/Exposure/**/*.{h,m}' h.public_header_files = 'SensorsAnalyticsSDK/Exposure/SAConfigOptions+Exposure.h', 'SensorsAnalyticsSDK/Exposure/SAExposureConfig.h', 'SensorsAnalyticsSDK/Exposure/SAExposureData.h', 'SensorsAnalyticsSDK/Exposure/SensorsAnalyticsSDK+Exposure.h', 'SensorsAnalyticsSDK/Exposure/UIView+ExposureIdentifier.h' diff --git a/SensorsAnalyticsSDK.xcodeproj/project.pbxproj b/SensorsAnalyticsSDK.xcodeproj/project.pbxproj index e6035922..166badd7 100644 --- a/SensorsAnalyticsSDK.xcodeproj/project.pbxproj +++ b/SensorsAnalyticsSDK.xcodeproj/project.pbxproj @@ -3044,7 +3044,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -3100,7 +3100,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -3126,7 +3126,7 @@ GENERATE_MASTER_OBJECT_FILE = YES; INFOPLIST_FILE = "$(SRCROOT)/SupportingFiles/SensorsAnalyticsSDK-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3161,7 +3161,7 @@ GENERATE_MASTER_OBJECT_FILE = YES; INFOPLIST_FILE = "$(SRCROOT)/SupportingFiles/SensorsAnalyticsSDK-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3187,7 +3187,7 @@ DEVELOPMENT_TEAM = 75FYWDWHL5; GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; INFOPLIST_FILE = SensorsAnalyticsTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3205,7 +3205,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 75FYWDWHL5; INFOPLIST_FILE = SensorsAnalyticsTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/SensorsAnalyticsSDK/Core/Builder/EventObject/SAPropertyValidator.m b/SensorsAnalyticsSDK/Core/Builder/EventObject/SAPropertyValidator.m index 58e74233..27edd5fa 100644 --- a/SensorsAnalyticsSDK/Core/Builder/EventObject/SAPropertyValidator.m +++ b/SensorsAnalyticsSDK/Core/Builder/EventObject/SAPropertyValidator.m @@ -36,9 +36,15 @@ - (void)sensorsdata_isValidPropertyKeyWithError:(NSError *__autoreleasing _Null } - (id)sensorsdata_propertyValueWithKey:(NSString *)key error:(NSError *__autoreleasing _Nullable *)error { - NSUInteger length = [self lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - if (length > kSAPropertyValueMaxLength) { - SALogWarn(@"%@'s length is longer than %ld", self, kSAPropertyValueMaxLength); + NSInteger maxLength = kSAPropertyValueMaxLength; + if ([key isEqualToString:@"app_crashed_reason"]) { + maxLength = maxLength * 2; + } + if (self.length >= maxLength) { + SALogWarn(@"%@'s length is longer than %ld", self, maxLength); + NSMutableString *tempString = [NSMutableString stringWithString:[self substringToIndex:maxLength - 1]]; + [tempString appendString:@"$"]; + return [tempString copy]; } return self; } diff --git a/SensorsAnalyticsSDK/Core/Interceptor/Flush/SARepeatFlushInterceptor.m b/SensorsAnalyticsSDK/Core/Interceptor/Flush/SARepeatFlushInterceptor.m index c7c4e06b..e611bce6 100644 --- a/SensorsAnalyticsSDK/Core/Interceptor/Flush/SARepeatFlushInterceptor.m +++ b/SensorsAnalyticsSDK/Core/Interceptor/Flush/SARepeatFlushInterceptor.m @@ -25,7 +25,7 @@ #import "SARepeatFlushInterceptor.h" #import "SAFlowManager.h" -static NSInteger const kSAFlushMaxRepeatCount = 100; +static NSInteger const kSAFlushMaxRepeatCount = 40; @interface SARepeatFlushInterceptor () @end diff --git a/SensorsAnalyticsSDK/Core/Network/SACarrierNamePropertyPlugin.m b/SensorsAnalyticsSDK/Core/Network/SACarrierNamePropertyPlugin.m index c303cece..f268d9a6 100644 --- a/SensorsAnalyticsSDK/Core/Network/SACarrierNamePropertyPlugin.m +++ b/SensorsAnalyticsSDK/Core/Network/SACarrierNamePropertyPlugin.m @@ -28,6 +28,7 @@ #import "SAConstants+Private.h" #import "SALimitKeyManager.h" #import "SAValidator.h" +#import "SACoreResources.h" #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST #import @@ -40,6 +41,7 @@ @interface SACarrierNamePropertyPlugin() #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST @property (nonatomic, strong) CTTelephonyNetworkInfo *networkInfo; +@property (nonatomic, strong) CTCarrier *carrier; #endif @end @implementation SACarrierNamePropertyPlugin @@ -71,24 +73,16 @@ - (NSString *)currentCarrierName { NSString *carrierName = nil; @try { - CTCarrier *carrier = nil; - -#ifdef __IPHONE_12_0 - if (@available(iOS 12.1, *)) { - // 排序 - NSArray *carrierKeysArray = [self.networkInfo.serviceSubscriberCellularProviders.allKeys sortedArrayUsingSelector:@selector(compare:)]; - carrier = self.networkInfo.serviceSubscriberCellularProviders[carrierKeysArray.firstObject]; - if (!carrier.mobileNetworkCode) { - carrier = self.networkInfo.serviceSubscriberCellularProviders[carrierKeysArray.lastObject]; + if (self.carrier != nil) { + NSString *networkCode = nil; + if ([self.carrier respondsToSelector:@selector(mobileNetworkCode)]) { + networkCode = [self.carrier mobileNetworkCode]; + } + + NSString *countryCode = nil; + if ([self.carrier respondsToSelector:@selector(mobileCountryCode)]) { + countryCode = [self.carrier mobileCountryCode]; } - } -#endif - if (!carrier) { - carrier = self.networkInfo.subscriberCellularProvider; - } - if (carrier != nil) { - NSString *networkCode = [carrier mobileNetworkCode]; - NSString *countryCode = [carrier mobileCountryCode]; // 中国运营商 mcc 标识 NSString *carrierChinaMCC = @"460"; @@ -116,12 +110,7 @@ - (NSString *)currentCarrierName { carrierName = SALocalizedString(@"SAPresetPropertyCarrierTietong"); } } else if (countryCode && networkCode) { //国外运营商解析 - //加载当前 bundle - NSBundle *sensorsBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"SensorsAnalyticsSDK" ofType:@"bundle"]]; - //文件路径 - NSString *jsonPath = [sensorsBundle pathForResource:@"sa_mcc_mnc_mini.json" ofType:nil]; - NSData *jsonData = [NSData dataWithContentsOfFile:jsonPath]; - NSDictionary *dicAllMcc = [SAJSONUtil JSONObjectWithData:jsonData]; + NSDictionary *dicAllMcc = [SACoreResources mcc]; if (dicAllMcc) { NSString *mccMncKey = [NSString stringWithFormat:@"%@%@", countryCode, networkCode]; carrierName = dicAllMcc[mccMncKey]; @@ -133,6 +122,26 @@ - (NSString *)currentCarrierName { } return carrierName; } + +- (CTCarrier *)carrier { + if (!_carrier) { +#ifdef __IPHONE_12_0 + if (@available(iOS 12.1, *)) { + // 排序 + NSArray *carrierKeysArray = [self.networkInfo.serviceSubscriberCellularProviders.allKeys sortedArrayUsingSelector:@selector(compare:)]; + _carrier = self.networkInfo.serviceSubscriberCellularProviders[carrierKeysArray.firstObject]; + if (![_carrier respondsToSelector:@selector(mobileNetworkCode)] || !_carrier.mobileNetworkCode) { + _carrier = self.networkInfo.serviceSubscriberCellularProviders[carrierKeysArray.lastObject]; + } + } +#endif + if (!_carrier && [self.networkInfo respondsToSelector:@selector(subscriberCellularProvider)]) { + _carrier = self.networkInfo.subscriberCellularProvider; + } + } + return _carrier; +} + #endif #pragma mark - SAPropertyPlugin method diff --git a/SensorsAnalyticsSDK/Core/SAConstants.m b/SensorsAnalyticsSDK/Core/SAConstants.m index 2fd20d01..32841719 100644 --- a/SensorsAnalyticsSDK/Core/SAConstants.m +++ b/SensorsAnalyticsSDK/Core/SAConstants.m @@ -188,7 +188,7 @@ void sensorsdata_dispatch_safe_sync(dispatch_queue_t queue,DISPATCH_NOESCAPE dis //event name、property key、value max length NSInteger kSAEventNameMaxLength = 100; -NSInteger kSAPropertyValueMaxLength = 1024; +NSInteger kSAPropertyValueMaxLength = 8192; #pragma mark - SA Visualized /// 埋点校验中,$WebClick 匹配可视化全埋点的事件名(集合) diff --git a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m index b1a2157f..3446ac8e 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.6" +#define VERSION @"4.5.7" void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag;