Tracking
Refreshed cached files
This commit is contained in:
fraxle
2026-06-07 10:50:42 +01:00
parent 1a69994833
commit a9d53eff46
7 changed files with 328 additions and 5 deletions
+13
View File
@@ -36,6 +36,16 @@ import { useColumnPopup } from './useColumnPopup.js';
import { useTableScroll } from './useTableScroll.js';
import { getActiveEvents, getLensEvent } from '../events.js';
function track(event, profile) {
try {
fetch('track.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(profile ? { event, profile } : { event }),
}).catch(() => {});
} catch (e) { /* ignore */ }
}
export function useAppState() {
// ── 1. LOCATION ──────────────────────────────────────────────────────
@@ -66,6 +76,8 @@ export function useAppState() {
const { forecast, airQuality, loading, error, now, fetchedAt, liveElev } = useForecast(location, isPro);
useEffect(() => { track('visit'); }, []);
const [searchQuery, setSearchQuery] = useState('');
const [searchResults, setSearchResults] = useState([]);
const [searching, setSearching] = useState(false);
@@ -150,6 +162,7 @@ export function useAppState() {
const toggleCol = (col) => setVisibleCols(prev => ({ ...prev, [col]: !prev[col] }));
const activateProfile = (key) => {
track('profile', key);
const profile = FILTER_PROFILES[key];
try { localStorage.setItem('sunscope_profile', key); } catch (e) { /* ignore */ }
setActiveProfile(key);