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

Fix/pr 240 #270

Merged
merged 3 commits into from
Feb 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class Analytics {
*
* @param {String} writeKey
* @param {Object} [options] (optional)
* @property {Number} flushAt (default: 20)
* @property {Number} flushInterval (default: 10000)
* @property {String} host (default: 'https://api.segment.io')
* @property {Boolean} enable (default: true)
* @property {Number} [flushAt] (default: 20)
* @property {Number} [flushInterval] (default: 10000)
* @property {String} [host] (default: 'https://api.segment.io')
* @property {Boolean} [enable] (default: true)
* @property {Object} [axiosConfig] (optional)
* @property {Object} [axiosInstance] (default: axios.create(options.axiosConfig))
*/

constructor (writeKey, options) {
Expand All @@ -36,6 +38,11 @@ class Analytics {
this.writeKey = writeKey
this.host = removeSlash(options.host || 'https://api.segment.io')
this.path = removeSlash(options.path || '/v1/batch')
let axiosInstance = options.axiosInstance
if (axiosInstance == null) {
axiosInstance = axios.create(options.axiosConfig)
}
this.axiosInstance = axiosInstance
this.timeout = options.timeout || false
this.flushAt = Math.max(options.flushAt, 1) || 20
this.flushInterval = options.flushInterval || 10000
Expand Down Expand Up @@ -126,7 +133,7 @@ class Analytics {
* Send a screen `message`.
*
* @param {Object} message
* @param {Function} fn (optional)
* @param {Function} [callback] (optional)
* @return {Analytics}
*/

Expand Down