First-party web analytics — events, cookieless visitor identity, rollups, queries
| Tier | observability |
| Role | unclassified (baselined) |
| Path | crates/observability/analytics |
| Edition | 2021 |
| Targets | observability_analytics |
| Public items | 116 across 16 modules |
| Tests | 108 |
What it is for
First-party web analytics — the reusable engine behind self-hosted website analytics: an event model, cookieless visitor identity, rollups, and queries. No third-party trackers, no cookies.
Capabilities
disclosure::probe (other)
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
fn grade_topology(hand : & & Run, driver : & Run) -> Verdict |
fn grade_trust(driver : & Run) -> Verdict |
fn grade_activation(hand : & & Run, driver : & Run) -> Verdict |
fn check_calibration(calibration : & Run, expectations : & (Context, & str, Expectation),) -> Result <(), Refusal> |
fn check_cohort(runs : & Run) -> Result <Vec <& Run>, Refusal> |
fn grade(hand : & & Run, driver : & Run, min_hand : usize) -> BTreeMap <String, Verdict> |
CanaryObservation
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub struct CanaryObservation |
CanaryOutcome
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub enum CanaryOutcome |
Context
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub enum Context |
Driver
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub enum Driver |
Driver :: fn as_str(self) -> & 'static str |
Expectation
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub enum Expectation |
fn parse_expectations(tsv : & str) -> Result <Vec <ExpectationRow>, String> |
fn expectations_for <'a>(rows : & 'a ExpectationRow, canary_set_version : u32, browser_build : & str,) -> Vec <(Context, & 'a str, Expectation)> |
ExpectationRow
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub struct ExpectationRow |
ProbeEvent
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub struct ProbeEvent |
fn topology(events : & ProbeEvent) -> Vec <String> |
Quantiles
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub struct Quantiles |
fn timing_quantiles(runs : & & Run) -> BTreeMap <String, Quantiles> |
Refusal
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub enum Refusal |
Run
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub const DEFAULT_MIN_HAND_RUNS: usize |
pub struct Run |
fn typed_the_script(run : & Run) -> bool |
fn pasted(run : & Run) -> bool |
fn hand_kinds(hand : & & Run) -> BTreeSet <String> |
Verdict
The probe battery's pure half: observations in, verdicts out (sprint 4.55).
| Item |
|---|
pub const VERDICT_POLICY_VERSION: u32 |
pub enum Verdict |
disclosure::retention (other)
Retention for disclosure-lab observations.
| Item |
|---|
pub const ABSOLUTE_GRACE_MINUTES: i64 |
LabRetention
Retention for disclosure-lab observations.
| Item |
|---|
pub enum LabRetention |
LabRetention :: fn is_ingest_gated(self) -> bool |
LabRetention :: fn mapping(self) -> RetentionMapping |
LabRetention :: fn deadlines(self, received_at : DateTime <Utc>) -> Option <RetentionDeadlines> |
RetentionDeadlines
Retention for disclosure-lab observations.
| Item |
|---|
pub struct RetentionDeadlines |
RetentionMapping
Retention for disclosure-lab observations.
| Item |
|---|
pub enum RetentionMapping |
disclosure::server_identity (other)
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
fn transition(from : & AudienceClass, to : & AudienceClass) -> Option <ClassTransition> |
AudienceAttributes
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub struct AudienceAttributes |
AudienceClass
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub enum AudienceClass |
AudienceRule
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub struct AudienceRule |
ClassTransition
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub struct ClassTransition |
ContainmentAttestation
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub struct ContainmentAttestation |
ContainmentAttestation :: fn is_complete(& self) -> bool |
LeverConfig
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub struct LeverConfig |
LeverConfig :: fn classify(& self, attrs : & AudienceAttributes) -> AudienceClass |
LeverConfig :: fn select(& self, attrs : & AudienceAttributes) -> Selection |
ProvenanceInput
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub struct ProvenanceInput |
ProvenanceInput :: fn new(path : impl Into <String>, stable_token : impl Into <String>) -> Self |
fn provenance_tag(key : & str, epoch : & str, input : & ProvenanceInput) -> String |
Selection
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub struct Selection |
SelectionReason
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub enum SelectionReason |
ServerIdentityMode
The server-identity lever: a per-audience choice of what the Server
| Item |
|---|
pub enum ServerIdentityMode |
ServerIdentityMode :: fn is_cacheable(self) -> bool |
ServerIdentityMode :: fn requires_containment(self) -> bool |
ProbeSettings
Per-probe settings for the disclosure lab.
| Item |
|---|
pub struct ProbeSettings |
disclosure::subject (other)
Subject pseudonymisation for disclosure-lab observations.
| Item |
|---|
fn probe_subject_hash(key : & str, epoch : & str, attributes : & str) -> String |
identity (other)
Cookieless visitor identity and request classification.
| Item |
|---|
fn phoenix_today() -> NaiveDate |
fn phoenix_date_of(utc : DateTime <Utc>) -> NaiveDate |
fn visitor_day_hash(salt : & str, date : NaiveDate, ip : & str, user_agent : & str) -> String |
fn classify_source(referrer_host : Option <& str>, utm_source : Option <& str>) -> Source |
fn classify_device(viewport_w : Option <i32>) -> DeviceClass |
AnalyticsEvent
The first-party pageview event model.
| Item |
|---|
pub struct AnalyticsEvent |
DeviceClass
The first-party pageview event model.
| Item |
|---|
pub enum DeviceClass |
DeviceClass :: fn as_str(& self) -> & 'static str |
DeviceClass :: fn from_str_lossy(s : & str) -> Self |
DeviceClass :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
EngagementUpdate
The first-party pageview event model.
| Item |
|---|
pub struct EngagementUpdate |
Source
The first-party pageview event model.
| Item |
|---|
pub enum Source |
Source :: fn as_str(& self) -> & 'static str |
Source :: fn from_str_lossy(s : & str) -> Self |
Source :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
ConversionRow
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct ConversionRow |
DateRange
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct DateRange |
DateRange :: fn last_n_days(n : i64, today : NaiveDate) -> Self |
DateRange :: fn days(& self) -> i64 |
DateRange :: fn previous_window(& self) -> Self |
DeviceStat
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct DeviceStat |
EventFilter
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct EventFilter |
EventFilter :: fn default() -> Self |
EventFilter :: fn where_fragment(& self) -> String |
GeoCoverage
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct GeoCoverage |
GeoCoverage :: fn in_area_rate(& self) -> f64 |
GeoCoverage :: fn out_of_area_rate(& self) -> f64 |
GeoCoverage :: fn unknown_rate(& self) -> f64 |
HeatCell
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct HeatCell |
LocationStat
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct LocationStat |
MonthRow
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct MonthRow |
OutOfAreaCall
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct OutOfAreaCall |
OverviewStats
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct OverviewStats |
OverviewStats :: fn conversion_rate(& self) -> f64 |
PageConversionStat
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct PageConversionStat |
PageConversionStat :: fn conversion_rate(& self) -> f64 |
PageStat
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct PageStat |
Path404Stat
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct Path404Stat |
SourceStat
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct SourceStat |
SourceStat :: fn conversion_rate(& self) -> f64 |
TrendPoint
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct TrendPoint |
VisitorEvent
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct VisitorEvent |
VisitorRetention
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct VisitorRetention |
VisitorStat
Report result types and date-range helpers for analytics queries.
| Item |
|---|
pub struct VisitorStat |
query::reports::semantics (other)
Cross-report semantics for the Sprint 28 analytics-reports suite
| Item |
|---|
pub const DEDUP_VISITORS: & str |
pub const PHOENIX_LOCAL_OCCURRED_AT: & str |
pub const PHOENIX_LOCAL_DATE: & str |
pub const RESOLVED_IDENTITY_USER_ID: & str |
pub const RESOLVED_IDENTITY_KIND: & str |
fn phoenix_offset() -> FixedOffset |
fn to_local(utc : DateTime <Utc>) -> NaiveDateTime |
fn normalize_path(raw : & str) -> String |
fn match_branded(query : & str, terms : & String) -> bool |
Period
_No module-level documentation is present in the source._
| Item |
|---|
pub enum Period |
Period :: fn as_str(& self) -> & 'static str |
Rollup
_No module-level documentation is present in the source._
| Item |
|---|
pub struct Rollup |
RollupMetrics
_No module-level documentation is present in the source._
| Item |
|---|
pub struct RollupMetrics |
RollupConfig
_No module-level documentation is present in the source._
| Item |
|---|
pub struct RollupConfig |
RollupConfig :: fn default() -> Self |
storage (other)
Persistence and query surface for first-party analytics.
| Item |
|---|
fn is_excluded_path(path : & str) -> bool |
AnalyticsError
Persistence and query surface for first-party analytics.
| Item |
|---|
pub enum AnalyticsError |
AnalyticsStore
Persistence and query surface for first-party analytics.
| Item |
|---|
pub trait AnalyticsStore |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
observability_analytics
disclosuredisclosure::probedisclosure::retentiondisclosure::server_identitydisclosure::settingsdisclosure::subjectidentitymodelqueryquery::reportsquery::reports::semanticsrolluprollup::computerollup::configrollup::jobstorage
flowchart TD n_observability_analytics["observability_analytics"] n_observability_analytics --> n_disclosure["disclosure"] n_disclosure --> n_disclosure__probe["probe"] n_disclosure --> n_disclosure__retention["retention"] n_disclosure --> n_disclosure__server_identity["server_identity"] n_disclosure --> n_disclosure__settings["settings"] n_disclosure --> n_disclosure__subject["subject"] n_observability_analytics --> n_identity["identity"] n_observability_analytics --> n_model["model"] n_observability_analytics --> n_query["query"] n_query --> n_query__reports["reports"] n_query__reports --> n_query__reports__semantics["semantics"] n_observability_analytics --> n_rollup["rollup"] n_rollup --> n_rollup__compute["compute"] n_rollup --> n_rollup__config["config"] n_rollup --> n_rollup__job["job"] n_observability_analytics --> n_storage["storage"]
Public surface
`disclosure::probe`
| Item | What it is |
|---|---|
pub const VERDICT_POLICY_VERSION: u32 | Bumped whenever a grading rule changes |
pub const DEFAULT_MIN_HAND_RUNS: usize | The ratified minimum number of hand runs before comparative grades exist. |
pub enum Driver | Who drove the page. |
Driver :: fn as_str(self) -> & 'static str | — |
pub struct ProbeEvent | One DOM event as the probe page recorded it (AC1's enumerated schema; the per-kind details ride in detail, which grading does not read). |
pub enum Context | Where a canary ran. |
pub enum CanaryOutcome | What a canary reported. |
pub struct CanaryObservation | — |
pub enum Expectation | What the expectation seed says a canary should do on a build. |
pub struct Run | One run: the observable facts, nothing interpreted. |
pub enum Verdict | The one thing a grade may say. |
pub enum Refusal | Why a battery cannot be graded. |
fn typed_the_script(run : & Run) -> bool | Whether a run typed the script it was asked to |
fn pasted(run : & Run) -> bool | Whether a run put the text in by paste or drop rather than keys |
pub struct Quantiles | Nearest-rank quantiles of inter-event deltas for one event kind. |
fn topology(events : & ProbeEvent) -> Vec <String> | The normalized topology of a run: event kinds in order, consecutive pointer moves collapsed to one, timing dropped. |
fn hand_kinds(hand : & & Run) -> BTreeSet <String> | The kinds the hand cohort emits in at least one run. |
fn grade_topology(hand : & & Run, driver : & Run) -> Verdict | Topology grade: a kind the hand emits that driver never does is missing_event_kind; a kind driver emits that no hand run does is extra_event_kind. |
fn grade_trust(driver : & Run) -> Verdict | Trust grade, exact per event kind: the first isTrusted: false names its seq and kind. |
fn grade_activation(hand : & & Run, driver : & Run) -> Verdict | Activation grade: isActive inside the click handler, compared to the hand. |
fn check_calibration(calibration : & Run, expectations : & (Context, & str, Expectation),) -> Result <(), Refusal> | Calibration check on the cdp-enable-on run: every canary the seed marks expected-positive for the build must have fired; an unsupported expectation is never required. |
fn check_cohort(runs : & Run) -> Result <Vec <& Run>, Refusal> | Cohort completeness: every required driver present, all runs on one script hash and one browser build, hand runs with DevTools open excluded |
fn timing_quantiles(runs : & & Run) -> BTreeMap <String, Quantiles> | Nearest-rank p10/p50/p90 per event kind, over every run given |
pub struct ExpectationRow | One row of the canary expectation seed (docs/reference/disclosure-lab/ canary-expectations.tsv): what a canary should do on a build. |
fn parse_expectations(tsv : & str) -> Result <Vec <ExpectationRow>, String> | Parse the seed TSV: a header line, then canary_set_version<TAB>browser_build_pattern<TAB>context<TAB>canary<TAB>expectation |
fn expectations_for <'a>(rows : & 'a ExpectationRow, canary_set_version : u32, browser_build : & str,) -> Vec <(Context, & 'a str, Expectation)> | The expectations that apply to one run: matching version and a build pattern the run's build contains. |
fn grade(hand : & & Run, driver : & Run, min_hand : usize) -> BTreeMap <String, Verdict> | Grade one driver's run against the hand cohort: one verdict per signal |
`disclosure::retention`
| Item | What it is |
|---|---|
pub const ABSOLUTE_GRACE_MINUTES: i64 | Grace between the deferrable window and the deadline that nothing extends |
pub enum LabRetention | How long a disclosure observation's raw payload may be kept |
pub enum RetentionMapping | How a LabRetention projects onto the estate's day-granular RetentionPolicy |
pub struct RetentionDeadlines | The two deadlines a stored raw payload carries. |
LabRetention :: fn is_ingest_gated(self) -> bool | Whether the raw payload must never be written at all |
LabRetention :: fn mapping(self) -> RetentionMapping | How this projects onto the estate's day-granular retention policy |
LabRetention :: fn deadlines(self, received_at : DateTime <Utc>) -> Option <RetentionDeadlines> | The deadlines a payload received at received_at carries, if it is stored under a bounded window |
`disclosure::server_identity`
| Item | What it is |
|---|---|
pub enum ServerIdentityMode | What the Server header discloses to a given audience. |
ServerIdentityMode :: fn is_cacheable(self) -> bool | Whether a response carrying this mode may be stored by a shared cache |
ServerIdentityMode :: fn requires_containment(self) -> bool | Whether the mode may only be enabled once containment is attested. |
pub struct ContainmentAttestation | Evidence that bait's containment requirements are met |
ContainmentAttestation :: fn is_complete(& self) -> bool | Whether every containment requirement is satisfied. |
pub struct AudienceAttributes | Request attributes usable for audience dispatch |
pub enum AudienceClass | The audience a request belongs to. |
pub struct ClassTransition | A change of audience class for the same visitor |
pub enum SelectionReason | Why a particular mode was selected |
pub struct Selection | The outcome of resolving the lever for one request. |
pub struct AudienceRule | One audience-class → mode mapping. |
pub struct LeverConfig | The lever's configuration. |
pub struct ProvenanceInput | Provenance identity inputs |
ProvenanceInput :: fn new(path : impl Into <String>, stable_token : impl Into <String>) -> Self | Build from a request path and a stable, non-IP-derived visitor token. |
fn provenance_tag(key : & str, epoch : & str, input : & ProvenanceInput) -> String | The deterministic, linkable identity for a provenance-mode response |
fn transition(from : & AudienceClass, to : & AudienceClass) -> Option <ClassTransition> | A change of audience class for the same visitor, if the class actually moved |
LeverConfig :: fn classify(& self, attrs : & AudienceAttributes) -> AudienceClass | Which audience a request belongs to |
LeverConfig :: fn select(& self, attrs : & AudienceAttributes) -> Selection | Resolve the lever for one request |
`disclosure::settings`
| Item | What it is |
|---|---|
pub struct ProbeSettings | Every probe the lab can run, as an explicit on/off switch |
`disclosure::subject`
| Item | What it is |
|---|---|
fn probe_subject_hash(key : & str, epoch : & str, attributes : & str) -> String | — |
`identity`
| Item | What it is |
|---|---|
fn phoenix_today() -> NaiveDate | Today's date in Phoenix local time. |
fn phoenix_date_of(utc : DateTime <Utc>) -> NaiveDate | The Phoenix-local calendar date for a given UTC instant. |
fn visitor_day_hash(salt : & str, date : NaiveDate, ip : & str, user_agent : & str) -> String | Cookieless daily visitor identity |
fn classify_source(referrer_host : Option <& str>, utm_source : Option <& str>) -> Source | Classify a pageview's traffic source |
fn classify_device(viewport_w : Option <i32>) -> DeviceClass | Classify device from the reported viewport width (CSS pixels): <768 mobile, 768..=1024 tablet, wider (or unknown) desktop. |
`model`
| Item | What it is |
|---|---|
pub enum Source | Classified traffic source for a pageview. |
Source :: fn as_str(& self) -> & 'static str | The canonical lowercase token, as stored in the database. |
Source :: fn from_str_lossy(s : & str) -> Self | Parse a stored source token; an unknown value falls back to Other rather than failing — analytics data is never critical-path. |
Source :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub enum DeviceClass | Device class, derived from the reported viewport width. |
DeviceClass :: fn as_str(& self) -> & 'static str | The canonical lowercase token, as stored in the database. |
DeviceClass :: fn from_str_lossy(s : & str) -> Self | Parse a stored device token; an unknown value falls back to Desktop. |
DeviceClass :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub struct AnalyticsEvent | A single first-party pageview event — the cookieless analogue of one row in a consumer's analytics_events table. |
pub struct EngagementUpdate | The unload-beacon payload — reports elapsed engagement for an event already recorded by the load beacon. |
`query`
| Item | What it is |
|---|---|
pub struct DateRange | An inclusive date range, in Phoenix-local calendar dates. |
DateRange :: fn last_n_days(n : i64, today : NaiveDate) -> Self | The last n days ending on today inclusive — n = 7 is a one-week window |
DateRange :: fn days(& self) -> i64 | The number of days the range spans, inclusive. |
DateRange :: fn previous_window(& self) -> Self | The equally-long window immediately before this one — for period-over-period deltas. |
pub struct OverviewStats | Headline numbers for the Overview dashboard. |
OverviewStats :: fn conversion_rate(& self) -> f64 | Conversions as a percentage of unique visitors (0 when there are no visitors). |
pub struct PageStat | One row of the Pages report. |
pub struct PageConversionStat | Sprint 28 (US-135) — one row of the Reports ▸ Pages report |
PageConversionStat :: fn conversion_rate(& self) -> f64 | Conversions / unique_visitors, as a percentage |
pub struct Path404Stat | Sprint 28 (US-135) — one row of the Reports ▸ 404 Dead-ends report |
pub struct GeoCoverage | Sprint 28 (US-136) — service-area coverage report row |
GeoCoverage :: fn in_area_rate(& self) -> f64 | — |
GeoCoverage :: fn out_of_area_rate(& self) -> f64 | — |
GeoCoverage :: fn unknown_rate(& self) -> f64 | — |
pub struct OutOfAreaCall | Sprint 28 (US-136) — one row of the out-of-area call list |
pub struct HeatCell | Sprint 28 (US-137) — one cell of the day-of-week × hour-of-day call heatmap |
pub struct MonthRow | Sprint 28 (US-137) — one month row of the call+form trend |
pub struct SourceStat | One row of the Sources report — the channel-comparison table. |
SourceStat :: fn conversion_rate(& self) -> f64 | Conversions as a percentage of this source's unique visitors. |
pub struct ConversionRow | One row of the Conversions report — a lead (form or call), attributed |
pub struct DeviceStat | Sprint 27 (US-133) — one row of the device-breakdown report |
pub struct TrendPoint | One point on the daily trend chart. |
pub struct LocationStat | One resolved visitor location — a row of the geography report and a marker on the drillable map (Sprint 22) |
pub struct VisitorStat | One row of the visitor drill-in (Sprint 26, US-128) |
pub struct VisitorEvent | One event in a visitor's drill-in timeline (Sprint 26, US-128). |
pub struct VisitorRetention | New-vs-returning visitor counts for a date range (Sprint 22) |
pub struct EventFilter | Sprint 25 — dashboard-side filter for analytics_events aggregation queries |
EventFilter :: fn default() -> Self | — |
EventFilter :: fn where_fragment(& self) -> String | Render the filter as a SQL fragment suitable for appending to an existing WHERE ... clause on analytics_events |
`query::reports::semantics`
| Item | What it is |
|---|---|
pub const DEDUP_VISITORS: & str | SQL expression that counts unique visitors by day |
pub const PHOENIX_LOCAL_OCCURRED_AT: & str | SQL expression that converts the occurred_at UTC timestamp to a Phoenix-local naive datetime |
pub const PHOENIX_LOCAL_DATE: & str | SQL expression giving the Phoenix-local calendar date of occurred_at |
pub const RESOLVED_IDENTITY_USER_ID: & str | SQL expression that resolves a visitor's user_id, preferring an explicit identity_user_links.user_id over an inferred identity_ip_links.user_id |
pub const RESOLVED_IDENTITY_KIND: & str | SQL expression that labels how a visitor's identity was resolved: 'user_link' when an explicit binding exists, 'ip_link' when only the probabilistic IP match exists, NULL for anonymous |
fn phoenix_offset() -> FixedOffset | The fixed offset Arizona uses year-round (UTC-7, no DST) |
fn to_local(utc : DateTime <Utc>) -> NaiveDateTime | Convert a UTC instant to a Phoenix-local naive datetime |
fn normalize_path(raw : & str) -> String | Normalize a URL path for joins across sources (GSC page ↔ analytics_events.path, redirect lookups, etc.) |
fn match_branded(query : & str, terms : & String) -> bool | Case-insensitive substring match of a search query against a curated list of branded terms |
`rollup`
| Item | What it is |
|---|---|
pub enum Period | — |
Period :: fn as_str(& self) -> & 'static str | — |
pub struct RollupMetrics | — |
pub struct Rollup | — |
`rollup::config`
| Item | What it is |
|---|---|
pub struct RollupConfig | — |
RollupConfig :: fn default() -> Self | — |
`storage`
| Item | What it is |
|---|---|
pub enum AnalyticsError | An analytics storage failure |
pub trait AnalyticsStore | Storage and query surface for first-party web analytics. |
fn is_excluded_path(path : & str) -> bool | Sprint 28 (US-135) — Hybrid 404 noise filter (Round 3 Q2b consensus, ChatGPT's hybrid adopted) |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
PgAnalyticsStore | postgres::PgAnalyticsStore |
PgAnalyticsStore | storage::PgAnalyticsStore |
ProbeSettings | settings::ProbeSettings |
RollupConfig | config::RollupConfig |
probe_subject_hash | subject::probe_subject_hash |
{AnalyticsEvent,DeviceClass,EngagementUpdate,Source} | model::{AnalyticsEvent,DeviceClass,EngagementUpdate,Source} |
{ConversionRow,DateRange,DeviceStat,EventFilter,GeoCoverage,HeatCell,LocationStat,MonthRow,OutOfAreaCall,OverviewStats,PageConversionStat,PageStat,Path404Stat,SourceStat,TrendPoint,VisitorEvent,VisitorRetention,VisitorStat,} | query::{ConversionRow,DateRange,DeviceStat,EventFilter,GeoCoverage,HeatCell,LocationStat,MonthRow,OutOfAreaCall,OverviewStats,PageConversionStat,PageStat,Path404Stat,SourceStat,TrendPoint,VisitorEvent,VisitorRetention,VisitorStat,} |
{LabRetention,RetentionDeadlines,RetentionMapping,ABSOLUTE_GRACE_MINUTES} | retention::{LabRetention,RetentionDeadlines,RetentionMapping,ABSOLUTE_GRACE_MINUTES} |
{classify_device,classify_source,phoenix_date_of,phoenix_today,visitor_day_hash,} | identity::{classify_device,classify_source,phoenix_date_of,phoenix_today,visitor_day_hash,} |
{is_excluded_path,AnalyticsError,AnalyticsStore} | storage::{is_excluded_path,AnalyticsError,AnalyticsStore} |
{provenance_tag,AudienceAttributes,AudienceClass,AudienceRule,ClassTransition,ContainmentAttestation,LeverConfig,ProvenanceInput,Selection,SelectionReason,ServerIdentityMode,} | server_identity::{provenance_tag,AudienceAttributes,AudienceClass,AudienceRule,ClassTransition,ContainmentAttestation,LeverConfig,ProvenanceInput,Selection,SelectionReason,ServerIdentityMode,} |
Boundary
Reaches into foundation.
Shares tier observability with 1 other crate: observability-sentinel.
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | observability |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/observability/analytics |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_observability["observability"] --> n_foundation["foundation"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-audit-log` | foundation | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json, json | yes | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio-test | ^0.4 | — | no | always |
Build. None.
Depended on by. 2 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_analytics["application-analytics"] -->|uses| SELF n_platform_disclosure_lab["platform-disclosure-lab"] -->|uses| SELF SELF["observability-analytics"] SELF -->|runtime| n_foundation_audit_log["foundation-audit-log"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
| Feature | Enables | On by default |
|---|---|---|
postgres | dep:sqlx | no |
flowchart LR n_postgres["postgres"] --> n_dep_sqlx["dep:sqlx"]
Targets
| Kind | Name | Source |
|---|---|---|
| lib | observability_analytics | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
AnalyticsError | declared, no public signature returns it |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
2 workspace crates depend on this one: application-analytics, platform-disclosure-lab.
Verification
| Kind | Count |
|---|---|
| Unit tests | 108 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
disclosure::probe | 26 | 0 | 26 |
disclosure::retention | 4 | 0 | 2 |
disclosure::server_identity | 12 | 0 | 0 |
disclosure::settings | 1 | 0 | 1 |
disclosure::subject | 1 | 0 | 1 |
identity | 5 | 0 | 4 |
model | 4 | 0 | 3 |
query | 18 | 0 | 17 |
query::reports::semantics | 9 | 0 | 0 |
rollup | 3 | 0 | 0 |
rollup::config | 1 | 0 | 0 |
storage | 3 | 0 | 3 |
What the tests establish, by name:
a_driver_with_no_key_events_is_distinguishable_by_missing_kind—src/disclosure/probe.rsa_hand_run_with_devtools_open_is_not_part_of_the_control—src/disclosure/probe.rsa_missing_driver_refuses_by_name—src/disclosure/probe.rsactivation_is_compared_against_the_hand—src/disclosure/probe.rsan_extra_event_kind_is_distinguishable—src/disclosure/probe.rscalibration_requires_expected_positive_and_never_unsupported—src/disclosure/probe.rsruns_on_different_builds_are_a_mixed_cohort—src/disclosure/probe.rsthe_expectation_seed_is_read_whole_and_applied_by_build—src/disclosure/probe.rsthe_first_untrusted_event_is_named_by_seq_and_kind—src/disclosure/probe.rstiming_quantiles_are_nearest_rank_per_kind—src/disclosure/probe.rstopology_collapses_consecutive_moves_and_drops_timing—src/disclosure/probe.rstwo_hand_runs_are_an_insufficient_baseline_but_trust_still_grades—src/disclosure/probe.rsverdicts_serialize_with_the_tag_the_report_reads—src/disclosure/probe.rswhat_was_typed_decides_membership—src/disclosure/probe.rsa_bounded_window_yields_two_deadlines_with_a_fixed_grace—src/disclosure/retention.rsa_sub_day_window_never_degrades_into_days—src/disclosure/retention.rsdefault_is_none_so_an_absent_setting_stores_nothing—src/disclosure/retention.rsforever_maps_to_zero_days_matching_the_compliance_convention—src/disclosure/retention.rsnone_and_forever_carry_no_deadlines—src/disclosure/retention.rsnone_never_maps_to_a_day_count—src/disclosure/retention.rsonly_none_is_an_ingest_gate—src/disclosure/retention.rsround_trips_through_json—src/disclosure/retention.rsthe_absolute_deadline_always_follows_the_deferrable_one—src/disclosure/retention.rsa_country_change_is_reported_as_a_class_transition—src/disclosure/server_identity.rsa_provenance_tag_distinguishes_paths_visitors_epochs_and_tenants—src/disclosure/server_identity.rsa_provenance_tag_is_128_bit_hex—src/disclosure/server_identity.rsa_provenance_tag_is_unchanged_when_the_visitor_changes_country—src/disclosure/server_identity.rsan_unchanged_class_is_not_a_transition—src/disclosure/server_identity.rsan_unmatched_request_falls_back_to_absent—src/disclosure/server_identity.rsbait_is_selected_once_containment_is_complete—src/disclosure/server_identity.rs- _… 78 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 101 | 116 |
Public modules with a //! block | 12 | 16 |
pie showData
title Public items with rustdoc
"Documented" : 101
"No rustdoc detected" : 15
Metrics
| Metric | Value |
|---|---|
| Rust source files | 18 |
| Source lines | 4966 |
| Code lines | 3588 |
| Public API items | 116 |
| Public modules | 16 |
| Tests | 108 |
| Examples | 0 |
| Cargo features | 1 |
| Direct runtime dependencies | 8 |
| Workspace reverse dependencies | 2 |
pie showData
title Public API by kind
"constant" : 8
"enum" : 15
"function" : 26
"method" : 29
"struct" : 37
"trait" : 1
pie showData
title Rust source composition
"Code" : 3588
"Blank or comment" : 1378
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.