@@ -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