Skip to content

Commit

Permalink
fix: remove private attributes from user object when bootstrap client…
Browse files Browse the repository at this point in the history
… sdk (#156)

as titled
  • Loading branch information
weihao-statsig authored Aug 6, 2024
1 parent fa9f0c5 commit 3a2936d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dotnet-statsig/src/Statsig/Server/Evaluation/Evaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ internal EvaluationDetails GetEvaluationDetails(string? reason = null)
layerConfigs.Add(hashedName, entry);
}

var userWithoutPrivateAttributes = user.ToMapForLogging();

var result = new Dictionary<string, Object>
{
["feature_gates"] = gates,
Expand All @@ -314,7 +316,7 @@ internal EvaluationDetails GetEvaluationDetails(string? reason = null)
["sdkType"] = _sdkDetails.SDKType,
["sdkVersion"] = _sdkDetails.SDKVersion,
},
["user"] = user,
["user"] = userWithoutPrivateAttributes,
};
return result;
}
Expand Down
18 changes: 18 additions & 0 deletions dotnet-statsig/src/Statsig/StatsigUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,24 @@ internal StatsigUser GetCopyForLogging()
return copy;
}

internal Dictionary<string, object> ToMapForLogging()
{
return new Dictionary<string, object>
{
{ "userID", UserID ?? string.Empty },
{ "userAgent", UserAgent ?? string.Empty },
{ "appVersion", AppVersion ?? string.Empty },
{ "country", Country ?? string.Empty},
{ "custom", CustomProperties ?? new Dictionary<string, object>() },
{ "customIDs", CustomIDs },
{ "email", Email ?? string.Empty },
{ "ip", IPAddress ?? string.Empty },
{ "locale", Locale ?? string.Empty },
{ "statsigEnvironment", StatsigEnvironment },
// Do NOT add private attributes here
};
}

internal Dictionary<string, string> GetParsedUserAgent()
{
if (_parsedUserAgent == null)
Expand Down

0 comments on commit 3a2936d

Please sign in to comment.