Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NR-352010 Changed NRMASAM to add the persisted attributes individually so that they get re-persisted #342

Merged
merged 7 commits into from
Jan 31, 2025
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
Loading