|
1 | 1 | package com.onesignal.session.internal.outcomes.impl
|
2 | 2 |
|
3 | 3 | import android.os.Process
|
| 4 | +import com.onesignal.common.NetworkUtils |
4 | 5 | import com.onesignal.common.exceptions.BackendException
|
5 | 6 | import com.onesignal.common.threading.suspendifyOnThread
|
6 | 7 | import com.onesignal.core.internal.config.ConfigModelStore
|
@@ -226,18 +227,18 @@ Outcome event was cached and will be reattempted on app cold start""",
|
226 | 227 | // The only case where an actual success has occurred and the OutcomeEvent should be sent back
|
227 | 228 | return OutcomeEvent.fromOutcomeEventParamstoOutcomeEvent(eventParams)
|
228 | 229 | } catch (ex: BackendException) {
|
229 |
| - if (ex.statusCode == HttpURLConnection.HTTP_BAD_REQUEST) { |
230 |
| - Logging.error("400 error sending outcome event, omitting further retries!") |
231 |
| - _outcomeEventsCache.deleteOldOutcomeEvent(eventParams) |
232 |
| - } else { |
233 |
| - Logging.warn( |
234 |
| - """OutcomeEventsController.sendAndCreateOutcomeEvent: Sending outcome with name: $name failed with status code: ${ex.statusCode} and response: ${ex.response} |
235 |
| -Outcome event was cached and will be reattempted on app cold start""", |
236 |
| - ) |
| 230 | + val responseType = NetworkUtils.getResponseStatusType(ex.statusCode) |
| 231 | + val err = "OutcomeEventsController.sendAndCreateOutcomeEvent: Sending outcome with name: $name failed with status code: ${ex.statusCode} and response: ${ex.response}" |
| 232 | + |
| 233 | + if (responseType == NetworkUtils.ResponseStatusType.RETRYABLE) { |
| 234 | + Logging.warn("$err Outcome event was cached and will be reattempted on app cold start") |
237 | 235 |
|
238 | 236 | // Only if we need to save and retry the outcome, then we will save the timestamp for future sending
|
239 | 237 | eventParams.timestamp = timestampSeconds
|
240 | 238 | _outcomeEventsCache.saveOutcomeEvent(eventParams)
|
| 239 | + } else { |
| 240 | + Logging.error("$err Outcome event will be omitted!") |
| 241 | + _outcomeEventsCache.deleteOldOutcomeEvent(eventParams) |
241 | 242 | }
|
242 | 243 |
|
243 | 244 | // Return null to determine not a failure, but not a success in terms of the request made
|
|
0 commit comments