1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! The edge's beacon as the `beacon` KPI source (spec 3.5 §7.12, Q4).
use KernelError;
use KpiSource;
use BeaconCounts;
use async_trait;
use ;
use Uuid;
use check_site;
/// The edge's cookieless beacon as the kernel's `beacon` KPI source (spec 3.5 §7.12): a
/// forward to `AwpEdge::beacon().read`, its store errors as the kernel's.
///
/// | Metric | Counts |
/// |---|---|
/// | `pageviews`, `pageviews:{path}` | Page views, all or of one path |
/// | `events:{name}` | One event, such as an experiment's `events:exp.headline.b.exposure` |
/// | `visitors` | Visitors under a live `persistent_profile` receipt, distinct per day |
///
/// The beacon counts nothing under `Sec-GPC: 1` and keeps no cookie, address or identifier
/// without a receipt; this source reads only its daily totals.
///
/// # Example
///
/// ```rust
/// use std::sync::Arc;
/// use adk_kernel::charter::KpiSource;
/// use adk_server::awp::{BeaconCounts, BeaconStore, InMemoryBeaconStore};
/// use adk_website::measurement::BeaconKpi;
/// use chrono::{Duration, TimeZone, Utc};
///
/// # #[tokio::main(flavor = "current_thread")]
/// # async fn main() -> adk_kernel::Result<()> {
/// let site = uuid::Uuid::new_v4();
/// let store = Arc::new(InMemoryBeaconStore::new());
/// let day = Utc.with_ymd_and_hms(2026, 10, 24, 0, 0, 0).unwrap();
/// store.add(day.date_naive(), "events:signup", 4).await.unwrap();
/// let beacon = BeaconKpi::new(site, BeaconCounts::new(store));
/// assert_eq!(beacon.read(site, "events:signup", day, day + Duration::days(1)).await?, Some(4.0));
/// # Ok(())
/// # }
/// ```