public void CanHideAllAttributesExceptKeyForNonAnonUser() { EventUser eu = EventUser.FromUser(_baseUser, _configWithAllAttrsPrivate); Assert.Equal(_baseUser.Key, eu.Key); Assert.Null(eu.Secondary); Assert.Null(eu.FirstName); Assert.Null(eu.LastName); Assert.Null(eu.Name); Assert.Null(eu.Avatar); Assert.Null(eu.IPAddress); Assert.Null(eu.Email); Assert.Null(eu.Anonymous); Assert.Null(eu.Custom); Assert.Equal(ImmutableSortedSet.Create <string>("secondary", "ip", "country", "firstName", "lastName", "name", "avatar", "email", "bizzle", "dizzle"), eu.PrivateAttrs); }
public void CanHideSomeAttributesPerUser() { EventUser eu = EventUser.FromUser(_userSpecifyingOwnPrivateAttrs, _baseConfig); Assert.Equal(_baseUser.Key, eu.Key); Assert.Equal(_baseUser.Secondary, eu.Secondary); Assert.Null(eu.FirstName); Assert.Equal(_baseUser.LastName, eu.LastName); Assert.Equal(_baseUser.Name, eu.Name); Assert.Equal(_baseUser.Avatar, eu.Avatar); Assert.Equal(_baseUser.IPAddress, eu.IPAddress); Assert.Equal(_baseUser.Email, eu.Email); Assert.Null(eu.Anonymous); Assert.Equal(new Dictionary <string, LdValue> { { "dizzle", LdValue.Of("ghi") } }, eu.Custom); Assert.Equal(ImmutableSortedSet.Create <string>("firstName", "bizzle"), eu.PrivateAttrs); }
private void WriteUser(User user) { if (user is null) { return; } var eu = EventUser.FromUser(user, _config); var userObj = _obj.Name("user").Object(); userObj.Name("key").String(eu.Key); userObj.MaybeName("secondary", eu.Secondary != null).String(eu.Secondary); userObj.MaybeName("ip", eu.IPAddress != null).String(eu.IPAddress); userObj.MaybeName("country", eu.Country != null).String(eu.Country); userObj.MaybeName("firstName", eu.FirstName != null).String(eu.FirstName); userObj.MaybeName("lastName", eu.LastName != null).String(eu.LastName); userObj.MaybeName("name", eu.Name != null).String(eu.Name); userObj.MaybeName("avatar", eu.Avatar != null).String(eu.Avatar); userObj.MaybeName("email", eu.Email != null).String(eu.Email); if (eu.Anonymous.HasValue) { userObj.Name("anonymous").Bool(eu.Anonymous.Value); } if (eu.Custom != null && eu.Custom.Count > 0) { var customObj = userObj.Name("custom").Object(); foreach (var kv in eu.Custom) { LdValueConverter.WriteJsonValue(kv.Value, customObj.Name(kv.Key)); } customObj.End(); } if (eu.PrivateAttrs != null) { var arr = userObj.Name("privateAttrs").Array(); foreach (var a in eu.PrivateAttrs) { arr.String(a); } arr.End(); } userObj.End(); }
public void CustomAttributesDictionaryIsReusedIfNoneArePrivate() { EventUser eu = EventUser.FromUser(_baseUser, _baseConfig); Assert.Same(_baseUser.Custom, eu.Custom); }