Skip to content

Commit

Permalink
Merge branch 'develop' into PersistentStore
Browse files Browse the repository at this point in the history
  • Loading branch information
mbruin-NR authored Feb 6, 2024
2 parents 1863135 + 39d5adb commit 5c95ea2
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Agent/Analytics/NRMAAnalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

@interface NRMAAnalytics : NSObject <NRMAHarvestAware>
- (void) setMaxEventBufferTime:(unsigned int) seconds;

- (NSUInteger) getMaxEventBufferSize;
- (void) setMaxEventBufferSize:(unsigned int) size;
- (NSUInteger) getMaxEventBufferTime;

- (id) initWithSessionStartTimeMS:(long long) sessionStartTime;

Expand Down
8 changes: 8 additions & 0 deletions Agent/Analytics/NRMAAnalytics.mm
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,30 @@ @implementation NRMAAnalytics
}

- (void) setMaxEventBufferSize:(unsigned int) size {
[NRMAAgentConfiguration setMaxEventBufferSize:size];
if([NRMAFlags shouldEnableNewEventSystem]){
[_eventManager setMaxEventBufferSize:size];
}
else {
_analyticsController->setMaxEventBufferSize(size);
}
}
- (NSUInteger) getMaxEventBufferSize {
return [_eventManager getMaxEventBufferSize];
}
- (void) setMaxEventBufferTime:(unsigned int)seconds
{
[NRMAAgentConfiguration setMaxEventBufferTime:seconds];
if([NRMAFlags shouldEnableNewEventSystem]){
[_eventManager setMaxEventBufferTimeInSeconds:seconds];
}
else {
_analyticsController->setMaxEventBufferTime(seconds);
}
}
- (NSUInteger) getMaxEventBufferTime {
return [_eventManager getMaxEventBufferTimeInSeconds];
}

