From 840c8ade725e66424bca4c8ec24d948312680cf6 Mon Sep 17 00:00:00 2001 From: Mike Bruin Date: Wed, 29 Jan 2025 16:02:24 -0500 Subject: [PATCH] NR-352010 Changed NRMASAM to add the persisted attributes individually so that they get re-persisted --- Agent/Analytics/NRMASAM.mm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Agent/Analytics/NRMASAM.mm b/Agent/Analytics/NRMASAM.mm index 800c0101..5a31de2a 100644 --- a/Agent/Analytics/NRMASAM.mm +++ b/Agent/Analytics/NRMASAM.mm @@ -30,30 +30,31 @@ @implementation NRMASAM { - (id)initWithAttributeValidator:(__nullable id)validator { self = [super init]; if (self) { + attributeValidator = validator; + _attributePersistentStore = [[PersistentEventStore alloc] initWithFilename:[NRMASAM attributeFilePath] andMinimumDelay:.025]; _privateAttributePersistentStore = [[PersistentEventStore alloc] initWithFilename:[NRMASAM privateAttributeFilePath] andMinimumDelay:.025]; // Load public attributes from file. NSDictionary *lastSessionAttributes = [PersistentEventStore getLastSessionEventsFromFilename:[NRMASAM attributeFilePath]]; + attributeDict = [[NSMutableDictionary alloc] init]; if (lastSessionAttributes != nil) { - attributeDict = [lastSessionAttributes mutableCopy]; - } - if (!attributeDict) { - attributeDict = [[NSMutableDictionary alloc] init]; + for(NSString* key in [lastSessionAttributes allKeys]) { + [self setAttribute:key value:[lastSessionAttributes valueForKey:key]]; + } } // Load private attributes from file. NSDictionary *lastSessionPrivateAttributes = [PersistentEventStore getLastSessionEventsFromFilename:[NRMASAM privateAttributeFilePath]]; - + privateAttributeDict = [[NSMutableDictionary alloc] init]; + if (lastSessionPrivateAttributes != nil) { - privateAttributeDict = [lastSessionPrivateAttributes mutableCopy]; - } - if (!privateAttributeDict) { - privateAttributeDict = [[NSMutableDictionary alloc] init]; + for(NSString* key in [lastSessionPrivateAttributes allKeys]) { + [self setNRSessionAttribute:key value:[lastSessionPrivateAttributes valueForKey:key]]; + } } - - attributeValidator = validator; + } return self; }