Перейти до основного вмісту

Journeys

Translator note: machine-translated baseline. Needs human review by a native UK speaker. EN source is canonical.

Journeys — це візуальні графи, які спрацьовують, коли стається подія (або гравець входить у сегмент). Drag-and-drop graph editor (React Flow) із сімома типами вузлів.

Типи вузлів

TypeПоведінка
triggerEntry — посилається на event name (або segment_entry). Auto-створено з trigger config.
waitТримає duration (duration_ms) АБО доки не спрацює подія (until_event з timeout).
send_messageRender template + provider, enqueue a message_send.
conditionГілка на trait гравця. Операторы: =, !=, >, >=, <, <=, exists. Два outgoing edges (if_true_next, if_false_next).
grant_bonusВидає bonus template. Опційний deposit_amount_source для deposit_match типів.
call_webhookHTTP POST до зовнішнього URL із Mustache-rendered body + опційний HMAC signature. Гілки на success / failure.
endTerminal — journey run завершується.

Triggers

Три kinds triggers:

  • Event triggertrigger.event = "deposit_confirmed". Journey спрацьовує на кожну подію, що збігається з name у проекті. Опційний property filter (trigger.where).
  • Segment entrytrigger.segment_id = "..." + trigger.kind = "segment_entry". Спрацьовує, коли гравець отримує membership у сегменті.
  • Manual / APIPOST /v1/journeys/:id/trigger { player_id } для testing або programmatic kickoff.

Graph constraints

  • Max 50 nodes per journey
  • Кожен node повинен мати унікальний id
  • start_node_id повинен посилатися на існуючий node
  • Cycles виявляються at save time (depth limit = 50)

Wait nodes

Два waiting modes:

{
"id": "wait_24h",
"type": "wait",
"duration_ms": 86400000, // чекай fixed duration (24h)
"next": "send_welcome"
}
{
"id": "wait_for_deposit",
"type": "wait",
"until_event": {
"event": "deposit_confirmed",
"timeout_ms": 604800000 // 7 днів
},
"next": "send_thanks"
}

until_event — journey's event-listening primitive — чекай до N ms на гравця, щоб зробив event_name; якщо timeout спрацює першим, follow next все одно.

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:

  • Render Mustache body проти { player, journey } context
  • Підписує HMAC-SHA256 над <timestamp>.<body> (відповідає нашій inbound webhook scheme — той самий secret usable on both legs)
  • Bounded timeout (≤10s)
  • 2xx → next_node_id; non-2xx / timeout / network error → on_failure_next_node_id (або fail journey, якщо не set)
  • https:// only — відмовляє plain HTTP, щоб уникнути leaking journey context

Common patterns

  • Welcome series: trigger signup → wait 24h → send_message email → wait 7d (або until deposit_confirmed) → grant_bonus.
  • Win-back: segment_entry "7d inactive" → send_message push → wait 3d → condition (deposit since?) → if not, send_message email with bonus link.
  • 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 if cleared.