Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #285 from Dahaden/dhaden/#284-add-axiosRetryConfig
Browse files Browse the repository at this point in the history
#284 Added options for axiosRetryConfig, disable axiosRetry if retryCount is 0
  • Loading branch information
pooyaj committed Jul 28, 2021
2 parents 3ec3f42 + add75b3 commit b13490a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions index.js
Expand Up @@ -27,6 +27,8 @@ class Analytics {
* @property {Boolean} [enable] (default: true)
* @property {Object} [axiosConfig] (optional)
* @property {Object} [axiosInstance] (default: axios.create(options.axiosConfig))
* @property {Object} [axiosRetryConfig] (optional)
* @property {Number} [retryCount] (default: 3)
*/

constructor (writeKey, options) {
Expand Down Expand Up @@ -54,11 +56,15 @@ class Analytics {
enumerable: true,
value: typeof options.enable === 'boolean' ? options.enable : true
})
axiosRetry(this.axiosInstance, {
retries: options.retryCount || 3,
retryCondition: this._isErrorRetryable,
retryDelay: axiosRetry.exponentialDelay
})
if (options.retryCount !== 0) {
axiosRetry(this.axiosInstance, {
retries: options.retryCount || 3,
retryDelay: axiosRetry.exponentialDelay,
...options.axiosRetryConfig,
// retryCondition is below optional config to ensure it does not get overridden
retryCondition: this._isErrorRetryable
})
}
}

_validate (message, type) {
Expand Down

0 comments on commit b13490a

Please sign in to comment.