async function scheduleWithSmartRetry(webhookUrl: string, payload: any) {
await cuey.schedule({
webhook_url: webhookUrl,
method: "POST",
scheduled_at: new Date(Date.now() + 60000).toISOString(),
payload: payload,
retry_config: {
maxRetries: 5,
backoffMs: 2000,
backoffType: "exponential",
},
});
// Monitor retries
const checkRetries = setInterval(async () => {
const { data: events } = await cuey.events.list({
status: "failed",
});
// Custom retry logic based on event data
events.forEach((event) => {
if (event.response_status === 429) {
// Rate limited - schedule with longer delay
scheduleWithSmartRetry(webhookUrl, payload);
}
});
}, 60000);
}