Journeys
Journeys jsou vizuální grafy, které spustí, když nastane událost (nebo hráč vstoupí do segmentu). Drag-and-drop graph editor (React Flow) se sedmi typy uzlů.
Typy uzlů
| Type | Chování |
|---|---|
| trigger | Vstup — referencuje event name (nebo segment_entry). Auto-vytvořeno z trigger configu. |
| wait | Drží duration (duration_ms) NEBO dokud nezahoří událost (until_event s timeoutem). |
| send_message | Vyrenderuje template + provider, zařadí message_send. |
| condition | Větví na trait hráče. Operátory: =, !=, >, >=, <, <=, exists. Dvě outgoing edges (if_true_next, if_false_next). |
| grant_bonus | Vystaví bonus template. Volitelný deposit_amount_source pro deposit_match typy. |
| call_webhook | HTTP POST na externí URL s Mustache-renderovaným body + volitelný HMAC signature. Větví na success / failure. |
| end | Terminální — journey run dokončí. |
Triggery
Tři druhy triggerů:
- Event trigger —
trigger.event = "deposit_confirmed". Journey spustí pro každou událost odpovídající jménu v projektu. Volitelný property filter (trigger.where). - Segment entry —
trigger.segment_id = "..."+trigger.kind = "segment_entry". Spustí, když hráč získá členství v segmentu. - Manual / API —
POST /v1/journeys/:id/trigger { player_id }pro testing nebo programatické kickoff.
Graph constraints
- Max 50 uzlů per journey
- Každý uzel musí mít unikátní
id start_node_idmusí referencovat existující uzel- Cykly se detekují at save time (depth limit = 50)
Wait nodes
Dva čekací módy:
{
"id": "wait_24h",
"type": "wait",
"duration_ms": 86400000, // čekej fixed duration (24h)
"next": "send_welcome"
}
{
"id": "wait_for_deposit",
"type": "wait",
"until_event": {
"event": "deposit_confirmed",
"timeout_ms": 604800000 // 7 dní
},
"next": "send_thanks"
}
until_event je journey's event-listening primitive — čekej až N ms na hráče, aby udělal event_name; pokud nejdřív zahoří timeout, follow next stejně.
Webhook nodes (Sprint 18)
{
"id": "anti_fraud_check",
"type": "call_webhook",
"url": "https://anti-fraud.example.com/check",
"method": "POST",
"body_template": "{\"player_id\":\"{{player.id}}\",\"run\":\"{{journey.run_id}}\"}",
"hmac_secret_env": "ANTI_FRAUD_HMAC_SECRET",
"timeout_ms": 3000,
"next_node_id": "grant_bonus_after_check",
"on_failure_next_node_id": "skip_bonus"
}
Webhook firer:
- Vyrenderuje Mustache body proti
{ player, journey }kontextu - Podepíše HMAC-SHA256 nad
<timestamp>.<body>(matchuje naše inbound webhook scheme — stejný secret použitelný na obou nohách) - Bounded timeout (≤10s)
- 2xx →
next_node_id; non-2xx / timeout / network error →on_failure_next_node_id(nebo fail journey, pokud nenastaveno) https://only — odmítá plain HTTP, aby neuniklo journey kontextu
Běžné patterny
- Welcome series: trigger
signup→ wait 24h → send_message email → wait 7d (nebo untildeposit_confirmed) → grant_bonus. - Win-back: segment_entry "7d inactive" → send_message push → wait 3d → condition (deposit since?) → if not, send_message email s bonus linkem.
- VIP onboarding: trigger
tier_promoted to platinum→ call_webhook (notify VIP host system) → send_message congrats email. - Risk gate: trigger
deposit_initiated→ call_webhook (anti-fraud) → on_failure: condition (held by anti-fraud?) → grant_bonus only pokud cleared.