BackendError is a type that represents an error that is returned from the backend in response to an action.
type BackendError = InvalidEmailError | UnknownError;InvalidEmailError happens particularly when the user tries to identify themselves with an invalid email address. Also, when you call _dixa_.invoke("setUserIdentity", {...payload}) with an invalid email address.
type InvalidEmailError = {
type: 'invalid-email-address';
email: string;
};You can add an event listener to listen to this error before setting the user identity.
// First add the listener
_dixa_.addListener('on-backend-error', (error) => {
if (error.type === 'invalid-email-address') {
console.error(`${error.email} is not a valid email address`);
}
});
// Then call the method
_dixa_.invoke('setUserIdentity', {
type: 'claim',
name: 'John Doe',
email: 'invalid-email',
});type UnknownError = {
type: 'unknown-error';
};UnknownError happens when the backend returns an error that is not known to the widget.