Skip to content

Commit

Permalink
Release 4.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
王洋洋 committed Sep 30, 2022
1 parent 94ca990 commit 4fc1164
Show file tree
Hide file tree
Showing 100 changed files with 4,260 additions and 768 deletions.
13 changes: 10 additions & 3 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.4.5"
s.version = "4.4.6"
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 Expand Up @@ -36,8 +36,8 @@ Pod::Spec.new do |s|
c.dependency 'SensorsAnalyticsSDK/Extension'
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'
c.ios.public_header_files = 'SensorsAnalyticsSDK/{Encrypt,RemoteConfig,ChannelMatch,Deeplink,DebugMode}/{SAConfigOptions,SensorsAnalyticsSDK}+*.h', 'SensorsAnalyticsSDK/Encrypt/SAEncryptProtocol.h', 'SensorsAnalyticsSDK/Encrypt/SASecretKey.h', 'SensorsAnalyticsSDK/Deeplink/SASlinkCreator.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}', 'SensorsAnalyticsSDK/Core/SAAlertController.h', 'SensorsAnalyticsSDK/UIRelated/**/*.{h,m}'
c.ios.public_header_files = 'SensorsAnalyticsSDK/{Encrypt,RemoteConfig,ChannelMatch,Deeplink,DebugMode}/{SAConfigOptions,SensorsAnalyticsSDK}+*.h', 'SensorsAnalyticsSDK/Encrypt/SAEncryptProtocol.h', 'SensorsAnalyticsSDK/Encrypt/SASecretKey.h', 'SensorsAnalyticsSDK/Deeplink/SASlinkCreator.h', 'SensorsAnalyticsSDK/UIRelated/UIView+SensorsAnalytics.h'
end

s.subspec 'Core' do |c|
Expand Down Expand Up @@ -125,4 +125,11 @@ Pod::Spec.new do |s|
d.project_header_files = 'CellClick_HookDelegate_Deprecated/*.h'
end

s.subspec 'Exposure' do |h|
h.ios.deployment_target = '8.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'
end

end
272 changes: 260 additions & 12 deletions SensorsAnalyticsSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "UIScrollView+SAAutoTrack.h"
#import "SAAutoTrackManager.h"
#import <objc/message.h>
#import "UIScrollView+SADelegateHashTable.h"

@implementation SAScrollViewDelegateProxy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ NS_ASSUME_NONNULL_BEGIN

@interface UITableView (AutoTrack)

@property (nonatomic, strong, nullable) NSHashTable *sensorsdata_delegateHashTable;

- (void)sensorsdata_setDelegate:(id <UITableViewDelegate>)delegate;

@end

@interface UICollectionView (AutoTrack)

@property (nonatomic, strong, nullable) NSHashTable *sensorsdata_delegateHashTable;

- (void)sensorsdata_setDelegate:(id <UICollectionViewDelegate>)delegate;

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,8 @@
#import "SAConstants+Private.h"
#import "SAAutoTrackManager.h"

static const void *kSATableViewDelegateHashTable = &kSATableViewDelegateHashTable;
static const void *kSACollectionViewDelegateHashTable = &kSACollectionViewDelegateHashTable;

@implementation UITableView (AutoTrack)

