New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@segment/analytics.js-integration-segmentio

Package Overview
Dependencies
Maintainers
11
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@segment/analytics.js-integration-segmentio - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

7

HISTORY.md

@@ -0,1 +1,8 @@

3.2.0 / 2016-09-01
==================
* Add unbundled metadata (#17)
* Add bundled integrations metadata to every request (#16)
3.1.1 / 2016-07-22

@@ -2,0 +9,0 @@ ==================

12

lib/index.js

@@ -13,2 +13,3 @@ 'use strict';

var json = require('json3');
var keys = require('@ndhoule/keys');
var localstorage = require('yields-store');

@@ -39,3 +40,5 @@ var md5 = require('spark-md5').hash;

.option('apiKey', '')
.option('apiHost', 'api.segment.io/v1');
.option('apiHost', 'api.segment.io/v1')
.option('addBundledMetadata', false)
.option('unbundledIntegrations', []);

@@ -177,2 +180,9 @@ /**

msg.sentAt = new Date();
if (this.options.addBundledMetadata) {
var bundled = keys(this.analytics.Integrations);
msg._metadata = {
bundled: bundled,
unbundled: this.options.unbundledIntegrations
};
}
// add some randomness to the messageId checksum

@@ -179,0 +189,0 @@ msg.messageId = 'ajs-' + md5(json.stringify(msg) + uuid());

3

package.json
{
"name": "@segment/analytics.js-integration-segmentio",
"description": "The Segmentio analytics.js integration.",
"version": "3.1.1",
"version": "3.2.0",
"keywords": [

@@ -27,2 +27,3 @@ "analytics.js",

"@ndhoule/extend": "^2.0.0",
"@ndhoule/keys": "^2.0.0",
"@segment/ad-params": "^1.0.0",

@@ -29,0 +30,0 @@ "@segment/analytics.js-integration": "^2.1.0",

@@ -282,2 +282,45 @@ 'use strict';

});
describe('unbundling', function() {
var segment;
beforeEach(function() {
var Analytics = analytics.constructor;
var ajs = new Analytics();
segment = new Segment(options);
ajs.use(Segment);
ajs.use(integration('other'));
ajs.add(segment);
ajs.initialize({ other: {} });
});
it('should add a list of bundled integrations when `addBundledMetadata` is set', function() {
segment.options.addBundledMetadata = true;
segment.normalize(object);
assert(object);
assert(object._metadata);
assert.deepEqual(object._metadata.bundled, [
'Segment.io',
'other'
]);
});
it('should add a list of unbundled integrations when `addBundledMetadata` and `unbundledIntegrations` are set', function() {
segment.options.addBundledMetadata = true;
segment.options.unbundledIntegrations = [ 'other2' ];
segment.normalize(object);
assert(object);
assert(object._metadata);
assert.deepEqual(object._metadata.unbundled, [ 'other2' ]);
});
it('should not add _metadata when `addBundledMetadata` is unset', function() {
segment.normalize(object);
assert(object);
assert(!object._metadata);
});
});
});

@@ -488,2 +531,21 @@ });

it('should send a normalized payload', sinon.test(function() {
var xhr = sinon.useFakeXMLHttpRequest();
var spy = sinon.spy();
xhr.onCreate = spy;
var payload = {
key1: 'value1',
key2: 'value2'
};
segment.normalize = function() { return payload; };
segment.send('/i', {});
assert(spy.calledOnce);
var req = spy.getCall(0).args[0];
assert.strictEqual(req.requestBody, JSON.stringify(payload));
}));
// FIXME(ndhoule): See note at `isPhantomJS` definition

@@ -490,0 +552,0 @@ (isPhantomJS ? xdescribe : describe)('e2e tests', function() {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc