Crisp uses a separate subresource for contact's custom properties (they call it “custom data”). This brings several challenges when mutating the data in a single use case.
Create use case
first creates the general contact
if that fails (usually the contact already exists), all is good, nothing in Crisp was changed, can be retried
then updates the contact's custom data subresource
that fails, we have inconsistent data in Crisp. The new contact was created, but custom data was not set
I chose to fail the whole Create use case when custom data patch fails with a custom error describing the issue. No one will actually read the map and implement the special case, but:
they probably will retry the failed Create
since the contact will exist, it will return 404 (Already exists)
that should be switched to Update (generally)
Alternatively, we could simply not support this use case (like Mixpanel integration) and quietly create the non-existent resource in Update.
Update use case
first updates the general contact
if that fails (404 or smth), all is good, nothing was changed, can be retried
then updates the contact's custom data subresource
that fails, we have inconsistent data in Crisp. The contact was updated, but custom data was not set
This is much easier since Update is much more idempotent-ish. We simply fail the whole use case call and it can be safely retried, yielding the desired end result.
Motivation and Context
Types of changes
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Description
Adding Crisp chat integration to crm/contacts.
Few concerns
Crisp uses a separate subresource for contact's custom properties (they call it “custom data”). This brings several challenges when mutating the data in a single use case.
Create
use caseI chose to fail the whole
Create
use case when custom data patch fails with a custom error describing the issue. No one will actually read the map and implement the special case, but:Create
Update
(generally)Alternatively, we could simply not support this use case (like Mixpanel integration) and quietly create the non-existent resource in
Update
.Update
use caseThis is much easier since
Update
is much more idempotent-ish. We simply fail the whole use case call and it can be safely retried, yielding the desired end result.Motivation and Context
Types of changes
Checklist: