Initial commit: StackPilot - Docker stack builder with 186 apps, compose analyser, analytics

This commit is contained in:
2026-08-03 23:28:15 +01:00
commit 341700ddac
18 changed files with 5042 additions and 0 deletions

37
src/utils/analytics.js Normal file
View File

@@ -0,0 +1,37 @@
// Lightweight analytics — tracks app selection popularity
// Uses a simple JSON API. Replace the URL with your own backend.
const ANALYTICS_URL = '/api/analytics';
/**
* Record which apps were included in a downloaded bundle.
* Fires on download — not on selection (avoids noise).
*/
export async function trackDownload(selectedAppIds) {
try {
await fetch(`${ANALYTICS_URL}/download`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
apps: selectedAppIds,
timestamp: new Date().toISOString(),
}),
});
} catch (e) {
// Silent fail — analytics should never break the app
}
}
/**
* Fetch popularity stats (app download counts).
* Returns: { [appId]: count }
*/
export async function fetchPopularity() {
try {
const res = await fetch(`${ANALYTICS_URL}/popularity`);
if (res.ok) return await res.json();
} catch (e) {
// Silent fail
}
return null;
}