feat: add expo mobile application source code

This commit is contained in:
2026-05-21 16:06:35 +07:00
parent 76d7a5c5c6
commit 0c65a7811b
77 changed files with 20356 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
import { storage } from './storage';
import * as StoreReview from 'expo-store-review';
const ACTIONS_COUNT_KEY = 'user_actions_count';
const LAST_PROMPT_DATE_KEY = 'last_review_prompt_date';
export const ActionTracker = {
/**
* Increment action count and check if we should show review prompt
*/
async trackAction(minActions: number = 10, enabled: boolean = true) {
if (!enabled) return;
try {
const currentCountStr = await storage.get(ACTIONS_COUNT_KEY);
const currentCount = parseInt(currentCountStr || '0', 10) + 1;
await storage.save(ACTIONS_COUNT_KEY, currentCount.toString());
if (currentCount >= minActions) {
const lastPrompt = await storage.get(LAST_PROMPT_DATE_KEY);
const now = new Date().getTime();
// Only prompt once every 30 days
const thirtyDays = 30 * 24 * 60 * 60 * 1000;
if (!lastPrompt || (now - parseInt(lastPrompt, 10)) > thirtyDays) {
if (await StoreReview.isAvailableAsync()) {
await StoreReview.requestReview();
await storage.save(LAST_PROMPT_DATE_KEY, now.toString());
// Reset counter after successful prompt
await storage.save(ACTIONS_COUNT_KEY, '0');
}
}
}
} catch (error) {
console.warn('[ActionTracker] Error:', error);
}
}
};