You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can provide an id with your events, to deduplicate events—if there’s a possibility that your integration might send duplicate events. The id must be a ULID. If two events contain the same id, we won’t process the event multiple times.
Deduplicating events helps you accurately represent people’s activity; can prevent people from accidentally entering or leaving campaigns based on the number of times that a person performed an event; and prevents duplicate events from impacting your workspace’s performance.
As you can see, the expected JSON has a top-level id attribute. However, the existing code doesn't allow for this. Apart from a handful exceptions, it nests all attributes into a data object.
This means users of the gem currently don't have a way to provide an id to prevent duplicate events.
Proposed fix
Add an (optional) id parameter to create_event and all methods that reference it. Pass it as a top-level key to the API.
This will be a backwards-compatible change, as current implementations won't currently provide an id directly into the create_event calls. Notably, any id that might be included in the attributes hash continue to work as before.
def track(customer_id, event_name, attributes = {}) needs to be updated too. This is a bit trickier, because it uses positional arguments. I think adding a fourth, optional argument does the trick: def track(customer_id, event_name, attributes = {}, id = nil)
Optionally, the following code can be used to validate the correctness of the id:
From the documentation
From https://customer.io/docs/journeys/events/#deduplicating-events
Relevant code
customerio-ruby/lib/customerio/client.rb
Lines 160 to 166 in f9984a7
customerio-ruby/lib/customerio/client.rb
Lines 186 to 193 in f9984a7
customerio-ruby/lib/customerio/client.rb
Lines 47 to 52 in f9984a7
Problem
As you can see, the expected JSON has a top-level
id
attribute. However, the existing code doesn't allow for this. Apart from a handful exceptions, it nests all attributes into adata
object.This means users of the gem currently don't have a way to provide an id to prevent duplicate events.
Proposed fix
Add an (optional)
id
parameter tocreate_event
and all methods that reference it. Pass it as a top-level key to the API.This will be a backwards-compatible change, as current implementations won't currently provide an
id
directly into thecreate_event
calls. Notably, anyid
that might be included in theattributes
hash continue to work as before.def track(customer_id, event_name, attributes = {})
needs to be updated too. This is a bit trickier, because it uses positional arguments. I think adding a fourth, optional argument does the trick:def track(customer_id, event_name, attributes = {}, id = nil)
Optionally, the following code can be used to validate the correctness of the id:
The text was updated successfully, but these errors were encountered: