Skip to content

Commit

Permalink
Release 4.5.15
Browse files Browse the repository at this point in the history
  • Loading branch information
王洋洋 committed Aug 17, 2023
1 parent eab2732 commit 4864d5a
Show file tree
Hide file tree
Showing 29 changed files with 208 additions and 73 deletions.
10 changes: 3 additions & 7 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 = "4.5.14"
s.version = "4.5.15"
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 @@ -27,12 +27,8 @@ Pod::Spec.new do |s|
b.dependency 'SensorsAnalyticsSDK/__Store'
end

s.subspec 'Extension' do |e|
e.dependency 'SensorsAnalyticsSDK/Base'
end

s.subspec 'Common' do |c|
c.dependency 'SensorsAnalyticsSDK/Extension'
c.dependency 'SensorsAnalyticsSDK/Base'
c.public_header_files = 'SensorsAnalyticsSDK/JSBridge/SensorsAnalyticsSDK+JavaScriptBridge.h'
c.source_files = 'SensorsAnalyticsSDK/Core/SAAlertController.{h,m}', 'SensorsAnalyticsSDK/JSBridge/**/*.{h,m}'
c.ios.source_files = 'SensorsAnalyticsSDK/RemoteConfig/**/*.{h,m}', 'SensorsAnalyticsSDK/ChannelMatch/**/*.{h,m}', 'SensorsAnalyticsSDK/Encrypt/**/*.{h,m}', 'SensorsAnalyticsSDK/Deeplink/**/*.{h,m}', 'SensorsAnalyticsSDK/DebugMode/**/*.{h,m}', 'SensorsAnalyticsSDK/Core/SAAlertController.h', 'SensorsAnalyticsSDK/UIRelated/**/*.{h,m}'
Expand Down Expand Up @@ -112,7 +108,7 @@ Pod::Spec.new do |s|
end

