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 });
0 commit comments