|
26 | 26 | #import "NRMACustomEvent.h" |
27 | 27 | #import "NRMARequestEvent.h" |
28 | 28 | #import "NRMAInteractionEvent.h" |
| 29 | +#import "NRMAUserActionEvent.h" |
29 | 30 | #import "NRMAPayload.h" |
30 | 31 | #import "NRMANetworkErrorEvent.h" |
31 | 32 | #import "NRMASAM.h" |
@@ -932,45 +933,64 @@ - (BOOL) checkBackgroundStatus { |
932 | 933 |
|
933 | 934 | - (BOOL)recordUserAction:(NRMAUserAction *)userAction { |
934 | 935 | if (userAction == nil) { return NO; }; |
935 | | - |
936 | | - NRMACustomEvent* event = [[NRMACustomEvent alloc] initWithEventType:kNRMA_RET_mobileUserAction |
937 | | - timestamp:[NRMAAnalytics currentTimeMillis] |
938 | | - sessionElapsedTimeInSeconds:[[NSDate date] timeIntervalSinceDate:_sessionStartTime] withAttributeValidator:_attributeValidator]; |
| 936 | + if([NRMAFlags shouldEnableNewEventSystem]){ |
| 937 | + NRMAUserActionEvent* event = [[NRMAUserActionEvent alloc] initWithTimestamp:[NRMAAnalytics currentTimeMillis] |
| 938 | + sessionElapsedTimeInSeconds:[[NSDate date] timeIntervalSinceDate:_sessionStartTime] |
| 939 | + category:kNRMA_RET_userAction withAttributeValidator:_attributeValidator]; |
939 | 940 |
|
940 | | - if (userAction.associatedMethod.length > 0) { |
941 | | - [event addAttribute:kNRMA_RA_methodExecuted value:userAction.associatedMethod]; |
942 | | - } |
| 941 | + if (userAction.associatedMethod.length > 0) { |
| 942 | + [event addAttribute:kNRMA_RA_methodExecuted value:userAction.associatedMethod]; |
| 943 | + } |
943 | 944 |
|
944 | | - if (userAction.associatedClass.length > 0) { |
945 | | - [event addAttribute:kNRMA_RA_targetObject value:userAction.associatedClass]; |
946 | | - } |
| 945 | + if (userAction.associatedClass.length > 0) { |
| 946 | + [event addAttribute:kNRMA_RA_targetObject value:userAction.associatedClass]; |
| 947 | + } |
947 | 948 |
|
948 | | - if (userAction.elementLabel.length > 0) { |
949 | | - [event addAttribute:kNRMA_RA_label value:userAction.elementLabel]; |
950 | | - } |
| 949 | + if (userAction.elementLabel.length > 0) { |
| 950 | + [event addAttribute:kNRMA_RA_label value:userAction.elementLabel]; |
| 951 | + } |
951 | 952 |
|
952 | | - if ((userAction.accessibilityId.length > 0)) { |
953 | | - [event addAttribute:kNRMA_RA_accessibility value:userAction.accessibilityId]; |
954 | | - } |
| 953 | + if ((userAction.accessibilityId.length > 0)) { |
| 954 | + [event addAttribute:kNRMA_RA_accessibility value:userAction.accessibilityId]; |
| 955 | + } |
955 | 956 |
|
956 | | - if ((userAction.interactionCoordinates.length > 0)) { |
957 | | - [event addAttribute:kNRMA_RA_touchCoordinates value:userAction.interactionCoordinates]; |
958 | | - } |
| 957 | + if ((userAction.interactionCoordinates.length > 0)) { |
| 958 | + [event addAttribute:kNRMA_RA_touchCoordinates value:userAction.interactionCoordinates]; |
| 959 | + } |
959 | 960 |
|
960 | | - if ((userAction.actionType.length > 0)) { |
961 | | - [event addAttribute:kNMRA_RA_actionType value:userAction.actionType]; |
962 | | - } |
| 961 | + if ((userAction.actionType.length > 0)) { |
| 962 | + [event addAttribute:kNMRA_RA_actionType value:userAction.actionType]; |
| 963 | + } |
963 | 964 |
|
964 | | - if ((userAction.elementFrame.length > 0)) { |
965 | | - [event addAttribute:kNRMA_RA_frame value:userAction.elementFrame]; |
966 | | - } |
| 965 | + if ((userAction.elementFrame.length > 0)) { |
| 966 | + [event addAttribute:kNRMA_RA_frame value:userAction.elementFrame]; |
| 967 | + } |
967 | 968 |
|
968 | | - NSString* deviceOrientation = [NewRelicInternalUtils deviceOrientation]; |
969 | | - if (deviceOrientation.length > 0) { |
970 | | - [event addAttribute:kNRMA_RA_orientation value:deviceOrientation]; |
971 | | - } |
| 969 | + NSString* deviceOrientation = [NewRelicInternalUtils deviceOrientation]; |
| 970 | + if (deviceOrientation.length > 0) { |
| 971 | + [event addAttribute:kNRMA_RA_orientation value:deviceOrientation]; |
| 972 | + } |
972 | 973 |
|
973 | | - return [_eventManager addEvent:[event autorelease]]; |
| 974 | + return [_eventManager addEvent:[event autorelease]]; |
| 975 | + } else { |
| 976 | + try { |
| 977 | + return _analyticsController->addUserActionEvent(userAction.associatedMethod.UTF8String, |
| 978 | + userAction.associatedClass.UTF8String, |
| 979 | + userAction.elementLabel.UTF8String, |
| 980 | + userAction.accessibilityId.UTF8String, |
| 981 | + userAction.interactionCoordinates.UTF8String, |
| 982 | + userAction.actionType.UTF8String, |
| 983 | + userAction.elementFrame.UTF8String, |
| 984 | + [NewRelicInternalUtils deviceOrientation].UTF8String, |
| 985 | + [self checkOfflineStatus], |
| 986 | + [self checkBackgroundStatus]); |
| 987 | + } catch (std::exception &error) { |
| 988 | + NRLOG_AGENT_VERBOSE(@"Failed to add TrackedGesture: %s.", error.what()); |
| 989 | + } catch (...) { |
| 990 | + NRLOG_AGENT_VERBOSE(@"Failed to add TrackedGesture: unknown error."); |
| 991 | + } |
| 992 | + } |
| 993 | + return false; |
974 | 994 | } |
975 | 995 |
|
976 | 996 | - (BOOL) incrementSessionAttribute:(NSString*)name value:(NSNumber*)number |
@@ -1123,14 +1143,6 @@ - (void) clearLastSessionsAnalytics { |
1123 | 1143 |
|
1124 | 1144 | - (void) sessionWillEnd { |
1125 | 1145 | _sessionWillEnd = YES; |
1126 | | - |
1127 | | - if([NRMAFlags shouldEnableGestureInstrumentation]) |
1128 | | - { |
1129 | | - NRMAUserAction* backgroundGesture = [NRMAUserActionBuilder buildWithBlock:^(NRMAUserActionBuilder *builder) { |
1130 | | - [builder withActionType:kNRMAUserActionAppBackground]; |
1131 | | - }]; |
1132 | | - [[NewRelicAgentInternal sharedInstance].gestureFacade recordUserAction:backgroundGesture]; |
1133 | | - } |
1134 | 1146 |
|
1135 | 1147 | [self endSessionReusable]; |
1136 | 1148 | } |
|
0 commit comments