managarten/apps-archived/memoro/apps/mobile/features/memos/config/realtimeConfig.ts
Till-JS 61d181fbc2 chore: archive inactive projects to apps-archived/
Move inactive projects out of active workspace:
- bauntown (community website)
- maerchenzauber (AI story generation)
- memoro (voice memo app)
- news (news aggregation)
- nutriphi (nutrition tracking)
- reader (reading app)
- uload (URL shortener)
- wisekeep (AI wisdom extraction)

Update CLAUDE.md documentation:
- Add presi to active projects
- Document archived projects section
- Update workspace configuration

Archived apps can be re-activated by moving back to apps/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 07:03:59 +01:00

90 lines
2.8 KiB
TypeScript

/**
* Feature flags for Realtime subscription migration
* Controls the gradual rollout from direct subscriptions to centralized service
*/
// Environment variable control for feature flags
const getEnvFlag = (key: string, defaultValue: boolean = false): boolean => {
const envValue = process.env[key];
if (envValue === undefined) return defaultValue;
return envValue.toLowerCase() === 'true';
};
export const RealtimeConfig = {
/**
* Use centralized MemoRealtimeService instead of direct Supabase subscriptions
* Can be overridden per environment
*/
USE_CENTRALIZED_REALTIME: getEnvFlag('EXPO_PUBLIC_USE_CENTRALIZED_REALTIME', false),
/**
* Enable DirectMemoTitle migration to centralized service
* When false, uses original DirectMemoTitle implementation
* When true, uses centralized service via useDirectMemoTitle hook
*/
MIGRATE_DIRECT_MEMO_TITLE: getEnvFlag('EXPO_PUBLIC_MIGRATE_DIRECT_MEMO_TITLE', true),
/**
* Development and debugging flags
*/
DEBUG_REALTIME_CONNECTIONS: getEnvFlag('EXPO_PUBLIC_DEBUG_REALTIME_CONNECTIONS', false),
/**
* Gradual rollout percentages (0-100)
* Used for A/B testing the migration
*/
MIGRATION_ROLLOUT_PERCENTAGE: parseInt(
process.env.EXPO_PUBLIC_MIGRATION_ROLLOUT_PERCENTAGE || '0',
10
),
/**
* Check if a specific user should use the new implementation
* Based on rollout percentage (simple hash-based distribution)
*/
shouldUseCentralizedRealtime: (userId?: string): boolean => {
// If feature flag is explicitly set, use that
if (process.env.EXPO_PUBLIC_USE_CENTRALIZED_REALTIME !== undefined) {
return RealtimeConfig.USE_CENTRALIZED_REALTIME;
}
// If no userId provided, use default
if (!userId) {
return RealtimeConfig.USE_CENTRALIZED_REALTIME;
}
// Simple hash-based rollout
const rolloutPercentage = RealtimeConfig.MIGRATION_ROLLOUT_PERCENTAGE;
if (rolloutPercentage === 0) return false;
if (rolloutPercentage >= 100) return true;
// Create a simple hash from userId
let hash = 0;
for (let i = 0; i < userId.length; i++) {
const char = userId.charCodeAt(i);
hash = (hash << 5) - hash + char;
hash = hash & hash; // Convert to 32-bit integer
}
// Convert hash to percentage (0-99)
const userPercentage = Math.abs(hash) % 100;
return userPercentage < rolloutPercentage;
},
/**
* Log configuration for debugging
*/
logConfig: (): void => {
if (RealtimeConfig.DEBUG_REALTIME_CONNECTIONS) {
console.log('RealtimeConfig:', {
USE_CENTRALIZED_REALTIME: RealtimeConfig.USE_CENTRALIZED_REALTIME,
MIGRATE_DIRECT_MEMO_TITLE: RealtimeConfig.MIGRATE_DIRECT_MEMO_TITLE,
MIGRATION_ROLLOUT_PERCENTAGE: RealtimeConfig.MIGRATION_ROLLOUT_PERCENTAGE,
DEBUG_REALTIME_CONNECTIONS: RealtimeConfig.DEBUG_REALTIME_CONNECTIONS,
});
}
},
};
export default RealtimeConfig;