Map<String, dynamic> toJson() { final userId = this.userId; final properties = this.properties; return { 'userId': userId, if (properties != null) 'properties': jsonEncode(properties), }; }