Skip to content

Commit

Permalink
Release 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujg-00 committed Apr 29, 2021
1 parent f3c7143 commit a12b862
Show file tree
Hide file tree
Showing 105 changed files with 5,834 additions and 1,935 deletions.
1 change: 0 additions & 1 deletion Example/SensorsData/AutoTrackViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ - (IBAction)onButton1Click:(UIButton *)sender {
}

- (IBAction)segmentOnClick:(UISegmentedControl *)sender {

}

- (IBAction)pageValueChanged:(UIPageControl *)sender {
Expand Down
10 changes: 9 additions & 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 = "2.5.5"
s.version = "2.6.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 @@ -21,6 +21,7 @@ Pod::Spec.new do |s|
s.subspec 'Core' do |c|
c.dependency 'SensorsAnalyticsSDK/Common'
c.dependency 'SensorsAnalyticsSDK/Gesture'
c.dependency 'SensorsAnalyticsSDK/Visualized'
end

# 支持 CAID 渠道匹配
Expand All @@ -37,6 +38,13 @@ Pod::Spec.new do |s|
g.private_header_files = 'SensorsAnalyticsSDK/Gesture/**/*.h'
end

# 可视化相关功能,包含可视化全埋点和点击图
s.subspec 'Visualized' do |f|
f.dependency 'SensorsAnalyticsSDK/Common'
f.source_files = "SensorsAnalyticsSDK/Visualized/**/*.{h,m}"
f.public_header_files = 'SensorsAnalyticsSDK/Visualized/SensorsAnalyticsSDK+Visualized.h'
end

# 开启 GPS 定位采集
s.subspec 'Location' do |f|
f.frameworks = 'CoreLocation'
Expand Down
735 changes: 421 additions & 314 deletions SensorsAnalyticsSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#import "SAAutoTrackUtils.h"
#import "SensorsAnalyticsSDK+Private.h"
#import "SAConstants+Private.h"
#import "SAModuleManager.h"
#import <objc/message.h>

@implementation SAScrollViewDelegateProxy
Expand Down Expand Up @@ -55,7 +56,20 @@ + (void)trackEventWithTarget:(NSObject *)target scrollView:(UIScrollView *)scrol
NSDictionary *dic = [SAAutoTrackUtils propertiesWithAutoTrackDelegate:scrollView didSelectedAtIndexPath:indexPath];
[properties addEntriesFromDictionary:dic];

[[SensorsAnalyticsSDK sharedInstance] trackAutoEvent:SA_EVENT_NAME_APP_CLICK properties:properties];
// 解析 Cell
UIView *cell = [SAAutoTrackUtils cellWithScrollView:scrollView selectedAtIndexPath:indexPath];
if (!cell) {
[[SensorsAnalyticsSDK sharedInstance] trackAutoEvent:SA_EVENT_NAME_APP_CLICK properties:properties];
return;
}

// 获取自定义属性
[SAModuleManager.sharedInstance visualPropertiesWithView:cell completionHandler:^(NSDictionary * _Nullable visualProperties) {
if (visualProperties) {
[properties addEntriesFromDictionary:visualProperties];
}
[[SensorsAnalyticsSDK sharedInstance] trackAutoEvent:SA_EVENT_NAME_APP_CLICK properties:properties];
}];
}

@end
21 changes: 0 additions & 21 deletions SensorsAnalyticsSDK/Core/AutoTrack/SAAutoTrackProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,4 @@
#pragma mark -
@protocol SAAutoTrackCellProperty <SAAutoTrackViewProperty>
- (NSString *)sensorsdata_elementPositionWithIndexPath:(NSIndexPath *)indexPath;
- (NSString *)sensorsdata_itemPathWithIndexPath:(NSIndexPath *)indexPath;

- (NSString *)sensorsdata_similarPathWithIndexPath:(NSIndexPath *)indexPath;
/// 遍历查找 cell 所在的 indexPath
@property (nonatomic, strong, readonly) NSIndexPath *sensorsdata_IndexPath;
@end



#pragma mark -
@protocol SAAutoTrackViewPathProperty <NSObject>

/// $AppClick 某个元素的相对路径,拼接 $element_path,用于可视化全埋点
@property (nonatomic, copy, readonly) NSString *sensorsdata_itemPath;

/// $AppClick 某个元素的相对路径,拼接 $element_selector,用于点击图
@property (nonatomic, copy, readonly) NSString *sensorsdata_heatMapPath;

@optional
/// 元素相似路径,可能包含 [-]
@property (nonatomic, copy, readonly) NSString *sensorsdata_similarPath;
@end
77 changes: 14 additions & 63 deletions SensorsAnalyticsSDK/Core/AutoTrack/SAAutoTrackUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark -
@interface SAAutoTrackUtils (Property)

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

/**
采集 ViewController 中的事件属性
Expand Down Expand Up @@ -87,74 +99,13 @@ NS_ASSUME_NONNULL_BEGIN

@end

#pragma mark -
@interface SAAutoTrackUtils (ViewPath)

/**
自动采集时,是否忽略这个 viewController 对象
@param viewController 需要判断的对象
@return 是否忽略
*/
+ (BOOL)isIgnoredViewPathForViewController:(UIViewController *)viewController;

/**
创建 view 的唯一标识符
@param view 需要创建的对象
@return 唯一标识符
*/
+ (nullable NSString *)viewIdentifierForView:(UIView *)view;

/**
通过响应链找到 对象的点击图路径
@param responder 响应链中的对象,可以是 UIView 或者 UIViewController
@return 路径
*/
+ (NSString *)itemHeatMapPathForResponder:(UIResponder *)responder;

/**
通过响应链找到 对象的序号
@param responder 响应链中的对象,可以是 UIView 或者 UIViewController
@return 路径
*/
+ (NSInteger )itemIndexForResponder:(UIResponder *)responder;

/**
找到 view 的路径数组
@param view 需要获取路径的 view
@return 路径数组
*/
+ (NSArray<NSString *> *)viewPathsForView:(UIView *)view;

/**
获取 view 的路径字符串
@param view 需要获取路径的 view
@param viewController view 所在的 viewController
@return 路径字符串
*/
+ (nullable NSString *)viewPathForView:(UIView *)view atViewController:(UIViewController *)viewController;

/**
获取 view 的模糊路径
@param view 需要获取路径的 view
@param viewController view 所在的 viewController
@param shouldSimilarPath 是否需要取相似路径
@return 路径字符串
*/
+ (NSString *)viewSimilarPathForView:(UIView *)view atViewController:(UIViewController *)viewController shouldSimilarPath:(BOOL)shouldSimilarPath;
@end

#pragma mark -
@interface SAAutoTrackUtils (IndexPath)

+ (nullable NSMutableDictionary<NSString *, NSString *> *)propertiesWithAutoTrackObject:(UIScrollView<SAAutoTrackViewProperty> *)object didSelectedAtIndexPath:(NSIndexPath *)indexPath;

+ (UIView *)cellWithScrollView:(UIScrollView *)scrollView selectedAtIndexPath:(NSIndexPath *)indexPath;

+ (NSDictionary *)propertiesWithAutoTrackDelegate:(UIScrollView *)scrollView didSelectedAtIndexPath:(NSIndexPath *)indexPath;
@end

Expand Down
Loading

0 comments on commit a12b862

Please sign in to comment.