Skip to content

Commit

Permalink
Release 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujg-00 committed Aug 13, 2021
1 parent 50747eb commit a0c5ba2
Show file tree
Hide file tree
Showing 30 changed files with 470 additions and 245 deletions.
4 changes: 2 additions & 2 deletions SensorsAnalyticsSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SensorsAnalyticsSDK"
s.version = "3.0.3"
s.version = "3.1.0"
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}" }
Expand All @@ -18,7 +18,7 @@ Pod::Spec.new do |s|
c.source_files = core_dir + "**/*.{h,m}"
c.public_header_files = core_dir + "SensorsAnalyticsSDK.h", core_dir + "SensorsAnalyticsSDK+Public.h", core_dir + "SAAppExtensionDataManager.h", core_dir + "SASecurityPolicy.h", core_dir + "SAConfigOptions.h", core_dir + "SAConstants.h"
c.ios.source_files = "SensorsAnalyticsSDK/RemoteConfig/**/*.{h,m}", "SensorsAnalyticsSDK/ChannelMatch/**/*.{h,m}", "SensorsAnalyticsSDK/Encrypt/**/*.{h,m}", "SensorsAnalyticsSDK/Deeplink/**/*.{h,m}", "SensorsAnalyticsSDK/DebugMode/**/*.{h,m}"
c.ios.public_header_files = "SensorsAnalyticsSDK/Encrypt/SASecretKey.h", "SensorsAnalyticsSDK/ChannelMatch/SensorsAnalyticsSDK+SAChannelMatch.h"
c.ios.public_header_files = "SensorsAnalyticsSDK/Encrypt/SAConfigOptions+Encrypt.h", "SensorsAnalyticsSDK/Encrypt/SAEncryptProtocol.h", "SensorsAnalyticsSDK/Encrypt/SASecretKey.h", "SensorsAnalyticsSDK/ChannelMatch/SensorsAnalyticsSDK+SAChannelMatch.h"
c.ios.resource = 'SensorsAnalyticsSDK/SensorsAnalyticsSDK.bundle'
c.ios.frameworks = 'CoreTelephony'
end
Expand Down
4 changes: 2 additions & 2 deletions SensorsAnalyticsSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
A82E894E267D918100475757 /* SASecretKeyFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = A82E893D267D918100475757 /* SASecretKeyFactory.m */; };
A82E894F267D918100475757 /* SAEncryptManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A82E893E267D918100475757 /* SAEncryptManager.m */; };
A82E8950267D918100475757 /* SAAESEncryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A82E893F267D918100475757 /* SAAESEncryptor.h */; };
A82E8951267D918100475757 /* SAEncryptProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = A82E8940267D918100475757 /* SAEncryptProtocol.h */; };
A82E8951267D918100475757 /* SAEncryptProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = A82E8940267D918100475757 /* SAEncryptProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
A82E8952267D918100475757 /* SAECCPluginEncryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A82E8941267D918100475757 /* SAECCPluginEncryptor.h */; };
A82E8953267D918100475757 /* SAECCEncryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A82E8942267D918100475757 /* SAECCEncryptor.h */; };
A82E8954267D918100475757 /* SARSAEncryptor.m in Sources */ = {isa = PBXBuildFile; fileRef = A82E8943267D918100475757 /* SARSAEncryptor.m */; };
Expand Down Expand Up @@ -284,7 +284,7 @@
F277F5E425CFCE56009B5CE6 /* NSObject+DelegateProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = F277F5E225CFCE56009B5CE6 /* NSObject+DelegateProxy.h */; };
F2E9723125E637820009A2B9 /* SAAppPushManager.h in Headers */ = {isa = PBXBuildFile; fileRef = F2E9722F25E637820009A2B9 /* SAAppPushManager.h */; };
F2E9723225E637820009A2B9 /* SAAppPushManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F2E9723025E637820009A2B9 /* SAAppPushManager.m */; };
FC002920262C189E00A18FE3 /* SAConfigOptions+Encrypt.h in Headers */ = {isa = PBXBuildFile; fileRef = FC0028EF2629756400A18FE3 /* SAConfigOptions+Encrypt.h */; };
FC002920262C189E00A18FE3 /* SAConfigOptions+Encrypt.h in Headers */ = {isa = PBXBuildFile; fileRef = FC0028EF2629756400A18FE3 /* SAConfigOptions+Encrypt.h */; settings = {ATTRIBUTES = (Public, ); }; };
FC23719523D0519A00DDD708 /* SALinkHandlerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = FC23719423D0519A00DDD708 /* SALinkHandlerTests.m */; };
FC3C58DA23BEEFB000D83BF4 /* SATrackTimerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = FC3C58D923BEEFB000D83BF4 /* SATrackTimerTests.m */; };
FC80AB7C242CB17A006D1D25 /* SAIdentifierTests.m in Sources */ = {isa = PBXBuildFile; fileRef = FC80AB7B242CB17A006D1D25 /* SAIdentifierTests.m */; };
Expand Down
4 changes: 2 additions & 2 deletions SensorsAnalyticsSDK/AutoTrack/SAAutoTrackManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ - (void)remoteConfigModelChanged:(NSNotification *)sender {

- (BOOL)isAutoTrackEnabled {
if (self.isDisableSDK) {
SALogDebug(@"【remote config】SDK is disabled");
SALogDebug(@"SDK is disabled");
return NO;
}

Expand All @@ -176,7 +176,7 @@ - (BOOL)isAutoTrackEnabled {

- (BOOL)isAutoTrackEventTypeIgnored:(SensorsAnalyticsAutoTrackEventType)eventType {
if (self.isDisableSDK) {
SALogDebug(@"【remote config】SDK is disabled");
SALogDebug(@"SDK is disabled");
return YES;
}

Expand Down
14 changes: 14 additions & 0 deletions SensorsAnalyticsSDK/Core/SAConfigOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, strong) SASecurityPolicy *securityPolicy API_UNAVAILABLE(macos);

/**
* @abstract
* 设置 flush 时网络发送策略
*
* @discussion
* 默认 3G、4G、WI-FI 环境下都会尝试 flush
*/
@property (nonatomic) SensorsAnalyticsNetworkType flushNetworkPolicy;

/**
* @property
*
Expand Down Expand Up @@ -119,6 +128,11 @@ NS_ASSUME_NONNULL_BEGIN
/// 开启 log 打印
@property (nonatomic, assign) BOOL enableLog;

/// 禁用 SDK,默认为 NO
///
/// 禁用后,SDK 将不会触发事件,也不会发送网络请求
@property (nonatomic, assign) BOOL disableSDK;

/// 开启点击图
@property (nonatomic, assign) BOOL enableHeatMap API_UNAVAILABLE(macos);

Expand Down
14 changes: 13 additions & 1 deletion SensorsAnalyticsSDK/Core/SAConfigOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@interface SAConfigOptions ()<NSCopying>

@property (nonatomic, strong, readwrite) NSMutableArray *encryptors;
@property (atomic, strong, readwrite) NSMutableArray *encryptors;

@end

Expand All @@ -53,6 +53,16 @@ - (instancetype)initWithServerURL:(NSString *)serverURL launchOptions:(id)launch
#ifdef SENSORS_ANALYTICS_ENABLE_AUTOTRACK_CHILD_VIEWSCREEN
_enableAutoTrackChildViewScreen = YES;
#endif

_flushNetworkPolicy =
#if TARGET_OS_IOS
SensorsAnalyticsNetworkType3G |
SensorsAnalyticsNetworkType4G |
#ifdef __IPHONE_14_1
SensorsAnalyticsNetworkType5G |
#endif
#endif
SensorsAnalyticsNetworkTypeWIFI;
}
return self;
}
Expand All @@ -68,6 +78,8 @@ - (id)copyWithZone:(nullable NSZone *)zone {
options.maxCacheSize = self.maxCacheSize;
options.enableLog = self.enableLog;
options.flushBeforeEnterBackground = self.flushBeforeEnterBackground;
options.flushNetworkPolicy = self.flushNetworkPolicy;
options.disableSDK = self.disableSDK;

#if TARGET_OS_IOS
// 支持 https 自签证书
Expand Down
8 changes: 8 additions & 0 deletions SensorsAnalyticsSDK/Core/SAModuleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ typedef NS_ENUM(NSUInteger, SAModuleType) {

+ (instancetype)sharedInstance;

- (BOOL)isDisableSDK;

/// 关闭所有的模块功能
- (void)disableAllModules;

/// 当前 SDK 中是否包含特定类型的模块
/// @param type 需要判断的模块类型
/// @return 是否包含
Expand All @@ -56,6 +61,9 @@ typedef NS_ENUM(NSUInteger, SAModuleType) {
/// @param type 模块类型
- (void)setEnable:(BOOL)enable forModuleType:(SAModuleType)type;

/// 更新数据接收地址
/// @param serverURL 新的数据接收地址
- (void)updateServerURL:(NSString *)serverURL;
@end

#pragma mark -
Expand Down
38 changes: 34 additions & 4 deletions SensorsAnalyticsSDK/Core/SAModuleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ @implementation SAModuleManager

+ (void)startWithConfigOptions:(SAConfigOptions *)configOptions debugMode:(SensorsAnalyticsDebugMode)debugMode {
SAModuleManager.sharedInstance.configOptions = configOptions;
// 禁止 SDK 时,不开启其他模块
if (configOptions.disableSDK) {
return;
}

// H5 打通模块
if (configOptions.enableJavaScriptBridge) {
Expand Down Expand Up @@ -172,6 +176,27 @@ - (void)setEnable:(BOOL)enable forModule:(NSString *)moduleName {

#pragma mark - Public

- (BOOL)isDisableSDK {
if (self.configOptions.disableSDK) {
return YES;
}
id<SARemoteConfigModuleProtocol, SAModuleProtocol> manager = (id<SARemoteConfigModuleProtocol, SAModuleProtocol>)self.modules[kSARemoteConfigModuleName];
return manager.isEnable ? manager.isDisableSDK : NO;
}

- (void)disableAllModules {
NSArray<NSString *> *allKeys = self.modules.allKeys;
for (NSString *key in allKeys) {
// 这两个模块是使用接口开启,所以在 SAConfigOptions 中不存在标记,无法重新开启
// 当定位弹窗出现时,如果关闭了定位模块,会导致弹窗消失
if (![key isEqualToString:kSALocationModuleName] &&
![key isEqualToString:kSADeviceOrientationModuleName] &&
![key isEqualToString:kSADebugModeModuleName]) {
[self.modules removeObjectForKey:key];
}
}
}

- (BOOL)contains:(SAModuleType)type {
NSString *moduleName = [self moduleNameForType:type];
NSString *className = [self classNameForModule:moduleName];
Expand All @@ -188,6 +213,15 @@ - (void)setEnable:(BOOL)enable forModuleType:(SAModuleType)type {
[self setEnable:enable forModule:name];
}

- (void)updateServerURL:(NSString *)serverURL {
[self.modules enumerateKeysAndObjectsUsingBlock:^(NSString *key, id<SAModuleProtocol> obj, BOOL *stop) {
if (!([obj conformsToProtocol:@protocol(SAModuleProtocol)] && [obj respondsToSelector:@selector(updateServerURL:)]) || !obj.isEnable) {
return;
}
[obj updateServerURL:serverURL];
}];
}

#pragma mark - Open URL

- (BOOL)canHandleURL:(NSURL *)url {
Expand Down Expand Up @@ -409,8 +443,4 @@ - (BOOL)isIgnoreEventObject:(SABaseEventObject *)obj {
return [self.remoteConfigManager isIgnoreEventObject:obj];
}

- (BOOL)isDisableSDK {
return [self.remoteConfigManager isDisableSDK];
}

@end
2 changes: 2 additions & 0 deletions SensorsAnalyticsSDK/Core/SAModuleProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, strong) SAConfigOptions *configOptions;

- (void)updateServerURL:(NSString *)serverURL;

@end

#pragma mark -
Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/SAObject+SAConfigOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ - (BOOL)isDebugMode {
}

- (SensorsAnalyticsNetworkType)networkTypePolicy {
return [[SensorsAnalyticsSDK.sdkInstance valueForKey:@"networkTypePolicy"] integerValue];
return SensorsAnalyticsSDK.sdkInstance.configOptions.flushNetworkPolicy;
}

- (NSInteger)flushBulkSize {
Expand Down
62 changes: 34 additions & 28 deletions SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (SensorsAnalyticsSDK * _Nullable)sharedInstance;

/// 禁用 SDK。调用后,SDK 将不采集事件,不发送网络请求
+ (void)disableSDK;

/// 开启 SDK。如果之前 SDK 是禁止状态,调用后将恢复数据采集功能
+ (void)enableSDK;

/**
* @abstract
* 返回预置的属性
Expand Down Expand Up @@ -125,28 +131,6 @@ NS_ASSUME_NONNULL_BEGIN

#pragma mark--cache and flush

/**
* @abstract
* 设置本地缓存最多事件条数
*
* @discussion
* 默认为 10000 条事件
*
*/
@property (nonatomic, getter = getMaxCacheSize) UInt64 maxCacheSize __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 maxCacheSize")));
- (UInt64)getMaxCacheSize __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 maxCacheSize")));

/**
* @abstract
* 设置 flush 时网络发送策略
*
* @discussion
* 默认 3G、4G、WI-FI 环境下都会尝试 flush
*
* @param networkType SensorsAnalyticsNetworkType
*/
- (void)setFlushNetworkPolicy:(SensorsAnalyticsNetworkType)networkType;

/**
* @abstract
* 登录,设置当前用户的 loginId
Expand Down Expand Up @@ -187,12 +171,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)resetAnonymousId;

/**
* @abstract
* 自动收集 App Crash 日志,该功能默认是关闭的
*/
- (void)trackAppCrash __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 enableTrackAppCrash"))) API_UNAVAILABLE(macos);

/**
* @abstract
* 设置是否显示 debugInfoView,对于 iOS,是 UIAlertView/UIAlertController
Expand Down Expand Up @@ -868,6 +846,28 @@ DeepLink 回调函数
*/
@property (atomic) BOOL flushBeforeEnterBackground __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 flushBeforeEnterBackground")));

/**
* @abstract
* 设置本地缓存最多事件条数
*
* @discussion
* 默认为 10000 条事件
*
*/
@property (nonatomic, getter = getMaxCacheSize) UInt64 maxCacheSize __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 maxCacheSize")));
- (UInt64)getMaxCacheSize __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 maxCacheSize")));

/**
* @abstract
* 设置 flush 时网络发送策略
*
* @discussion
* 默认 3G、4G、WI-FI 环境下都会尝试 flush
*
* @param networkType SensorsAnalyticsNetworkType
*/
- (void)setFlushNetworkPolicy:(SensorsAnalyticsNetworkType)networkType __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 flushNetworkPolicy")));

/**
* @abstract
* 根据传入的配置,初始化并返回一个 SensorsAnalyticsSDK 的单例
Expand Down Expand Up @@ -921,6 +921,12 @@ DeepLink 回调函数
*/
- (void)setDebugMode:(SensorsAnalyticsDebugMode)debugMode __attribute__((deprecated("已过时,建议动态开启调试模式"))) API_UNAVAILABLE(macos);

/**
* @abstract
* 自动收集 App Crash 日志,该功能默认是关闭的
*/
- (void)trackAppCrash __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 enableTrackAppCrash"))) API_UNAVAILABLE(macos);

/**
* @abstract
* 提供一个接口,用来在用户注册的时候,用注册ID来替换用户以前的匿名ID
Expand Down
4 changes: 4 additions & 0 deletions SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@
#if __has_include("SASecretKey.h")
#import "SASecretKey.h"
#endif

#if __has_include("SAConfigOptions+Encrypt.h")
#import "SAConfigOptions+Encrypt.h"
#endif
Loading

0 comments on commit a0c5ba2

Please sign in to comment.