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.

2.4 KB
Raw Blame
from enum import Enum
from typing import Union

from posthog.scopes import APIScopeObject


class NotificationType(str, Enum):
    COMMENT_MENTION = "comment_mention"
    ALERT_FIRING = "alert_firing"
    ISSUE_ASSIGNED = "issue_assigned"
    APPROVAL_REQUESTED = "approval_requested"
    APPROVAL_RESOLVED = "approval_resolved"
    EXPERIMENT_CONCLUDED = "experiment_concluded"
    PIPELINE_FAILURE = "pipeline_failure"
    PROJECT_CREATED = "project_created"
    USAGE_SPIKE = "usage_spike"
    REMINDER = "reminder"
    WEB_ANALYTICS_DIGEST = "web_analytics_digest"
    ACHIEVEMENT_UNLOCKED = "achievement_unlocked"
    SUBSCRIPTION_NUDGE = "subscription_nudge"
    EMAIL_REPUTATION = "email_reputation"
    MATERIALIZATION_FAILURE = "materialization_failure"
    NOTIFICATION_SETTINGS_CHANGED = "notification_settings_changed"
    DATA_QUALITY_CHECK_FAILURE = "data_quality_check_failure"
    WORKFLOW_SUGGESTION = "workflow_suggestion"
    WAREHOUSE_SUGGESTION_ASSIGNED = "warehouse_suggestion_assigned"
    FEATURE_FLAG_FAILURE = "feature_flag_failure"
    FIRST_REPORT_COMPLETED = "first_report_completed"
    REPORT_CLAIM_TAKEN_OVER = "report_claim_taken_over"


class Priority(str, Enum):
    NORMAL = "normal"
    CRITICAL = "critical"


# Discriminator for transient "resource edited elsewhere" realtime events. These ride the
# notifications SSE transport but are NOT inbox notifications (no NotificationEvent row, no unread
# count) — see products.notifications.backend.logic.publish_resource_edited.
RESOURCE_EDITED_EVENT_TYPE = "resource_edited"


class TargetType(str, Enum):
    USER = "user"
    TEAM = "team"
    ORGANIZATION = "organization"
    ROLE = "role"


class SourceType(str, Enum):
    REPLAY = "replay"
    NOTEBOOK = "notebook"
    INSIGHT = "insight"
    FEATURE_FLAG = "feature_flag"
    DASHBOARD = "dashboard"
    SURVEY = "survey"
    EXPERIMENT = "experiment"
    ERROR_TRACKING = "error_tracking"
    CUSTOMER_ANALYTICS = "customer_analytics"
    TICKET = "ticket"
    REPLAY_OBSERVATION = "replay_observation"


class NotificationOnlyResourceType(str, Enum):
    """Resource types that only exist in the notification system (no AC counterpart)."""

    PIPELINE = "pipeline"
    APPROVAL = "approval"
    COMMENT = "comment"


# Derived from APIScopeObject (used by ACCESS_CONTROL_RESOURCES) — keep in sync
# if ACCESS_CONTROL_RESOURCES changes its element type
type NotificationResourceType = Union[APIScopeObject, NotificationOnlyResourceType]