Skip to content

Commit

Permalink
Some changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
mbruin-NR committed Jan 11, 2024
1 parent 1394872 commit c5c102d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Agent/Analytics/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ 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_Attrib_offline;

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;

extern NSString *const kNRMA_Offline_file;
extern NSString *const kNRMA_Offline_folder;

// Integer Analytics Constants
static int kNRMA_Attrib_Max_Name_Length = 256;
Expand Down
3 changes: 2 additions & 1 deletion Agent/Analytics/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
NSString * const kNRMA_Attrib_dtId = @"id";
NSString * const kNRMA_Attrib_dtTraceId = @"trace.id";
NSString * const kNRMA_Attrib_name = @"name";
NSString * const kNRMA_Attrib_offline = @"offline";

NSString * const kNRMA_Val_errorType_HTTP = @"HTTPError";
NSString * const kNRMA_Val_errorType_Network = @"NetworkFailure";
Expand All @@ -92,4 +93,4 @@
NSString * const kNRMA_Attrib_file = @"attributes.txt";
NSString * const kNRMA_Attrib_file_private = @"privateAttributes.txt";

NSString * const kNRMA_Offline_file = @"offlineStorage";
NSString * const kNRMA_Offline_folder = @"offlineStorage";
20 changes: 9 additions & 11 deletions Agent/General/NewRelicAgentInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,20 @@ - (void) onSessionStart {
// Initializing analytics take a while. Take care executing time sensitive code after this point the since initializeAnalytics method will delay its execution.
[self initializeAnalytics];
NRMAReachability* r = [NewRelicInternalUtils reachability];

NRMANetworkStatus status;
@synchronized(r) {
status = [r currentReachabilityStatus];
}
if ([NRMAFlags shouldEnableHandledExceptionEvents]) {
self.handledExceptionsController = [[NRMAHandledExceptions alloc] initWithAnalyticsController:self.analyticsController
sessionStartTime:self.appSessionStartDate
agentConfiguration:self.agentConfiguration
platform:[NewRelicInternalUtils osName]
sessionId:[self currentSessionId]];

@synchronized(r) {
NRMANetworkStatus status = [r currentReachabilityStatus];
if (status != NotReachable) {
[self.handledExceptionsController processAndPublishPersistedReports];
}

if (status != NotReachable) {
[self.handledExceptionsController processAndPublishPersistedReports];
}

[NRMAHarvestController addHarvestListener:self.handledExceptionsController];
Expand All @@ -499,11 +500,8 @@ - (void) onSessionStart {

// Attempt to upload crash report files (if any exist)
if ([NRMAFlags shouldEnableCrashReporting]) {
@synchronized(r) {
NRMANetworkStatus status = [r currentReachabilityStatus];
if (status != NotReachable) {
[[NRMAExceptionHandlerManager manager].uploader uploadCrashReports];
}
if (status != NotReachable) {
[[NRMAExceptionHandlerManager manager].uploader uploadCrashReports];
}
}

Expand Down
3 changes: 2 additions & 1 deletion Agent/Harvester/NRMAHarvester.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <Utilities/Application.hpp>
#import "NRMASupportMetricHelper.h"
#import "NRMAFlags.h"
#import "Constants.h"

#define kNRSupportabilityResponseCode kNRSupportabilityPrefix @"/Collector/ResponseStatusCodes"

Expand Down Expand Up @@ -370,7 +371,7 @@ - (BOOL) checkOfflineAndPersist:(NRMAHarvestResponse*) response {
}
if([NRMAOfflineStorage checkErrorToPersist:response.error]) {
NSMutableDictionary *tempAnalyticsAttributes = [[NSMutableDictionary alloc] initWithDictionary:self.harvestData.analyticsAttributes];
[tempAnalyticsAttributes setValue:[NSNumber numberWithBool:YES] forKey:@"offline"];
[tempAnalyticsAttributes setValue:[NSNumber numberWithBool:YES] forKey:kNRMA_Attrib_offline];
[self.harvestData setAnalyticsAttributes:[[NSDictionary alloc] initWithDictionary:tempAnalyticsAttributes]];

NSError* error = nil;
Expand Down
2 changes: 1 addition & 1 deletion Agent/Utilities/NRMAOfflineStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ - (BOOL) clearAllOfflineFiles {
}

- (NSString*) offlineDirectoryPath {
return [NSString stringWithFormat:@"%@/%@/%@",[NewRelicInternalUtils getStorePath],kNRMA_Offline_file,_name];
return [NSString stringWithFormat:@"%@/%@/%@",[NewRelicInternalUtils getStorePath],kNRMA_Offline_folder,_name];
}

- (NSString*) newOfflineFilePath {
Expand Down

0 comments on commit c5c102d

Please sign in to comment.