@@ -608,11 +608,7 @@ public Builder privateEmail(String email) {
608608 * @return the builder
609609 */
610610 public Builder custom (String k , String v ) {
611- checkCustomAttribute (k );
612- if (k != null && v != null ) {
613- custom .put (k , new JsonPrimitive (v ));
614- }
615- return this ;
611+ return custom (k , v == null ? null : new JsonPrimitive (v ));
616612 }
617613
618614 /**
@@ -625,11 +621,7 @@ public Builder custom(String k, String v) {
625621 * @return the builder
626622 */
627623 public Builder custom (String k , Number n ) {
628- checkCustomAttribute (k );
629- if (k != null && n != null ) {
630- custom .put (k , new JsonPrimitive (n ));
631- }
632- return this ;
624+ return custom (k , n == null ? null : new JsonPrimitive (n ));
633625 }
634626
635627 /**
@@ -642,9 +634,22 @@ public Builder custom(String k, Number n) {
642634 * @return the builder
643635 */
644636 public Builder custom (String k , Boolean b ) {
637+ return custom (k , b == null ? null : new JsonPrimitive (b ));
638+ }
639+
640+ /**
641+ * Add a custom attribute whose value can be any JSON type. When set to one of the
642+ * <a href="http://docs.launchdarkly.com/docs/targeting-users#targeting-based-on-user-attributes">built-in
643+ * user attribute keys</a>, this custom attribute will be ignored.
644+ *
645+ * @param k the key for the custom attribute
646+ * @param v the value for the custom attribute
647+ * @return the builder
648+ */
649+ public Builder custom (String k , JsonElement v ) {
645650 checkCustomAttribute (k );
646- if (k != null && b != null ) {
647- custom .put (k , new JsonPrimitive ( b ) );
651+ if (k != null && v != null ) {
652+ custom .put (k , v );
648653 }
649654 return this ;
650655 }
@@ -757,6 +762,21 @@ public Builder privateCustom(String k, Boolean b) {
757762 return custom (k , b );
758763 }
759764
765+ /**
766+ * Add a custom attribute of any JSON type, that will not be sent back to LaunchDarkly.
767+ * When set to one of the
768+ * <a href="http://docs.launchdarkly.com/docs/targeting-users#targeting-based-on-user-attributes">built-in
769+ * user attribute keys</a>, this custom attribute will be ignored.
770+ *
771+ * @param k the key for the custom attribute
772+ * @param v the value for the custom attribute
773+ * @return the builder
774+ */
775+ public Builder privateCustom (String k , JsonElement v ) {
776+ privateAttrNames .add (k );
777+ return custom (k , v );
778+ }
779+
760780 /**
761781 * Add a list of {@link java.lang.String}-valued custom attributes. When set to one of the
762782 * <a href="http://docs.launchdarkly.com/docs/targeting-users#targeting-based-on-user-attributes">
0 commit comments