Skip to content

Commit

Permalink
Release 2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujg-00 committed Mar 20, 2021
1 parent 5d30cbc commit e59ae42
Show file tree
Hide file tree
Showing 36 changed files with 1,255 additions and 290 deletions.
16 changes: 14 additions & 2 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.4.0"
s.version = "2.5.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 @@ -11,13 +11,25 @@ Pod::Spec.new do |s|
s.frameworks = 'UIKit', 'Foundation', 'SystemConfiguration', 'CoreTelephony', 'CoreGraphics', 'QuartzCore', 'CoreMotion'
s.libraries = 'icucore', 'sqlite3', 'z'

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

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

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

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

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions SensorsAnalyticsSDK/Core/AutoTrack/ElementInfo/SAViewElementInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// SAViewElementInfo.h
// SensorsAnalyticsSDK
//
// Created by yuqiang on 2021/2/18.
// 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 "SAAutoTrackProperty.h"

NS_ASSUME_NONNULL_BEGIN

@interface SAViewElementInfo : NSObject

@property (nonatomic, weak) UIView *view;

- (instancetype)initWithView:(UIView *)view;

- (NSString *)elementType;

- (BOOL)isSupportElementPosition;

- (BOOL)isVisualView;

@end

@interface SAAlertElementInfo : SAViewElementInfo
@end

@interface SAMenuElementInfo : SAViewElementInfo
@end

NS_ASSUME_NONNULL_END
114 changes: 114 additions & 0 deletions SensorsAnalyticsSDK/Core/AutoTrack/ElementInfo/SAViewElementInfo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//
// SAViewElementInfo.m
// SensorsAnalyticsSDK
//
// Created by yuqiang on 2021/2/18.
// 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.
//

#if ! __has_feature(objc_arc)
#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 "SAViewElementInfo.h"
#import "SAModuleManager.h"

#pragma mark - View Element Type
@implementation SAViewElementInfo

- (instancetype)initWithView:(UIView *)view {
if (self = [super init]) {
self.view = view;
}
return self;
}

- (NSString *)elementType {
return NSStringFromClass(self.view.class);
}

- (BOOL)isSupportElementPosition {
return YES;
}

- (BOOL)isVisualView {
if (!self.view.userInteractionEnabled || self.view.alpha <= 0.01 || self.view.isHidden) {
return NO;
}
return [SAModuleManager.sharedInstance isGestureVisualView:self.view];
}

@end

#pragma mark - Alert Element Type
@implementation SAAlertElementInfo

- (NSString *)elementType {
#ifndef SENSORS_ANALYTICS_DISABLE_PRIVATE_APIS
UIWindow *window = self.view.window;
if ([NSStringFromClass(window.class) isEqualToString:@"_UIAlertControllerShimPresenterWindow"]) {
CGFloat actionHeight = self.view.bounds.size.height;
if (actionHeight > 50) {
return NSStringFromClass(UIActionSheet.class);
} else {
return NSStringFromClass(UIAlertView.class);
}
} else {
return NSStringFromClass(UIAlertController.class);
}
#else
return NSStringFromClass(UIAlertController.class);
#endif
}

- (BOOL)isSupportElementPosition {
return NO;
}

- (BOOL)isVisualView {
if (SAModuleManager.sharedInstance.gestureManager) {
return YES;
}
return [super isVisualView];
}

@end

#pragma mark - Menu Element Type
@implementation SAMenuElementInfo

- (NSString *)elementType {
if (@available(iOS 13.0, *)) {
return NSStringFromClass(UIMenu.class);
}
return nil;
}

- (BOOL)isSupportElementPosition {
return NO;
}

