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
115
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 4.1.1 to 4.2.0

2

lib/index.js

@@ -64,3 +64,3 @@ 'use strict';

.option('deleteCrossDomainId', false)
.option('saveCrossDomainIdInLocalStorage', false)
.option('saveCrossDomainIdInLocalStorage', true)
.option('retryQueue', true)

@@ -67,0 +67,0 @@ .option('addBundledMetadata', false)

{
"name": "@segment/analytics.js-integration-segmentio",
"description": "The Segmentio analytics.js integration.",
"version": "4.1.1",
"version": "4.2.0",
"keywords": [

@@ -6,0 +6,0 @@ "analytics.js",

@@ -310,3 +310,3 @@ 'use strict';

it('should set xid if available, is enabled, and context.traits is not defined', function() {
it('should set xid from cookie, and context.traits is not defined', function() {
segment.cookie('seg_xid', 'test_id');

@@ -318,2 +318,3 @@ segment.options.crossDomainIdServers = [

];
segment.options.saveCrossDomainIdInLocalStorage = false;

@@ -324,3 +325,3 @@ segment.normalize(object);

it('should set xid if available, is enabled, and context.traits is defined', function() {
it('should set xid from cookie, and context.traits is defined', function() {
segment.cookie('seg_xid', 'test_id');

@@ -332,2 +333,3 @@ segment.options.crossDomainIdServers = [

];
segment.options.saveCrossDomainIdInLocalStorage = false;

@@ -339,2 +341,29 @@ var msg = { context: { traits: { email: 'prateek@segment.com' } } };

it('should set xid from localStorage, and context.traits is not defined', function() {
window.localStorage.setItem('seg_xid', 'test_id');
segment.options.crossDomainIdServers = [
'userdata.example1.com',
'xid.domain2.com',
'localhost'
];
segment.options.saveCrossDomainIdInLocalStorage = true;
segment.normalize(object);
assert.equal(object.context.traits.crossDomainId, 'test_id');
});
it('should set xid from localStorage, is enabled, and context.traits is defined', function() {
window.localStorage.setItem('seg_xid', 'test_id');
segment.options.crossDomainIdServers = [
'userdata.example1.com',
'xid.domain2.com',
'localhost'
];
segment.options.saveCrossDomainIdInLocalStorage = true;
var msg = { context: { traits: { email: 'prateek@segment.com' } } };
segment.normalize(msg);
assert.equal(msg.context.traits.crossDomainId, 'test_id');
});
it('should not set xid if available, and is disabled', function() {

@@ -1006,6 +1035,2 @@ segment.cookie('seg_xid', 'test_id');

it('should obtain crossDomainId', function() {
var res = null;
segment.retrieveCrossDomainId(function(err, response) {
res = response;
});
server.respondWith('GET', 'https://xid.domain2.com/v1/id/' + segment.options.apiKey, [

@@ -1016,4 +1041,16 @@ 200,

]);
server.respond();
if (segment.options.saveCrossDomainIdInLocalStorage) {
server.respondWith('GET', 'https://localhost/v1/saveId?writeKey=' + segment.options.apiKey + '&xid=xdomain-id-1', [
200,
{ 'Content-Type': 'text/plan' },
'OK'
]);
}
server.respondImmediately = true;
var res = null;
segment.retrieveCrossDomainId(function(err, response) {
res = response;
});
var identify = segment.onidentify.args[0];

@@ -1029,7 +1066,2 @@ analytics.assert(identify[0].traits().crossDomainId === 'xdomain-id-1');

it('should generate crossDomainId if no server has it', function() {
var res = null;
segment.retrieveCrossDomainId(function(err, response) {
res = response;
});
server.respondWith('GET', 'https://xid.domain2.com/v1/id/' + segment.options.apiKey, [

@@ -1045,4 +1077,16 @@ 200,

]);
server.respond();
if (segment.options.saveCrossDomainIdInLocalStorage) {
server.respondWith('GET', /https:\/\/localhost\/v1\/saveId/, [
200,
{ 'Content-Type': 'text/plan' },
'OK'
]);
}
server.respondImmediately = true;
var res = null;
segment.retrieveCrossDomainId(function(err, response) {
res = response;
});
var identify = segment.onidentify.args[0];

@@ -1115,9 +1159,2 @@ var crossDomainId = identify[0].traits().crossDomainId;

it('should succeed even if one server fails', function() {
var err = null;
var res = null;
segment.retrieveCrossDomainId(function(error, response) {
err = error;
res = response;
});
server.respondWith('GET', 'https://xid.domain2.com/v1/id/' + segment.options.apiKey, [

@@ -1133,4 +1170,18 @@ 500,

]);
server.respond();
if (segment.options.saveCrossDomainIdInLocalStorage) {
server.respondWith('GET', 'https://localhost/v1/saveId?writeKey=' + segment.options.apiKey + '&xid=xidxid', [
200,
{ 'Content-Type': 'text/plan' },
'OK'
]);
}
server.respondImmediately = true;
var err = null;
var res = null;
segment.retrieveCrossDomainId(function(error, response) {
err = error;
res = response;
});
var identify = segment.onidentify.args[0];

@@ -1137,0 +1188,0 @@ analytics.assert(identify[0].traits().crossDomainId === 'xidxid');

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