Upload Error Handling (v3.2.0)
Key Changes
All HTTP 4xx errors resulting in a rejected upload have been unified into uploadTrackingTerminated.
- The following cases are now deprecated and will no longer be triggered:
uploadBadRequest,uploadUnauthorized,uploadForbidden,uploadNotFound,uploadTooLarge,uploadUnprocessable. uploadFailedanduploadServerErrorremain unchanged.
Trigger Conditions
This error occurs when the server returns a 4xx response to an audio data upload, indicating that the session is no longer valid.
Common Scenarios:
- Duplicate Session: A new session is started with the same
user_idon a different device. - Duration Timeout: The tracking session exceeds the maximum limit of 24 hours.
Implementation
The SDK automatically handles session closure and stops recording. Your app only needs to manage the UI transition within the didFail callback.
func didFail(error: Asleep.AsleepError) {
switch error {
case .uploadTrackingTerminated(let msg):
// Example msg: "Upload failed with HTTP 403: Session already closed"
showAlert("Sleep tracking has ended.")
navigateToResult()
case .uploadServerError:
break
default:
break
}
}Important Notes
- Remove Manual Termination: If your existing code calls
stopTracking()upon receiving an upload error, please remove it. Duplicate calls may cause unnecessary errors as the SDK now manages termination automatically. - Restarting Sessions: To resume tracking after this error, you must initialize a completely new session.
- Deprecated Cases: While deprecated cases still exist in the enum, they are no longer dispatched by the SDK.
Would you like me to help you draft an announcement email for your developers regarding these changes?
Updated about 15 hours ago
