Skip to content

Commit c5c2dfa

Browse files
Merge branch 'develop' of github.com:newrelic/newrelic-ios-agent into examples-merge
2 parents 0464180 + 0d876ec commit c5c2dfa

File tree

249 files changed

+10891
-72258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+10891
-72258
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ jobs:
2727
xcode-version: '14.3'
2828

2929
- name: Install lcov
30-
run: brew install lcov
30+
run: |
31+
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/e92d2ae54954ebf485b484d8522104700b144fee/Formula/lcov.rb > lcov.rb
32+
brew install ./lcov.rb
3133
3234
- name: Update gem
3335
run: bundle update

.github/workflows/productionDeploy.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,19 @@ jobs:
6666
- name: Print XCFramework name
6767
run: echo "${{ env.version }}"
6868

69-
# - name: Create Prod Podspec for XCFramework version
70-
# run: |
71-
# cd main
69+
- name: Create Prod Podspec for XCFramework version
70+
run: |
71+
cd main
7272
73-
# cp cocoapods/NewRelicAgent.podspec.template NewRelicAgent.podspec
74-
# REPLACE=X.XX
75-
# sed -i bak "s/$REPLACE/${{ env.version }}/g" NewRelicAgent.podspec
73+
cp cocoapods/NewRelicAgent.podspec.template NewRelicAgent.podspec
74+
REPLACE=X.XX
75+
sed -i bak "s/$REPLACE/${{ env.version }}/g" NewRelicAgent.podspec
7676
77-
# rm NewRelicAgent.podspecbak
77+
rm NewRelicAgent.podspecbak
7878
79-
# pod trunk push --allow-warnings NewRelicAgent.podspec
80-
# env:
81-
# COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
79+
pod trunk push --allow-warnings NewRelicAgent.podspec
80+
env:
81+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
8282

8383
- name: Create Prod Package.swift for XCFramework version
8484
run: |

Agent.xcodeproj/project.pbxproj

Lines changed: 206 additions & 28 deletions
Large diffs are not rendered by default.

Agent/ActivityTracing/NRMATraceController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ + (BOOL) completeActivityTraceWithExitTimestampMillis:(double)exitTimestampMilli
287287
duration:[NSNumber numberWithDouble:(activityTrace.endTime - activityTrace.startTime)]];
288288
[NRMATaskQueue queue:activityTrace];
289289

290-
[[NSNotificationCenter defaultCenter] postNotificationName:kNRInteractionDidCompleteNotification
291-
object:activityTrace];
290+
[[NewRelicAgentInternal sharedInstance].analyticsController addInteractionEvent:activityTrace.name
291+
interactionDuration:activityTrace.endTime - activityTrace.startTime];
292292

293293
#ifndef DISABLE_NR_EXCEPTION_WRAPPER
294294
} @catch (NSException* exception) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// AttributeValidatorProtocol.h
3+
// Agent
4+
//
5+
// Created by Steve Malsam on 6/15/23.
6+
// Copyright © 2023 New Relic. All rights reserved.
7+
//
8+
9+
#ifndef AttributeValidatorProtocol_h
10+
#define AttributeValidatorProtocol_h
11+
12+
typedef BOOL (^NameValidator)(NSString*);
13+
typedef BOOL (^ValueValidator)(id);
14+
typedef BOOL (^EventTypeValidator)(NSString*);
15+
16+
@protocol AttributeValidatorProtocol <NSObject>
17+
18+
- (BOOL)nameValidator:(NSString *)name;
19+
- (BOOL)valueValidator:(id)value;
20+
- (BOOL)eventTypeValidator:(NSString *)eventType;
21+
22+
@end
23+
24+
#endif /* AttributeValidatorProtocol_h */
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// BlockAttributeValidator.h
3+
// Agent
4+
//
5+
// Created by Steve Malsam on 6/15/23.
6+
// Copyright © 2023 New Relic. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
#import "AttributeValidatorProtocol.h"
12+
13+
NS_ASSUME_NONNULL_BEGIN
14+
15+
@interface BlockAttributeValidator : NSObject <AttributeValidatorProtocol>
16+
17+
@property (copy, readonly) NameValidator nameValidator;
18+
@property (copy, readonly) ValueValidator valueValidator;
19+
@property (copy, readonly) EventTypeValidator eventTypeValidator;
20+
21+
- (instancetype)initWithNameValidator:(NameValidator)nameValidator
22+
valueValidator:(ValueValidator)valueValidator
23+
andEventTypeValidator:(EventTypeValidator)eventTypeValidator;
24+
25+
@end
26+
27+
NS_ASSUME_NONNULL_END
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// BlockAttributeValidator.m
3+
// Agent
4+
//
5+
// Created by Steve Malsam on 6/15/23.
6+
// Copyright © 2023 New Relic. All rights reserved.
7+
//
8+
9+
#import "BlockAttributeValidator.h"
10+
11+
@implementation BlockAttributeValidator
12+
13+
- (nonnull instancetype)initWithNameValidator:(nonnull NameValidator)nameValidator
14+
valueValidator:(nonnull ValueValidator)valueValidator
15+
andEventTypeValidator:(nonnull EventTypeValidator)eventTypeValidator {
16+
self = [super init];
17+
if(self) {
18+
_nameValidator = nameValidator;
19+
_valueValidator = valueValidator;
20+
_eventTypeValidator = eventTypeValidator;
21+
}
22+
23+
return self;
24+
}
25+
26+
- (BOOL)eventTypeValidator:(NSString *)eventType {
27+
return self.eventTypeValidator(eventType);
28+
}
29+
30+
- (BOOL)nameValidator:(NSString *)name {
31+
return self.nameValidator(name);
32+
}
33+
34+
- (BOOL)valueValidator:(id)value {
35+
return self.valueValidator(value);
36+
}
37+
38+
@end

Agent/Analytics/Constants.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//
2+
// Constants.h
3+
// Agent
4+
//
5+
// Created by Mike Bruin on 8/9/23.
6+
// Copyright © 2023 New Relic. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
extern NSString *const kNRMA_RA_eventType;
12+
extern NSString *const kNRMA_RA_type;
13+
extern NSString *const kNRMA_RA_timestamp;
14+
extern NSString *const kNRMA_RA_category;
15+
extern NSString *const kNRMA_RA_accountId;
16+
extern NSString *const kNRMA_RA_appId;
17+
extern NSString *const kNRMA_RA_appName;
18+
extern NSString *const kNRMA_RA_uuid;
19+
extern NSString *const kNRMA_RA_sessionDuration;
20+
extern NSString *const kNRMA_RA_sessionElapsedTime;
21+
extern NSString *const kNRMA_RA_payload;
22+
extern NSString *const kNRMA_RA_InteractionDuration;
23+
extern NSString *const kNRMA_RA_osName;
24+
extern NSString *const kNRMA_RA_osVersion;
25+
extern NSString *const kNRMA_RA_osMajorVersion;
26+
extern NSString *const kNRMA_RA_deviceManufacturer;
27+
extern NSString *const kNRMA_RA_deviceModel;
28+
extern NSString *const kNRMA_RA_carrier;
29+
extern NSString *const kNRMA_RA_newRelicVersion;
30+
extern NSString *const kNRMA_RA_memUsageMb;
31+
extern NSString *const kNRMA_RA_sessionId;
32+
extern NSString *const kNRMA_RA_install;
33+
extern NSString *const kNRMA_RA_upgradeFrom;
34+
extern NSString *const kNRMA_RA_platform;
35+
extern NSString *const kNRMA_RA_platformVersion;
36+
extern NSString *const kNRMA_RA_lastInteraction;
37+
extern NSString *const kNRMA_RA_appDataHeader;
38+
extern NSString *const kNRMA_RA_responseBody;
39+
40+
extern NSString *const kNRMA_RET_mobile;
41+
extern NSString *const kNRMA_RET_mobileSession;
42+
extern NSString *const kNRMA_RET_mobileRequest;
43+
extern NSString *const kNRMA_RET_mobileRequestError;
44+
extern NSString *const kNRMA_RET_mobileCrash;
45+
extern NSString *const kNRMA_RET_mobileBreadcrumb;
46+
extern NSString *const kNRMA_RET_mobileUserAction;
47+
48+
extern NSString *const kNRMA_RA_methodExecuted;
49+
extern NSString *const kNRMA_RA_targetObject;
50+
extern NSString *const kNRMA_RA_label;
51+
extern NSString *const kNRMA_RA_accessibility;
52+
extern NSString *const kNRMA_RA_touchCoordinates;
53+
extern NSString *const kNMRA_RA_actionType;
54+
extern NSString *const kNRMA_RA_frame;
55+
extern NSString *const kNRMA_RA_orientation;
56+
57+
extern NSString *const kNRMA_RP_newRelic;
58+
extern NSString *const kNRMA_RP_nr;
59+
60+
extern NSString *const kNRMA_Attrib_guid;
61+
extern NSString *const kNRMA_Attrib_traceId;
62+
extern NSString *const kNRMA_Attrib_parentId;
63+
extern NSString *const kNRMA_Attrib_userId;
64+
65+
extern NSString *const kNRMA_Attrib_connectionType;
66+
extern NSString *const kNRMA_Attrib_requestUrl;
67+
extern NSString *const kNRMA_Attrib_requestDomain;
68+
extern NSString *const kNRMA_Attrib_requestPath;
69+
extern NSString *const kNRMA_Attrib_requestMethod;
70+
extern NSString *const kNRMA_Attrib_bytesReceived;
71+
extern NSString *const kNRMA_Attrib_bytesSent;
72+
extern NSString *const kNRMA_Attrib_responseTime;
73+
extern NSString *const kNRMA_Attrib_statusCode;
74+
extern NSString *const kNRMA_Attrib_networkErrorCode;
75+
extern NSString *const kNRMA_Attrib_networkError;
76+
extern NSString *const kNRMA_Attrib_errorType;
77+
extern NSString *const kNRMA_Attrib_contentType;
78+
extern NSString *const kNRMA_Attrib_dtGuid;
79+
extern NSString *const kNRMA_Attrib_dtId;
80+
extern NSString *const kNRMA_Attrib_dtTraceId;
81+
extern NSString *const kNRMA_Attrib_name;
82+
83+
extern NSString *const kNRMA_Val_errorType_HTTP;
84+
extern NSString *const kNRMA_Val_errorType_Network;
85+
86+
extern NSString *const kNRMA_Attrib_file;
87+
extern NSString *const kNRMA_Attrib_file_private;
88+
89+
90+
// Integer Analytics Constants
91+
static int kNRMA_Attrib_Max_Name_Length = 256;
92+
static int kNRMA_Attrib_Max_Value_Size_Bytes = 4096;
93+
static int kNRMA_Attrib_Max_Number_Attributes = 128;

