From e45774defe6c24684aa1eadd6fcbe1e0bdaf28aa Mon Sep 17 00:00:00 2001 From: Josh Wymer Date: Mon, 3 Feb 2020 22:44:03 -0600 Subject: [PATCH] Add additional track props for tap event --- Mixpanel/Mixpanel.m | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Mixpanel/Mixpanel.m b/Mixpanel/Mixpanel.m index f553c7ba7..6e492515c 100755 --- a/Mixpanel/Mixpanel.m +++ b/Mixpanel/Mixpanel.m @@ -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 @@ -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];