- (id) initWithSessionStartTimeMS:(long long) sessionStartTime {
self = [super init];
Expand Down
2 changes: 2 additions & 0 deletions Agent/Analytics/NRMAEventManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface NRMAEventManager : NSObject

- (void)setMaxEventBufferSize:(NSUInteger)size;
- (NSUInteger)getMaxEventBufferSize;
- (void)setMaxEventBufferTimeInSeconds:(NSUInteger)seconds;
- (NSUInteger)getMaxEventBufferTimeInSeconds;
- (BOOL)didReachMaxQueueTime:(NSTimeInterval)currentTimeMilliseconds;
- (BOOL)addEvent:(id<NRMAAnalyticEventProtocol>)event;
- (void)empty;
Expand Down
8 changes: 8 additions & 0 deletions Agent/Analytics/NRMAEventManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ - (void)setMaxEventBufferSize:(NSUInteger)size {
maxBufferSize = size;
}

- (NSUInteger)getMaxEventBufferSize {
return maxBufferSize;
}

- (void)setMaxEventBufferTimeInSeconds:(NSUInteger)seconds {
if(seconds < kMinBufferTimeSeconds) {
NRLOG_ERROR(@"Buffer Time cannot be less than %lu Seconds", (unsigned long)kMinBufferTimeSeconds);
Expand All @@ -83,6 +87,10 @@ - (void)setMaxEventBufferTimeInSeconds:(NSUInteger)seconds {
maxBufferTimeSeconds = seconds;
}

- (NSUInteger)getMaxEventBufferTimeInSeconds {
return maxBufferTimeSeconds;
}

- (BOOL)didReachMaxQueueTime:(NSTimeInterval)currentTimeMilliseconds {
if(oldestEventTimestamp == 0) {
return false;
Expand Down
3 changes: 1 addition & 2 deletions Agent/Harvester/DataStore/NRMAAgentConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
+ (void) setMaxEventBufferTime:(NSUInteger)seconds;
+ (NSUInteger) getMaxEventBufferTime;

+ (void) setMaxEventBufferSize:(NSUInteger)seconds;
+ (void) setMaxEventBufferSize:(NSUInteger)size;
+ (NSUInteger) getMaxEventBufferSize;

@end
5 changes: 2 additions & 3 deletions Agent/Harvester/DataStore/NRMAAgentConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ + (NSUInteger) getMaxEventBufferTime {
return __NRMA__maxEventBufferTime;
}


+ (void) setMaxEventBufferSize:(NSUInteger)seconds {
__NRMA__maxEventBufferSize = seconds;
+ (void) setMaxEventBufferSize:(NSUInteger)size {
__NRMA__maxEventBufferSize = size;
}
+ (NSUInteger) getMaxEventBufferSize {
return __NRMA__maxEventBufferSize;
Expand Down
4 changes: 3 additions & 1 deletion Agent/Public/NRConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ extern "C" {
NRMAPlatform_ReactNative,
NRMAPlatform_Flutter,
NRMAPlatform_Capacitor,
NRMAPlatform_MAUI
NRMAPlatform_MAUI,
NRMAPlatform_Unreal
};

// these constants are paired with enum values of NRMAApplicationPlatform
Expand All @@ -49,6 +50,7 @@ extern "C" {
#define kNRMAPlatformString_Flutter @"Flutter"
#define kNRMAPlatformString_Capacitor @"Capacitor"
#define kNRMAPlatformString_MAUI @"MAUI"
#define kNRMAPlatformString_Unreal @"Unreal"


//Custom Trace Types
Expand Down
2 changes: 0 additions & 2 deletions Agent/Public/NewRelic.m
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,6 @@ + (BOOL) recordBreadcrumb:(NSString* __nonnull)name
* harvest cycle.
*/
+ (void) setMaxEventBufferTime:(unsigned int)seconds {
[NRMAAgentConfiguration setMaxEventBufferTime:seconds];

[[NewRelicAgentInternal sharedInstance].analyticsController setMaxEventBufferTime:seconds];
}
/*
Expand Down
2 changes: 2 additions & 0 deletions Agent/Utilities/NewRelicInternalUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ + (NSString*) stringFromNRMAApplicationPlatform:(NRMAApplicationPlatform)applica
return kNRMAPlatformString_Capacitor;
case NRMAPlatform_MAUI:
return kNRMAPlatformString_MAUI;
case NRMAPlatform_Unreal:
return kNRMAPlatformString_Unreal;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,6 @@ - (void) testJSONEscapeCharacters {

}



- (void) testDuplicateStore {
//todo: reenable test (disabled for beta 1, no persistent store)
// NRMAAnalytics* analytics = [[NRMAAnalytics alloc] initWithSessionStartTimeMS:0];
Expand Down Expand Up @@ -1097,6 +1095,28 @@ - (void) testMidSessionHarvest {
// XCTAssertTrue(array.count == 0, @"dup events should have been cleared out on harvest before.");
}

-(void)testSetMaxEventBufferSize {
NRMAAnalytics* analytics = [[NRMAAnalytics alloc] initWithSessionStartTimeMS:0];

[analytics setMaxEventBufferSize:2000];

XCTAssertEqual([analytics getMaxEventBufferSize], 2000);

analytics = [[NRMAAnalytics alloc] initWithSessionStartTimeMS:0];
XCTAssertEqual([analytics getMaxEventBufferSize], 2000);
}

-(void)testSetMaxEventBufferTime {
NRMAAnalytics* analytics = [[NRMAAnalytics alloc] initWithSessionStartTimeMS:0];

[analytics setMaxEventBufferTime:2000];

XCTAssertEqual([analytics getMaxEventBufferTime], 2000);

analytics = [[NRMAAnalytics alloc] initWithSessionStartTimeMS:0];
XCTAssertEqual([analytics getMaxEventBufferTime], 2000);
}

- (void) testBadInput {
BOOL result;
//- (BOOL) addInteractionEvent:(NSString*)name interactionDuration:(double)duration_secs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ - (void) testCorrectness
NRMAApplicationPlatform capacitor = NRMAPlatform_Capacitor;
NSString* capacitorPlatformString = [NewRelicInternalUtils stringFromNRMAApplicationPlatform:capacitor];
XCTAssertTrue([capacitorPlatformString isEqualToString:expectedCapacitorString]);

NSString* expectedUnrealString = @"Unreal";

NRMAApplicationPlatform Unreal = NRMAPlatform_Unreal;
NSString* UnrealPlatformString = [NewRelicInternalUtils stringFromNRMAApplicationPlatform:Unreal];
XCTAssertTrue([UnrealPlatformString isEqualToString:expectedUnrealString]);
}


Expand Down

0 comments on commit 5c95ea2

Please sign in to comment.