Module livekit.plugins.posthog.models

Data contracts, event models, and configuration types for livekit-plugins-posthog.

Classes

class ErrorWaterfallStep (error_type: str, count: int, percentage: float, status_code: int)
Expand source code
@dataclass
class ErrorWaterfallStep:
    """A single error category in the Error Waterfall card."""
    error_type: str
    count: int
    percentage: float
    status_code: int

A single error category in the Error Waterfall card.

Instance variables

var count : int

The type of the None singleton.

var error_type : str

The type of the None singleton.

var percentage : float

The type of the None singleton.

var status_code : int

The type of the None singleton.

class FunnelStep (name: str, visitors: int, conversion_rate: float)
Expand source code
@dataclass
class FunnelStep:
    """A discrete step in a PostHog conversion funnel."""
    name: str
    visitors: int
    conversion_rate: float

A discrete step in a PostHog conversion funnel.

Instance variables

var conversion_rate : float

The type of the None singleton.

var name : str

The type of the None singleton.

var visitors : int

The type of the None singleton.

class LatencyWaterfallEvent (session_id: str,
stt_duration: float = 0.0,
eou_delay: float = 0.0,
llm_ttft: float = 0.0,
llm_duration: float = 0.0,
tts_ttfb: float = 0.0,
tts_duration: float = 0.0,
total_turn_latency: float = 0.0)
Expand source code
@dataclass
class LatencyWaterfallEvent:
    """Full turn latency waterfall emitted to PostHog for conversational performance analysis."""
    session_id: str
    stt_duration: float = 0.0
    eou_delay: float = 0.0
    llm_ttft: float = 0.0
    llm_duration: float = 0.0
    tts_ttfb: float = 0.0
    tts_duration: float = 0.0
    total_turn_latency: float = 0.0

Full turn latency waterfall emitted to PostHog for conversational performance analysis.

Instance variables

var eou_delay : float

The type of the None singleton.

var llm_duration : float

The type of the None singleton.

var llm_ttft : float

The type of the None singleton.

var session_id : str

The type of the None singleton.

var stt_duration : float

The type of the None singleton.

var total_turn_latency : float

The type of the None singleton.

var tts_duration : float

The type of the None singleton.

var tts_ttfb : float

The type of the None singleton.

class PostHogPluginOptions (api_key: str | None = None,
host: str = 'https://us.i.posthog.com',
project_id: str | None = None,
personal_api_key: str | None = None,
flush_at: int = 1,
flush_interval: float = 0.5,
capture_tts_metrics: bool = True,
capture_stt_metrics: bool = True,
capture_eou_metrics: bool = True,
capture_interruption_metrics: bool = True)
Expand source code
@dataclass
class PostHogPluginOptions:
    """Configuration options for the PostHog LiveKit plugin."""
    api_key: Optional[str] = None
    host: str = "https://us.i.posthog.com"
    project_id: Optional[str] = None
    personal_api_key: Optional[str] = None
    flush_at: int = 1
    flush_interval: float = 0.5
    capture_tts_metrics: bool = True
    capture_stt_metrics: bool = True
    capture_eou_metrics: bool = True
    capture_interruption_metrics: bool = True

Configuration options for the PostHog LiveKit plugin.

Instance variables

var api_key : str | None

The type of the None singleton.

var capture_eou_metrics : bool

The type of the None singleton.

var capture_interruption_metrics : bool

The type of the None singleton.

var capture_stt_metrics : bool

The type of the None singleton.

var capture_tts_metrics : bool

The type of the None singleton.

var flush_at : int

The type of the None singleton.

var flush_interval : float

The type of the None singleton.

var host : str

The type of the None singleton.

var personal_api_key : str | None

The type of the None singleton.

var project_id : str | None

The type of the None singleton.

class PluginOptions (api_key: str | None = None,
host: str = 'https://us.i.posthog.com',
project_id: str | None = None,
personal_api_key: str | None = None,
flush_at: int = 1,
flush_interval: float = 0.5,
capture_tts_metrics: bool = True,
capture_stt_metrics: bool = True,
capture_eou_metrics: bool = True,
capture_interruption_metrics: bool = True)
Expand source code
@dataclass
class PostHogPluginOptions:
    """Configuration options for the PostHog LiveKit plugin."""
    api_key: Optional[str] = None
    host: str = "https://us.i.posthog.com"
    project_id: Optional[str] = None
    personal_api_key: Optional[str] = None
    flush_at: int = 1
    flush_interval: float = 0.5
    capture_tts_metrics: bool = True
    capture_stt_metrics: bool = True
    capture_eou_metrics: bool = True
    capture_interruption_metrics: bool = True

Configuration options for the PostHog LiveKit plugin.

Instance variables

var api_key : str | None

The type of the None singleton.

var capture_eou_metrics : bool

The type of the None singleton.

var capture_interruption_metrics : bool

The type of the None singleton.

var capture_stt_metrics : bool

The type of the None singleton.

var capture_tts_metrics : bool

The type of the None singleton.

var flush_at : int

The type of the None singleton.

var flush_interval : float

The type of the None singleton.

var host : str

The type of the None singleton.

var personal_api_key : str | None

The type of the None singleton.

var project_id : str | None

The type of the None singleton.

class RetentionStep (interval: str, retention_rate: float, users: int)
Expand source code
@dataclass
class RetentionStep:
    """A cohort interval in the Retention Trend card."""
    interval: str
    retention_rate: float
    users: int

A cohort interval in the Retention Trend card.

Instance variables

var interval : str

The type of the None singleton.

var retention_rate : float

The type of the None singleton.

var users : int

The type of the None singleton.

class SessionReplayLinkEvent (session_id: str,
livekit_room: str,
participant_identity: str,
replay_url: str,
timestamp: float = 0.0)
Expand source code
@dataclass
class SessionReplayLinkEvent:
    """Event linking LiveKit WebRTC session recording to PostHog Session Replay."""
    session_id: str
    livekit_room: str
    participant_identity: str
    replay_url: str
    timestamp: float = 0.0

Event linking LiveKit WebRTC session recording to PostHog Session Replay.

Instance variables

var livekit_room : str

The type of the None singleton.

var participant_identity : str

The type of the None singleton.

var replay_url : str

The type of the None singleton.

var session_id : str

The type of the None singleton.

var timestamp : float

The type of the None singleton.

class VisualErrorWaterfallCard (type: str = 'error_waterfall',
title: str = 'API Error Waterfall',
timeframe: str = '24h',
total_errors: int = 0,
errors: List[ErrorWaterfallStep] = <factory>,
primary_root_cause: str = '',
timestamp: int = 0)
Expand source code
@dataclass
class VisualErrorWaterfallCard:
    """Payload pushed over WebRTC data channel for error triaging."""
    type: str = "error_waterfall"
    title: str = "API Error Waterfall"
    timeframe: str = "24h"
    total_errors: int = 0
    errors: List[ErrorWaterfallStep] = field(default_factory=list)
    primary_root_cause: str = ""
    timestamp: int = 0

Payload pushed over WebRTC data channel for error triaging.

Instance variables

var errors : List[ErrorWaterfallStep]

The type of the None singleton.

var primary_root_cause : str

The type of the None singleton.

var timeframe : str

The type of the None singleton.

var timestamp : int

The type of the None singleton.

var title : str

The type of the None singleton.

var total_errors : int

The type of the None singleton.

var type : str

The type of the None singleton.

class VisualFunnelCard (type: str = 'funnel_viz',
title: str = 'Conversion Funnel',
funnel_id: str = 'default_funnel',
steps: List[FunnelStep] = <factory>,
primary_drop_step: str = '',
timestamp: int = 0)
Expand source code
@dataclass
class VisualFunnelCard:
    """Payload pushed over WebRTC data channel conforming to Contract A."""
    type: str = "funnel_viz"
    title: str = "Conversion Funnel"
    funnel_id: str = "default_funnel"
    steps: List[FunnelStep] = field(default_factory=list)
    primary_drop_step: str = ""
    timestamp: int = 0

Payload pushed over WebRTC data channel conforming to Contract A.

Instance variables

var funnel_id : str

The type of the None singleton.

var primary_drop_step : str

The type of the None singleton.

var steps : List[FunnelStep]

The type of the None singleton.

var timestamp : int

The type of the None singleton.

var title : str

The type of the None singleton.

var type : str

The type of the None singleton.

class VisualRetentionCard (type: str = 'retention_trend',
title: str = 'Cohort Retention Trend',
cohort_name: str = 'All Users',
intervals: List[RetentionStep] = <factory>,
terminal_retention: float = 0.0,
timestamp: int = 0)
Expand source code
@dataclass
class VisualRetentionCard:
    """Payload pushed over WebRTC data channel for cohort retention analysis."""
    type: str = "retention_trend"
    title: str = "Cohort Retention Trend"
    cohort_name: str = "All Users"
    intervals: List[RetentionStep] = field(default_factory=list)
    terminal_retention: float = 0.0
    timestamp: int = 0

Payload pushed over WebRTC data channel for cohort retention analysis.

Instance variables

var cohort_name : str

The type of the None singleton.

var intervals : List[RetentionStep]

The type of the None singleton.

var terminal_retention : float

The type of the None singleton.

var timestamp : int

The type of the None singleton.

var title : str

The type of the None singleton.

var type : str

The type of the None singleton.