Skip to content

Commit

Permalink
Release 4.5.10
Browse files Browse the repository at this point in the history
  • Loading branch information
王洋洋 committed May 26, 2023
1 parent 48fefdc commit e310d8e
Show file tree
Hide file tree
Showing 20 changed files with 204 additions and 21 deletions.
4 changes: 2 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 = "4.5.9"
s.version = "4.5.10"
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 @@ -128,7 +128,7 @@ Pod::Spec.new do |s|
h.ios.deployment_target = '9.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'
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', 'SensorsAnalyticsSDK/Exposure/SAExposureListener.h'
end

end
4 changes: 4 additions & 0 deletions SensorsAnalyticsSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@
F211742226E9A72C00D65E19 /* SAApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = F211742026E9A72B00D65E19 /* SAApplication.m */; };
F21C226728F7B0E500847823 /* NSDictionary+SACopyProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = F21C226528F7B0E500847823 /* NSDictionary+SACopyProperties.h */; };
F21C226828F7B0E500847823 /* NSDictionary+SACopyProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = F21C226628F7B0E500847823 /* NSDictionary+SACopyProperties.m */; };
F226AF6629EE37A800ED14A0 /* SAExposureListener.h in Headers */ = {isa = PBXBuildFile; fileRef = F226AF6429EE37A800ED14A0 /* SAExposureListener.h */; settings = {ATTRIBUTES = (Public, ); }; };
F226E66C28BC6149000443A7 /* SAUIProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = F226E66A28BC6149000443A7 /* SAUIProperties.h */; };
F226E66D28BC6149000443A7 /* SAUIProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = F226E66B28BC6149000443A7 /* SAUIProperties.m */; };
F226E67028BC62EB000443A7 /* UIView+SAItemPath.h in Headers */ = {isa = PBXBuildFile; fileRef = F226E66E28BC62EB000443A7 /* UIView+SAItemPath.h */; };
Expand Down Expand Up @@ -1036,6 +1037,7 @@
F214CE57249A07DF00A2633D /* SADatabaseUnitTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SADatabaseUnitTest.m; path = SensorsAnalyticsTests/Tracker/SADatabaseUnitTest.m; sourceTree = SOURCE_ROOT; };
F21C226528F7B0E500847823 /* NSDictionary+SACopyProperties.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+SACopyProperties.h"; sourceTree = "<group>"; };
F21C226628F7B0E500847823 /* NSDictionary+SACopyProperties.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+SACopyProperties.m"; sourceTree = "<group>"; };
F226AF6429EE37A800ED14A0 /* SAExposureListener.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SAExposureListener.h; sourceTree = "<group>"; };
F226E66A28BC6149000443A7 /* SAUIProperties.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SAUIProperties.h; sourceTree = "<group>"; };
F226E66B28BC6149000443A7 /* SAUIProperties.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SAUIProperties.m; sourceTree = "<group>"; };
F226E66E28BC62EB000443A7 /* UIView+SAItemPath.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIView+SAItemPath.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2291,6 +2293,7 @@
F2FBB33728A2692D008D10EB /* SAExposureData.h */,
F2FBB33828A2692D008D10EB /* SAExposureData.m */,
F2C877B628A65849002BDA2C /* SAExposureData+Private.h */,
F226AF6429EE37A800ED14A0 /* SAExposureListener.h */,
F273487728A9EA1500C34E64 /* SAExposureDelegateProxy.h */,
F273487828A9EA1500C34E64 /* SAExposureDelegateProxy.m */,
F286963028A34FFC00276F78 /* SAExposureManager.h */,
Expand Down Expand Up @@ -2384,6 +2387,7 @@
A8CC223D2685E50C00E96A03 /* SARemoteConfigCheckOperator.h in Headers */,
881A41F6253D7B5000854F69 /* NSString+SAHashCode.h in Headers */,
4DD1286725F872A4008C0B1E /* NSInvocation+SAHelpers.h in Headers */,
F226AF6629EE37A800ED14A0 /* SAExposureListener.h in Headers */,
F20231CA28BF43FB0034D8B3 /* UIView+SARNView.h in Headers */,
88EC2DF12757689800EF9778 /* SAStoreManager.h in Headers */,
45A5656A263C174300C9C41B /* SAEventLibObject.h in Headers */,
Expand Down
4 changes: 4 additions & 0 deletions SensorsAnalyticsSDK/AutoTrack/AppClick/SAAppClickTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ NS_ASSUME_NONNULL_BEGIN
/// @param view UIView
- (BOOL)isIgnoreEventWithView:(UIView *)view;

