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.

839 B
Raw Blame
use std::sync::Arc;

use crate::core::error::UnhandledError;
use crate::modes::notifications::config::NotificationsConfig;
use crate::modes::notifications::rate_limit::IssueCreatedRateLimiter;
use crate::modes::notifications::temporal::IssueLifecycleWorkflowStarters;

#[derive(Clone)]
pub struct NotificationsContext {
    pub issue_lifecycle_workflow_starters: IssueLifecycleWorkflowStarters,
    pub issue_created_limiter: Arc<IssueCreatedRateLimiter>,
}

impl NotificationsContext {
    pub async fn from_config(config: &NotificationsConfig) -> Result<Self, UnhandledError> {
        Ok(Self {
            issue_lifecycle_workflow_starters: IssueLifecycleWorkflowStarters::from_config(config)
                .await?,
            issue_created_limiter: Arc::new(IssueCreatedRateLimiter::from_config(config).await?),
        })
    }
}