Count your events for your rules
Beta. The request and response shapes may still change.
Define a counter over the events you send with Dispatch events. Each event that matches the filter is counted, over a sliding window, into the counter of its key value. A rule reads the counter of the evaluated identifier as aggregate.custom.<name>.
The name must be unique among your aggregates: a name already in use answers 409 with aggregate_already_exists. You can have at most 20 aggregates: one more answers 409 with aggregate_limit_reached. Only the description can change after creation.
aggregate.custom.<name>.
This aggregate counts the confirmed fraud reports for each phone number over the last 14 days:
aggregate.custom.fraud_reports > 3 then triggers for a phone number with more than 3 such events in the last 14 days.
What you can count
COUNT_DISTINCT counter keeps at most 10,000 values. Past this, the values seen least recently are dropped, so the count stops at 10,000.
Limits
You can have at most 20 aggregates. One more answers409 with aggregate_limit_reached: delete one first.
Your aggregates also share a limit on how many counters they hold: see Limits.
Only the description can change after creation. Choose the key, the window and the filter with care: to change them, you create a new aggregate, which starts from zero.
A new aggregate does not count past events: it counts the events you send after it is created. Until a full window has passed since it counted its first event, a rule reading it reports NOT_EVALUATED. For a 14d window, this is 14 days after the first counted event. An aggregate that has not counted an event yet, for example because no event matched its filter, stays NOT_EVALUATED. See Aggregates.Authorizations
Body
What the aggregate counts for each value of key.
COUNT- The number of matching events.COUNT_DISTINCT- The number of different values ofdistinctin the matching events. A counter keeps at most 10,000 values: past this, the values seen least recently are dropped, so the count stops at 10,000.
COUNT, COUNT_DISTINCT "COUNT"
The event values that select a counter: there is one counter for each combination of their values. At least one, and each one only once.
target.phone_number- The phone number of the event target.target.email_address- The email address of the event target.target.phone_prefix_7andtarget.phone_prefix_9- The first 6 or 8 digits of the phone number of the event target: its first 7 or 9 characters, without the leading+. For+33612345678, they are336123and33612345.
An event has one target, so key and distinct together read either the email address or the phone number fields, not both. An event that has no value for one of them is not counted.
target.phone_number, target.email_address, target.phone_prefix_7, target.phone_prefix_9 The event value a COUNT_DISTINCT aggregate counts the different values of. Required for COUNT_DISTINCT, refused for COUNT. It takes the same values as key.
target.phone_number, target.email_address, target.phone_prefix_7, target.phone_prefix_9 "target.phone_number"
Response
Created