diff --git a/SensorsAnalyticsSDK.podspec b/SensorsAnalyticsSDK.podspec index 2147053b..32ac1eca 100644 --- a/SensorsAnalyticsSDK.podspec +++ b/SensorsAnalyticsSDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SensorsAnalyticsSDK" - s.version = "4.4.0" + s.version = "4.4.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}" } @@ -22,7 +22,7 @@ Pod::Spec.new do |s| core_dir = "SensorsAnalyticsSDK/Core/" b.source_files = core_dir + "**/*.{h,m}" b.exclude_files = core_dir + "SAAlertController.h", core_dir + "SAAlertController.m" - b.public_header_files = core_dir + "SensorsAnalyticsSDK.h", core_dir + "SensorsAnalyticsSDK+Public.h", core_dir + "SASecurityPolicy.h", core_dir + "SAConfigOptions.h", core_dir + "SAConstants.h", core_dir + "PropertyPlugin/SAPropertyPluginProtocol.h" + b.public_header_files = core_dir + "SensorsAnalyticsSDK.h", core_dir + "SensorsAnalyticsSDK+Public.h", core_dir + "SASecurityPolicy.h", core_dir + "SAConfigOptions.h", core_dir + "SAConstants.h", core_dir + "PropertyPlugin/SAPropertyPlugin.h" b.resource = 'SensorsAnalyticsSDK/SensorsAnalyticsSDK.bundle' b.ios.frameworks = 'CoreTelephony' b.dependency 'SensorsAnalyticsSDK/__Store' diff --git a/SensorsAnalyticsSDK/Core/Interceptor/Flush/SAFlushInterceptor.m b/SensorsAnalyticsSDK/Core/Interceptor/Flush/SAFlushInterceptor.m index 5807d879..0ff38a10 100644 --- a/SensorsAnalyticsSDK/Core/Interceptor/Flush/SAFlushInterceptor.m +++ b/SensorsAnalyticsSDK/Core/Interceptor/Flush/SAFlushInterceptor.m @@ -83,7 +83,6 @@ - (void)requestWithInput:(SAFlowData *)input completion:(void (^)(BOOL success)) SAURLSessionTaskCompletionHandler handler = ^(NSData * _Nullable data, NSHTTPURLResponse * _Nullable response, NSError * _Nullable error) { if (error || ![response isKindOfClass:[NSHTTPURLResponse class]]) { input.message = [NSString stringWithFormat:@"%@ network failure: %@", self, error ? error : @"Unknown error"]; - input.state = SAFlowStateStop; return completion(NO); } @@ -115,9 +114,8 @@ - (void)requestWithInput:(SAFlowData *)input completion:(void (^)(BOOL success)) BOOL flushSuccess = input.configOptions.debugMode != SensorsAnalyticsDebugOff || successCode; if (!flushSuccess) { input.message = [NSString stringWithFormat:@"flush failed, statusCode: %ld",statusCode]; - input.state = SAFlowStateStop; } - completion(YES); + completion(flushSuccess); }; NSURLRequest *request = [self buildFlushRequestWithInput:input]; diff --git a/SensorsAnalyticsSDK/Core/PropertyPlugin/SAPropertyPlugin.h b/SensorsAnalyticsSDK/Core/PropertyPlugin/SAPropertyPlugin.h index c44c8187..953c7f93 100644 --- a/SensorsAnalyticsSDK/Core/PropertyPlugin/SAPropertyPlugin.h +++ b/SensorsAnalyticsSDK/Core/PropertyPlugin/SAPropertyPlugin.h @@ -48,8 +48,6 @@ typedef NS_ENUM(NSUInteger, SAPropertyPluginPriority) { @property (nonatomic, copy, readonly) NSString *event; @property (nonatomic, assign, readonly) SAEventType type; @property (nonatomic, assign, readonly) UInt64 time; -/// 开机时间,用于统计事件时长 -@property (nonatomic, assign, readonly) UInt64 currentSystemUpTime; @property (nonatomic, strong, readonly) id lib; diff --git a/SensorsAnalyticsSDK/Core/SAConfigOptions.m b/SensorsAnalyticsSDK/Core/SAConfigOptions.m index 69fde294..c35d0549 100644 --- a/SensorsAnalyticsSDK/Core/SAConfigOptions.m +++ b/SensorsAnalyticsSDK/Core/SAConfigOptions.m @@ -67,12 +67,9 @@ @interface SAConfigOptions () @property (nonatomic, assign) BOOL enableDeviceOrientation; @property (nonatomic, assign) BOOL enableRemoteConfig; @property (nonatomic, assign) BOOL enableChannelMatch; -@property (nonatomic, assign) BOOL enableDebugMode; @property (nonatomic, assign) BOOL enableDeepLink; @property (nonatomic, assign) BOOL enableAutoTrack; -//@property (nonatomic) SensorsAnalyticsDebugMode debugMode; - @end @implementation SAConfigOptions @@ -111,7 +108,6 @@ - (instancetype)initWithServerURL:(NSString *)serverURL launchOptions:(id)launch //default private switch _enableRemoteConfig = YES; _enableChannelMatch = YES; - _enableDebugMode = YES; _enableDeepLink = YES; _enableAutoTrack = YES; @@ -178,7 +174,6 @@ - (id)copyWithZone:(nullable NSZone *)zone { //private switch options.enableRemoteConfig = self.enableRemoteConfig; options.enableChannelMatch = self.enableChannelMatch; - options.enableDebugMode = self.enableDebugMode; options.enableDeepLink = self.enableDeepLink; options.enableAutoTrack = self.enableAutoTrack; options.customADChannelURL = self.customADChannelURL; diff --git a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Private.h b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Private.h index 6efcc43a..f3a69666 100644 --- a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Private.h +++ b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Private.h @@ -57,9 +57,6 @@ /// 需要在队列外执行 - (void)buildDynamicSuperProperties; -/// 注册属性插件 -- (void)registerPropertyPlugin:(SAPropertyPlugin *)plugin; - #pragma mark - property @property (nonatomic, strong, readonly) SAConfigOptions *configOptions; @property (nonatomic, strong, readonly) SANetwork *network; diff --git a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h index 571136cd..49c7e8b1 100644 --- a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h +++ b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h @@ -20,6 +20,7 @@ #import #import "SAConstants.h" +#import "SAPropertyPlugin.h" @class SASecurityPolicy; @class SAConfigOptions; @@ -417,6 +418,14 @@ extern NSString * const SensorsAnalyticsIdentityKeyEmail; */ - (NSDictionary *)currentSuperProperties; +/** + * @abstract + * 注册属性插件 + * + * @param plugin 属性插件对象 + */ +- (void)registerPropertyPlugin:(SAPropertyPlugin *)plugin; + /** * @abstract * 得到 SDK 的版本 diff --git a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m index 7ef63cfe..b08ec0e7 100755 --- a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m +++ b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m @@ -62,7 +62,7 @@ #import "SASessionPropertyPlugin.h" #import "SAEventStore.h" -#define VERSION @"4.4.0" +#define VERSION @"4.4.1" void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag; @@ -1188,6 +1188,11 @@ - (void)trackFromH5WithEventObject:(SABaseEventObject *)object properties:(NSDic #pragma mark - Deprecated @implementation SensorsAnalyticsSDK (Deprecated) +// 广告 SDK 调用,暂时保留 +- (void)asyncTrackEventObject:(SABaseEventObject *)object properties:(NSDictionary *)properties { + [self trackEventObject:object properties:properties]; +} + - (NSInteger)flushInterval { @synchronized(self) { return self.configOptions.flushInterval; diff --git a/SensorsAnalyticsSDK/Core/TrackTimer/SAEventDurationPropertyPlugin.m b/SensorsAnalyticsSDK/Core/TrackTimer/SAEventDurationPropertyPlugin.m index 0bb2b5f4..91139161 100644 --- a/SensorsAnalyticsSDK/Core/TrackTimer/SAEventDurationPropertyPlugin.m +++ b/SensorsAnalyticsSDK/Core/TrackTimer/SAEventDurationPropertyPlugin.m @@ -25,6 +25,7 @@ #import "SAEventDurationPropertyPlugin.h" #import "SAConstants+Private.h" #import "SAPropertyPlugin+SAPrivate.h" +#import "SABaseEventObject.h" @interface SAEventDurationPropertyPlugin() @property (nonatomic, weak) SATrackTimer *trackTimer; @@ -57,10 +58,12 @@ - (SAPropertyPluginPriority)priority { } - (NSDictionary *)properties { - if (!self.filter) { + if (![self.filter isKindOfClass:SABaseEventObject.class]) { return nil; } - NSNumber *eventDuration = [self.trackTimer eventDurationFromEventId:self.filter.event currentSysUpTime:self.filter.currentSystemUpTime]; + + SABaseEventObject *eventObject = (SABaseEventObject *)self.filter; + NSNumber *eventDuration = [self.trackTimer eventDurationFromEventId:eventObject.eventId currentSysUpTime:eventObject.currentSystemUpTime]; if (!eventDuration) { return nil; } diff --git a/SensorsAnalyticsSDK/DebugMode/SADebugModeManager.m b/SensorsAnalyticsSDK/DebugMode/SADebugModeManager.m index d51a4465..88892dc1 100644 --- a/SensorsAnalyticsSDK/DebugMode/SADebugModeManager.m +++ b/SensorsAnalyticsSDK/DebugMode/SADebugModeManager.m @@ -67,6 +67,13 @@ - (void)setConfigOptions:(SAConfigOptions *)configOptions { self.enable = configOptions.debugMode != SensorsAnalyticsDebugOff; } +- (BOOL)isEnable { + if ([SAApplication isAppExtension]) { + return NO; + } + return self.configOptions.debugMode != SensorsAnalyticsDebugOff; +} + #pragma mark - SAOpenURLProtocol - (BOOL)canHandleURL:(nonnull NSURL *)url { diff --git a/SensorsAnalyticsSDK/Visualized/Config/SAVisualPropertiesConfigSources.h b/SensorsAnalyticsSDK/Visualized/Config/SAVisualPropertiesConfigSources.h index 1edc639e..1f186aa3 100644 --- a/SensorsAnalyticsSDK/Visualized/Config/SAVisualPropertiesConfigSources.h +++ b/SensorsAnalyticsSDK/Visualized/Config/SAVisualPropertiesConfigSources.h @@ -54,7 +54,7 @@ NS_ASSUME_NONNULL_BEGIN /// 禁用默认初始化 - (instancetype)init NS_UNAVAILABLE; /// 禁用默认初始化 -- (instancetype)new NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; /// 加载配置 - (void)loadConfig; diff --git a/SensorsAnalyticsSDK/Visualized/VisualProperties/ViewNode/SAViewNodeTree.h b/SensorsAnalyticsSDK/Visualized/VisualProperties/ViewNode/SAViewNodeTree.h index 0f364d0b..b705af78 100644 --- a/SensorsAnalyticsSDK/Visualized/VisualProperties/ViewNode/SAViewNodeTree.h +++ b/SensorsAnalyticsSDK/Visualized/VisualProperties/ViewNode/SAViewNodeTree.h @@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN /// 禁用默认初始化 - (instancetype)init NS_UNAVAILABLE; /// 禁用默认初始化 -- (instancetype)new NS_UNAVAILABLE; ++ (instancetype)new NS_UNAVAILABLE; /// 视图添加或移除 - (void)didMoveToSuperviewWithView:(UIView *)view;