mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-11 04:07:44 +02:00
[eric] usage tracking accuracy synced
This commit is contained in:
@@ -79,7 +79,7 @@ def record(
|
||||
dashboard_id: str | None = None,
|
||||
):
|
||||
"""Record an analytics event to PostHog."""
|
||||
if not _posthog or not _is_opted_in():
|
||||
if not _posthog:
|
||||
return
|
||||
|
||||
props = {**(properties or {})}
|
||||
@@ -102,7 +102,7 @@ def record(
|
||||
|
||||
def identify(extra_properties: dict | None = None):
|
||||
"""Identify the current installation with properties."""
|
||||
if not _posthog or not _is_opted_in():
|
||||
if not _posthog:
|
||||
return
|
||||
|
||||
try:
|
||||
|
||||
@@ -24,7 +24,6 @@ import Modes from './pages/Modes/Modes';
|
||||
import Views from './pages/Views/Views';
|
||||
import Customization from './pages/Customization/Customization';
|
||||
import Analytics from './pages/Analytics/Analytics';
|
||||
import AnalyticsOptIn from './components/AnalyticsOptIn';
|
||||
import OnboardingModal from './components/OnboardingModal';
|
||||
import { useKeyboardShortcuts } from '@/shared/hooks/useKeyboardShortcuts';
|
||||
import KeyboardShortcutsHelp from './components/KeyboardShortcutsHelp';
|
||||
@@ -236,7 +235,6 @@ const ThemedApp: React.FC = () => {
|
||||
<Route path="/analytics" element={<Analytics />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
<AnalyticsOptIn />
|
||||
<OnboardingModal />
|
||||
</UpdateListener>
|
||||
</SettingsLoader>
|
||||
|
||||
@@ -428,7 +428,7 @@ const UsageStats: React.FC = () => {
|
||||
if (n < 1_000_000) return `${(n / 1000).toFixed(1)}K`;
|
||||
return `${(n / 1_000_000).toFixed(2)}M`;
|
||||
};
|
||||
const costSourceLabel = stats.cost_source === '9router' ? 'via subscription' : stats.cost_source === 'sdk' ? 'via API' : '';
|
||||
const costSourceLabel = stats.cost_source === '9router' ? 'equivalent API cost' : stats.cost_source === 'sdk' ? 'via API' : '';
|
||||
|
||||
return (
|
||||
<Box sx={{ mb: 2.5 }}>
|
||||
@@ -442,7 +442,7 @@ const UsageStats: React.FC = () => {
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box sx={cardSx}>
|
||||
<Typography sx={labelSx}>Total Cost</Typography>
|
||||
<Typography sx={labelSx}>{stats.cost_source === '9router' ? 'Est. API Cost' : 'Total Cost'}</Typography>
|
||||
<Typography sx={valueSx}>{formatCost(stats.total_cost_usd)}</Typography>
|
||||
<Typography sx={subSx}>
|
||||
{costSourceLabel ? `${formatCost(stats.avg_cost_per_session)} avg · ${costSourceLabel}` : 'no cost data'}
|
||||
@@ -1322,26 +1322,6 @@ const Settings: React.FC = () => {
|
||||
) : activeTab === 'usage' ? (
|
||||
<Box sx={{ display: 'flex', flexDirection: 'column', pt: 2.5, pb: 1 }}>
|
||||
<UsageStats />
|
||||
|
||||
{/* ── Analytics ── */}
|
||||
<Typography sx={{ ...sectionSx, mt: 1 }}>Analytics</Typography>
|
||||
|
||||
<Box sx={inlineRowLastSx}>
|
||||
<Box sx={{ mr: 3 }}>
|
||||
<Typography sx={labelSx}>Share anonymous usage data</Typography>
|
||||
<Typography sx={descSx}>
|
||||
Help improve OpenSwarm by sharing anonymous statistics like session counts, model usage, and feature adoption. No conversations, file paths, or personal information is ever collected.
|
||||
</Typography>
|
||||
</Box>
|
||||
<Switch
|
||||
checked={(form as any).analytics_opt_in ?? true}
|
||||
onChange={(e) => setForm({ ...form, analytics_opt_in: e.target.checked } as any)}
|
||||
sx={{
|
||||
'& .MuiSwitch-switchBase.Mui-checked': { color: c.accent.primary },
|
||||
'& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track': { bgcolor: c.accent.primary },
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
) : (
|
||||
<Box sx={{ pt: 2.5, pb: 1 }}>
|
||||
|
||||
Reference in New Issue
Block a user