- (BOOL)isVisualView {
// 在 iOS 14 中, 应当圈选 UICollectionViewCell
if ([self.view.superview isKindOfClass:UICollectionViewCell.class]) {
return NO;
}
if (SAModuleManager.sharedInstance.gestureManager) {
return YES;
}
return [super isVisualView];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// SAViewElementInfoFactory.h
// SensorsAnalyticsSDK
//
// Created by yuqiang on 2021/2/18.
// 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 "SAViewElementInfo.h"

NS_ASSUME_NONNULL_BEGIN

@interface SAViewElementInfoFactory : NSObject

+ (SAViewElementInfo *)elementInfoWithView:(UIView *)view;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// SAViewElementInfoFactory.m
// SensorsAnalyticsSDK
//
// Created by yuqiang on 2021/2/18.
// 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.
//

#if ! __has_feature(objc_arc)
#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 "SAViewElementInfoFactory.h"

@implementation SAViewElementInfoFactory

+ (SAViewElementInfo *)elementInfoWithView:(UIView *)view {
NSString *viewType = NSStringFromClass(view.class);
if ([viewType isEqualToString:@"_UIInterfaceActionCustomViewRepresentationView"] ||
[viewType isEqualToString:@"_UIAlertControllerCollectionViewCell"]) {
return [[SAAlertElementInfo alloc] initWithView:view];
}
if ([viewType isEqualToString:@"_UIContextMenuActionView"] ||
[viewType isEqualToString:@"_UIContextMenuActionsListCell"]) {
return [[SAMenuElementInfo alloc] initWithView:view];
}
return [[SAViewElementInfo alloc] initWithView:view];
}

@end
6 changes: 0 additions & 6 deletions SensorsAnalyticsSDK/Core/AutoTrack/SAAutoTrackUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (nullable UIViewController *)findNextViewControllerByResponder:(UIResponder *)responder;

/// 是否为弹框
+ (BOOL)isAlertForResponder:(UIResponder *)responder;

/// 是否为弹框点击
+ (BOOL)isAlertClickForView:(UIView *)view;

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

Expand Down
45 changes: 14 additions & 31 deletions SensorsAnalyticsSDK/Core/AutoTrack/SAAutoTrackUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,21 @@ + (UIViewController *)currentViewController {
return currentViewController;
}

+ (BOOL)canFindPresentedViewController:(UIViewController *)viewController {
if (!viewController) {
return NO;
}
if ([viewController isKindOfClass:UIAlertController.class]) {
return NO;
}
if ([@"_UIContextMenuActionsOnlyViewController" isEqualToString:NSStringFromClass(viewController.class)]) {
return NO;
}
return YES;
}

+ (UIViewController *)findCurrentViewControllerFromRootViewController:(UIViewController *)viewController isRoot:(BOOL)isRoot {
if (viewController.presentedViewController && ![viewController.presentedViewController isKindOfClass:UIAlertController.class]) {
if ([self canFindPresentedViewController:viewController.presentedViewController]) {
return [self findCurrentViewControllerFromRootViewController:viewController.presentedViewController isRoot:NO];
}

Expand Down Expand Up @@ -127,36 +140,6 @@ + (UIViewController *)findCurrentViewControllerFromRootViewController:(UIViewCon
return viewController;
}

+ (BOOL)isAlertForResponder:(UIResponder *)responder {
do {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
BOOL isUIAlertView = [responder isKindOfClass:UIAlertView.class];
BOOL isUIActionSheet = [responder isKindOfClass:UIActionSheet.class];
#pragma clang diagnostic pop

BOOL isUIAlertController = [responder isKindOfClass:UIAlertController.class];

if ([[responder nextResponder] isKindOfClass:SAAlertController.class]) {
return NO;
}
if (isUIAlertController || isUIAlertView || isUIActionSheet) {
return YES;
}
} while ((responder = [responder nextResponder]));
return NO;
}

/// 是否为弹框点击
+ (BOOL)isAlertClickForView:(UIView *)view {
#ifndef SENSORS_ANALYTICS_DISABLE_PRIVATE_APIS
if ([NSStringFromClass(view.class) isEqualToString:@"_UIInterfaceActionCustomViewRepresentationView"] || [NSStringFromClass(view.class) isEqualToString:@"_UIAlertControllerCollectionViewCell"]) { // 标记弹框
return YES;
}
#endif
return NO;
}

/// 在间隔时间内是否采集 $AppClick 全埋点
+ (BOOL)isValidAppClickForObject:(id<SAAutoTrackViewProperty>)object {
if (!object) {
Expand Down
Loading

0 comments on commit e59ae42

Please sign in to comment.