- (void)setSensorsdata_delegateHashTable:(NSHashTable *)delegateHashTable {
objc_setAssociatedObject(self, kSATableViewDelegateHashTable, delegateHashTable, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSHashTable *)sensorsdata_delegateHashTable {
NSHashTable *delegateHashTable = objc_getAssociatedObject(self, kSATableViewDelegateHashTable);
if (!delegateHashTable) {
delegateHashTable = [NSHashTable weakObjectsHashTable];
self.sensorsdata_delegateHashTable = delegateHashTable;
}
return delegateHashTable;
}

- (void)sensorsdata_setDelegate:(id <UITableViewDelegate>)delegate {
//resolve optional selectors
[SAScrollViewDelegateProxy resolveOptionalSelectorsForDelegate:delegate];
Expand All @@ -71,19 +55,6 @@ - (void)sensorsdata_setDelegate:(id <UITableViewDelegate>)delegate {

@implementation UICollectionView (AutoTrack)

- (void)setSensorsdata_delegateHashTable:(NSHashTable *)delegateHashTable {
objc_setAssociatedObject(self, kSACollectionViewDelegateHashTable, delegateHashTable, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSHashTable *)sensorsdata_delegateHashTable {
NSHashTable *delegateHashTable = objc_getAssociatedObject(self, kSACollectionViewDelegateHashTable);
if (!delegateHashTable) {
delegateHashTable = [NSHashTable weakObjectsHashTable];
self.sensorsdata_delegateHashTable = delegateHashTable;
}
return delegateHashTable;
}

- (void)sensorsdata_setDelegate:(id <UICollectionViewDelegate>)delegate {
//resolve optional selectors
[SAScrollViewDelegateProxy resolveOptionalSelectorsForDelegate:delegate];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#import "SAAlertController.h"
#import "SAAutoTrackUtils.h"
#import "SAJSONUtil.h"
#import "SAUIProperties.h"

static NSArray <UIView *>* sensorsdata_searchVisualSubView(NSString *type, UIView *view) {
NSMutableArray *subViews = [NSMutableArray array];
Expand Down Expand Up @@ -116,7 +117,7 @@ - (BOOL)isTrackable {
return NO;
}
// 屏蔽 SAAlertController 的点击事件
UIViewController *viewController = [SAAutoTrackUtils findNextViewControllerByResponder:self.gesture.view];
UIViewController *viewController = [SAUIProperties findNextViewControllerByResponder:self.gesture.view];
if ([viewController isKindOfClass:UIAlertController.class] && [viewController.nextResponder isKindOfClass:SAAlertController.class]) {
return NO;
}
Expand Down Expand Up @@ -145,7 +146,7 @@ - (BOOL)isTrackable {
return NO;
}
// 屏蔽 SAAlertController 的点击事件
UIViewController *viewController = [SAAutoTrackUtils findNextViewControllerByResponder:self.gesture.view];
UIViewController *viewController = [SAUIProperties findNextViewControllerByResponder:self.gesture.view];
if ([viewController isKindOfClass:UIAlertController.class] && [viewController.nextResponder isKindOfClass:SAAlertController.class]) {
return NO;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#import "UIViewController+SAAutoTrack.h"
#import "SAAutoTrackUtils.h"
#import "SAAutoTrackManager.h"
#import "UIView+SensorsAnalytics.h"

@implementation UIApplication (AutoTrack)

Expand Down
19 changes: 6 additions & 13 deletions SensorsAnalyticsSDK/AutoTrack/AppClick/UIView+SAAutoTrack.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#import <objc/runtime.h>
#import "SAViewElementInfoFactory.h"
#import "SAAutoTrackManager.h"
#import "SAUIProperties.h"
#import "UIView+SARNView.h"
#import "UIView+SensorsAnalytics.h"

static void *const kSALastAppClickIntervalPropertyName = (void *)&kSALastAppClickIntervalPropertyName;

Expand Down Expand Up @@ -78,7 +81,7 @@ - (NSString *)sensorsdata_elementContent {
return nil;
#pragma clang diagnostic pop
}
if ([SAAutoTrackUtils isKindOfRNView:self]) { // RN 元素,https://reactnative.dev
if ([self isSensorsdataRNView]) { // RN 元素,https://reactnative.dev
NSString *content = [self.accessibilityLabel stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
if (content.length > 0) {
return content;
Expand Down Expand Up @@ -122,16 +125,6 @@ - (NSString *)sensorsdata_elementId {
return self.sensorsAnalyticsViewID;
}

- (UIViewController *)sensorsdata_viewController {
UIViewController *viewController = [SAAutoTrackUtils findNextViewControllerByResponder:self];

// 获取当前 controller 作为 screen_name
if (!viewController || [viewController isKindOfClass:UIAlertController.class]) {
viewController = [SAAutoTrackUtils currentViewController];
}
return viewController;
}

@end

@implementation UILabel (AutoTrack)
Expand All @@ -154,7 +147,7 @@ - (NSString *)sensorsdata_elementContent {

- (NSString *)sensorsdata_elementPosition {
if ([NSStringFromClass(self.class) isEqualToString:@"UISegment"]) {
NSInteger index = [SAAutoTrackUtils itemIndexForResponder:self];
NSInteger index = [SAUIProperties indexWithResponder:self];
return index > 0 ? [NSString stringWithFormat:@"%ld", (long)index] : @"0";
}
return [super sensorsdata_elementPosition];
Expand Down Expand Up @@ -201,7 +194,7 @@ - (NSString *)sensorsdata_elementType {
- (NSString *)sensorsdata_elementPosition {
// UITabBarItem
if ([NSStringFromClass(self.class) isEqualToString:@"UITabBarButton"]) {
NSInteger index = [SAAutoTrackUtils itemIndexForResponder:self];
NSInteger index = [SAUIProperties indexWithResponder:self];
if (index < 0) {
index = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#import "SAAppLifecycle.h"
#import "SensorsAnalyticsSDK+Private.h"
#import "SAAutoTrackManager.h"
#import "SAUIProperties.h"

@implementation SAPageLeaveObject

Expand Down Expand Up @@ -95,7 +96,7 @@ - (void)trackPageEnter:(UIViewController *)viewController {
currentURL = [screenAutoTrackerController getScreenUrl];
}
currentURL = [currentURL isKindOfClass:NSString.class] ? currentURL : NSStringFromClass(viewController.class);
object.referrerURL = [self referrerURLWithURL:currentURL eventProperties:[SAAutoTrackUtils propertiesWithViewController:(UIViewController<SAAutoTrackViewControllerProperty> *)viewController]];
object.referrerURL = [self referrerURLWithURL:currentURL eventProperties:[SAUIProperties propertiesWithViewController:(UIViewController<SAAutoTrackViewControllerProperty> *)viewController]];
self.pageLeaveObjects[address] = object;
}

Expand Down Expand Up @@ -148,7 +149,7 @@ - (void)appLifecycleStateWillChange:(NSNotification *)notification {

- (NSMutableDictionary *)propertiesWithViewController:(UIViewController<SAAutoTrackViewControllerProperty> *)viewController {
NSMutableDictionary *eventProperties = [[NSMutableDictionary alloc] init];
NSDictionary *autoTrackProperties = [SAAutoTrackUtils propertiesWithViewController:viewController];
NSDictionary *autoTrackProperties = [SAUIProperties propertiesWithViewController:viewController];
[eventProperties addEntriesFromDictionary:autoTrackProperties];
if (eventProperties[kSAEventPropertyScreenUrl]) {
return eventProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#import "SAReferrerManager.h"
#import "SAModuleManager.h"
#import "SensorsAnalyticsSDK+SAAutoTrack.h"
#import "SAUIProperties.h"

@interface SAAppViewScreenTracker ()

Expand Down Expand Up @@ -140,7 +141,7 @@ - (BOOL)isBlackListContainsViewController:(UIViewController *)viewController {
- (NSDictionary *)buildWithViewController:(UIViewController *)viewController properties:(NSDictionary<NSString *, id> *)properties autoTrack:(BOOL)autoTrack {
NSMutableDictionary *eventProperties = [[NSMutableDictionary alloc] init];

NSDictionary *autoTrackProperties = [SAAutoTrackUtils propertiesWithViewController:viewController];
NSDictionary *autoTrackProperties = [SAUIProperties propertiesWithViewController:viewController];
[eventProperties addEntriesFromDictionary:autoTrackProperties];

if (autoTrack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,6 @@ - (BOOL)sensorsdata_isIgnored {
return ![[SAAutoTrackManager defaultManager].appClickTracker shouldTrackViewController:self];
}

- (NSString *)sensorsdata_screenName {
return NSStringFromClass([self class]);
}

- (NSString *)sensorsdata_title {
__block NSString *titleViewContent = nil;
__block NSString *controllerTitle = nil;
[SACommonUtility performBlockOnMainThread:^{
titleViewContent = self.navigationItem.titleView.sensorsdata_elementContent;
controllerTitle = self.navigationItem.title;
}];
if (titleViewContent.length > 0) {
return titleViewContent;
}

if (controllerTitle.length > 0) {
return controllerTitle;
}
return nil;
}

- (void)sa_autotrack_viewDidAppear:(BOOL)animated {
// 防止 tabbar 切换,可能漏采 $AppViewScreen 全埋点
if ([self isKindOfClass:UINavigationController.class]) {
Expand Down
16 changes: 5 additions & 11 deletions SensorsAnalyticsSDK/AutoTrack/SAAutoTrackProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,23 @@
#import <Foundation/Foundation.h>

@protocol SAAutoTrackViewControllerProperty <NSObject>

@property (nonatomic, readonly) BOOL sensorsdata_isIgnored;
@property (nonatomic, copy, readonly) NSString *sensorsdata_screenName;
@property (nonatomic, copy, readonly) NSString *sensorsdata_title;

@end

#pragma mark -
@protocol SAAutoTrackViewProperty <NSObject>

@property (nonatomic, readonly) BOOL sensorsdata_isIgnored;
/// 记录上次触发点击事件的开机时间
@property (nonatomic, assign) NSTimeInterval sensorsdata_timeIntervalForLastAppClick;

@property (nonatomic, copy, readonly) NSString *sensorsdata_elementType;
@property (nonatomic, copy, readonly) NSString *sensorsdata_elementContent;
@property (nonatomic, copy, readonly) NSString *sensorsdata_elementId;

/// 元素位置,UISegmentedControl 中返回选中的 index,
@property (nonatomic, copy, readonly) NSString *sensorsdata_elementPosition;

/// 获取 view 所在的 viewController,或者当前的 viewController
@property (nonatomic, readonly) UIViewController<SAAutoTrackViewControllerProperty> *sensorsdata_viewController;
@end

#pragma mark -
@protocol SAAutoTrackCellProperty <SAAutoTrackViewProperty>

- (NSString *)sensorsdata_elementPositionWithIndexPath:(NSIndexPath *)indexPath;

@end
36 changes: 0 additions & 36 deletions SensorsAnalyticsSDK/AutoTrack/SAAutoTrackUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,14 @@ NS_ASSUME_NONNULL_BEGIN

@interface SAAutoTrackUtils : NSObject

#if UIKIT_DEFINE_AS_PROPERTIES
/// 返回当前的 ViewController
@property(class, nonatomic, readonly) UIViewController *currentViewController;
#else
+ (UIViewController *)currentViewController;
#endif

/**
获取响应链中的下一个 UIViewController
@param responder 响应链中的对象
@return 下一个 ViewController
*/
+ (nullable UIViewController *)findNextViewControllerByResponder:(UIResponder *)responder;

/// 在间隔时间内是否采集 $AppClick 全埋点
+ (BOOL)isValidAppClickForObject:(id<SAAutoTrackViewProperty>)object;

/// 判断是否为 RN 元素
+ (BOOL)isKindOfRNView:(UIView *)view;
@end

#pragma mark -
@interface SAAutoTrackUtils (Property)

/**
通过响应链找到 对象的序号
-1:nextResponder 不是父视图或同类元素,比如 controller.view,涉及路径不带序号
>=0:元素序号
@param responder 响应链中的对象,可以是 UIView 或者 UIViewController
@return 序号
*/
+ (NSInteger )itemIndexForResponder:(UIResponder *)responder;

/**
采集 ViewController 中的事件属性
@param viewController 需要采集的 ViewController
@return 事件中与 ViewController 相关的属性字典
*/
+ (NSMutableDictionary<NSString *, NSString *> *)propertiesWithViewController:(UIViewController<SAAutoTrackViewControllerProperty> *)viewController;

/**
通过 AutoTrack 控件,获取事件的属性
Expand Down
Loading

0 comments on commit 4fc1164

Please sign in to comment.