Socket
Socket
Sign inDemoInstall

analytics-node

Package Overview
Dependencies
17
Maintainers
5
Versions
48
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.5.0 to 4.0.0

9

History.md

@@ -0,1 +1,10 @@

v4.0.0 / 2021-2-17
==========================
* BREAKING: throws error when message is over 32kb #268
* Allow passing in Axios instance in options #270
* Fix data parameter always undefined on callback for track method #231
* Allow to update endpoint to send batch events #246
* Vulnerability fixes #264, #243, #263, #226, #227, #228, #247, #248, #252, #253, #257, #261
* Fixed a typo to reflect actual code behaviour #233
v3.5.0 / 2021-1-5

@@ -2,0 +11,0 @@ ==========================

38

index.js

@@ -24,6 +24,8 @@ 'use strict'

* @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))
*/

@@ -39,2 +41,8 @@

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

@@ -59,11 +67,3 @@ this.flushAt = Math.max(options.flushAt, 1) || 20

_validate (message, type) {
try {
looselyValidate(message, type)
} catch (e) {
if (e.message === 'Your message must be < 32kb.') {
console.log('Your message must be < 32kb. This is currently surfaced as a warning to allow clients to update. Versions released after August 1, 2018 will throw an error instead. Please update your code before then.', message)
return
}
throw e
}
looselyValidate(message, type)
}

@@ -131,3 +131,3 @@

* @param {Object} message
* @param {Function} fn (optional)
* @param {Function} [callback] (optional)
* @return {Analytics}

@@ -212,3 +212,3 @@ */

this.flushed = true
this.flush()
this.flush(callback)
return

@@ -218,7 +218,7 @@ }

if (this.queue.length >= this.flushAt) {
this.flush()
this.flush(callback)
}
if (this.flushInterval && !this.timer) {
this.timer = setTimeout(this.flush.bind(this), this.flushInterval)
this.timer = setTimeout(this.flush.bind(this, callback), this.flushInterval)
}

@@ -265,3 +265,3 @@ }

// Don't set the user agent if we're not on a browser. The latest spec allows
// Don't set the user agent if we're on a browser. The latest spec allows
// the User-Agent header (see https://fetch.spec.whatwg.org/#terminology-headers

@@ -277,3 +277,3 @@ // and https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader),

method: 'POST',
url: `${this.host}/v1/batch`,
url: `${this.host}${this.path}`,
auth: {

@@ -280,0 +280,0 @@ username: this.writeKey

{
"name": "analytics-node",
"version": "3.5.0",
"version": "4.0.0",
"description": "The hassle-free way to integrate analytics into any Node.js application",

@@ -15,12 +15,5 @@ "license": "MIT",

},
"size-limit": [
{
"limit": "25 KB",
"path": "index.js"
}
],
"scripts": {
"circle-lint": ".buildscript/circle.sh",
"dependencies": "yarn",
"size": "size-limit",
"test": "standard && nyc ava --timeout=20s&& .buildscript/e2e.sh",

@@ -65,6 +58,11 @@ "report-coverage": "nyc report --reporter=lcov > coverage.lcov && codecov",

"sinon": "^7.3.2",
"size-limit": "^1.3.5",
"snyk": "^1.171.1",
"standard": "^12.0.1"
},
"resolutions": {
"kind-of": "^6.0.3",
"lodash": "^4.17.19",
"set-value": "^2.0.1",
"yargs-parser": "^13.1.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc