Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.4 KB
Raw Blame
from typing import Optional

from products.approvals.backend.actions.base import BaseAction

ACTION_REGISTRY: dict[str, type[BaseAction]] = {}


def register_actions():
    from products.approvals.backend.actions.experiment_holdouts import (
        DeleteExperimentHoldoutAction,
        UpdateExperimentHoldoutAction,
    )
    from products.approvals.backend.actions.experiments import (
        LaunchExperimentAction,
        PauseExperimentAction,
        UpdateExperimentAction,
    )
    from products.approvals.backend.actions.feature_flags import (
        DisableFeatureFlagAction,
        EnableFeatureFlagAction,
        UpdateFeatureFlagAction,
    )

    ACTION_REGISTRY[EnableFeatureFlagAction.key] = EnableFeatureFlagAction
    ACTION_REGISTRY[DisableFeatureFlagAction.key] = DisableFeatureFlagAction
    ACTION_REGISTRY[UpdateFeatureFlagAction.key] = UpdateFeatureFlagAction
    ACTION_REGISTRY[LaunchExperimentAction.key] = LaunchExperimentAction
    ACTION_REGISTRY[PauseExperimentAction.key] = PauseExperimentAction
    ACTION_REGISTRY[UpdateExperimentAction.key] = UpdateExperimentAction
    ACTION_REGISTRY[UpdateExperimentHoldoutAction.key] = UpdateExperimentHoldoutAction
    ACTION_REGISTRY[DeleteExperimentHoldoutAction.key] = DeleteExperimentHoldoutAction


def get_action(action_key: str) -> Optional[type[BaseAction]]:
    if not ACTION_REGISTRY:
        register_actions()
    return ACTION_REGISTRY.get(action_key)