Skip to content

Commit

Permalink
Release 2.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujg-00 committed Jun 2, 2021
1 parent 9294b81 commit f3af22b
Show file tree
Hide file tree
Showing 74 changed files with 1,787 additions and 1,383 deletions.
29 changes: 7 additions & 22 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 = "2.6.4"
s.version = "2.6.5"
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 @@ -13,15 +13,12 @@ Pod::Spec.new do |s|

s.subspec 'Common' do |c|
core_dir = "SensorsAnalyticsSDK/Core/"
auto_track_dir = "SensorsAnalyticsSDK/Core/AutoTrack/"
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", auto_track_dir + "SensorsAnalyticsSDK+SAAutoTrack.h"
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.resource = 'SensorsAnalyticsSDK/SensorsAnalyticsSDK.bundle'
end

s.subspec 'Core' do |c|
c.dependency 'SensorsAnalyticsSDK/Common'
c.dependency 'SensorsAnalyticsSDK/Gesture'
c.dependency 'SensorsAnalyticsSDK/Visualized'
end

Expand All @@ -32,16 +29,16 @@ Pod::Spec.new do |s|
f.private_header_files = 'SensorsAnalyticsSDK/CAID/**/*.h'
end

# 手势采集
s.subspec 'Gesture' do |g|
# 全埋点
s.subspec 'AutoTrack' do |g|
g.dependency 'SensorsAnalyticsSDK/Common'
g.source_files = "SensorsAnalyticsSDK/Gesture/**/*.{h,m}"
g.private_header_files = 'SensorsAnalyticsSDK/Gesture/**/*.h'
g.source_files = "SensorsAnalyticsSDK/AutoTrack/**/*.{h,m}"
g.public_header_files = 'SensorsAnalyticsSDK/AutoTrack/SensorsAnalyticsSDK+SAAutoTrack.h'
end

# 可视化相关功能,包含可视化全埋点和点击图
s.subspec 'Visualized' do |f|
f.dependency 'SensorsAnalyticsSDK/Common'
f.dependency 'SensorsAnalyticsSDK/AutoTrack'
f.source_files = "SensorsAnalyticsSDK/Visualized/**/*.{h,m}"
f.public_header_files = 'SensorsAnalyticsSDK/Visualized/SensorsAnalyticsSDK+Visualized.h'
end
Expand Down Expand Up @@ -84,18 +81,6 @@ Pod::Spec.new do |s|
w.public_header_files = 'SensorsAnalyticsSDK/WKWebView/SensorsAnalyticsSDK+WKWebView.h'
end

# 允许使用私有 API,v2.0.0 已废弃,待删除
s.subspec 'ENABLE_NO_PUBLIC_APIS' do |f|
f.dependency 'SensorsAnalyticsSDK/Core'
f.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'SENSORS_ANALYTICS_ENABLE_NO_PUBLICK_APIS=1'}
end

# 不采集 UITabBar 点击事件
s.subspec 'DISABLE_AUTOTRACK_UITABBAR' do |f|
f.dependency 'SensorsAnalyticsSDK/Core'
f.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'SENSORS_ANALYTICS_DISABLE_AUTOTRACK_UITABBAR=1'}
end

# 采集 crash slideAdress 信息,需要打开 enableTrackAppCrash 才生效
s.subspec 'CRASH_SLIDEADDRESS' do |f|
f.dependency 'SensorsAnalyticsSDK/Core'
Expand Down
474 changes: 250 additions & 224 deletions SensorsAnalyticsSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/AppPush/UIApplication+PushClick.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// UIApplication+AutoTrack.h
// UIApplication+PushClick.h
// SensorsAnalyticsSDK
//
// Created by 陈玉国 on 2021/1/7.
Expand Down
4 changes: 2 additions & 2 deletions SensorsAnalyticsSDK/AppPush/UIApplication+PushClick.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// UIApplication+AutoTrack.m
// UIApplication+PushClick.m
// SensorsAnalyticsSDK
//
// Created by 陈玉国 on 2021/1/7.
Expand All @@ -22,7 +22,7 @@
#error This file must be compiled with ARC. Either turn on ARC for the project or use -fobjc-arc flag on this file.
#endif

