Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:newrelic/newrelic-ios-agent into…
Browse files Browse the repository at this point in the history
… examples-merge
  • Loading branch information
cdillard-NewRelic committed Jan 9, 2024
2 parents 0464180 + 0d876ec commit c5c2dfa
Show file tree
Hide file tree
Showing 249 changed files with 10,891 additions and 72,258 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
xcode-version: '14.3'

- name: Install lcov
run: brew install lcov
run: |
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/e92d2ae54954ebf485b484d8522104700b144fee/Formula/lcov.rb > lcov.rb
brew install ./lcov.rb
- name: Update gem
run: bundle update
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/productionDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ jobs:
- name: Print XCFramework name
run: echo "${{ env.version }}"

# - name: Create Prod Podspec for XCFramework version
# run: |
# cd main
- name: Create Prod Podspec for XCFramework version
run: |
cd main
# cp cocoapods/NewRelicAgent.podspec.template NewRelicAgent.podspec
# REPLACE=X.XX
# sed -i bak "s/$REPLACE/${{ env.version }}/g" NewRelicAgent.podspec
cp cocoapods/NewRelicAgent.podspec.template NewRelicAgent.podspec
REPLACE=X.XX
sed -i bak "s/$REPLACE/${{ env.version }}/g" NewRelicAgent.podspec
# rm NewRelicAgent.podspecbak
rm NewRelicAgent.podspecbak
# pod trunk push --allow-warnings NewRelicAgent.podspec
# env:
# COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
pod trunk push --allow-warnings NewRelicAgent.podspec
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

- name: Create Prod Package.swift for XCFramework version
run: |
Expand Down
234 changes: 206 additions & 28 deletions Agent.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Agent/ActivityTracing/NRMATraceController.m
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ + (BOOL) completeActivityTraceWithExitTimestampMillis:(double)exitTimestampMilli
duration:[NSNumber numberWithDouble:(activityTrace.endTime - activityTrace.startTime)]];
[NRMATaskQueue queue:activityTrace];

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

