systemprompt_analytics/repository/funnel/mod.rs
1//! Conversion-funnel definitions and per-session progress tracking.
2//!
3//! [`FunnelRepository`] manages `funnels` and their ordered `funnel_steps`,
4//! records `funnel_progress` as sessions advance, and computes drop-off
5//! statistics. Mutations live in `mutations`, reads in `finders` and `stats`,
6//! and shared row types in `types`.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11mod finders;
12mod mutations;
13mod stats;
14mod types;
15
16use crate::Result;
17use sqlx::PgPool;
18use std::sync::Arc;
19use systemprompt_database::DbPool;
20
21#[derive(Clone, Debug)]
22pub struct FunnelRepository {
23 pool: Arc<PgPool>,
24 write_pool: Arc<PgPool>,
25}
26
27impl FunnelRepository {
28 pub fn new(db: &DbPool) -> Result<Self> {
29 let pool = db.pool_arc()?;
30 let write_pool = db.write_pool_arc()?;
31 Ok(Self { pool, write_pool })
32 }
33}