#import "UIApplication+AutoTrack.h"
#import "UIApplication+PushClick.h"
#import "SAApplicationDelegateProxy.h"
#import <objc/runtime.h>

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

@implementation SAScrollViewDelegateProxy
Expand All @@ -48,30 +48,8 @@ + (void)trackEventWithTarget:(NSObject *)target scrollView:(UIScrollView *)scrol
if (target != scrollView.delegate) {
return;
}

NSMutableDictionary *properties = [SAAutoTrackUtils propertiesWithAutoTrackObject:(UIScrollView<SAAutoTrackViewProperty> *)scrollView didSelectedAtIndexPath:indexPath];
if (!properties) {
return;
}
NSDictionary *dic = [SAAutoTrackUtils propertiesWithAutoTrackDelegate:scrollView didSelectedAtIndexPath:indexPath];
[properties addEntriesFromDictionary:dic];

// 解析 Cell
UIView *cell = [SAAutoTrackUtils cellWithScrollView:scrollView selectedAtIndexPath:indexPath];
if (!cell) {
SAAutoTrackEventObject *object = [[SAAutoTrackEventObject alloc] initWithEventId:kSAEventNameAppClick];
[SensorsAnalyticsSDK.sharedInstance asyncTrackEventObject:object properties:properties];
return;
}

// 获取自定义属性
[SAModuleManager.sharedInstance visualPropertiesWithView:cell completionHandler:^(NSDictionary * _Nullable visualProperties) {
if (visualProperties) {
[properties addEntriesFromDictionary:visualProperties];
}
SAAutoTrackEventObject *object = [[SAAutoTrackEventObject alloc] initWithEventId:kSAEventNameAppClick];
[SensorsAnalyticsSDK.sharedInstance asyncTrackEventObject:object properties:properties];
}];
[SAAutoTrackManager.sharedInstance.appClickTracker autoTrackEventWithScrollView:scrollView atIndexPath:indexPath];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
#import "SAScrollViewDelegateProxy.h"
#import <objc/runtime.h>
#import <objc/message.h>
#import "SensorsAnalyticsSDK.h"
#import "SAConstants+Private.h"
#import "SensorsAnalyticsSDK+Private.h"

#import "SAAutoTrackManager.h"

@implementation UITableView (AutoTrack)

Expand All @@ -44,7 +42,7 @@ - (void)sensorsdata_setDelegate:(id <UITableViewDelegate>)delegate {
}