/// ignore AppClick on an array of view class names
/// - Parameter views: view class names
- (void)ignoreAppClickOnViews:(NSArray<Class>*)views;

@end

NS_ASSUME_NONNULL_END
16 changes: 13 additions & 3 deletions SensorsAnalyticsSDK/AutoTrack/AppClick/SAAppClickTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,28 @@ - (void)trackEventWithView:(UIView *)view properties:(NSDictionary<NSString *,id
}

- (void)ignoreViewType:(Class)aClass {
if (!aClass) {
return;
}
[_ignoredViewTypeList addObject:aClass];
}

- (BOOL)isViewTypeIgnored:(Class)aClass {
for (Class obj in _ignoredViewTypeList) {
if ([aClass isSubclassOfClass:obj]) {
for (Class tempClass in self.ignoredViewTypeList) {
if ([aClass isSubclassOfClass:tempClass]) {
return YES;
}
}
return NO;
}

- (void)ignoreAppClickOnViews:(NSArray<Class> *)views {
if (![views isKindOfClass:[NSArray class]]) {
return;
}
[self.ignoredViewTypeList addObjectsFromArray:views];
}

- (BOOL)isIgnoreEventWithView:(UIView *)view {
UIViewController *viewController = [SAUIProperties findNextViewControllerByResponder:view];
return self.isIgnored || [self isViewTypeIgnored:[view class]] || [self isViewControllerIgnored:viewController];
Expand All @@ -163,7 +173,7 @@ - (BOOL)isBlackListContainsViewController:(UIViewController *)viewController {
}

- (void)autoTrackEventWithView:(UIView *)view properties:(NSDictionary<NSString *, id> * _Nullable)properties {
if (self.isIgnored) {
if (self.isIgnored || view.sensorsdata_isIgnored) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions SensorsAnalyticsSDK/AutoTrack/SAAppTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
/// 是否被动启动
@property (nonatomic, assign, getter=isPassively) BOOL passively;
/// 用户设置的不被 AutoTrack 的 Controllers
@property (nonatomic, strong) NSMutableSet<NSString *> *ignoredViewControllers;
@property (nonatomic, strong) NSMutableSet<Class> *ignoredViewControllers;

/// 获取 tracker 对应的事件 ID
- (NSString *)eventId;
Expand All @@ -48,8 +48,8 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)shouldTrackViewController:(UIViewController *)viewController;

/// 在 AutoTrack 时,用户可以设置哪些 controllers 不被 AutoTrack
/// @param controllers controller ‘字符串’数组
- (void)ignoreAutoTrackViewControllers:(NSArray<NSString *> *)controllers;
/// @param controllers controller ‘类型’数组
- (void)ignoreAutoTrackViewControllers:(NSArray<Class> *)controllers;

/// 判断某个 ViewController 是否被忽略
/// @param viewController UIViewController
Expand Down
6 changes: 3 additions & 3 deletions SensorsAnalyticsSDK/AutoTrack/SAAppTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ - (BOOL)shouldTrackViewController:(UIViewController *)viewController {
return YES;
}

- (void)ignoreAutoTrackViewControllers:(NSArray<NSString *> *)controllers {
- (void)ignoreAutoTrackViewControllers:(NSArray<Class> *)controllers {
if (controllers == nil || controllers.count == 0) {
return;
}
Expand All @@ -79,8 +79,8 @@ - (BOOL)isViewControllerIgnored:(UIViewController *)viewController {
return NO;
}

NSString *screenName = NSStringFromClass([viewController class]);
return [self.ignoredViewControllers containsObject:screenName];
Class viewControllerClass = [viewController class];
return [self.ignoredViewControllers containsObject:viewControllerClass];
}

- (NSDictionary *)autoTrackViewControllerBlackList {
Expand Down
31 changes: 31 additions & 0 deletions SensorsAnalyticsSDK/AutoTrack/SensorsAnalyticsSDK+SAAutoTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ NS_ASSUME_NONNULL_BEGIN

@end


/// Referrer category
@interface SensorsAnalyticsSDK (SAReferrer)


Expand All @@ -205,6 +207,14 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (NSString *)getLastScreenUrl API_UNAVAILABLE(macos);

/**
* @abstract
* 获取 currentScreenUrl
*
* @return currentScreenUrl
*/
- (NSString *)getCurrentScreenUrl API_UNAVAILABLE(macos);

/**
* @abstract
* 获取 LastScreenTrackProperties
Expand All @@ -221,4 +231,25 @@ NS_ASSUME_NONNULL_BEGIN

@end

/// ignore AppClick or AppViewScreen category
@interface SensorsAnalyticsSDK (SAAutoTrackIgnore)

/// ignore AppClick on an array of view classes
/// - Parameter views: view classes
- (void)ignoreAppClickOnViews:(NSArray<Class>*)views;

/// ignore AppClick on an array of view controller classes
/// - Parameter viewControllers: view controller classes
- (void)ignoreAppClickOnViewControllers:(NSArray<Class>*)viewControllers;

/// ignore AppViewScreen on an array of view controller classes
/// - Parameter viewControllers: view controller classes
- (void)ignoreAppViewScreenOnViewControllers:(NSArray<Class>*)viewControllers;

/// ignore AppClick and AppViewScreen on an array of view controller classes
/// - Parameter viewControllers: view controller classes
- (void)ignoreAppClickAndViewScreenOnViewControllers:(NSArray<Class>*)viewControllers;

@end

NS_ASSUME_NONNULL_END
42 changes: 40 additions & 2 deletions SensorsAnalyticsSDK/AutoTrack/SensorsAnalyticsSDK+SAAutoTrack.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,21 @@ - (BOOL)isViewTypeIgnored:(Class)aClass {
}

- (void)ignoreAutoTrackViewControllers:(NSArray<NSString *> *)controllers {
[SAAutoTrackManager.defaultManager.appClickTracker ignoreAutoTrackViewControllers:controllers];
[SAAutoTrackManager.defaultManager.appViewScreenTracker ignoreAutoTrackViewControllers:controllers];
if (![controllers isKindOfClass:[NSArray class]]) {
return;
}
NSMutableArray<Class> *tempControllers = [NSMutableArray array];
for (NSString *viewControllerName in controllers) {
if(![viewControllerName isKindOfClass:[NSString class]]) {
break;
}
Class viewControllerClass = NSClassFromString(viewControllerName);
if (viewControllerClass) {
[tempControllers addObject:viewControllerClass];
}
}
[SAAutoTrackManager.defaultManager.appClickTracker ignoreAutoTrackViewControllers:tempControllers];
[SAAutoTrackManager.defaultManager.appViewScreenTracker ignoreAutoTrackViewControllers:tempControllers];
}

- (BOOL)isViewControllerIgnored:(UIViewController *)viewController {
Expand Down Expand Up @@ -118,18 +131,43 @@ - (void)enableAutoTrack:(SensorsAnalyticsAutoTrackEventType)eventType {

@end


@implementation SensorsAnalyticsSDK (SAReferrer)

- (NSString *)getLastScreenUrl {
return [SAReferrerManager sharedInstance].referrerURL;
}

- (NSString *)getCurrentScreenUrl {
return [SAReferrerManager sharedInstance].currentScreenUrl;
}

- (NSDictionary *)getLastScreenTrackProperties {
return [SAReferrerManager sharedInstance].referrerProperties;
}

- (void)clearReferrerWhenAppEnd {
[SAReferrerManager sharedInstance].isClearReferrer = YES;
}
@end

@implementation SensorsAnalyticsSDK (SAAutoTrackIgnore)

- (void)ignoreAppClickOnViews:(NSArray<Class> *)views {
[SAAutoTrackManager.defaultManager.appClickTracker ignoreAppClickOnViews:views];
}

- (void)ignoreAppClickOnViewControllers:(NSArray<Class> *)viewControllers {
[SAAutoTrackManager.defaultManager.appClickTracker ignoreAutoTrackViewControllers:viewControllers];
}

- (void)ignoreAppViewScreenOnViewControllers:(NSArray<Class> *)viewControllers {
[SAAutoTrackManager.defaultManager.appViewScreenTracker ignoreAutoTrackViewControllers:viewControllers];
}

- (void)ignoreAppClickAndViewScreenOnViewControllers:(NSArray<Class> *)viewControllers {
[SAAutoTrackManager.defaultManager.appClickTracker ignoreAutoTrackViewControllers:viewControllers];
[SAAutoTrackManager.defaultManager.appViewScreenTracker ignoreAutoTrackViewControllers:viewControllers];
}

@end
1 change: 1 addition & 0 deletions SensorsAnalyticsSDK/Core/Referrer/SAReferrerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (atomic, copy, readonly) NSDictionary *referrerProperties;
@property (atomic, copy, readonly) NSString *referrerURL;
@property (nonatomic, copy, readonly) NSString *referrerTitle;
@property (atomic, copy, readonly) NSString *currentScreenUrl;

+ (instancetype)sharedInstance;

Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/Referrer/SAReferrerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ @interface SAReferrerManager ()
@property (atomic, copy) NSString *referrerURL;
@property (nonatomic, copy) NSString *referrerTitle;
@property (nonatomic, copy) NSString *currentTitle;
@property (nonatomic, copy) NSString *currentScreenUrl;
@property (atomic, copy) NSString *currentScreenUrl;
@property (nonatomic, copy) NSDictionary *currentScreenProperties;

@end
Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#import "SALimitKeyManager.h"
#import "NSDictionary+SACopyProperties.h"

#define VERSION @"4.5.9"
#define VERSION @"4.5.10"

void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag;

Expand Down
5 changes: 3 additions & 2 deletions SensorsAnalyticsSDK/Exposure/SAExposureData+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ NS_ASSUME_NONNULL_BEGIN

@interface SAExposureData (Private)

@property (nonatomic, copy) NSString *exposureIdentifier;
@property (nonatomic, copy) NSString *event;
@property (nonatomic, copy) SAExposureConfig *config;
@property (nonatomic, copy) NSDictionary *properties;

/// updated properties from method updateExposure:withProperties:
@property (nonatomic, copy) NSDictionary *updatedProperties;

@end

NS_ASSUME_NONNULL_END
6 changes: 6 additions & 0 deletions SensorsAnalyticsSDK/Exposure/SAExposureData.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
//

#import "SAExposureConfig.h"
#import "SAExposureListener.h"

NS_ASSUME_NONNULL_BEGIN

@interface SAExposureData : NSObject

@property (nonatomic, copy, readonly) NSString *event;
@property (nonatomic, copy, readonly) NSString *exposureIdentifier;
@property (nonatomic, copy, readonly) SAExposureConfig *config;
@property (nonatomic, weak) id<SAExposureListener> exposureListener;

- (instancetype)init NS_UNAVAILABLE;

/// init method
Expand Down
8 changes: 7 additions & 1 deletion SensorsAnalyticsSDK/Exposure/SAExposureData.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
#endif

#import "SAExposureData.h"
#import "NSDictionary+SACopyProperties.h"

@interface SAExposureData ()

@property (nonatomic, copy) NSString *event;
@property (nonatomic, copy) NSDictionary *properties;
@property (nonatomic, copy) NSString *exposureIdentifier;
@property (nonatomic, copy) SAExposureConfig *config;
@property (nonatomic, copy) NSDictionary *updatedProperties;

@end

Expand All @@ -55,10 +57,14 @@ - (instancetype)initWithEvent:(NSString *)event properties:(NSDictionary *)prope
self = [super init];
if (self) {
_event = event;
_properties = properties;
_properties = [properties sensorsdata_deepCopy];
_exposureIdentifier = exposureIdentifier;
_config = config;
}
return self;
}

- (void)setUpdatedProperties:(NSDictionary *)updatedProperties {
_updatedProperties = [updatedProperties sensorsdata_deepCopy];
}
@end
34 changes: 34 additions & 0 deletions SensorsAnalyticsSDK/Exposure/SAExposureListener.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// SAExposureListener.h
// SensorsAnalyticsSDK
//
// Created by 陈玉国 on 2023/4/18.
// Copyright © 2015-2023 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>
@class SAExposureData;

NS_ASSUME_NONNULL_BEGIN

@protocol SAExposureListener <NSObject>

@optional
- (BOOL)shouldExpose:(UIView *)view withData:(SAExposureData *)data;
- (void)didExpose:(UIView *)view withData:(SAExposureData *)data;

@end

NS_ASSUME_NONNULL_END
6 changes: 6 additions & 0 deletions SensorsAnalyticsSDK/Exposure/SAExposureManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ NS_ASSUME_NONNULL_BEGIN

- (SAExposureViewObject *)exposureViewWithView:(UIView *)view;

/// update properties for certain view that need to expose
/// - Parameters:
/// - view: view to expose
/// - properties: properties to update
- (void)updateExposure:(UIView *)view withProperties:(NSDictionary *)properties;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit e310d8e

Please sign in to comment.