s.subspec 'ApplicationExtension' do |e|
e.dependency 'SensorsAnalyticsSDK/Extension'
e.dependency 'SensorsAnalyticsSDK/Base'
e.source_files = 'SensorsAnalyticsSDK/AppExtension/*.{h,m}'
e.public_header_files = 'SensorsAnalyticsSDK/AppExtension/SensorsAnalyticsSDK+SAAppExtension.h'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CB6EBAE2228551EC003CFBA8"
BuildableName = "SensorsAnalyticsTests.xctest"
BlueprintName = "SensorsAnalyticsTests"
ReferencedContainer = "container:SensorsAnalyticsSDK.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
Expand Down Expand Up @@ -42,6 +58,15 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CB6EBAE2228551EC003CFBA8"
BuildableName = "SensorsAnalyticsTests.xctest"
BlueprintName = "SensorsAnalyticsTests"
ReferencedContainer = "container:SensorsAnalyticsSDK.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
4 changes: 2 additions & 2 deletions SensorsAnalyticsSDK/AutoTrack/SAAutoTrackManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ - (void)setEnable:(BOOL)enable {

#pragma mark - SAAutoTrackModuleProtocol

- (void)trackAppEndWhenCrashed {
- (void)trackAppEndWhenCrashed NS_EXTENSION_UNAVAILABLE("AppEnd Event not supported for iOS extensions.") {
if (!self.enable) {
return;
}
Expand All @@ -131,7 +131,7 @@ - (void)trackAppEndWhenCrashed {
}];
}

- (void)trackPageLeaveWhenCrashed {
- (void)trackPageLeaveWhenCrashed NS_EXTENSION_UNAVAILABLE("PageLeave Event not supported for iOS extensions.") {
if (!self.enable) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param aClass View 对应的 Class
*/
- (void)ignoreViewType:(Class)aClass;
- (void)ignoreViewType:(Class)aClass NS_EXTENSION_UNAVAILABLE("AutoTrack not supported for iOS extensions.");

/**
* @abstract
Expand All @@ -95,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param controllers controller ‘字符串’数组
*/
- (void)ignoreAutoTrackViewControllers:(NSArray<NSString *> *)controllers;
- (void)ignoreAutoTrackViewControllers:(NSArray<NSString *> *)controllers NS_EXTENSION_UNAVAILABLE("AutoTrack not supported for iOS extensions.");

/**
* @abstract
Expand Down Expand Up @@ -156,7 +156,7 @@ NS_ASSUME_NONNULL_BEGIN
* https://sensorsdata.cn/manual/ios_sdk.html
* 该功能默认关闭
*/
- (void)enableAutoTrack:(SensorsAnalyticsAutoTrackEventType)eventType __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 autoTrackEventType")));
- (void)enableAutoTrack:(SensorsAnalyticsAutoTrackEventType)eventType __attribute__((deprecated("已过时,请参考 SAConfigOptions 类的 autoTrackEventType"))) NS_EXTENSION_UNAVAILABLE("AutoTrack not supported for iOS extensions.");

@end

Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/ChannelMatch/SAChannelMatchManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ - (void)hideIndicator {
_window = nil;
}

- (UIWindow *)alertWindow {
- (UIWindow *)alertWindow NS_EXTENSION_UNAVAILABLE("App Alert not supported for iOS extensions.") {
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000)
if (@available(iOS 13.0, *)) {
__block UIWindowScene *scene = nil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ NS_ASSUME_NONNULL_BEGIN
@param event event 的名称
*/
- (void)trackChannelEvent:(NSString *)event;
- (void)trackChannelEvent:(NSString *)event NS_EXTENSION_UNAVAILABLE("ChannelMatch not supported for iOS extensions.");

/**
调用 track 接口并附加渠道信息
@param event event 的名称
@param propertyDict event 的属性
*/
- (void)trackChannelEvent:(NSString *)event properties:(nullable NSDictionary *)propertyDict;
- (void)trackChannelEvent:(NSString *)event properties:(nullable NSDictionary *)propertyDict NS_EXTENSION_UNAVAILABLE("ChannelMatch not supported for iOS extensions.");

/**
* @abstract
Expand All @@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
* @discussion
* 注意:如果之前使用 - trackInstallation: 触发的激活事件,需要继续保持原来的调用,无需改成 - trackAppInstall: ,否则会导致激活事件数据分离。
*/
- (void)trackAppInstall;
- (void)trackAppInstall NS_EXTENSION_UNAVAILABLE("ChannelMatch not supported for iOS extensions.");

/**
* @abstract
Expand All @@ -57,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param properties 激活事件的属性
*/
- (void)trackAppInstallWithProperties:(nullable NSDictionary *)properties;
- (void)trackAppInstallWithProperties:(nullable NSDictionary *)properties NS_EXTENSION_UNAVAILABLE("ChannelMatch not supported for iOS extensions.");

/**
* @abstract
Expand All @@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param properties 激活事件的属性
* @param disableCallback 是否关闭这次渠道匹配的回调请求
*/
- (void)trackAppInstallWithProperties:(nullable NSDictionary *)properties disableCallback:(BOOL)disableCallback;
- (void)trackAppInstallWithProperties:(nullable NSDictionary *)properties disableCallback:(BOOL)disableCallback NS_EXTENSION_UNAVAILABLE("ChannelMatch not supported for iOS extensions.");

/**
* @abstract
Expand All @@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param event event 的名称
*/
- (void)trackInstallation:(NSString *)event;
- (void)trackInstallation:(NSString *)event NS_EXTENSION_UNAVAILABLE("ChannelMatch not supported for iOS extensions.");

/**
* @abstract
Expand All @@ -98,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param event event 的名称
* @param propertyDict event 的属性
*/
- (void)trackInstallation:(NSString *)event withProperties:(nullable NSDictionary *)propertyDict;
- (void)trackInstallation:(NSString *)event withProperties:(nullable NSDictionary *)propertyDict NS_EXTENSION_UNAVAILABLE("ChannelMatch not supported for iOS extensions.");

/**
* @abstract
Expand All @@ -116,7 +116,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param propertyDict event 的属性
* @param disableCallback 是否关闭这次渠道匹配的回调请求
*/
- (void)trackInstallation:(NSString *)event withProperties:(nullable NSDictionary *)propertyDict disableCallback:(BOOL)disableCallback;
- (void)trackInstallation:(NSString *)event withProperties:(nullable NSDictionary *)propertyDict disableCallback:(BOOL)disableCallback NS_EXTENSION_UNAVAILABLE("ChannelMatch not supported for iOS extensions.");

@end

Expand Down
23 changes: 10 additions & 13 deletions SensorsAnalyticsSDK/Core/NSString+SAHashCode.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,16 @@
@implementation NSString (HashCode)

- (int)sensorsdata_hashCode {
int hash = 0;
for (int i = 0; i<[self length]; i++) {
NSString *s = [self substringWithRange:NSMakeRange(i, 1)];
char *unicode = (char *)[s cStringUsingEncoding:NSUnicodeStringEncoding];
int charactorUnicode = 0;

size_t length = strnlen(unicode, 4);
for (int n = 0; n < length; n ++) {
charactorUnicode += (int)((unicode[n] & 0xff) << (n * sizeof(char) * 8));
}
hash = hash * 31 + charactorUnicode;
int hashCode = 0;
NSUInteger length = [self length];
if (length == 0) {
return hashCode;
}
for (NSUInteger i = 0; i < length; i++) {
unichar character = [self characterAtIndex:i];
hashCode = hashCode * 31 + (int)character;
}

return hash;
return hashCode;
}

@end
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/SAAlertController.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ - (void)showAlertController {
[self presentViewController:alertController animated:YES completion:nil];
}

- (UIWindow *)currentAlertWindow {
- (UIWindow *)currentAlertWindow NS_EXTENSION_UNAVAILABLE("App Alert not supported for iOS extensions.") {
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000)
if (@available(iOS 13.0, *)) {
__block UIWindowScene *scene = nil;
Expand Down
10 changes: 5 additions & 5 deletions SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extern NSString * const SensorsAnalyticsIdentityKeyEmail;
* @param serverUrl 当前的 serverUrl
* @param isRequestRemoteConfig 是否请求远程配置
*/
- (void)setServerUrl:(NSString *)serverUrl isRequestRemoteConfig:(BOOL)isRequestRemoteConfig API_UNAVAILABLE(macos);
- (void)setServerUrl:(NSString *)serverUrl isRequestRemoteConfig:(BOOL)isRequestRemoteConfig API_UNAVAILABLE(macos) NS_EXTENSION_UNAVAILABLE("RemoteConfig not supported for iOS extensions.");

#pragma mark--cache and flush

Expand Down Expand Up @@ -465,15 +465,15 @@ extern NSString * const SensorsAnalyticsIdentityKeyEmail;
* @param url 打开的 URL
* @return YES/NO
*/
- (BOOL)canHandleURL:(NSURL *)url API_UNAVAILABLE(macos);
- (BOOL)canHandleURL:(NSURL *)url API_UNAVAILABLE(macos) NS_EXTENSION_UNAVAILABLE("HandleURL not supported for iOS extensions.");

/**
* @abstract
* 处理 url scheme 跳转打开 App
*
* @param url 打开本 app 的回调的 url
*/
- (BOOL)handleSchemeUrl:(NSURL *)url API_UNAVAILABLE(macos);
- (BOOL)handleSchemeUrl:(NSURL *)url API_UNAVAILABLE(macos) NS_EXTENSION_UNAVAILABLE("HandleURL not supported for iOS extensions.");

#pragma mark - profile
/**
Expand Down Expand Up @@ -624,7 +624,7 @@ extern NSString * const SensorsAnalyticsIdentityKeyEmail;
* 注意:清除 keychain 中 kSAService 名下的数据,包括 distinct_id 标记。
*
*/
- (void)clearKeychainData API_UNAVAILABLE(macos);
- (void)clearKeychainData API_UNAVAILABLE(macos) NS_EXTENSION_UNAVAILABLE("KeychainData not supported for iOS extensions.");

@end

Expand Down Expand Up @@ -692,7 +692,7 @@ extern NSString * const SensorsAnalyticsIdentityKeyEmail;
目前 DebugMode 为动态开启,详细请参考说明文档:https://www.sensorsdata.cn/manual/ios_sdk.html
@param debugMode 调试模式
*/
- (void)setDebugMode:(SensorsAnalyticsDebugMode)debugMode __attribute__((deprecated("已过时,建议动态开启调试模式"))) API_UNAVAILABLE(macos);
- (void)setDebugMode:(SensorsAnalyticsDebugMode)debugMode __attribute__((deprecated("已过时,建议动态开启调试模式"))) API_UNAVAILABLE(macos) NS_EXTENSION_UNAVAILABLE("DebugMode not supported for iOS extensions.");

/**
* @abstract
Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#import "SALimitKeyManager.h"
#import "NSDictionary+SACopyProperties.h"

#define VERSION @"4.5.14"
#define VERSION @"4.5.15"

void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag;

Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/Utils/SAGzipUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ showing how deflateInit2() can be used to make zlib generate a compressed
*/

if (!pUncompressedData || [pUncompressedData length] == 0) {
if (!pUncompressedData || [pUncompressedData length] == 0 || [pUncompressedData bytes] == NULL) {
SALogError(@" Error: Can't compress an empty or null NSData object.");
return nil;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param show 是否显示
*/
- (void)showDebugInfoView:(BOOL)show API_UNAVAILABLE(macos);
- (void)showDebugInfoView:(BOOL)show API_UNAVAILABLE(macos) NS_EXTENSION_UNAVAILABLE("DebugMode not supported for iOS extensions.");

- (SensorsAnalyticsDebugMode)debugMode;

Expand Down
8 changes: 4 additions & 4 deletions SensorsAnalyticsSDK/Deeplink/SensorsAnalyticsSDK+Deeplink.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ DeepLink 回调函数
succes:deepLink 唤起结果
appAwakePassedTime:获取渠道信息所用时间
*/
- (void)setDeeplinkCallback:(void(^)(NSString *_Nullable params, BOOL success, NSInteger appAwakePassedTime))callback API_UNAVAILABLE(macos) __attribute__((deprecated("已过时,请参考 setDeepLinkCompletion")));
- (void)setDeeplinkCallback:(void(^)(NSString *_Nullable params, BOOL success, NSInteger appAwakePassedTime))callback API_UNAVAILABLE(macos) __attribute__((deprecated("已过时,请参考 setDeepLinkCompletion"))) NS_EXTENSION_UNAVAILABLE("DeepLink not supported for iOS extensions.");

/**
触发 $AppDeepLinkLaunch 事件
@param url 唤起 App 的 DeepLink url
*/
- (void)trackDeepLinkLaunchWithURL:(NSString *)url API_UNAVAILABLE(macos);
- (void)trackDeepLinkLaunchWithURL:(NSString *)url API_UNAVAILABLE(macos) NS_EXTENSION_UNAVAILABLE("DeepLink not supported for iOS extensions.");

/**
手动触发 Deferred DeepLink 请求,需要在获取设备权限、网络权限后调用
@param properties 发送请求时自定义参数
*/
- (void)requestDeferredDeepLink:(NSDictionary *)properties API_UNAVAILABLE(macos);
- (void)requestDeferredDeepLink:(NSDictionary *)properties API_UNAVAILABLE(macos) NS_EXTENSION_UNAVAILABLE("DeepLink not supported for iOS extensions.");

/**
@abstract
Expand All @@ -74,7 +74,7 @@ DeepLink 回调函数
若您同时实现了 setDeepLinkCompletion 和 setDeeplinkCallback 两个 API,SDK 内部也只会回调 setDeepLinkCompletion 回调函数。
@param completion 唤起后的回调函数,当页面跳转成功时,completion 返回值 return YES,反之则 return NO
*/
- (void)setDeepLinkCompletion:(BOOL(^)(SADeepLinkObject *_Nullable obj))completion API_UNAVAILABLE(macos);
- (void)setDeepLinkCompletion:(BOOL(^)(SADeepLinkObject *_Nullable obj))completion API_UNAVAILABLE(macos) NS_EXTENSION_UNAVAILABLE("DeepLink not supported for iOS extensions.");

@end

Expand Down
14 changes: 2 additions & 12 deletions SensorsAnalyticsSDK/Exposure/SAExposureManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ - (void)addExposureView:(UIView *)view withData:(SAExposureData *)data {
}
SAExposureViewObject *exposureViewObject = [[SAExposureViewObject alloc] initWithView:view exposureData:data];
exposureViewObject.view.sensorsdata_exposureMark = kSAExposureViewMark;
//get view related items, such as viewController, scrollView, state
if (![view isKindOfClass:[UITableViewCell class]] && ![view isKindOfClass:[UICollectionViewCell class]]) {
exposureViewObject.scrollView = (UIScrollView *)[self nearbyScrollViewByView:view];
}
[exposureViewObject findNearbyScrollView];
[exposureViewObject addExposureViewObserver];
[self.exposureViewObjects addObject:exposureViewObject];
[exposureViewObject exposureConditionCheck];
Expand Down Expand Up @@ -130,14 +127,6 @@ - (SAExposureViewObject *)exposureViewWithView:(UIView *)view {
return nil;
}

- (UIView *)nearbyScrollViewByView:(UIView *)view {
UIView *superView = view.superview;
if ([superView isKindOfClass:[UIScrollView class]] || !superView) {
return superView;
}
return [self nearbyScrollViewByView:superView];
}

- (void)addListener {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil];
Expand All @@ -147,6 +136,7 @@ - (void)addListener {
- (void)swizzleMethods {
[SAMethodHelper swizzleRespondsToSelector];
[UIView sa_swizzleMethod:@selector(didMoveToSuperview) withMethod:@selector(sensorsdata_didMoveToSuperview) error:NULL];
[UIView sa_swizzleMethod:@selector(didMoveToWindow) withMethod:@selector(sensorsdata_didMoveToWindow) error:NULL];
[UITableView sa_swizzleMethod:@selector(setDelegate:) withMethod:@selector(sensorsdata_exposure_setDelegate:) error:NULL];
[UICollectionView sa_swizzleMethod:@selector(setDelegate:) withMethod:@selector(sensorsdata_exposure_setDelegate:) error:NULL];
[UIViewController sa_swizzleMethod:@selector(viewDidAppear:) withMethod:@selector(sensorsdata_exposure_viewDidAppear:) error:NULL];
Expand Down
1 change: 1 addition & 0 deletions SensorsAnalyticsSDK/Exposure/SAExposureViewObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ typedef NS_ENUM(NSUInteger, SAExposureViewType) {
- (void)addExposureViewObserver;
- (void)clear;
- (void)exposureConditionCheck;
- (void)findNearbyScrollView;

@end

Expand Down
Loading

0 comments on commit 4864d5a

Please sign in to comment.