Skip to content

Commit 840c8ad

Browse files
committed
NR-352010 Changed NRMASAM to add the persisted attributes individually so that they get re-persisted
1 parent 3ecb494 commit 840c8ad

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Agent/Analytics/NRMASAM.mm

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,31 @@ @implementation NRMASAM {
3030
- (id)initWithAttributeValidator:(__nullable id<AttributeValidatorProtocol>)validator {
3131
self = [super init];
3232
if (self) {
33+
attributeValidator = validator;
34+
3335
_attributePersistentStore = [[PersistentEventStore alloc] initWithFilename:[NRMASAM attributeFilePath] andMinimumDelay:.025];
3436

3537
_privateAttributePersistentStore = [[PersistentEventStore alloc] initWithFilename:[NRMASAM privateAttributeFilePath] andMinimumDelay:.025];
3638

3739
// Load public attributes from file.
3840
NSDictionary *lastSessionAttributes = [PersistentEventStore getLastSessionEventsFromFilename:[NRMASAM attributeFilePath]];
41+
attributeDict = [[NSMutableDictionary alloc] init];
3942
if (lastSessionAttributes != nil) {
40-
attributeDict = [lastSessionAttributes mutableCopy];
41-
}
42-
if (!attributeDict) {
43-
attributeDict = [[NSMutableDictionary alloc] init];
43+
for(NSString* key in [lastSessionAttributes allKeys]) {
44+
[self setAttribute:key value:[lastSessionAttributes valueForKey:key]];
45+
}
4446
}
4547

4648
// Load private attributes from file.
4749
NSDictionary *lastSessionPrivateAttributes = [PersistentEventStore getLastSessionEventsFromFilename:[NRMASAM privateAttributeFilePath]];
48-
50+
privateAttributeDict = [[NSMutableDictionary alloc] init];
51+
4952
if (lastSessionPrivateAttributes != nil) {
50-
privateAttributeDict = [lastSessionPrivateAttributes mutableCopy];
51-
}
52-
if (!privateAttributeDict) {
53-
privateAttributeDict = [[NSMutableDictionary alloc] init];
53+
for(NSString* key in [lastSessionPrivateAttributes allKeys]) {
54+
[self setNRSessionAttribute:key value:[lastSessionPrivateAttributes valueForKey:key]];
55+
}
5456
}
55-
56-
attributeValidator = validator;
57+
5758
}
5859
return self;
5960
}

0 commit comments

Comments
 (0)