Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Expose infrastructure onboarding diagnostics
rcourtman74c2660f8da9
diff --git a/frontend-modern/src/components/Settings/DiagnosticsResultsPanel.tsx b/frontend-modern/src/components/Settings/DiagnosticsResultsPanel.tsxindex 6f9ffefa2f..103944989b 100644--- a/frontend-modern/src/components/Settings/DiagnosticsResultsPanel.tsx+++ b/frontend-modern/src/components/Settings/DiagnosticsResultsPanel.tsx@@ -18,6 +18,7 @@ import XCircle from 'lucide-solid/icons/x-circle';import { StatusDot } from '@/components/shared/StatusDot';import { getSimpleStatusIndicator, getStatusIndicatorBadgeToneClasses } from '@/utils/status';import { getSemanticTonePresentation } from '@/utils/semanticTonePresentation';+import { getInfrastructureOnboardingProductPresentation } from '@/utils/infrastructureOnboardingPresentation';import {DIAGNOSTICS_EMPTY_PBS_MESSAGE,DIAGNOSTICS_EMPTY_STATE_COPY,@@ -28,6 +29,8 @@ import type {CommercialFunnelDimensionBreakdown,CommercialFunnelStageCounts,DiagnosticsData,+ InfrastructureOnboardingPlatformBreakdown,+ InfrastructureOnboardingStageCounts,} from '@/components/Settings/diagnosticsModel';const DiagnosticCard: Component<{@@ -95,7 +98,7 @@ const formatCommercialDayLabel = (day?: string): string => {return parsed.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });};-const getCommercialFunnelBadge = (+const getDiagnosticsActivityBadge = (status?: string,): {badgeStatus: 'online' | 'offline' | 'warning' | 'unknown';@@ -147,6 +150,60 @@ const totalCommercialSignals = (summary?: CommercialFunnelStageCounts | null): n);};+const formatInfrastructureOnboardingPathLabel = (value?: string): string => {+ switch (value) {+ case 'api':+ return 'API';+ case 'agent':+ return 'Agent';+ default:+ return titleCaseDelimitedLabel(value, { fallback: 'Unknown' });+ }+};++const formatInfrastructureOnboardingPlatformLabel = (value?: string): string => {+ switch (value) {+ case 'vmware':+ case 'truenas':+ case 'pve':+ case 'pbs':+ case 'pmg':+ case 'agent':+ return getInfrastructureOnboardingProductPresentation(value).label;+ default:+ return titleCaseDelimitedLabel(value, { fallback: 'Unknown' });+ }+};++const formatInfrastructureOnboardingPlatformSummary = (+ entry: InfrastructureOnboardingPlatformBreakdown,+): string => {+ const segments: string[] = [];+ if (entry.catalog_selected > 0) {+ segments.push(`Catalog ${entry.catalog_selected}`);+ }+ if (entry.credentials_opened > 0) {+ segments.push(`Credentials ${entry.credentials_opened}`);+ }+ return segments.join(' • ') || 'No recorded activity';+};++const totalInfrastructureOnboardingSignals = (+ summary?: InfrastructureOnboardingStageCounts | null,+): number => {+ if (!summary) return 0;+ return (+ summary.opened ++ summary.api_path_selected ++ summary.agent_path_selected ++ summary.probe_detected ++ summary.probe_no_match ++ summary.probe_error ++ summary.catalog_selected ++ summary.credentials_opened+ );+};+interface DiagnosticsResultsPanelProps {diagnosticsData: DiagnosticsData | null;loading: boolean;@@ -381,8 +438,8 @@ export const DiagnosticsResultsPanel: Component<DiagnosticsResultsPanelProps> =</div><div class="ml-auto"><StatusBadge- status={getCommercialFunnelBadge(props.diagnosticsData?.commercialFunnel?.status).badgeStatus}- label={getCommercialFunnelBadge(props.diagnosticsData?.commercialFunnel?.status).label}+ status={getDiagnosticsActivityBadge(props.diagnosticsData?.commercialFunnel?.status).badgeStatus}+ label={getDiagnosticsActivityBadge(props.diagnosticsData?.commercialFunnel?.status).label}/></div></div>@@ -522,6 +579,170 @@ export const DiagnosticsResultsPanel: Component<DiagnosticsResultsPanelProps> =</Card></Show>+ <Show when={props.diagnosticsData?.infrastructureOnboarding}>+ <Card padding="md" class="lg:col-span-2">+ <div class="mb-4 flex items-center gap-3 border-b border-border pb-3">+ <div class="rounded-md bg-blue-100 p-2 dark:bg-blue-900">+ <Server class="h-4 w-4 text-blue-600 dark:text-blue-400" />+ </div>+ <div>+ <h4 class="text-sm font-semibold text-base-content">Infrastructure Onboarding</h4>+ <p class="text-xs text-muted">+ Local add-infrastructure activity over the last{' '}+ {props.diagnosticsData?.infrastructureOnboarding?.windowDays ?? 0} days.+ </p>+ </div>+ <div class="ml-auto">+ <StatusBadge+ status={+ getDiagnosticsActivityBadge(props.diagnosticsData?.infrastructureOnboarding?.status)+ .badgeStatus+ }+ label={+ getDiagnosticsActivityBadge(props.diagnosticsData?.infrastructureOnboarding?.status)+ .label+ }+ />+ </div>+ </div>++ <div class="grid gap-4 xl:grid-cols-[minmax(0,220px)_minmax(0,1fr)_minmax(0,1fr)]">+ <div class="space-y-2 text-xs">+ <MetricRow+ label="Signals"+ value={totalInfrastructureOnboardingSignals(+ props.diagnosticsData?.infrastructureOnboarding?.summary,+ )}+ />+ <MetricRow+ label="Opens"+ value={props.diagnosticsData?.infrastructureOnboarding?.summary?.opened ?? 0}+ />+ <MetricRow+ label="API Paths"+ value={props.diagnosticsData?.infrastructureOnboarding?.summary?.api_path_selected ?? 0}+ />+ <MetricRow+ label="Agent Paths"+ value={props.diagnosticsData?.infrastructureOnboarding?.summary?.agent_path_selected ?? 0}+ />+ <MetricRow+ label="Detected Probes"+ value={props.diagnosticsData?.infrastructureOnboarding?.summary?.probe_detected ?? 0}+ />+ <MetricRow+ label="No-Match Probes"+ value={props.diagnosticsData?.infrastructureOnboarding?.summary?.probe_no_match ?? 0}+ />+ <MetricRow+ label="Credentials Opened"+ value={props.diagnosticsData?.infrastructureOnboarding?.summary?.credentials_opened ?? 0}+ />+ </div>++ <div>+ <div class="mb-2 flex items-center justify-between">+ <h5 class="text-xs font-semibold uppercase tracking-wide text-muted">+ Recent Daily Trend+ </h5>+ <span class="text-[11px] text-muted">UTC day buckets</span>+ </div>+ <div class="space-y-2">+ <Show+ when={(props.diagnosticsData?.infrastructureOnboarding?.daily?.length || 0) > 0}+ fallback={<p class="text-xs text-muted">No daily onboarding activity recorded.</p>}+ >+ <For each={props.diagnosticsData?.infrastructureOnboarding?.daily?.slice(-7) || []}>+ {(bucket) => (+ <div class="rounded-md border border-border-subtle px-3 py-2 text-xs">+ <div class="flex items-center justify-between gap-3">+ <span class="font-medium text-base-content">+ {formatCommercialDayLabel(bucket.day)}+ </span>+ <span class="text-muted">+ Opens {bucket.opened} • Credentials {bucket.credentials_opened} • No Match{' '}+ {bucket.probe_no_match}+ </span>+ </div>+ </div>+ )}+ </For>+ </Show>+ </div>+ </div>++ <div class="grid gap-4 md:grid-cols-2 xl:grid-cols-1">+ <div>+ <div class="mb-2 text-xs font-semibold uppercase tracking-wide text-muted">+ Path Choices+ </div>+ <div class="space-y-2">+ <Show+ when={(props.diagnosticsData?.infrastructureOnboarding?.paths?.length || 0) > 0}+ fallback={<p class="text-xs text-muted">No path selection recorded.</p>}+ >+ <For each={props.diagnosticsData?.infrastructureOnboarding?.paths?.slice(0, 4) || []}>+ {(entry) => (+ <div class="rounded-md border border-border-subtle px-3 py-2 text-xs">+ <div class="font-medium text-base-content">+ {formatInfrastructureOnboardingPathLabel(entry.key)}+ </div>+ <div class="mt-1 text-muted">{entry.count} selections</div>+ </div>+ )}+ </For>+ </Show>+ </div>+ </div>++ <div>+ <div class="mb-2 text-xs font-semibold uppercase tracking-wide text-muted">+ Top Platforms+ </div>+ <div class="space-y-2">+ <Show+ when={(props.diagnosticsData?.infrastructureOnboarding?.platforms?.length || 0) > 0}+ fallback={<p class="text-xs text-muted">No platform selection recorded.</p>}+ >+ <For each={props.diagnosticsData?.infrastructureOnboarding?.platforms?.slice(0, 4) || []}>+ {(entry) => (+ <div class="rounded-md border border-border-subtle px-3 py-2 text-xs">+ <div class="font-medium text-base-content">+ {formatInfrastructureOnboardingPlatformLabel(entry.key)}+ </div>+ <div class="mt-1 text-muted">+ {formatInfrastructureOnboardingPlatformSummary(entry)}+ </div>+ </div>+ )}+ </For>+ </Show>+ </div>+ </div>+ </div>+ </div>++ <Show when={(props.diagnosticsData?.infrastructureOnboarding?.notes?.length || 0) > 0}>+ <div class="mt-4 rounded-md border border-amber-200 bg-amber-50 p-2 dark:border-amber-800 dark:bg-amber-900">+ <div class="flex items-start gap-2 text-xs text-amber-700 dark:text-amber-300">+ <AlertTriangle class="mt-0.5 h-4 w-4 flex-shrink-0" />+ <div class="space-y-1">+ <For each={props.diagnosticsData?.infrastructureOnboarding?.notes || []}>+ {(note) => <div>{note}</div>}+ </For>+ </div>+ </div>+ </div>+ </Show>++ <Show when={props.diagnosticsData?.infrastructureOnboarding?.error}>+ <div class="mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700 dark:border-red-800 dark:bg-red-900 dark:text-red-300">+ {props.diagnosticsData?.infrastructureOnboarding?.error}+ </div>+ </Show>+ </Card>+ </Show>+<Show when={props.diagnosticsData?.apiTokens}><Card padding="md"><div class="mb-4 flex items-center gap-3 border-b border-border pb-3">diff --git a/frontend-modern/src/components/Settings/__tests__/DiagnosticsResultsPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/DiagnosticsResultsPanel.test.tsxindex c8ba1b085c..bd9c6bef7b 100644--- a/frontend-modern/src/components/Settings/__tests__/DiagnosticsResultsPanel.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/DiagnosticsResultsPanel.test.tsx@@ -98,6 +98,61 @@ describe('DiagnosticsResultsPanel', () => {],notes: ['Local pricing and activation events show at least one completed conversion.'],},+ infrastructureOnboarding: {+ enabled: true,+ status: 'warning',+ windowDays: 30,+ summary: {+ opened: 4,+ api_path_selected: 2,+ agent_path_selected: 1,+ probe_detected: 1,+ probe_no_match: 2,+ probe_error: 0,+ catalog_selected: 2,+ credentials_opened: 1,+ period: {+ from: '2026-03-19T00:00:00Z',+ to: '2026-04-18T00:00:00Z',+ },+ },+ daily: [+ {+ day: '2026-04-17',+ opened: 2,+ api_path_selected: 1,+ agent_path_selected: 1,+ probe_detected: 0,+ probe_no_match: 1,+ probe_error: 0,+ catalog_selected: 1,+ credentials_opened: 0,+ },+ {+ day: '2026-04-18',+ opened: 2,+ api_path_selected: 1,+ agent_path_selected: 0,+ probe_detected: 1,+ probe_no_match: 1,+ probe_error: 0,+ catalog_selected: 1,+ credentials_opened: 1,+ },+ ],+ paths: [+ { key: 'api', count: 2 },+ { key: 'agent', count: 1 },+ ],+ platforms: [+ {+ key: 'truenas',+ catalog_selected: 2,+ credentials_opened: 1,+ },+ ],+ notes: ['More probed addresses miss than detect a supported API-backed platform.'],+ },errors: [],};@@ -115,5 +170,9 @@ describe('DiagnosticsResultsPanel', () => {expect(screen.getByText('Self Hosted Plan')).toBeInTheDocument();expect(screen.getByText('Settings Self Hosted Billing Compare Prompt')).toBeInTheDocument();expect(screen.getByText(/Pricing 3/i)).toBeInTheDocument();+ expect(screen.getByText('Infrastructure Onboarding')).toBeInTheDocument();+ expect(screen.getByText('Credentials Opened')).toBeInTheDocument();+ expect(screen.getByText('TrueNAS SCALE')).toBeInTheDocument();+ expect(screen.getByText('API')).toBeInTheDocument();});});diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.tsindex 5314988180..c92394ccd3 100644--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts@@ -180,12 +180,15 @@ describe('settings architecture guardrails', () => {);});- it('keeps diagnostics commercial funnel rendering on the shared results/model boundary', () => {+ it('keeps diagnostics funnel rendering on the shared results/model boundary', () => {expect(diagnosticsResultsPanelSource).toContain('Commercial Funnel');+ expect(diagnosticsResultsPanelSource).toContain('Infrastructure Onboarding');expect(diagnosticsResultsPanelSource).toContain('titleCaseDelimitedLabel');expect(diagnosticsResultsPanelSource).not.toContain("apiFetchJSON('/api/diagnostics')");expect(diagnosticsModelSource).toContain('export interface CommercialFunnelDiagnostic');expect(diagnosticsModelSource).toContain('export interface CommercialFunnelSummary');+ expect(diagnosticsModelSource).toContain('export interface InfrastructureOnboardingDiagnostic');+ expect(diagnosticsModelSource).toContain('export interface InfrastructureOnboardingSummary');});});diff --git a/frontend-modern/src/components/Settings/diagnosticsModel.ts b/frontend-modern/src/components/Settings/diagnosticsModel.tsindex 75ac5a0933..15a5dd722c 100644--- a/frontend-modern/src/components/Settings/diagnosticsModel.ts+++ b/frontend-modern/src/components/Settings/diagnosticsModel.ts@@ -126,6 +126,51 @@ export interface CommercialFunnelDiagnostic {error?: string;}+export interface InfrastructureOnboardingStageCounts {+ opened: number;+ api_path_selected: number;+ agent_path_selected: number;+ probe_detected: number;+ probe_no_match: number;+ probe_error: number;+ catalog_selected: number;+ credentials_opened: number;+}++export interface InfrastructureOnboardingSummary extends InfrastructureOnboardingStageCounts {+ period: {+ from: string;+ to: string;+ };+}++export interface InfrastructureOnboardingDayBreakdown extends InfrastructureOnboardingStageCounts {+ day: string;+}++export interface InfrastructureOnboardingPathBreakdown {+ key: string;+ count: number;+}++export interface InfrastructureOnboardingPlatformBreakdown {+ key: string;+ catalog_selected: number;+ credentials_opened: number;+}++export interface InfrastructureOnboardingDiagnostic {+ enabled: boolean;+ status: 'active' | 'idle' | 'warning' | 'error' | 'unavailable';+ windowDays: number;+ summary: InfrastructureOnboardingSummary;+ daily: InfrastructureOnboardingDayBreakdown[];+ paths: InfrastructureOnboardingPathBreakdown[];+ platforms: InfrastructureOnboardingPlatformBreakdown[];+ notes?: string[];+ error?: string;+}+export interface AIChatDiagnostic {enabled: boolean;running: boolean;@@ -147,6 +192,7 @@ export interface DiagnosticsData {system: SystemDiagnostic;metricsStore?: MetricsStoreDiagnostic | null;commercialFunnel?: CommercialFunnelDiagnostic | null;+ infrastructureOnboarding?: InfrastructureOnboardingDiagnostic | null;apiTokens?: APITokenDiagnostic | null;dockerAgents?: DockerAgentDiagnostic | null;alerts?: AlertsDiagnostic | null;diff --git a/internal/api/diagnostics.go b/internal/api/diagnostics.goindex 4878e8b8db..ab147f1e6c 100644--- a/internal/api/diagnostics.go+++ b/internal/api/diagnostics.go@@ -28,20 +28,21 @@ import (// DiagnosticsInfo contains comprehensive diagnostic informationtype DiagnosticsInfo struct {- Version string `json:"version"`- Runtime string `json:"runtime"`- Uptime float64 `json:"uptime"`- Nodes []NodeDiagnostic `json:"nodes"`- PBS []PBSDiagnostic `json:"pbs"`- System SystemDiagnostic `json:"system"`- MetricsStore *MetricsStoreDiagnostic `json:"metricsStore,omitempty"`- CommercialFunnel *CommercialFunnelDiagnostic `json:"commercialFunnel,omitempty"`- Discovery *DiscoveryDiagnostic `json:"discovery,omitempty"`- APITokens *APITokenDiagnostic `json:"apiTokens,omitempty"`- DockerAgents *DockerAgentDiagnostic `json:"dockerAgents,omitempty"`- Alerts *AlertsDiagnostic `json:"alerts,omitempty"`- AIChat *AIChatDiagnostic `json:"aiChat,omitempty"`- Errors []string `json:"errors"`+ Version string `json:"version"`+ Runtime string `json:"runtime"`+ Uptime float64 `json:"uptime"`+ Nodes []NodeDiagnostic `json:"nodes"`+ PBS []PBSDiagnostic `json:"pbs"`+ System SystemDiagnostic `json:"system"`+ MetricsStore *MetricsStoreDiagnostic `json:"metricsStore,omitempty"`+ CommercialFunnel *CommercialFunnelDiagnostic `json:"commercialFunnel,omitempty"`+ InfrastructureOnboarding *InfrastructureOnboardingDiagnostic `json:"infrastructureOnboarding,omitempty"`+ Discovery *DiscoveryDiagnostic `json:"discovery,omitempty"`+ APITokens *APITokenDiagnostic `json:"apiTokens,omitempty"`+ DockerAgents *DockerAgentDiagnostic `json:"dockerAgents,omitempty"`+ Alerts *AlertsDiagnostic `json:"alerts,omitempty"`+ AIChat *AIChatDiagnostic `json:"aiChat,omitempty"`+ Errors []string `json:"errors"`// NodeSnapshots captures the raw memory payload and derived usage Pulse last observed per node.NodeSnapshots []monitoring.NodeMemorySnapshot `json:"nodeSnapshots"`// GuestSnapshots captures recent per-guest memory breakdowns (VM/LXC) with the raw Proxmox fields.@@ -92,6 +93,10 @@ func (d DiagnosticsInfo) NormalizeCollections() DiagnosticsInfo {normalized := d.CommercialFunnel.NormalizeCollections()d.CommercialFunnel = &normalized}+ if d.InfrastructureOnboarding != nil {+ normalized := d.InfrastructureOnboarding.NormalizeCollections()+ d.InfrastructureOnboarding = &normalized+ }if d.Discovery != nil {normalized := d.Discovery.NormalizeCollections()d.Discovery = &normalized@@ -237,6 +242,34 @@ func (d CommercialFunnelDiagnostic) NormalizeCollections() CommercialFunnelDiagnreturn d}+type InfrastructureOnboardingDiagnostic struct {+ Enabled bool `json:"enabled"`+ Status string `json:"status"`+ WindowDays int `json:"windowDays"`+ Summary conversionInfrastructureOnboardingSummary `json:"summary"`+ Daily []conversionInfrastructureOnboardingDayBreakdown `json:"daily"`+ Paths []conversionInfrastructureOnboardingPathBreakdown `json:"paths"`+ Platforms []conversionInfrastructureOnboardingPlatformBreakdown `json:"platforms"`+ Notes []string `json:"notes"`+ Error string `json:"error,omitempty"`+}++func (d InfrastructureOnboardingDiagnostic) NormalizeCollections() InfrastructureOnboardingDiagnostic {+ if d.Daily == nil {+ d.Daily = []conversionInfrastructureOnboardingDayBreakdown{}+ }+ if d.Paths == nil {+ d.Paths = []conversionInfrastructureOnboardingPathBreakdown{}+ }+ if d.Platforms == nil {+ d.Platforms = []conversionInfrastructureOnboardingPlatformBreakdown{}+ }+ if d.Notes == nil {+ d.Notes = []string{}+ }+ return d+}+func isFallbackMemorySource(source string) bool {return monitoring.MemorySourceIsFallback(source)}@@ -483,8 +516,84 @@ func buildCommercialFunnelDiagnostic(ctx context.Context, store *conversionStorereturn &diag}+func buildInfrastructureOnboardingDiagnostic(+ ctx context.Context,+ store *conversionStore,+ now time.Time,+) *InfrastructureOnboardingDiagnostic {+ diag := (&InfrastructureOnboardingDiagnostic{+ Enabled: store != nil,+ Status: "idle",+ WindowDays: infrastructureOnboardingDiagnosticsWindowDays,+ Notes: []string{},+ }).NormalizeCollections()++ if store == nil {+ diag.Status = "unavailable"+ diag.Error = "conversion store not initialized"+ diag.Notes = append(diag.Notes, "Local infrastructure onboarding analytics are unavailable on this instance.")+ return &diag+ }++ to := now.UTC().Truncate(24 * time.Hour).Add(24 * time.Hour)+ from := to.AddDate(0, 0, -infrastructureOnboardingDiagnosticsWindowDays)+ orgID := diagnosticsCommercialOrgID(ctx)++ report, err := store.InfrastructureOnboardingReport(orgID, from, to)+ if err != nil {+ diag.Status = "error"+ diag.Error = "failed to query local infrastructure onboarding analytics"+ diag.Notes = append(diag.Notes, "Diagnostics could not read the local infrastructure onboarding report.")+ return &diag+ }++ diag.Summary = report.Summary+ diag.Daily = report.Daily+ diag.Paths = report.Paths+ diag.Platforms = report.Platforms++ totalSignal := report.Summary.Opened ++ report.Summary.APIPathSelected ++ report.Summary.AgentPathSelected ++ report.Summary.ProbeDetected ++ report.Summary.ProbeNoMatch ++ report.Summary.ProbeError ++ report.Summary.CatalogSelected ++ report.Summary.CredentialsOpened++ switch {+ case totalSignal == 0:+ diag.Status = "idle"+ diag.Notes = append(diag.Notes, "No infrastructure onboarding activity was recorded in the last 30 days.")+ case report.Summary.Opened > 0 && report.Summary.CredentialsOpened == 0:+ diag.Status = "warning"+ diag.Notes = append(diag.Notes, "Infrastructure onboarding sessions are not reaching credential handoff in the current window.")+ case report.Summary.ProbeNoMatch > report.Summary.ProbeDetected:+ diag.Status = "warning"+ diag.Notes = append(diag.Notes, "More probed addresses miss than detect a supported API-backed platform in the current window.")+ case report.Summary.CredentialsOpened > 0:+ diag.Status = "active"+ diag.Notes = append(diag.Notes, "Infrastructure onboarding reached at least one credential handoff in the current window.")+ default:+ diag.Status = "active"+ }++ if report.Summary.ProbeNoMatch > 0 {+ diag.Notes = append(diag.Notes, "Some probed addresses did not match a supported API-backed platform.")+ }+ if report.Summary.Opened > report.Summary.CredentialsOpened && report.Summary.CredentialsOpened > 0 {+ diag.Notes = append(diag.Notes, "Some onboarding sessions drop before credentials open.")+ }+ if report.Summary.AgentPathSelected > 0 && report.Summary.APIPathSelected == 0 {+ diag.Notes = append(diag.Notes, "Current onboarding activity is exclusively using the agent path.")+ }++ return &diag+}+const diagnosticsCacheTTL = 45 * time.Secondconst commercialFunnelDiagnosticsWindowDays = 30+const infrastructureOnboardingDiagnosticsWindowDays = 30type cachedDiagnosticsEntry struct {diag DiagnosticsInfo@@ -896,6 +1005,7 @@ func (r *Router) computeDiagnostics(ctx context.Context) DiagnosticsInfo {diag.APITokens = buildAPITokenDiagnostic(r.config, r.monitor)diag.MetricsStore = buildMetricsStoreDiagnostic(r.monitor)diag.CommercialFunnel = buildCommercialFunnelDiagnostic(ctx, r.conversionStore, time.Now().UTC())+ diag.InfrastructureOnboarding = buildInfrastructureOnboardingDiagnostic(ctx, r.conversionStore, time.Now().UTC())// Test each configured nodefor _, node := range r.config.PVEInstances {diff --git a/internal/api/diagnostics_additional_test.go b/internal/api/diagnostics_additional_test.goindex 3c02a048cc..9cd958ab3a 100644--- a/internal/api/diagnostics_additional_test.go+++ b/internal/api/diagnostics_additional_test.go@@ -212,6 +212,9 @@ func TestComputeDiagnostics_Basic(t *testing.T) {if diag.CommercialFunnel == nil {t.Fatalf("expected commercial funnel diagnostics")}+ if diag.InfrastructureOnboarding == nil {+ t.Fatalf("expected infrastructure onboarding diagnostics")+ }if diag.APITokens == nil {t.Fatalf("expected api token diagnostics")}@@ -293,6 +296,88 @@ func TestComputeDiagnostics_CommercialFunnelUsesOrgScopedConversionReport(t *tes}}+func TestComputeDiagnostics_InfrastructureOnboardingUsesOrgScopedReport(t *testing.T) {+ cfg := &config.Config{DataPath: t.TempDir()}+ monitor := newMonitorForDiagnostics(t, cfg)+ store, err := pkglicensing.NewConversionStore(filepath.Join(t.TempDir(), "conversion.db"))+ if err != nil {+ t.Fatalf("NewConversionStore() error = %v", err)+ }+ defer store.Close()++ base := time.Now().UTC().Truncate(time.Hour).Add(-6 * time.Hour)+ for _, event := range []pkglicensing.StoredConversionEvent{+ {+ OrgID: "org-a",+ EventType: pkglicensing.EventInfrastructureOnboardingOpened,+ Surface: "settings_infrastructure_add",+ IdempotencyKey: "org-a:opened",+ CreatedAt: base,+ },+ {+ OrgID: "org-a",+ EventType: pkglicensing.EventInfrastructureOnboardingPathSelected,+ Surface: "settings_infrastructure_add",+ Capability: "api",+ IdempotencyKey: "org-a:path",+ CreatedAt: base.Add(time.Hour),+ },+ {+ OrgID: "org-a",+ EventType: pkglicensing.EventInfrastructureOnboardingProbeResult,+ Surface: "settings_infrastructure_add",+ Capability: "no-match",+ IdempotencyKey: "org-a:probe",+ CreatedAt: base.Add(2 * time.Hour),+ },+ {+ OrgID: "org-a",+ EventType: pkglicensing.EventInfrastructureOnboardingCredentialsOpened,+ Surface: "settings_infrastructure_add",+ Capability: "agent",+ IdempotencyKey: "org-a:credentials",+ CreatedAt: base.Add(3 * time.Hour),+ },+ {+ OrgID: "org-b",+ EventType: pkglicensing.EventInfrastructureOnboardingOpened,+ Surface: "settings_infrastructure_add",+ IdempotencyKey: "org-b:opened",+ CreatedAt: base,+ },+ } {+ if err := store.Record(event); err != nil {+ t.Fatalf("Record(%s) error = %v", event.IdempotencyKey, err)+ }+ }++ router := &Router{config: cfg, monitor: monitor, conversionStore: store}+ ctx := context.WithValue(context.Background(), OrgIDContextKey, "org-a")+ diag := router.computeDiagnostics(ctx)++ if diag.InfrastructureOnboarding == nil {+ t.Fatalf("expected infrastructure onboarding diagnostics")+ }+ if diag.InfrastructureOnboarding.Summary.Opened != 1 {+ t.Fatalf("Opened = %d, want 1", diag.InfrastructureOnboarding.Summary.Opened)+ }+ if diag.InfrastructureOnboarding.Summary.APIPathSelected != 1 {+ t.Fatalf("APIPathSelected = %d, want 1", diag.InfrastructureOnboarding.Summary.APIPathSelected)+ }+ if diag.InfrastructureOnboarding.Summary.ProbeNoMatch != 1 {+ t.Fatalf("ProbeNoMatch = %d, want 1", diag.InfrastructureOnboarding.Summary.ProbeNoMatch)+ }+ if diag.InfrastructureOnboarding.Summary.CredentialsOpened != 1 {+ t.Fatalf("CredentialsOpened = %d, want 1", diag.InfrastructureOnboarding.Summary.CredentialsOpened)+ }+ if len(diag.InfrastructureOnboarding.Paths) == 0 || diag.InfrastructureOnboarding.Paths[0].Key != "api" {+ t.Fatalf("unexpected path breakdown: %+v", diag.InfrastructureOnboarding.Paths)+ }+ if diag.InfrastructureOnboarding.Status != "warning" {+ t.Fatalf("Status = %q, want warning", diag.InfrastructureOnboarding.Status)+ }+}+func TestBuildAPITokenDiagnostic_WithDockerUsage(t *testing.T) {now := time.Now()lastUsed := now.Add(-time.Hour)diff --git a/internal/api/diagnostics_contract_test.go b/internal/api/diagnostics_contract_test.gonew file mode 100644index 0000000000..b3bb6b2ed3--- /dev/null+++ b/internal/api/diagnostics_contract_test.go@@ -0,0 +1,67 @@+package api++import (+ "encoding/json"+ "testing"+ "time"+)++func TestContract_DiagnosticsInfoInfrastructureOnboardingJSONSnapshot(t *testing.T) {+ payload := EmptyDiagnosticsInfo()+ infrastructureOnboarding := (&InfrastructureOnboardingDiagnostic{+ Enabled: true,+ Status: "idle",+ WindowDays: 30,+ Summary: conversionInfrastructureOnboardingSummary{+ Period: struct {+ From time.Time `json:"from"`+ To time.Time `json:"to"`+ }{+ From: time.Date(2026, 4, 1, 0, 0, 0, 0, time.UTC),+ To: time.Date(2026, 5, 1, 0, 0, 0, 0, time.UTC),+ },+ },+ }).NormalizeCollections()+ payload.InfrastructureOnboarding = &infrastructureOnboarding++ got, err := json.Marshal(payload.NormalizeCollections())+ if err != nil {+ t.Fatalf("marshal diagnostics onboarding info: %v", err)+ }++ const want = `{+ "version":"",+ "runtime":"",+ "uptime":0,+ "nodes":[],+ "pbs":[],+ "system":{"os":"","arch":"","goVersion":"","numCPU":0,"numGoroutine":0,"memoryMB":0},+ "infrastructureOnboarding":{+ "enabled":true,+ "status":"idle",+ "windowDays":30,+ "summary":{+ "opened":0,+ "api_path_selected":0,+ "agent_path_selected":0,+ "probe_detected":0,+ "probe_no_match":0,+ "probe_error":0,+ "catalog_selected":0,+ "credentials_opened":0,+ "period":{"from":"2026-04-01T00:00:00Z","to":"2026-05-01T00:00:00Z"}+ },+ "daily":[],+ "paths":[],+ "platforms":[],+ "notes":[]+ },+ "errors":[],+ "nodeSnapshots":[],+ "guestSnapshots":[],+ "memorySources":[],+ "memorySourceBreakdown":[]+ }`++ assertJSONSnapshot(t, got, want)+}diff --git a/internal/api/licensing_bridge.go b/internal/api/licensing_bridge.goindex 2745842134..c2c78897a9 100644--- a/internal/api/licensing_bridge.go+++ b/internal/api/licensing_bridge.go@@ -60,6 +60,12 @@ type conversionFunnelSummary = pkglicensing.FunnelSummarytype conversionFunnelDayBreakdown = pkglicensing.FunnelDayBreakdowntype conversionFunnelDimensionBreakdown = pkglicensing.FunnelDimensionBreakdowntype conversionFunnelReport = pkglicensing.FunnelReport+type conversionInfrastructureOnboardingStageCounts = pkglicensing.InfrastructureOnboardingStageCounts+type conversionInfrastructureOnboardingSummary = pkglicensing.InfrastructureOnboardingSummary+type conversionInfrastructureOnboardingDayBreakdown = pkglicensing.InfrastructureOnboardingDayBreakdown+type conversionInfrastructureOnboardingPathBreakdown = pkglicensing.InfrastructureOnboardingPathBreakdown+type conversionInfrastructureOnboardingPlatformBreakdown = pkglicensing.InfrastructureOnboardingPlatformBreakdown+type conversionInfrastructureOnboardingReport = pkglicensing.InfrastructureOnboardingReporttype trialActivationClaimsModel = pkglicensing.TrialActivationClaimstype purchaseReturnClaimsModel = pkglicensing.PurchaseReturnClaimstype entitlementLeaseClaimsModel = pkglicensing.EntitlementLeaseClaimsdiff --git a/pkg/licensing/conversion_store.go b/pkg/licensing/conversion_store.goindex fe18af48c5..303a5d6c4b 100644--- a/pkg/licensing/conversion_store.go+++ b/pkg/licensing/conversion_store.go@@ -71,6 +71,64 @@ type FunnelReport struct {Capabilities []FunnelDimensionBreakdown `json:"capabilities"`}+type InfrastructureOnboardingStageCounts struct {+ Opened int64 `json:"opened"`+ APIPathSelected int64 `json:"api_path_selected"`+ AgentPathSelected int64 `json:"agent_path_selected"`+ ProbeDetected int64 `json:"probe_detected"`+ ProbeNoMatch int64 `json:"probe_no_match"`+ ProbeError int64 `json:"probe_error"`+ CatalogSelected int64 `json:"catalog_selected"`+ CredentialsOpened int64 `json:"credentials_opened"`+}++type InfrastructureOnboardingSummary struct {+ InfrastructureOnboardingStageCounts+ Period struct {+ From time.Time `json:"from"`+ To time.Time `json:"to"`+ } `json:"period"`+}++type InfrastructureOnboardingDayBreakdown struct {+ Day string `json:"day"`+ InfrastructureOnboardingStageCounts+}++type InfrastructureOnboardingPathBreakdown struct {+ Key string `json:"key"`+ Count int64 `json:"count"`+}++type InfrastructureOnboardingPlatformBreakdown struct {+ Key string `json:"key"`+ CatalogSelected int64 `json:"catalog_selected"`+ CredentialsOpened int64 `json:"credentials_opened"`+}++type InfrastructureOnboardingReport struct {+ Summary InfrastructureOnboardingSummary `json:"summary"`+ Daily []InfrastructureOnboardingDayBreakdown `json:"daily"`+ Paths []InfrastructureOnboardingPathBreakdown `json:"paths"`+ Platforms []InfrastructureOnboardingPlatformBreakdown `json:"platforms"`+}++var infrastructureOnboardingEventTypes = []string{+ EventInfrastructureOnboardingOpened,+ EventInfrastructureOnboardingPathSelected,+ EventInfrastructureOnboardingProbeResult,+ EventInfrastructureOnboardingCatalogSelected,+ EventInfrastructureOnboardingCredentialsOpened,+}++var infrastructureOnboardingPlatformCapabilities = map[string]struct{}{+ "vmware": {},+ "truenas": {},+ "pve": {},+ "pbs": {},+ "pmg": {},+}+func applyFunnelStageCount(counts *FunnelStageCounts, eventType string, count int64) {if counts == nil {return@@ -129,6 +187,90 @@ func compareFunnelBreakdowns(a, b FunnelDimensionBreakdown) int {}}+func applyInfrastructureOnboardingStageCount(+ counts *InfrastructureOnboardingStageCounts,+ eventType string,+ capability string,+ count int64,+) {+ if counts == nil {+ return+ }++ switch strings.TrimSpace(eventType) {+ case EventInfrastructureOnboardingOpened:+ counts.Opened += count+ case EventInfrastructureOnboardingPathSelected:+ switch strings.TrimSpace(capability) {+ case "api":+ counts.APIPathSelected += count+ case "agent":+ counts.AgentPathSelected += count+ }+ case EventInfrastructureOnboardingProbeResult:+ switch strings.TrimSpace(capability) {+ case "detected":+ counts.ProbeDetected += count+ case "no-match":+ counts.ProbeNoMatch += count+ case "error":+ counts.ProbeError += count+ }+ case EventInfrastructureOnboardingCatalogSelected:+ counts.CatalogSelected += count+ case EventInfrastructureOnboardingCredentialsOpened:+ counts.CredentialsOpened += count+ }+}++func compareInfrastructureOnboardingPathBreakdowns(+ a,+ b InfrastructureOnboardingPathBreakdown,+) int {+ switch {+ case a.Count != b.Count:+ if a.Count > b.Count {+ return -1+ }+ return 1+ case a.Key < b.Key:+ return -1+ case a.Key > b.Key:+ return 1+ default:+ return 0+ }+}++func compareInfrastructureOnboardingPlatformBreakdowns(+ a,+ b InfrastructureOnboardingPlatformBreakdown,+) int {+ switch {+ case a.CredentialsOpened != b.CredentialsOpened:+ if a.CredentialsOpened > b.CredentialsOpened {+ return -1+ }+ return 1+ case a.CatalogSelected != b.CatalogSelected:+ if a.CatalogSelected > b.CatalogSelected {+ return -1+ }+ return 1+ case a.Key < b.Key:+ return -1+ case a.Key > b.Key:+ return 1+ default:+ return 0+ }+}++func isInfrastructureOnboardingPlatformCapability(capability string) bool {+ _, ok := infrastructureOnboardingPlatformCapabilities[strings.TrimSpace(capability)]+ return ok+}+func ensureOwnerOnlyDir(dir string) error {return securityutil.EnsureSecureStorageDir(dir, privateDirPerm)}@@ -560,7 +702,7 @@ func (s *ConversionStore) FunnelDimensionBreakdown(orgID string, from, to time.T}}()- buckets := make(map[string]*FunnelDimensionBreakdown)+ buckets := make(map[string]int)for rows.Next() {var key stringvar eventType string@@ -572,13 +714,13 @@ func (s *ConversionStore) FunnelDimensionBreakdown(orgID string, from, to time.Tif key == "" {continue}- entry, ok := buckets[key]+ entryIndex, ok := buckets[key]if !ok {breakdown = append(breakdown, FunnelDimensionBreakdown{Key: key})- entry = &breakdown[len(breakdown)-1]- buckets[key] = entry+ entryIndex = len(breakdown) - 1+ buckets[key] = entryIndex}- applyFunnelStageCount(&entry.FunnelStageCounts, eventType, count)+ applyFunnelStageCount(&breakdown[entryIndex].FunnelStageCounts, eventType, count)}if err := rows.Err(); err != nil {return nil, fmt.Errorf("failed to iterate funnel %s rows: %w", dimension, err)@@ -617,6 +759,117 @@ func (s *ConversionStore) FunnelReport(orgID string, from, to time.Time) (*Funne}, nil}+func (s *ConversionStore) InfrastructureOnboardingReport(+ orgID string,+ from,+ to time.Time,+) (*InfrastructureOnboardingReport, error) {+ if s == nil || s.db == nil {+ return nil, fmt.Errorf("conversion store is not initialized")+ }+ if from.IsZero() || to.IsZero() {+ return nil, fmt.Errorf("from/to are required")+ }++ orgID = strings.TrimSpace(orgID)+ if orgID == "" {+ return nil, fmt.Errorf("org_id is required")+ }++ startDay := from.UTC().Truncate(24 * time.Hour)+ endDay := to.UTC().Truncate(24 * time.Hour)+ if !to.UTC().Equal(endDay) {+ endDay = endDay.Add(24 * time.Hour)+ }++ report := &InfrastructureOnboardingReport{}+ report.Summary.Period.From = from.UTC()+ report.Summary.Period.To = to.UTC()++ dayBuckets := make(map[string]*InfrastructureOnboardingDayBreakdown)+ if startDay.Before(endDay) {+ report.Daily = make([]InfrastructureOnboardingDayBreakdown, 0, int(endDay.Sub(startDay)/(24*time.Hour)))+ for day := startDay; day.Before(endDay); day = day.Add(24 * time.Hour) {+ entry := InfrastructureOnboardingDayBreakdown{Day: day.Format("2006-01-02")}+ report.Daily = append(report.Daily, entry)+ dayBuckets[entry.Day] = &report.Daily[len(report.Daily)-1]+ }+ }++ pathBuckets := make(map[string]int)+ platformBuckets := make(map[string]int)++ recordEvent := func(event StoredConversionEvent) {+ capability := strings.TrimSpace(event.Capability)+ applyInfrastructureOnboardingStageCount(+ &report.Summary.InfrastructureOnboardingStageCounts,+ event.EventType,+ capability,+ 1,+ )++ dayKey := event.CreatedAt.UTC().Format("2006-01-02")+ if dayEntry := dayBuckets[dayKey]; dayEntry != nil {+ applyInfrastructureOnboardingStageCount(+ &dayEntry.InfrastructureOnboardingStageCounts,+ event.EventType,+ capability,+ 1,+ )+ }++ if event.EventType == EventInfrastructureOnboardingPathSelected && capability != "" {+ entryIndex, ok := pathBuckets[capability]+ if !ok {+ report.Paths = append(report.Paths, InfrastructureOnboardingPathBreakdown{Key: capability})+ entryIndex = len(report.Paths) - 1+ pathBuckets[capability] = entryIndex+ }+ report.Paths[entryIndex].Count+++ }++ if !isInfrastructureOnboardingPlatformCapability(capability) {+ return+ }+ if event.EventType != EventInfrastructureOnboardingCatalogSelected &&+ event.EventType != EventInfrastructureOnboardingCredentialsOpened {+ return+ }++ entryIndex, ok := platformBuckets[capability]+ if !ok {+ report.Platforms = append(report.Platforms, InfrastructureOnboardingPlatformBreakdown{Key: capability})+ entryIndex = len(report.Platforms) - 1+ platformBuckets[capability] = entryIndex+ }+ switch event.EventType {+ case EventInfrastructureOnboardingCatalogSelected:+ report.Platforms[entryIndex].CatalogSelected+++ case EventInfrastructureOnboardingCredentialsOpened:+ report.Platforms[entryIndex].CredentialsOpened+++ }+ }++ for _, eventType := range infrastructureOnboardingEventTypes {+ events, err := s.Query(orgID, from, to, eventType)+ if err != nil {+ return nil, err+ }+ for _, event := range events {+ recordEvent(event)+ }+ }++ sort.SliceStable(report.Paths, func(i, j int) bool {+ return compareInfrastructureOnboardingPathBreakdowns(report.Paths[i], report.Paths[j]) < 0+ })+ sort.SliceStable(report.Platforms, func(i, j int) bool {+ return compareInfrastructureOnboardingPlatformBreakdowns(report.Platforms[i], report.Platforms[j]) < 0+ })++ return report, nil+}+func (s *ConversionStore) Close() error {if s == nil || s.db == nil {return nildiff --git a/pkg/licensing/conversion_store_onboarding_report_test.go b/pkg/licensing/conversion_store_onboarding_report_test.gonew file mode 100644index 0000000000..37a64aa34b--- /dev/null+++ b/pkg/licensing/conversion_store_onboarding_report_test.go@@ -0,0 +1,211 @@+package licensing++import (+ "path/filepath"+ "testing"+ "time"+)++func TestConversionStoreInfrastructureOnboardingReport(t *testing.T) {+ store, err := NewConversionStore(filepath.Join(t.TempDir(), "conversion.db"))+ if err != nil {+ t.Fatalf("NewConversionStore() error = %v", err)+ }+ defer store.Close()++ windowStart := time.Date(2026, 4, 20, 0, 0, 0, 0, time.UTC)+ windowEnd := windowStart.Add(48 * time.Hour)++ for _, event := range []StoredConversionEvent{+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingOpened,+ Surface: "settings_infrastructure_add",+ IdempotencyKey: "org-a:opened:1",+ CreatedAt: windowStart.Add(2 * time.Hour),+ },+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingPathSelected,+ Surface: "settings_infrastructure_add",+ Capability: "api",+ IdempotencyKey: "org-a:path:api",+ CreatedAt: windowStart.Add(2*time.Hour + time.Minute),+ },+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingProbeResult,+ Surface: "settings_infrastructure_add",+ Capability: "no-match",+ IdempotencyKey: "org-a:probe:no-match",+ CreatedAt: windowStart.Add(2*time.Hour + 2*time.Minute),+ },+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingPathSelected,+ Surface: "settings_infrastructure_add",+ Capability: "agent",+ IdempotencyKey: "org-a:path:agent",+ CreatedAt: windowStart.Add(2*time.Hour + 3*time.Minute),+ },+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingCredentialsOpened,+ Surface: "settings_infrastructure_add",+ Capability: "agent",+ IdempotencyKey: "org-a:credentials:agent",+ CreatedAt: windowStart.Add(2*time.Hour + 4*time.Minute),+ },+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingOpened,+ Surface: "settings_infrastructure_add",+ IdempotencyKey: "org-a:opened:2",+ CreatedAt: windowStart.Add(26 * time.Hour),+ },+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingPathSelected,+ Surface: "settings_infrastructure_add",+ Capability: "api",+ IdempotencyKey: "org-a:path:api:2",+ CreatedAt: windowStart.Add(26*time.Hour + time.Minute),+ },+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingProbeResult,+ Surface: "settings_infrastructure_add",+ Capability: "detected",+ IdempotencyKey: "org-a:probe:detected",+ CreatedAt: windowStart.Add(26*time.Hour + 2*time.Minute),+ },+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingCatalogSelected,+ Surface: "settings_infrastructure_add",+ Capability: "truenas",+ IdempotencyKey: "org-a:catalog:truenas",+ CreatedAt: windowStart.Add(26*time.Hour + 3*time.Minute),+ },+ {+ OrgID: "org-a",+ EventType: EventInfrastructureOnboardingCredentialsOpened,+ Surface: "settings_infrastructure_add",+ Capability: "truenas",+ IdempotencyKey: "org-a:credentials:truenas",+ CreatedAt: windowStart.Add(26*time.Hour + 4*time.Minute),+ },+ {+ OrgID: "org-b",+ EventType: EventInfrastructureOnboardingOpened,+ Surface: "settings_infrastructure_add",+ IdempotencyKey: "org-b:opened:1",+ CreatedAt: windowStart.Add(2 * time.Hour),+ },+ } {+ if err := store.Record(event); err != nil {+ t.Fatalf("Record(%s) error = %v", event.IdempotencyKey, err)+ }+ }++ report, err := store.InfrastructureOnboardingReport("org-a", windowStart, windowEnd)+ if err != nil {+ t.Fatalf("InfrastructureOnboardingReport() error = %v", err)+ }++ if report.Summary.Opened != 2 {+ t.Fatalf("Opened = %d, want 2", report.Summary.Opened)+ }+ if report.Summary.APIPathSelected != 2 {+ t.Fatalf("APIPathSelected = %d, want 2", report.Summary.APIPathSelected)+ }+ if report.Summary.AgentPathSelected != 1 {+ t.Fatalf("AgentPathSelected = %d, want 1", report.Summary.AgentPathSelected)+ }+ if report.Summary.ProbeNoMatch != 1 || report.Summary.ProbeDetected != 1 {+ t.Fatalf("unexpected probe summary: %+v", report.Summary.InfrastructureOnboardingStageCounts)+ }+ if report.Summary.CatalogSelected != 1 {+ t.Fatalf("CatalogSelected = %d, want 1", report.Summary.CatalogSelected)+ }+ if report.Summary.CredentialsOpened != 2 {+ t.Fatalf("CredentialsOpened = %d, want 2", report.Summary.CredentialsOpened)+ }++ if len(report.Daily) != 2 {+ t.Fatalf("len(Daily) = %d, want 2", len(report.Daily))+ }+ if report.Daily[0].ProbeNoMatch != 1 || report.Daily[1].ProbeDetected != 1 {+ t.Fatalf("unexpected daily breakdown: %+v", report.Daily)+ }++ if len(report.Paths) != 2 {+ t.Fatalf("len(Paths) = %d, want 2", len(report.Paths))+ }+ if report.Paths[0].Key != "api" || report.Paths[0].Count != 2 {+ t.Fatalf("unexpected path ranking: %+v", report.Paths)+ }++ if len(report.Platforms) != 1 {+ t.Fatalf("len(Platforms) = %d, want 1", len(report.Platforms))+ }+ if report.Platforms[0].Key != "truenas" ||+ report.Platforms[0].CatalogSelected != 1 ||+ report.Platforms[0].CredentialsOpened != 1 {+ t.Fatalf("unexpected platform breakdown: %+v", report.Platforms)+ }+}++func TestConversionStoreFunnelDimensionBreakdownAccumulatesAcrossMultipleKeys(t *testing.T) {+ store, err := NewConversionStore(filepath.Join(t.TempDir(), "conversion.db"))+ if err != nil {+ t.Fatalf("NewConversionStore() error = %v", err)+ }+ defer store.Close()++ windowStart := time.Date(2026, 4, 20, 0, 0, 0, 0, time.UTC)+ windowEnd := windowStart.Add(24 * time.Hour)++ for _, event := range []StoredConversionEvent{+ {+ OrgID: "org-a",+ EventType: EventCheckoutClicked,+ Surface: "settings_self_hosted_billing_compare_prompt",+ IdempotencyKey: "org-a:checkout:1",+ CreatedAt: windowStart.Add(time.Hour),+ },+ {+ OrgID: "org-a",+ EventType: EventPricingViewed,+ Surface: "settings_self_hosted_billing_plan",+ IdempotencyKey: "org-a:pricing:1",+ CreatedAt: windowStart.Add(2 * time.Hour),+ },+ {+ OrgID: "org-a",+ EventType: EventCheckoutClicked,+ Surface: "settings_self_hosted_billing_compare_prompt",+ IdempotencyKey: "org-a:checkout:2",+ CreatedAt: windowStart.Add(3 * time.Hour),+ },+ } {+ if err := store.Record(event); err != nil {+ t.Fatalf("Record(%s) error = %v", event.IdempotencyKey, err)+ }+ }++ breakdown, err := store.FunnelDimensionBreakdown("org-a", windowStart, windowEnd, "surface")+ if err != nil {+ t.Fatalf("FunnelDimensionBreakdown() error = %v", err)+ }++ if len(breakdown) != 2 {+ t.Fatalf("len(breakdown) = %d, want 2", len(breakdown))+ }+ if breakdown[0].Key != "settings_self_hosted_billing_compare_prompt" || breakdown[0].CheckoutClicked != 2 {+ t.Fatalf("unexpected primary breakdown entry: %+v", breakdown)+ }+ if breakdown[1].Key != "settings_self_hosted_billing_plan" || breakdown[1].PricingViewed != 1 {+ t.Fatalf("unexpected secondary breakdown entry: %+v", breakdown)+ }+}