edit
Update the user's profile.
This method creates a patch to apply changes to the user's profile.
Signature
This method has the following signature:
user.edit(): Patch
The return is a Patch for specifying the sequence of operations to apply to the user's profile. Calling save on the patch returns a promise that resolves to the userProfileChanged event after successful transmission.
Example
Here is a basic example of how to use this method:
import croct from '@croct/plug';const patch = croct.user.edit();const promise = patch.set('company', 'Croct').add('interests', 'JavaScript').add('custom.pets', 'crocodile').save();promise.then(() => console.log('Profile updated successfully'));
Attributes
These are the currently supported attributes:
- firstNamestring
The user's first name. For example, "John".
The value must be between 1 and 50 characters long.
- lastNamestring
The user's last name. For example, "Doe".
The value must be between 1 and 50 characters long.
- birthDatestring
The user's birth date. For example, "1990-01-01".
The value must be a valid ISO 8601 date in the form YYYY-MM-DD.
- genderstring
The gender of the user.
These are the possible values and what they represent:
Value Description male Male gender. female Female gender. neutral Neither male nor female gender. unknown An unspecified gender. - emailstring
The user's email address.
The value must be between 1 and 254 characters long.
- alternateEmailstring
The user's alternate email address, such as a work email address or secondary email address.
The value must be between 1 and 254 characters long.
- phonestring
The user's phone number.
The value must be between 1 and 30 characters long.
- alternatePhonestring
The user's alternate phone number, such as a work phone number or a secondary phone number.
The value must be between 1 and 30 characters long.
- addressobject
The user's address.
- streetstring
The address' street.
The value must be between 1 and 100 characters long.
- districtstring
The address' district.
The value must be between 1 and 100 characters long.
- citystring
The address' city.
The value must be between 1 and 100 characters long.
- regionstring
The address' region.
The value must be between 1 and 100 characters long.
- countrystring
The address' country.
The value must be between 1 and 100 characters long.
- postalCodestring
The address' postal code.
The value must be between 1 and 20 characters long.
- street
- avatarstring
The URL of the user's avatar image.
- companystring
The company the user works for.
The value must be between 1 and 200 characters long.
- companyUrlstring
The URL of the company the user works for.
- jobTitlestring
The job title of the user.
The value must be between 1 and 50 characters long.
- interestsarray<string>
The user's demonstrated interests, such as "ab testing", "analytics", "data science", etc.
The value must be a list of up to 30 strings, each between 1 and 30 characters long.
- activitiesarray<string>
The user's performed activities, like "sign up", "purchase", "upgrade", etc.
The value must be a list of up to 30 strings, each between 1 and 30 characters long.
- custom.*object
A custom attribute, where * is the name of the attribute, such as custom.pets or custom.loyaltyNumber.
Best practiceUse descriptive camel case names like pets, favoriteColor, and loyaltyNumber for custom attributes to improve readability and consistency with standard attributes.
The following restrictions apply to custom attributes:
- Profiles support up to 10 custom attributes
- Attribute names must be strings up to 20 characters, starting with a letter or underscore, followed by letters, digits, or underscores
- Attributes can be primitives (strings, numbers, booleans, null) or collections (lists, maps)
- Strings can be up to 100 characters long
- Lists can contain up to 30 elements, including primitives, lists of primitives, or maps of primitives
- Maps can contain up to 30 elements, including primitives, lists of primitives, or maps of primitives
- Map keys must be strings up to 50 characters long
Note that attribute names are case-insensitive, meaning that loyaltyNumber and loyaltynumber are treated as the same attribute and will override each other.