Skip to content

Commit

Permalink
Prevent setUserId nil log
Browse files Browse the repository at this point in the history
  • Loading branch information
cdillard-NewRelic committed Jan 30, 2025
1 parent 3ecb494 commit 68166ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Agent/Analytics/NRMAAnalytics.mm
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,13 @@ - (BOOL) setSessionAttribute:(NSString*)name value:(id)value persistent:(BOOL)is
[](bool) { return true;});
return _analyticsController->addNRAttribute(attribute);
} else {
NRLOG_AGENT_ERROR(@"Session attribute \'value\' must be either an NSString* or NSNumber*");
if (name == kNRMA_Attrib_userId && !value ) {
NRLOG_AGENT_VERBOSE(@"Successfully set userId to nil");
return YES;

}else {
NRLOG_AGENT_ERROR(@"Session attribute \'value\' must be either an NSString* or NSNumber*");
}
return NO;
}
} catch (std::exception& error) {
Expand Down
4 changes: 4 additions & 0 deletions Agent/Analytics/NRMASAM.mm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ - (BOOL) checkAttribute:(NSString*)name value:(id)value {
BOOL validAttribute = [attributeValidator nameValidator:name];
BOOL validValue = [attributeValidator valueValidator:value];

if (name == kNRMA_Attrib_userId && !value ) {
NRLOG_AGENT_VERBOSE(@"Successfully set userId to nil");
return YES;
}
if (!(validAttribute && validValue)) {
NRLOG_AGENT_VERBOSE(@"Failed to create attribute named %@", name);
return NO;
Expand Down

0 comments on commit 68166ad

Please sign in to comment.