I'm working with an API that interacts with CustomerIo. My code is structured to send user attributes to CustomerIo and, upon receiving a successful response, it makes an additional call to CustomerIo with an 'attributes_updated' event. The code looks like this:
result = CustomerIoApiGateway.send_user(user_attributes, {'id' => @user.id})
if result.success?
result = CustomerIoApiGateway.send_event(@user, 'attributes_updated', user_attributes)
end
On the CustomerIo side, I have a campaign triggered by the attributes_updated event. This campaign calculates new attribute values such as crm_usage_setup based on the attributes I've sent (such as team_clients_count )
However, I'm facing an issue with the order of execution on CustomerIo’s side. Sometimes, the sequence of operations is not as expected, leading to scenarios where CustomerIo:
- Registers the 'attributes_updated' event.
- Executes the campaign, updating the
crm_usage_setup
value based on old `team_clients_count` attribute value. - Updates the attributes (team_clients_count) to the new ones.
This issue leads to incorrect calculations for the crm_usage_setup
because the Campaign is beign triggered by attributes_updated event and executed, before Customer.io updates team_client_count attribute itself (which i have sent to CIO, before attributes_updated event )
I would greatly appreciate any suggestions or ideas on how to resolve this issue to ensure the correct order of execution. Thank you in advance!