Initial commit

This commit is contained in:
2026-08-07 23:53:15 +05:30
commit 90f14a73b2
222 changed files with 35000 additions and 0 deletions

36
src/lib/userTracking.js Normal file
View File

@@ -0,0 +1,36 @@
import { base44 } from '@/api/base44Client';
let _cachedUser = null;
let _userFetched = false;
async function getCurrentUser() {
if (_userFetched) return _cachedUser;
try {
_cachedUser = await base44.auth.me();
} catch {
_cachedUser = null;
}
_userFetched = true;
return _cachedUser;
}
/** Best-effort activity logging — never throws, never blocks the main flow. */
export async function logActivity(eventType, extra = {}) {
try {
const me = await getCurrentUser();
const record = {
event_type: eventType,
user_email: me?.email || extra.email || 'anonymous',
user_name: me?.full_name || extra.name || '',
account_type: extra.account_type || me?.account_type || 'unknown',
details: extra.details || '',
};
await base44.entities.UserActivity.create(record);
base44.analytics.track({
eventName: eventType,
properties: { account_type: record.account_type },
});
} catch {
// silent — tracking must not break user flows
}
}