Expand description
Local uses and insights (privacy-respecting behavioral capture)
This module provides anonymous usage pattern collection that stays entirely local. All data uses strongly-typed enums - no arbitrary strings can leak. Users can disable via config, environment, or by building without the feature. Local uses and insights module
This module provides privacy-respecting behavioral capture for sqry, enabling users to understand their own usage patterns and share anonymous insights if they choose to.
§Architecture
sqry operations ──▶ UsesCollector ──▶ Daily JSONL files
(fire-and-forget) │
▼
DiagnosticsAggregator ◀─┘
│
▼
Weekly summaries + Insights reports§Privacy Guarantees
All data is local-first:
- Events capture behavioral patterns, never code content
- All fields are strongly-typed enums (no arbitrary strings)
- Sharing is always explicit and requires confirmation
- Users can disable entirely via config or environment
§Feature Gating
This module is gated behind the uses feature flag. The hierarchy is:
uses: Local uses recordinginsights: Local summaries and reports (requiresuses)troubleshoot: Support bundle generation (requiresinsights)
Build with --no-default-features to produce a binary with no collection code.
§Usage
ⓘ
use sqry_core::uses::{UseEvent, UseEventType, QueryKind, DiagnosticsAggregator};
// Record an event (fire-and-forget)
let event = UseEvent::new(UseEventType::QueryExecuted {
kind: QueryKind::CallChain,
result_count: 42,
});
collector.record(event);
// Get weekly insights
let aggregator = DiagnosticsAggregator::new(&uses_dir);
let summary = aggregator.summarize_week("2025-W50")?;Structs§
- Auto
Summarize Config - Configuration for automatic summarization
- Collector
Timed Use - RAII timer for collector - records event with duration on drop
- Contextual
Feedback Config - Configuration for contextual feedback prompts
- Diagnostics
Aggregator - Diagnostics aggregator - transforms raw events into weekly summaries
- Diagnostics
Summary - Weekly diagnostics summary - aggregated from daily event logs
- Graph
Abandon Rate - Per-graph-kind abandonment rate for detailed insights
- IsoWeek
Period - Newtype for ISO week periods - validated format only
- Sanitized
Config - Sanitized config for troubleshoot bundles - no paths, no secrets
- Share
Snapshot - Share snapshot - self-contained payload for
sqry insights --share - Sqry
Version - Newtype for sqry version - validated semver format only
- Structured
Error - Structured error - no arbitrary strings, no paths
- System
Info - System information - enum-only, no version strings
- Timed
Use - RAII timer for recording event duration on drop
- TopWorkflow
- Workflow count entry for diagnostics summary
- Troubleshoot
Bundle - Troubleshoot bundle - structured data for issue reporting
- UseEvent
- A single use event captured by sqry
- Uses
Collector - Global uses collector - fire-and-forget event capture
- Uses
Config - Configuration for local uses and insights
- Uses
Storage - Storage operations for reading and managing use event files
- Uses
Writer - Background writer that receives events from the collector channel and writes them to daily JSONL files.
- Workflow
Trace - Workflow trace - strictly typed enum steps (opt-in via –include-trace)
Enums§
- Aggregator
Error - Errors that can occur during aggregation
- Arch
Kind - Architecture kinds
- Build
Kind - Build type kinds
- Config
Load Error - Errors that can occur when loading configuration
- Config
Save Error - Errors that can occur when saving configuration
- Error
Category - Error categories for troubleshoot bundles
- Error
Kind - Error kinds for troubleshoot bundles
- Export
Format - Supported export formats
- Feedback
Context - Context in which feedback was requested
- Feedback
Response - User feedback response options
- Graph
Kind - Types of graphs that can be expanded
- OsKind
- Operating system kinds
- Prompt
Frequency - Frequency of feedback prompts
- Query
Kind - Types of queries that can be executed
- UseEvent
Type - Sum enum with data variants - uses internally tagged serialization.
- View
Kind - Types of views that can be displayed
- Workflow
Step - Workflow step enum - tagged serialization like
UseEventType
Functions§
- generate_
bundle - Generate a troubleshoot bundle from usage data.