#ifndef DISABLE_NR_EXCEPTION_WRAPPER
} @catch (NSException* exception) {
Expand Down
24 changes: 24 additions & 0 deletions Agent/Analytics/AttributeValidatorProtocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// AttributeValidatorProtocol.h
// Agent
//
// Created by Steve Malsam on 6/15/23.
// Copyright © 2023 New Relic. All rights reserved.
//

#ifndef AttributeValidatorProtocol_h
#define AttributeValidatorProtocol_h

typedef BOOL (^NameValidator)(NSString*);
typedef BOOL (^ValueValidator)(id);
typedef BOOL (^EventTypeValidator)(NSString*);

@protocol AttributeValidatorProtocol <NSObject>

- (BOOL)nameValidator:(NSString *)name;
- (BOOL)valueValidator:(id)value;
- (BOOL)eventTypeValidator:(NSString *)eventType;

@end

#endif /* AttributeValidatorProtocol_h */
27 changes: 27 additions & 0 deletions Agent/Analytics/BlockAttributeValidator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// BlockAttributeValidator.h
// Agent
//
// Created by Steve Malsam on 6/15/23.
// Copyright © 2023 New Relic. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "AttributeValidatorProtocol.h"

NS_ASSUME_NONNULL_BEGIN

@interface BlockAttributeValidator : NSObject <AttributeValidatorProtocol>

@property (copy, readonly) NameValidator nameValidator;
@property (copy, readonly) ValueValidator valueValidator;
@property (copy, readonly) EventTypeValidator eventTypeValidator;

- (instancetype)initWithNameValidator:(NameValidator)nameValidator
valueValidator:(ValueValidator)valueValidator
andEventTypeValidator:(EventTypeValidator)eventTypeValidator;

@end

NS_ASSUME_NONNULL_END
38 changes: 38 additions & 0 deletions Agent/Analytics/BlockAttributeValidator.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// BlockAttributeValidator.m
// Agent
//
// Created by Steve Malsam on 6/15/23.
// Copyright © 2023 New Relic. All rights reserved.
//

#import "BlockAttributeValidator.h"

@implementation BlockAttributeValidator

- (nonnull instancetype)initWithNameValidator:(nonnull NameValidator)nameValidator
valueValidator:(nonnull ValueValidator)valueValidator
andEventTypeValidator:(nonnull EventTypeValidator)eventTypeValidator {
self = [super init];
if(self) {
_nameValidator = nameValidator;
_valueValidator = valueValidator;
_eventTypeValidator = eventTypeValidator;
}

return self;
}

- (BOOL)eventTypeValidator:(NSString *)eventType {
return self.eventTypeValidator(eventType);
}

- (BOOL)nameValidator:(NSString *)name {
return self.nameValidator(name);
}

- (BOOL)valueValidator:(id)value {
return self.valueValidator(value);
}

@end
93 changes: 93 additions & 0 deletions Agent/Analytics/Constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// Constants.h
// Agent
//
// Created by Mike Bruin on 8/9/23.
// Copyright © 2023 New Relic. All rights reserved.
//

#import <Foundation/Foundation.h>

extern NSString *const kNRMA_RA_eventType;
extern NSString *const kNRMA_RA_type;
extern NSString *const kNRMA_RA_timestamp;
extern NSString *const kNRMA_RA_category;
extern NSString *const kNRMA_RA_accountId;
extern NSString *const kNRMA_RA_appId;
extern NSString *const kNRMA_RA_appName;
extern NSString *const kNRMA_RA_uuid;
extern NSString *const kNRMA_RA_sessionDuration;
extern NSString *const kNRMA_RA_sessionElapsedTime;
extern NSString *const kNRMA_RA_payload;
extern NSString *const kNRMA_RA_InteractionDuration;
extern NSString *const kNRMA_RA_osName;
extern NSString *const kNRMA_RA_osVersion;
extern NSString *const kNRMA_RA_osMajorVersion;
extern NSString *const kNRMA_RA_deviceManufacturer;
extern NSString *const kNRMA_RA_deviceModel;
extern NSString *const kNRMA_RA_carrier;
extern NSString *const kNRMA_RA_newRelicVersion;
extern NSString *const kNRMA_RA_memUsageMb;
extern NSString *const kNRMA_RA_sessionId;
extern NSString *const kNRMA_RA_install;
extern NSString *const kNRMA_RA_upgradeFrom;
extern NSString *const kNRMA_RA_platform;
extern NSString *const kNRMA_RA_platformVersion;
extern NSString *const kNRMA_RA_lastInteraction;
extern NSString *const kNRMA_RA_appDataHeader;
extern NSString *const kNRMA_RA_responseBody;

extern NSString *const kNRMA_RET_mobile;
extern NSString *const kNRMA_RET_mobileSession;
extern NSString *const kNRMA_RET_mobileRequest;
extern NSString *const kNRMA_RET_mobileRequestError;
extern NSString *const kNRMA_RET_mobileCrash;
extern NSString *const kNRMA_RET_mobileBreadcrumb;
extern NSString *const kNRMA_RET_mobileUserAction;

extern NSString *const kNRMA_RA_methodExecuted;
extern NSString *const kNRMA_RA_targetObject;
extern NSString *const kNRMA_RA_label;
extern NSString *const kNRMA_RA_accessibility;
extern NSString *const kNRMA_RA_touchCoordinates;
extern NSString *const kNMRA_RA_actionType;
extern NSString *const kNRMA_RA_frame;
extern NSString *const kNRMA_RA_orientation;

extern NSString *const kNRMA_RP_newRelic;
extern NSString *const kNRMA_RP_nr;

extern NSString *const kNRMA_Attrib_guid;
extern NSString *const kNRMA_Attrib_traceId;
extern NSString *const kNRMA_Attrib_parentId;
extern NSString *const kNRMA_Attrib_userId;

extern NSString *const kNRMA_Attrib_connectionType;
extern NSString *const kNRMA_Attrib_requestUrl;
extern NSString *const kNRMA_Attrib_requestDomain;
extern NSString *const kNRMA_Attrib_requestPath;
extern NSString *const kNRMA_Attrib_requestMethod;
extern NSString *const kNRMA_Attrib_bytesReceived;
extern NSString *const kNRMA_Attrib_bytesSent;
extern NSString *const kNRMA_Attrib_responseTime;
extern NSString *const kNRMA_Attrib_statusCode;
extern NSString *const kNRMA_Attrib_networkErrorCode;
extern NSString *const kNRMA_Attrib_networkError;
extern NSString *const kNRMA_Attrib_errorType;
extern NSString *const kNRMA_Attrib_contentType;
extern NSString *const kNRMA_Attrib_dtGuid;
extern NSString *const kNRMA_Attrib_dtId;
extern NSString *const kNRMA_Attrib_dtTraceId;
extern NSString *const kNRMA_Attrib_name;

extern NSString *const kNRMA_Val_errorType_HTTP;
extern NSString *const kNRMA_Val_errorType_Network;

extern NSString *const kNRMA_Attrib_file;
extern NSString *const kNRMA_Attrib_file_private;


// Integer Analytics Constants
static int kNRMA_Attrib_Max_Name_Length = 256;
static int kNRMA_Attrib_Max_Value_Size_Bytes = 4096;
static int kNRMA_Attrib_Max_Number_Attributes = 128;
93 changes: 93 additions & 0 deletions Agent/Analytics/Constants.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// Constants.m
// Agent
//
// Created by Mike Bruin on 8/9/23.
// Copyright © 2023 New Relic. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Constants.h"

NSString * const kNRMA_RA_eventType = @"eventType";
NSString * const kNRMA_RA_type = @"type";
NSString * const kNRMA_RA_timestamp = @"timestamp";
NSString * const kNRMA_RA_category = @"category";
NSString * const kNRMA_RA_accountId = @"accountId";
NSString * const kNRMA_RA_appId = @"appId";
NSString * const kNRMA_RA_appName = @"appName";
NSString * const kNRMA_RA_uuid = @"uuid";
NSString * const kNRMA_RA_sessionDuration = @"sessionDuration";
NSString * const kNRMA_RA_sessionElapsedTime = @"timeSinceLoad";
NSString * const kNRMA_RA_payload = @"payload";
NSString * const kNRMA_RA_InteractionDuration = @"interactionDuration";
NSString * const kNRMA_RA_osName = @"osName";
NSString * const kNRMA_RA_osVersion = @"osVersion";
NSString * const kNRMA_RA_osMajorVersion = @"osMajorVersion";
NSString * const kNRMA_RA_deviceManufacturer = @"deviceManufacturer";
NSString * const kNRMA_RA_deviceModel = @"deviceModel";
NSString * const kNRMA_RA_carrier = @"carrier";
NSString * const kNRMA_RA_newRelicVersion = @"newRelicVersion";
NSString * const kNRMA_RA_memUsageMb = @"memUsageMb";
NSString * const kNRMA_RA_sessionId = @"sessionId";
NSString * const kNRMA_RA_install = @"install";
NSString * const kNRMA_RA_upgradeFrom = @"upgradeFrom";
NSString * const kNRMA_RA_platform = @"platform";
NSString * const kNRMA_RA_platformVersion = @"platformVersion";
NSString * const kNRMA_RA_lastInteraction = @"lastInteraction";
NSString * const kNRMA_RA_appDataHeader = @"nr.X-NewRelic-App-Data";
NSString * const kNRMA_RA_responseBody = @"nr.responseBody";

//reserved mobile eventTypes
NSString * const kNRMA_RET_mobile = @"Mobile";
NSString * const kNRMA_RET_mobileSession = @"MobileSession";
NSString * const kNRMA_RET_mobileRequest = @"MobileRequest";
NSString * const kNRMA_RET_mobileRequestError = @"MobileRequestError";
NSString * const kNRMA_RET_mobileCrash = @"MobileCrash";
NSString * const kNRMA_RET_mobileBreadcrumb = @"MobileBreadcrumb";
NSString * const kNRMA_RET_mobileUserAction = @"MobileUserAction";

//gesture attributes (not reserved)
NSString * const kNRMA_RA_methodExecuted = @"methodExecuted";
NSString * const kNRMA_RA_targetObject = @"targetObject";
NSString * const kNRMA_RA_label = @"label";
NSString * const kNRMA_RA_accessibility = @"accessibility";
NSString * const kNRMA_RA_touchCoordinates = @"touchCoordinates";
NSString * const kNMRA_RA_actionType = @"actionType";
NSString * const kNRMA_RA_frame = @"controlRect";
NSString * const kNRMA_RA_orientation = @"orientation";
//reserved prefix
NSString * const kNRMA_RP_newRelic = @"newRelic";
NSString * const kNRMA_RP_nr = @"nr.";

//Intrinsic Event Attributes (not reserved)
NSString * const kNRMA_Attrib_guid = @"guid";
NSString * const kNRMA_Attrib_traceId = @"traceId";
NSString * const kNRMA_Attrib_parentId = @"nr.parentId";
NSString * const kNRMA_Attrib_userId = @"userId";

//Request Event Attributes (not reserved)
NSString * const kNRMA_Attrib_connectionType = @"connectionType";
NSString * const kNRMA_Attrib_requestUrl = @"requestUrl";
NSString * const kNRMA_Attrib_requestDomain = @"requestDomain";
NSString * const kNRMA_Attrib_requestPath = @"requestPath";
NSString * const kNRMA_Attrib_requestMethod = @"requestMethod";
NSString * const kNRMA_Attrib_bytesReceived = @"bytesReceived";
NSString * const kNRMA_Attrib_bytesSent = @"bytesSent";
NSString * const kNRMA_Attrib_responseTime = @"responseTime";
NSString * const kNRMA_Attrib_statusCode = @"statusCode";
NSString * const kNRMA_Attrib_networkErrorCode = @"networkErrorCode";
NSString * const kNRMA_Attrib_networkError = @"networkError";
NSString * const kNRMA_Attrib_errorType = @"errorType";
NSString * const kNRMA_Attrib_contentType = @"contentType";
NSString * const kNRMA_Attrib_dtGuid = @"guid";
NSString * const kNRMA_Attrib_dtId = @"id";
NSString * const kNRMA_Attrib_dtTraceId = @"trace.id";
NSString * const kNRMA_Attrib_name = @"name";

NSString * const kNRMA_Val_errorType_HTTP = @"HTTPError";
NSString * const kNRMA_Val_errorType_Network = @"NetworkFailure";


NSString * const kNRMA_Attrib_file = @"attributes.txt";
NSString * const kNRMA_Attrib_file_private = @"privateAttributes.txt";
26 changes: 26 additions & 0 deletions Agent/Analytics/Events/NRMAAnalyticEventProtocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// NRMAAnalyticEventProtocol.h
// Agent
//
// Created by Steve Malsam on 6/8/23.
// Copyright © 2023 New Relic. All rights reserved.
//

#ifndef NRMAAnalyticEventProtocol_h
#define NRMAAnalyticEventProtocol_h

#import "NRMAJSON.h"

@protocol NRMAAnalyticEventProtocol <NSObject, NRMAJSONABLE>

@property NSTimeInterval timestamp;
@property NSTimeInterval sessionElapsedTimeSeconds;
@property (nonatomic) NSString *eventType;


- (BOOL) addAttribute:(NSString *)name value:(id)value;
- (NSTimeInterval)getEventAge;

@end

#endif /* NRMAAnalyticEventProtocol_h */
25 changes: 25 additions & 0 deletions Agent/Analytics/Events/NRMACustomEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// NRMACustomEvent.h
// Agent
//
// Created by Steve Malsam on 6/13/23.
// Copyright © 2023 New Relic. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "NRMAMobileEvent.h"
#import "AttributeValidatorProtocol.h"

NS_ASSUME_NONNULL_BEGIN

@interface NRMACustomEvent : NRMAMobileEvent

- (instancetype) initWithEventType:(NSString *)eventType
timestamp:(NSTimeInterval)timestamp
sessionElapsedTimeInSeconds:(NSTimeInterval)sessionElapsedTimeSeconds
withAttributeValidator:(__nullable id<AttributeValidatorProtocol>) attributeValidator;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit c5c2dfa

Please sign in to comment.