Agent/Analytics/Constants.m

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//
2+
// Constants.m
3+
// Agent
4+
//
5+
// Created by Mike Bruin on 8/9/23.
6+
// Copyright © 2023 New Relic. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import "Constants.h"
11+
12+
NSString * const kNRMA_RA_eventType = @"eventType";
13+
NSString * const kNRMA_RA_type = @"type";
14+
NSString * const kNRMA_RA_timestamp = @"timestamp";
15+
NSString * const kNRMA_RA_category = @"category";
16+
NSString * const kNRMA_RA_accountId = @"accountId";
17+
NSString * const kNRMA_RA_appId = @"appId";
18+
NSString * const kNRMA_RA_appName = @"appName";
19+
NSString * const kNRMA_RA_uuid = @"uuid";
20+
NSString * const kNRMA_RA_sessionDuration = @"sessionDuration";
21+
NSString * const kNRMA_RA_sessionElapsedTime = @"timeSinceLoad";
22+
NSString * const kNRMA_RA_payload = @"payload";
23+
NSString * const kNRMA_RA_InteractionDuration = @"interactionDuration";
24+
NSString * const kNRMA_RA_osName = @"osName";
25+
NSString * const kNRMA_RA_osVersion = @"osVersion";
26+
NSString * const kNRMA_RA_osMajorVersion = @"osMajorVersion";
27+
NSString * const kNRMA_RA_deviceManufacturer = @"deviceManufacturer";
28+
NSString * const kNRMA_RA_deviceModel = @"deviceModel";
29+
NSString * const kNRMA_RA_carrier = @"carrier";
30+
NSString * const kNRMA_RA_newRelicVersion = @"newRelicVersion";
31+
NSString * const kNRMA_RA_memUsageMb = @"memUsageMb";
32+
NSString * const kNRMA_RA_sessionId = @"sessionId";
33+
NSString * const kNRMA_RA_install = @"install";
34+
NSString * const kNRMA_RA_upgradeFrom = @"upgradeFrom";
35+
NSString * const kNRMA_RA_platform = @"platform";
36+
NSString * const kNRMA_RA_platformVersion = @"platformVersion";
37+
NSString * const kNRMA_RA_lastInteraction = @"lastInteraction";
38+
NSString * const kNRMA_RA_appDataHeader = @"nr.X-NewRelic-App-Data";
39+
NSString * const kNRMA_RA_responseBody = @"nr.responseBody";
40+
41+
//reserved mobile eventTypes
42+
NSString * const kNRMA_RET_mobile = @"Mobile";
43+
NSString * const kNRMA_RET_mobileSession = @"MobileSession";
44+
NSString * const kNRMA_RET_mobileRequest = @"MobileRequest";
45+
NSString * const kNRMA_RET_mobileRequestError = @"MobileRequestError";
46+
NSString * const kNRMA_RET_mobileCrash = @"MobileCrash";
47+
NSString * const kNRMA_RET_mobileBreadcrumb = @"MobileBreadcrumb";
48+
NSString * const kNRMA_RET_mobileUserAction = @"MobileUserAction";
49+
50+
//gesture attributes (not reserved)
51+
NSString * const kNRMA_RA_methodExecuted = @"methodExecuted";
52+
NSString * const kNRMA_RA_targetObject = @"targetObject";
53+
NSString * const kNRMA_RA_label = @"label";
54+
NSString * const kNRMA_RA_accessibility = @"accessibility";
55+
NSString * const kNRMA_RA_touchCoordinates = @"touchCoordinates";
56+
NSString * const kNMRA_RA_actionType = @"actionType";
57+
NSString * const kNRMA_RA_frame = @"controlRect";
58+
NSString * const kNRMA_RA_orientation = @"orientation";
59+
//reserved prefix
60+
NSString * const kNRMA_RP_newRelic = @"newRelic";
61+
NSString * const kNRMA_RP_nr = @"nr.";
62+
63+
//Intrinsic Event Attributes (not reserved)
64+
NSString * const kNRMA_Attrib_guid = @"guid";
65+
NSString * const kNRMA_Attrib_traceId = @"traceId";
66+
NSString * const kNRMA_Attrib_parentId = @"nr.parentId";
67+
NSString * const kNRMA_Attrib_userId = @"userId";
68+
69+
//Request Event Attributes (not reserved)
70+
NSString * const kNRMA_Attrib_connectionType = @"connectionType";
71+
NSString * const kNRMA_Attrib_requestUrl = @"requestUrl";
72+
NSString * const kNRMA_Attrib_requestDomain = @"requestDomain";
73+
NSString * const kNRMA_Attrib_requestPath = @"requestPath";
74+
NSString * const kNRMA_Attrib_requestMethod = @"requestMethod";
75+
NSString * const kNRMA_Attrib_bytesReceived = @"bytesReceived";
76+
NSString * const kNRMA_Attrib_bytesSent = @"bytesSent";
77+
NSString * const kNRMA_Attrib_responseTime = @"responseTime";
78+
NSString * const kNRMA_Attrib_statusCode = @"statusCode";
79+
NSString * const kNRMA_Attrib_networkErrorCode = @"networkErrorCode";
80+
NSString * const kNRMA_Attrib_networkError = @"networkError";
81+
NSString * const kNRMA_Attrib_errorType = @"errorType";
82+
NSString * const kNRMA_Attrib_contentType = @"contentType";
83+
NSString * const kNRMA_Attrib_dtGuid = @"guid";
84+
NSString * const kNRMA_Attrib_dtId = @"id";
85+
NSString * const kNRMA_Attrib_dtTraceId = @"trace.id";
86+
NSString * const kNRMA_Attrib_name = @"name";
87+
88+
NSString * const kNRMA_Val_errorType_HTTP = @"HTTPError";
89+
NSString * const kNRMA_Val_errorType_Network = @"NetworkFailure";
90+
91+
92+
NSString * const kNRMA_Attrib_file = @"attributes.txt";
93+
NSString * const kNRMA_Attrib_file_private = @"privateAttributes.txt";
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// NRMAAnalyticEventProtocol.h
3+
// Agent
4+
//
5+
// Created by Steve Malsam on 6/8/23.
6+
// Copyright © 2023 New Relic. All rights reserved.
7+
//
8+
9+
#ifndef NRMAAnalyticEventProtocol_h
10+
#define NRMAAnalyticEventProtocol_h
11+
12+
#import "NRMAJSON.h"
13+
14+
@protocol NRMAAnalyticEventProtocol <NSObject, NRMAJSONABLE>
15+
16+
@property NSTimeInterval timestamp;
17+
@property NSTimeInterval sessionElapsedTimeSeconds;
18+
@property (nonatomic) NSString *eventType;
19+
20+
21+
- (BOOL) addAttribute:(NSString *)name value:(id)value;
22+
- (NSTimeInterval)getEventAge;
23+
24+
@end
25+
26+
#endif /* NRMAAnalyticEventProtocol_h */
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// NRMACustomEvent.h
3+
// Agent
4+
//
5+
// Created by Steve Malsam on 6/13/23.
6+
// Copyright © 2023 New Relic. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
#import "NRMAMobileEvent.h"
12+
#import "AttributeValidatorProtocol.h"
13+
14+
NS_ASSUME_NONNULL_BEGIN
15+
16+
@interface NRMACustomEvent : NRMAMobileEvent
17+
18+
- (instancetype) initWithEventType:(NSString *)eventType
19+
timestamp:(NSTimeInterval)timestamp
20+
sessionElapsedTimeInSeconds:(NSTimeInterval)sessionElapsedTimeSeconds
21+
withAttributeValidator:(__nullable id<AttributeValidatorProtocol>) attributeValidator;
22+
23+
@end
24+
25+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)