Skip to content

Commit

Permalink
Add additional track props for tap event
Browse files Browse the repository at this point in the history
  • Loading branch information
jbwyme committed Feb 4, 2020
1 parent 6752289 commit e45774d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Mixpanel/Mixpanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -1874,16 +1874,17 @@ + (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNoti
return;
}

NSDictionary *userInfo = response.notification.request.content.userInfo;
UNNotificationRequest *request = response.notification.request;
NSDictionary *userInfo = request.content.userInfo;

// Initialize properties to track to Mixpanel
NSMutableDictionary *trackingProps = [[NSMutableDictionary alloc] init];
[trackingProps setValuesForKeysWithDictionary:@{
@"campaign_id": [userInfo valueForKeyPath:@"mp.c"],
@"message_id": [userInfo valueForKeyPath:@"mp.m"],
@"notification_id": request.identifier,
}];


MPLogInfo(@"%@ didReceiveNotificationResponse action: %@", self, response.actionIdentifier);

// If the notification was dismissed, just track and return
Expand Down Expand Up @@ -1921,6 +1922,18 @@ + (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNoti
}
}

// Add additional tracking props
if (ontap != nil && ontap != (id)[NSNull null]) {
NSString *tapActionType = ontap[@"type"];
if (tapActionType != nil) {
trackingProps[@"tap_action_type"] = tapActionType
}
NSString *tapActionUri = ontap[@"uri"];
if (tapActionUri != nil) {
trackingProps[@"tap_action_uri"] = tapActionUri
}
}

// Track tap event to all Mixpanel instances
[instances.allKeys enumerateObjectsUsingBlock:^(NSString *token, NSUInteger idx, BOOL * _Nonnull stop) {
Mixpanel *instance = instances[token];
Expand Down

0 comments on commit e45774d

Please sign in to comment.