Skip to content

Commit

Permalink
Update context object with referrer information (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
f2prateek committed Jul 10, 2016
1 parent 5b34049 commit 5a62886
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Analytics/Classes/Internal/SEGSegmentIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ @interface SEGSegmentIntegration ()
@property (nonatomic, strong) NSMutableDictionary *traits;
@property (nonatomic, assign) SEGAnalytics *analytics;
@property (nonatomic, assign) SEGAnalyticsConfiguration *configuration;
@property (nonatomic, assign) NSDictionary *referrer;

@end

Expand Down Expand Up @@ -258,6 +259,10 @@ - (NSDictionary *)liveContext
traits;
});

if (self.referrer) {
context[@"referrer"] = [self.referrer copy];
}

return [context copy];
}

Expand Down Expand Up @@ -403,6 +408,22 @@ - (void)registeredForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
[self.context[@"device"] setObject:[token copy] forKey:@"token"];
}

- (void)continueUserActivity:(NSUserActivity *)activity
{
if ([activity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
self.referrer = @{
@"url" : activity.webpageURL,
};
}
}

- (void)openURL:(NSURL *)url options:(NSDictionary *)options
{
self.referrer = @{
@"url" : url.absoluteString,
};
}

#pragma mark - Queueing

- (NSDictionary *)integrationsDictionary:(NSDictionary *)integrations
Expand Down

0 comments on commit 5a62886

Please sign in to comment.