DispelEvilBot/common/analytics/events.py

63 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Каталог событий аналитики.
Единственный источник правды по типам событий. Список синхронизирован
с документацией (``docs/events.md``) — рассинхрон ловит ``tests/test_analytics.py``.
Правило: добавляешь новое событие — добавь его в ``EventType`` и в ``docs/events.md``.
"""
from __future__ import annotations
from enum import StrEnum
class EventType(StrEnum):
"""Типы событий (значение = колонка ``event_type`` в Postgres)."""
# --- Сообщения и команды ---
COMMAND = "command"
# --- Экономика ---
PURIFICATION = "purification"
EXP_ACCRUAL = "exp_accrual"
LEVEL_UP = "level_up"
MONEY_ACCRUAL = "money_accrual"
MONEY_SPEND = "money_spend"
EGGS = "eggs"
PURCHASE_TITLE = "purchase_title"
PURCHASE_DONAT = "purchase_donat"
# --- Участники ---
JOIN = "join"
LEAVE = "leave"
NICK_SET = "nick_set"
# --- Подписки и доступ ---
SUBSCRIBE = "subscribe"
UNSUBSCRIBE = "unsubscribe"
ACCESS_DENIED = "access_denied"
# --- Жизненный цикл бота и ошибки ---
BOT_START = "bot_start"
BOT_STOP = "bot_stop"
BOT_ALIVE = "bot_alive"
ERROR = "error"
#: Полный список типов событий (для проверки синхронности с документацией).
ALL_EVENT_TYPES: frozenset[str] = frozenset(member.value for member in EventType)
#: Колонки таблицы ``analytics.events`` в порядке вставки.
EVENT_COLUMNS: tuple[str, ...] = (
"event_time",
"event_type",
"user_id",
"username",
"chat_id",
"payload",
"bot_version",
"prod",
)
__all__ = ["ALL_EVENT_TYPES", "EVENT_COLUMNS", "EventType"]