Skip to content

Commit

Permalink
Release 3.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujg-00 committed Aug 30, 2021
1 parent 90a3da5 commit 33a562f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion 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.1.3"
s.version = "3.1.4"
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 Down
4 changes: 4 additions & 0 deletions SensorsAnalyticsSDK/AppPush/SAAppPushManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import "SALog.h"
#import "UIApplication+PushClick.h"
#import "SensorsAnalyticsSDK+Private.h"
#import "SAMethodHelper.h"

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#import "SAUNUserNotificationCenterDelegateProxy.h"
Expand All @@ -49,6 +50,9 @@ - (void)setConfigOptions:(SAConfigOptions *)configOptions {
}

- (void)proxyNotifications {
//处理未实现代理方法也能采集事件的逻辑
[SAMethodHelper swizzleRespondsToSelector];

//UIApplicationDelegate proxy
[SAApplicationDelegateProxy resolveOptionalSelectorsForDelegate:[UIApplication sharedApplication].delegate];
[SAApplicationDelegateProxy proxyDelegate:[UIApplication sharedApplication].delegate selectors:[NSSet setWithArray:@[@"application:didReceiveLocalNotification:", @"application:didReceiveRemoteNotification:fetchCompletionHandler:"]]];
Expand Down
4 changes: 0 additions & 4 deletions SensorsAnalyticsSDK/AutoTrack/SAAutoTrackManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#import "UIApplication+AutoTrack.h"
#import "UIViewController+AutoTrack.h"
#import "SASwizzle.h"
#import "NSObject+DelegateProxy.h"
#import "SAAppStartTracker.h"
#import "SAAppEndTracker.h"
#import "SAConstants+Private.h"
Expand Down Expand Up @@ -275,9 +274,6 @@ - (void)enableAppClickAutoTrack {
[UITableView sa_swizzleMethod:@selector(setDelegate:)
withMethod:selector
error:NULL];
[NSObject sa_swizzleMethod:@selector(respondsToSelector:)
withMethod:@selector(sensorsdata_respondsToSelector:)
error:NULL];
[UICollectionView sa_swizzleMethod:@selector(setDelegate:)
withMethod:selector
error:NULL];
Expand Down
4 changes: 4 additions & 0 deletions SensorsAnalyticsSDK/Core/HookDelegate/SAMethodHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ NS_ASSUME_NONNULL_BEGIN
/// @param toClass 需要替换的方法的类
+ (IMP _Nullable)replaceInstanceMethodWithDestinationSelector:(SEL)destinationSelector sourceSelector:(SEL)sourceSelector fromClass:(Class)fromClass toClass:(Class)toClass;

/// swizzle respondsToSelector 方法
/// 用于处理未实现代理方法也能采集事件的逻辑
+ (void)swizzleRespondsToSelector;

@end

NS_ASSUME_NONNULL_END
11 changes: 11 additions & 0 deletions SensorsAnalyticsSDK/Core/HookDelegate/SAMethodHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#import "SAMethodHelper.h"
#import <objc/runtime.h>
#import "SALog.h"
#import "SASwizzle.h"
#import "NSObject+DelegateProxy.h"

@implementation SAMethodHelper

Expand Down Expand Up @@ -71,4 +73,13 @@ + (IMP _Nullable)replaceInstanceMethodWithDestinationSelector:(SEL)destinationSe
return class_replaceMethod(toClass, destinationSelector, methodIMP, types);
}

+ (void)swizzleRespondsToSelector {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[NSObject sa_swizzleMethod:@selector(respondsToSelector:)
withMethod:@selector(sensorsdata_respondsToSelector:)
error:NULL];
});
}

@end
9 changes: 4 additions & 5 deletions SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#import "SAProfileEventObject.h"
#import "SAJSONUtil.h"

#define VERSION @"3.1.3"
#define VERSION @"3.1.4"

void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag;

Expand Down Expand Up @@ -331,13 +331,12 @@ - (void)login:(NSString *)loginId {
}

- (void)login:(NSString *)loginId withProperties:(NSDictionary * _Nullable )properties {
if (![self.identifier isValidLoginId:loginId]) {
return;
}

SASignUpEventObject *object = [[SASignUpEventObject alloc] initWithEventId:kSAEventNameSignUp];
object.dynamicSuperProperties = [self.superProperty acquireDynamicSuperProperties];
dispatch_async(self.serialQueue, ^{
if (![self.identifier isValidLoginId:loginId]) {
return;
}
[self.identifier login:loginId];
[[NSNotificationCenter defaultCenter] postNotificationName:SA_TRACK_LOGIN_NOTIFICATION object:nil];
[self trackEventObject:object properties:properties];
Expand Down

0 comments on commit 33a562f

Please sign in to comment.