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:

firstName
string

The user's first name. For example, "John".

The value must be between 1 and 50 characters long.

lastName
string

The user's last name. For example, "Doe".

The value must be between 1 and 50 characters long.

birthDate
string

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.

gender
string

The gender of the user.

These are the possible values and what they represent:

ValueDescription
maleMale gender.
femaleFemale gender.
neutralNeither male nor female gender.
unknownAn unspecified gender.
email
string

The user's email address.

The value must be between 1 and 254 characters long.

alternateEmail
string

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.

phone
string

The user's phone number.

The value must be between 1 and 30 characters long.

alternatePhone
string

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.

address
object

The user's address.

street
string

The address' street.

The value must be between 1 and 100 characters long.

district
string

The address' district.

The value must be between 1 and 100 characters long.

city
string

The address' city.

The value must be between 1 and 100 characters long.

region
string

The address' region.

The value must be between 1 and 100 characters long.

country
string

The address' country.

The value must be between 1 and 100 characters long.

postalCode
string

The address' postal code.

The value must be between 1 and 20 characters long.

avatar
string

The URL of the user's avatar image.

company
string

The company the user works for.

The value must be between 1 and 200 characters long.

companyUrl
string

The URL of the company the user works for.

jobTitle
string

The job title of the user.

The value must be between 1 and 50 characters long.

interests
array<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.

activities
array<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.

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.