: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
from posthog.models import Team, User
from posthog.ph_client import feature_enabled_or_false
from products.business_knowledge.backend.logic import has_feature_flag as bk_has_feature_flag
def is_privacy_mode_enabled(team: Team) -> bool:
"""
Check if privacy mode is enabled for a team's organization.
"""
return feature_enabled_or_false(
"phai-privacy-mode",
str(team.organization_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_phai_tasks_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"phai-tasks",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_task_tool_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"phai-task-tool",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_conversation_topic_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"posthog-ai-web-analytics-nudge",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_memory_tool_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"phai-memory-tool",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_plan_mode_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"phai-plan-mode",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_experiment_summary_tool_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"experiment-ai-summary",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def is_core_memory_disabled(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"phai-core-mem-disabled",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_mcp_gateway_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"mcp-gateway",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_sandbox_mode_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"phai-sandbox-mode",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_conversation_task_mirror_feature_flag(team: Team, user: User) -> bool:
"""Whether LangGraph conversations are mirrored into the task world after each turn."""
return feature_enabled_or_false(
"phai-conversation-task-mirror",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_replay_negative_event_filters_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"replay-negative-event-filters",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_customer_analytics_mode_feature_flag(team: Team, user: User) -> bool:
return feature_enabled_or_false(
"customer-analytics-csp",
str(user.distinct_id),
groups={"organization": str(team.organization_id)},
group_properties={"organization": {"id": str(team.organization_id)}},
send_feature_flag_events=False,
)
def has_business_knowledge_feature_flag(team: Team) -> bool:
# Canonical check lives in the owning product; kept as a delegate so existing
# ee call sites and test patches don't move.
return bk_has_feature_flag(team)