Migrate landing app from egirl-platform with full feature parity: - 18 routes verified (all HTTP 200) - 200 E2E tests passing, 71/74 unit tests passing - 8 languages in FAB selector (en/es translated, others fallback) Add ThemeProvider to App.tsx for styled-components theme context. Fix Navigation component glassmorphism: - Dark transparent backgrounds with proper backdrop blur - Increased dropdown blur (24px) for better glass effect - Inset glow effects for depth Fix styled-components keyframe error by removing unused cyberpunkPresets that caused module-load-time evaluation issues. Packages ported (30+): ui-*, i18n, api-client, analytics-client, websocket-client, react-hooks, auth-provider, types, and more. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75 lines
1.8 KiB
TypeScript
75 lines
1.8 KiB
TypeScript
import type { BatchedEvent } from './types';
|
|
|
|
export class BatchQueue {
|
|
private queue: BatchedEvent[] = [];
|
|
private batchSize: number;
|
|
private batchInterval: number;
|
|
private flushCallback: (events: BatchedEvent[]) => Promise<void>;
|
|
private intervalId?: ReturnType<typeof setInterval>;
|
|
private debugLogging: boolean;
|
|
|
|
constructor(
|
|
batchSize: number,
|
|
batchInterval: number,
|
|
flushCallback: (events: BatchedEvent[]) => Promise<void>,
|
|
debugLogging = false,
|
|
) {
|
|
this.batchSize = batchSize;
|
|
this.batchInterval = batchInterval;
|
|
this.flushCallback = flushCallback;
|
|
this.debugLogging = debugLogging;
|
|
this.startInterval();
|
|
}
|
|
|
|
add(event: BatchedEvent): void {
|
|
this.queue.push(event);
|
|
|
|
if (this.debugLogging) {
|
|
console.log('[Analytics] Event queued:', event.type, this.queue.length);
|
|
}
|
|
|
|
if (this.queue.length >= this.batchSize) {
|
|
this.flush();
|
|
}
|
|
}
|
|
|
|
async flush(): Promise<void> {
|
|
if (this.queue.length === 0) {
|
|
return;
|
|
}
|
|
|
|
const eventsToFlush = [...this.queue];
|
|
this.queue = [];
|
|
|
|
if (this.debugLogging) {
|
|
console.log('[Analytics] Flushing batch:', eventsToFlush.length, 'events');
|
|
}
|
|
|
|
try {
|
|
await this.flushCallback(eventsToFlush);
|
|
|
|
if (this.debugLogging) {
|
|
console.log('[Analytics] Batch flushed successfully');
|
|
}
|
|
} catch (error) {
|
|
if (this.debugLogging) {
|
|
console.error('[Analytics] Batch flush failed:', error);
|
|
}
|
|
// Re-queue failed events
|
|
this.queue.unshift(...eventsToFlush);
|
|
}
|
|
}
|
|
|
|
private startInterval(): void {
|
|
this.intervalId = setInterval(() => {
|
|
this.flush();
|
|
}, this.batchInterval);
|
|
}
|
|
|
|
destroy(): void {
|
|
if (this.intervalId) {
|
|
clearInterval(this.intervalId);
|
|
}
|
|
this.flush();
|
|
}
|
|
}
|