How score streaks work
A score streak campaign tracks three layered ideas: time windows (periods), consecutive activity (streaks), and cumulative score (milestones).Periods and loss conditions
Every time a customer earns a score point, the campaign opens a period window — a countdown timer during which the customer must send the next qualifying event to keep the streak alive. If the timer runs out before the next event, the cycle is lost: the streak resets to zero and a new cycle begins. The loss window is defined byloss.conditions[0]:
MINUTES, HOURS, DAYS, WEEKS, MONTHS.
Cycles
A cycle is one continuous run of activity without a loss. Each loss or reset starts a fresh cycle identified by a newcurrent_cycle_id. This means multiple cycles can exist in a single streak record over its lifetime, and the history events are stamped with the cycle they belong to.
Milestones
Rules in a score streak campaign define score thresholds that trigger rewards. When a customer’scurrent_score reaches or exceeds a milestone, that milestone’s effects (rewards) are granted once per milestone per cycle.
Scheduled resets
Optionally, a campaign can define a reset calendar that forcefully closes the active cycle on a schedule — daily, weekly, or monthly. This is independent of the loss condition: a customer with a perfect streak will still be reset on the configured date.Score streak lifecycle
History events stored in the
events JSON column:
Campaign configuration
Milestone rules
Each rule in a score streak campaign must have amilestone score value. When the customer’s score reaches that value within a cycle, the rule’s effects are applied. Multiple rules can define different reward tiers:
- Conditions in milestone rules are ignored; only
milestoneandeffectsmatter. - When the score reaches milestone 10, only that rule fires — the lower milestones (1, 5) do not fire again for the same score.
- If a score crosses a milestone for the first time in a cycle, the reward is granted. If the same milestone is crossed again later in the same cycle (e.g. after a reversal), the reward is granted again.
Event reversal behavior
When a source event is reversed:- All
GAINandMILESTONEhistory events from that source are markedreversed_at. - An
EVENT_REVERSALhistory event is appended with the negative score delta. - If the reversed event was in the active cycle,
current_score,current_streak,period_score, andperiod_event_countare decremented. - The
highest_milestone_scoreis recalculated from surviving milestone events. - If the score drops below a previously reached milestone, re-triggering the qualifying event will grant the milestone reward again.
Manual admin reset
Support operators can force-reset a customer’s active streak cycle without waiting for the loss cron or a scheduled reset. This appends aMANUAL_RESET history event, starts a new current_cycle_id, and zeros score counters for the active cycle.
Endpoint (internal): POST /api/admin/score-streaks/reset
Requires the
checksum header with the CRON_AUTH_SECRET value. This endpoint is not part of the public Storefront API.