Skip to content

Commit ec3f650

Browse files
author
王洋洋
committed
Release 4.5.6
1 parent 1f66748 commit ec3f650

File tree

7 files changed

+81
-49
lines changed

7 files changed

+81
-49
lines changed

SensorsAnalyticsSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "SensorsAnalyticsSDK"
3-
s.version = "4.5.5"
3+
s.version = "4.5.6"
44
s.summary = "The official iOS SDK of Sensors Analytics."
55
s.homepage = "http://www.sensorsdata.cn"
66
s.source = { :git => 'https://github.com/sensorsdata/sa-sdk-ios.git', :tag => "v#{s.version}" }

SensorsAnalyticsSDK/AutoTrack/AppClick/SAAppClickTracker.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#import "UIViewController+SAAutoTrack.h"
3434
#import "SAModuleManager.h"
3535
#import "SALog.h"
36+
#import "SAUIProperties.h"
3637

3738
@interface SAAppClickTracker ()
3839

@@ -149,7 +150,8 @@ - (BOOL)isViewTypeIgnored:(Class)aClass {
149150
}
150151

151152
- (BOOL)isIgnoreEventWithView:(UIView *)view {
152-
return self.isIgnored || [self isViewTypeIgnored:[view class]];
153+
UIViewController *viewController = [SAUIProperties findNextViewControllerByResponder:view];
154+
return self.isIgnored || [self isViewTypeIgnored:[view class]] || [self isViewControllerIgnored:viewController];
153155
}
154156

155157
#pragma mark – Private Methods

SensorsAnalyticsSDK/AutoTrack/SensorsAnalyticsSDK+SAAutoTrack.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,31 @@ NS_ASSUME_NONNULL_BEGIN
194194

195195
@end
196196

197+
@interface SensorsAnalyticsSDK (SAReferrer)
198+
199+
200+
/**
201+
* @abstract
202+
* 获取 LastScreenUrl
203+
*
204+
* @return LastScreenUrl
205+
*/
206+
- (NSString *)getLastScreenUrl API_UNAVAILABLE(macos);
207+
208+
/**
209+
* @abstract
210+
* 获取 LastScreenTrackProperties
211+
*
212+
* @return LastScreenTrackProperties
213+
*/
214+
- (NSDictionary *)getLastScreenTrackProperties API_UNAVAILABLE(macos);
215+
216+
/**
217+
* @abstract
218+
* App 退出或进到后台时清空 referrer,默认情况下不清空
219+
*/
220+
- (void)clearReferrerWhenAppEnd API_UNAVAILABLE(macos);
221+
222+
@end
223+
197224
NS_ASSUME_NONNULL_END

SensorsAnalyticsSDK/AutoTrack/SensorsAnalyticsSDK+SAAutoTrack.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#import "SAWeakPropertyContainer.h"
3131
#include <objc/runtime.h>
3232
#import "SAUIProperties.h"
33+
#import "SAReferrerManager.h"
3334

3435
@implementation UIImage (SensorsAnalytics)
3536

@@ -116,3 +117,19 @@ - (void)enableAutoTrack:(SensorsAnalyticsAutoTrackEventType)eventType {
116117
}
117118

118119
@end
120+
121+
@implementation SensorsAnalyticsSDK (SAReferrer)
122+
123+
- (NSString *)getLastScreenUrl {
124+
return [SAReferrerManager sharedInstance].referrerURL;
125+
}
126+
127+
- (NSDictionary *)getLastScreenTrackProperties {
128+
return [SAReferrerManager sharedInstance].referrerProperties;
129+
}
130+
131+
- (void)clearReferrerWhenAppEnd {
132+
[SAReferrerManager sharedInstance].isClearReferrer = YES;
133+
}
134+
135+
@end

SensorsAnalyticsSDK/Core/Referrer/SAReferrerManager.m

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727

2828
@interface SAReferrerManager ()
2929

30-
@property (atomic, copy, readwrite) NSDictionary *referrerProperties;
31-
@property (atomic, copy, readwrite) NSString *referrerURL;
32-
@property (nonatomic, copy, readwrite) NSString *referrerTitle;
30+
@property (atomic, copy) NSDictionary *referrerProperties;
31+
@property (atomic, copy) NSString *referrerURL;
32+
@property (nonatomic, copy) NSString *referrerTitle;
3333
@property (nonatomic, copy) NSString *currentTitle;
34+
@property (nonatomic, copy) NSString *currentScreenUrl;
35+
@property (nonatomic, copy) NSDictionary *currentScreenProperties;
3436

3537
@end
3638

@@ -46,21 +48,23 @@ + (instancetype)sharedInstance {
4648
}
4749

4850
- (NSDictionary *)propertiesWithURL:(NSString *)currentURL eventProperties:(NSDictionary *)eventProperties {
49-
NSString *referrerURL = self.referrerURL;
51+
self.referrerURL = self.currentScreenUrl;
52+
self.referrerProperties = self.currentScreenProperties;
5053
NSMutableDictionary *newProperties = [NSMutableDictionary dictionaryWithDictionary:eventProperties];
5154

5255
// 客户自定义属性中包含 $url 时,以客户自定义内容为准
5356
if (!newProperties[kSAEventPropertyScreenUrl]) {
5457
newProperties[kSAEventPropertyScreenUrl] = currentURL;
5558
}
5659
// 客户自定义属性中包含 $referrer 时,以客户自定义内容为准
57-
if (referrerURL && !newProperties[kSAEventPropertyScreenReferrerUrl]) {
58-
newProperties[kSAEventPropertyScreenReferrerUrl] = referrerURL;
60+
if (self.referrerURL && !newProperties[kSAEventPropertyScreenReferrerUrl]) {
61+
newProperties[kSAEventPropertyScreenReferrerUrl] = self.referrerURL;
5962
}
60-
// $referrer 内容以最终页面浏览事件中的 $url 为准
61-
self.referrerURL = newProperties[kSAEventPropertyScreenUrl];
62-
self.referrerProperties = newProperties;
6363

64+
NSMutableDictionary *lastScreenProperties = [NSMutableDictionary dictionaryWithDictionary:newProperties];
65+
[lastScreenProperties removeObjectForKey:kSAEventPropertyScreenReferrerUrl];
66+
self.currentScreenProperties = [lastScreenProperties copy];
67+
self.currentScreenUrl = newProperties[kSAEventPropertyScreenUrl];
6468
dispatch_async(self.serialQueue, ^{
6569
[self cacheReferrerTitle:newProperties];
6670
});

SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -331,28 +331,6 @@ extern NSString * const SensorsAnalyticsIdentityKeyEmail;
331331
*/
332332
- (NSString *)getCookieWithDecode:(BOOL)decode;
333333

334-
/**
335-
* @abstract
336-
* 获取 LastScreenUrl
337-
*
338-
* @return LastScreenUrl
339-
*/
340-
- (NSString *)getLastScreenUrl API_UNAVAILABLE(macos);
341-
342-
/**
343-
* @abstract
344-
* App 退出或进到后台时清空 referrer,默认情况下不清空
345-
*/
346-
- (void)clearReferrerWhenAppEnd API_UNAVAILABLE(macos);
347-
348-
/**
349-
* @abstract
350-
* 获取 LastScreenTrackProperties
351-
*
352-
* @return LastScreenTrackProperties
353-
*/
354-
- (NSDictionary *)getLastScreenTrackProperties API_UNAVAILABLE(macos);
355-
356334
/**
357335
* @abstract
358336
* 修改入库之前的事件属性
@@ -428,6 +406,14 @@ extern NSString * const SensorsAnalyticsIdentityKeyEmail;
428406
*/
429407
- (void)registerPropertyPlugin:(SAPropertyPlugin *)plugin;
430408

409+
/**
410+
* @abstract
411+
* 注销属性插件
412+
*
413+
* @param pluginClass 插件类型
414+
*/
415+
- (void)unregisterPropertyPluginWithPluginClass:(Class)pluginClass;
416+
431417
/**
432418
* @abstract
433419
* 得到 SDK 的版本

SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#import "SALimitKeyManager.h"
6565
#import "NSDictionary+SACopyProperties.h"
6666

67-
#define VERSION @"4.5.5"
67+
#define VERSION @"4.5.6"
6868

6969
void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag;
7070

@@ -845,6 +845,12 @@ - (void)registerPropertyPlugin:(SAPropertyPlugin *)plugin {
845845
});
846846
}
847847

848+
- (void)unregisterPropertyPluginWithPluginClass:(Class)pluginClass {
849+
dispatch_async(self.serialQueue, ^{
850+
[SAPropertyPluginManager.sharedInstance unregisterPropertyPluginWithPluginClass:pluginClass];
851+
});
852+
}
853+
848854
#pragma mark - Local caches
849855

850856
- (void)startFlushTimer {
@@ -883,18 +889,6 @@ - (void)stopFlushTimer {
883889
});
884890
}
885891

886-
- (NSString *)getLastScreenUrl {
887-
return [SAReferrerManager sharedInstance].referrerURL;
888-
}
889-
890-
- (void)clearReferrerWhenAppEnd {
891-
[SAReferrerManager sharedInstance].isClearReferrer = YES;
892-
}
893-
894-
- (NSDictionary *)getLastScreenTrackProperties {
895-
return [SAReferrerManager sharedInstance].referrerProperties;
896-
}
897-
898892
- (SensorsAnalyticsDebugMode)debugMode {
899893
return self.configOptions.debugMode;
900894
}
@@ -999,9 +993,6 @@ - (void)clearKeychainData {
999993
#pragma mark - setup Flow
1000994

1001995
- (void)trackEventObject:(SABaseEventObject *)object properties:(NSDictionary *)properties {
1002-
if (object.isSignUp) {
1003-
[[NSNotificationCenter defaultCenter] postNotificationName:SA_TRACK_LOGIN_NOTIFICATION object:nil];
1004-
}
1005996
NSString *eventName = object.event;
1006997
if (!object.hybridH5 && eventName) {
1007998
object.isInstantEvent = [self.configOptions.instantEvents containsObject:eventName];
@@ -1011,6 +1002,11 @@ - (void)trackEventObject:(SABaseEventObject *)object properties:(NSDictionary *)
10111002
input.identifier = self.identifier;
10121003
input.properties = [properties sensorsdata_deepCopy];
10131004
[SAFlowManager.sharedInstance startWithFlowID:kSATrackFlowId input:input completion:nil];
1005+
1006+
// H5 打通场景,在 Flow 实现登录,通知放在最后,防止外部不能及时拿到最新 loginId
1007+
if (object.isSignUp) {
1008+
[[NSNotificationCenter defaultCenter] postNotificationName:SA_TRACK_LOGIN_NOTIFICATION object:nil];
1009+
}
10141010
}
10151011

10161012
- (void)flushAllEventRecords {

0 commit comments

Comments
 (0)