Files
Pulse/pkg/server/telemetry_licensed_features.go
rcourtman 84226ad7bc Count successful history reads beyond seven days
Measure delivered extended history before changing free and paid features.
Count only successful responses containing an older metric point and retain
only bounded daily totals. Expose the rolling sum through schema v19 and
Preview with matching privacy disclosure and explicit report coverage.
2026-10-16 19:21:03 +01:00

46 lines
1.7 KiB
Go

package server
import (
"time"
"github.com/rcourtman/pulse-go-rewrite/internal/config"
"github.com/rcourtman/pulse-go-rewrite/internal/telemetry"
)
// applyLicensedFeatureConfigSnapshot adds content-free adoption counts for
// licensed features whose state lives in persisted config files.
//
// Counts only. Schedule names, delivery recipients, report scope, and profile
// names all stay on the install; the aggregate answers "how many are
// configured and how many ran", nothing about what they contain.
func applyLicensedFeatureConfigSnapshot(snap *telemetry.Snapshot, persistence *config.ConfigPersistence, now time.Time) {
if snap == nil || persistence == nil {
return
}
if store, err := persistence.LoadReportScheduleStore(); err == nil && store != nil {
since := now.Add(-telemetry.PulseIntelligenceTelemetryWindow)
for _, schedule := range store.Schedules {
snap.ReportSchedules++
if schedule.Enabled {
snap.ReportSchedulesEnabled++
}
if schedule.LastRunAt != nil && schedule.LastRunAt.After(since) {
snap.ReportSchedulesRun30d++
}
}
}
if profiles, err := persistence.LoadAgentProfiles(); err == nil {
snap.AgentProfiles = len(profiles)
}
snap.SuccessfulHistoryReadsOver7d30d = persistence.CountSuccessfulExtendedHistoryReadsSince(now.Add(-telemetry.PulseIntelligenceTelemetryWindow), now)
// Audit adoption is a read count, not store presence: the SQLite audit
// logger is installed on every install for defense in depth, so only an
// operator reaching a license-gated read surface distinguishes an install
// that uses audit logging from one that merely has it.
snap.AuditReads30d = persistence.CountAuditReadActivitySince(now.Add(-telemetry.PulseIntelligenceTelemetryWindow))
}