// 判断是否忽略 $AppClick 事件采集
if ([[SensorsAnalyticsSDK sharedInstance] isAutoTrackEventTypeIgnored:SensorsAnalyticsEventTypeAppClick]) {
if ([SAAutoTrackManager.sharedInstance isAutoTrackEventTypeIgnored:SensorsAnalyticsEventTypeAppClick]) {
return;
}

Expand All @@ -68,7 +66,7 @@ - (void)sensorsdata_setDelegate:(id <UICollectionViewDelegate>)delegate {
}

// 判断是否忽略 $AppClick 事件采集
if ([[SensorsAnalyticsSDK sharedInstance] isAutoTrackEventTypeIgnored:SensorsAnalyticsEventTypeAppClick]) {
if ([SAAutoTrackManager.sharedInstance isAutoTrackEventTypeIgnored:SensorsAnalyticsEventTypeAppClick]) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// limitations under the License.
//

#import <UIkit/UIkit.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#import "SAConstants+Private.h"
#import "UIView+AutoTrack.h"
#import "SAAutoTrackUtils.h"
#import "SAModuleManager.h"
#import "SAAutoTrackManager.h"

@implementation SAGestureTarget

Expand All @@ -51,18 +51,8 @@ - (void)trackGestureRecognizerAppClick:(UIGestureRecognizer *)gesture {
if (!processor.isTrackable) {
return;
}

NSMutableDictionary *properties = [[SAAutoTrackUtils propertiesWithAutoTrackObject:processor.trackableView] mutableCopy];
if (properties.count == 0) {
return;
}
[SAModuleManager.sharedInstance visualPropertiesWithView:processor.trackableView completionHandler:^(NSDictionary * _Nullable visualProperties) {
if (visualProperties) {
[properties addEntriesFromDictionary:visualProperties];
}
SAAutoTrackEventObject *eventObject = [[SAAutoTrackEventObject alloc] initWithEventId:kSAEventNameAppClick];
[SensorsAnalyticsSDK.sharedInstance asyncTrackEventObject:eventObject properties:properties];
}];

[SAAutoTrackManager.sharedInstance.appClickTracker autoTrackEventWithGestureView:processor.trackableView];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,20 @@ @implementation UIGestureRecognizer (SAAutoTrack)
#pragma mark - Hook Method
- (instancetype)sensorsdata_initWithTarget:(id)target action:(SEL)action {
[self sensorsdata_initWithTarget:target action:action];
self.sensorsdata_gestureTarget = [SAGestureTarget targetWithGesture:self];
self.sensorsdata_targetActionModels = [NSMutableArray array];
[self removeTarget:target action:action];
[self addTarget:target action:action];
return self;
}

- (void)sensorsdata_addTarget:(id)target action:(SEL)action {
// 在 iOS 12 及以下系统中, 从 StoryBoard 加载的手势不会调用 - initWithTarget:action: 方法;
// 1. 在 - addTarget:action 时对 sensorsdata_gestureTarget 和 sensorsdata_targetActionModels 进行初始化
// 2. sensorsdata_gestureTarget 可能会初始化为空值, 因此使用 sensorsdata_targetActionModels 判断是否初始化过.
if (!self.sensorsdata_targetActionModels) {
self.sensorsdata_targetActionModels = [NSMutableArray array];
self.sensorsdata_gestureTarget = [SAGestureTarget targetWithGesture:self];
}

// Track 事件需要在原有事件之前触发(原有事件中更改页面内容,会导致部分内容获取不准确)
if (self.sensorsdata_gestureTarget) {
if (![SAGestureTargetActionModel containsObjectWithTarget:target andAction:action fromModels:self.sensorsdata_targetActionModels]) {
Expand Down
60 changes: 60 additions & 0 deletions SensorsAnalyticsSDK/AutoTrack/AppClick/SAAppClickTracker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// SAAppClickTracker.h
// SensorsAnalyticsSDK
//
// Created by 张敏超🍎 on 2021/4/27.
// Copyright © 2021 Sensors Data Co., Ltd. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import <UIKit/UIKit.h>
#import "SAAppTracker.h"

NS_ASSUME_NONNULL_BEGIN

@interface SAAppClickTracker : SAAppTracker

/// 触发 UIApplication 全埋点点击事件
/// @param view UIView
- (void)autoTrackEventWithView:(UIView *)view;

/// 触发 Cell 全埋点点击事件
/// @param scrollView cell 所在的视图
/// @param indexPath cell 位置
- (void)autoTrackEventWithScrollView:(UIScrollView *)scrollView atIndexPath:(NSIndexPath *)indexPath;

/// 触发 Gesture 全埋点点击事件
/// @param view UIView
- (void)autoTrackEventWithGestureView:(UIView *)view;

/// 通过代码触发 UIView 的 $AppClick 事件
/// @param view UIView
/// @param properties 自定义属性
- (void)trackEventWithView:(UIView *)view properties:(NSDictionary<NSString *, id> * _Nullable)properties;

/// 忽略某一类型的 View
/// @param aClass View 对应的 Class
- (void)ignoreViewType:(Class)aClass;

/// 判断某个 View 类型是否被忽略
/// @param aClass Class View 对应的 Class
- (BOOL)isViewTypeIgnored:(Class)aClass;

/// 是否忽略视图的点击事件
/// @param view UIView
- (BOOL)isIgnoreEventWithView:(UIView *)view;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit f3af22b

Please sign in to comment.