PluginsAmplitude
Amplitude Error Handlers
Built-in and custom error handling for Amplitude
The Amplitude plugin includes built-in error handlers for common Amplitude API error scenarios.
New to Corsair? Learn about error handling before customizing error handlers.
Full Implementation: See the Amplitude plugin source code.
Built-in Error Handlers
Rate Limit Errors
Triggers: HTTP 429 status
Behavior:
- Maximum retries: 5
- Respects
Retry-Afterheader
Example:
// Corsair handles rate limits automatically
await corsair.amplitude.api.events.upload({
events: [{ event_type: "page_view", user_id: "user-123" }],
});Authentication Errors
Triggers: HTTP 401 status, invalid API key
Behavior:
- Maximum retries: 0 (no retries)
- Fails immediately
How to Fix:
- Verify your Amplitude API key is correct
- Check the key has not been revoked in your Amplitude project settings
- Ensure you're using the correct project's API key
Invalid Request Errors
Triggers: HTTP 400 status, malformed event data
Behavior:
- Maximum retries: 0 (no retries)
How to Fix:
- Verify required fields are present on each event object
- Check event property types match expected formats
- Ensure
user_idordevice_idis present on each event
Network Errors
Triggers: Connection errors, timeouts
Behavior:
- Maximum retries: 3
- Uses exponential backoff
Custom Error Handlers
amplitude({
errorHandlers: {
INVALID_EVENT_SCHEMA: {
match: (error) => {
return error.message.includes("invalid_uploadtime");
},
handler: async (error, context) => {
console.log("Invalid event timestamp detected");
return {
maxRetries: 0,
};
},
},
},
})For comprehensive error handling strategies, patterns, and best practices, see the Error Handling concepts page.