async function captureWithBackoff(client, options) {
const maxRetries = 5;
for (let attempt = 0; attempt < maxRetries; attempt++) {
const result = await client.capture(options);
if (result.success) return result;
if (result.statusCode !== 429) throw new Error(result.error);
const delay = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s, 8s, 16s
console.log(`Rate limited. Retrying in ${delay}ms...`);
await new Promise(resolve => setTimeout(resolve, delay));
}
throw new Error('Rate limit retry attempts exhausted');
}