Skip to content

Commit

Permalink
NR-352010 Changed NRMASAM to add the persisted attributes individuall…
Browse files Browse the repository at this point in the history
…y so that they get re-persisted
  • Loading branch information
mbruin-NR committed Jan 29, 2025
1 parent 3ecb494 commit 840c8ad
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Agent/Analytics/NRMASAM.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,31 @@ @implementation NRMASAM {
- (id)initWithAttributeValidator:(__nullable id<AttributeValidatorProtocol>)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;
}
Expand Down

0 comments on commit 840c8ad

Please sign in to comment.