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

Commit e39cf68

Browse files
authored
Merge pull request #270 from North-Two-Five/fix/pr-240
Fix/pr 240
2 parents 5d05f73 + d6d6879 commit e39cf68

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ class Analytics {
2121
*
2222
* @param {String} writeKey
2323
* @param {Object} [options] (optional)
24-
* @property {Number} flushAt (default: 20)
25-
* @property {Number} flushInterval (default: 10000)
26-
* @property {String} host (default: 'https://api.segment.io')
27-
* @property {Boolean} enable (default: true)
24+
* @property {Number} [flushAt] (default: 20)
25+
* @property {Number} [flushInterval] (default: 10000)
26+
* @property {String} [host] (default: 'https://api.segment.io')
27+
* @property {Boolean} [enable] (default: true)
28+
* @property {Object} [axiosConfig] (optional)
29+
* @property {Object} [axiosInstance] (default: axios.create(options.axiosConfig))
2830
*/
2931

3032
constructor (writeKey, options) {
@@ -36,6 +38,11 @@ class Analytics {
3638
this.writeKey = writeKey
3739
this.host = removeSlash(options.host || 'https://api.segment.io')
3840
this.path = removeSlash(options.path || '/v1/batch')
41+
let axiosInstance = options.axiosInstance
42+
if (axiosInstance == null) {
43+
axiosInstance = axios.create(options.axiosConfig)
44+
}
45+
this.axiosInstance = axiosInstance
3946
this.timeout = options.timeout || false
4047
this.flushAt = Math.max(options.flushAt, 1) || 20
4148
this.flushInterval = options.flushInterval || 10000
@@ -126,7 +133,7 @@ class Analytics {
126133
* Send a screen `message`.
127134
*
128135
* @param {Object} message
129-
* @param {Function} fn (optional)
136+
* @param {Function} [callback] (optional)
130137
* @return {Analytics}
131138
*/
132139

0 commit comments

Comments
 (0)