diff --git a/integrations/segmentio/lib/index.js b/integrations/segmentio/lib/index.js index d701199f4..d50d5667d 100644 --- a/integrations/segmentio/lib/index.js +++ b/integrations/segmentio/lib/index.js @@ -470,14 +470,10 @@ Segment.prototype.retrieveCrossDomainId = function(callback) { var self = this; var writeKey = this.options.apiKey; - // Exclude the current domain from the list of servers we're querying - var currentTld = getTld(window.location.hostname); var domains = []; for (var i = 0; i < this.options.crossDomainIdServers.length; i++) { var domain = this.options.crossDomainIdServers[i]; - if (getTld(domain) !== currentTld) { - domains.push(domain); - } + domains.push(domain); } getCrossDomainIdFromServerList(domains, writeKey, function(err, res) { diff --git a/integrations/segmentio/package.json b/integrations/segmentio/package.json index 098ad42fa..207487fce 100644 --- a/integrations/segmentio/package.json +++ b/integrations/segmentio/package.json @@ -1,7 +1,7 @@ { "name": "@segment/analytics.js-integration-segmentio", "description": "The Segmentio analytics.js integration.", - "version": "4.2.3", + "version": "4.2.5", "keywords": [ "analytics.js", "analytics.js-integration", diff --git a/integrations/segmentio/test/index.test.js b/integrations/segmentio/test/index.test.js index 6c66bfeae..e3e898228 100644 --- a/integrations/segmentio/test/index.test.js +++ b/integrations/segmentio/test/index.test.js @@ -1117,26 +1117,6 @@ describe('Segment.io', function() { } describe('with ' + scenario, function() { - it('should generate xid locally if there is only one (current hostname) server', function() { - segment.options.crossDomainIdServers = ['localhost']; - segment.options.saveCrossDomainIdInLocalStorage = - cases[scenario]; - - var res = null; - segment.retrieveCrossDomainId(function(err, response) { - res = response; - }); - - var identify = segment.onidentify.args[0]; - var crossDomainId = identify[0].traits().crossDomainId; - analytics.assert(crossDomainId); - - analytics.assert(res.crossDomainId === crossDomainId); - analytics.assert(res.fromDomain === 'localhost'); - - assert.equal(segment.getCachedCrossDomainId(), crossDomainId); - }); - it('should obtain crossDomainId', function() { server.respondWith( 'GET', @@ -1194,6 +1174,15 @@ describe('Segment.io', function() { '{ "id": null }' ] ); + server.respondWith( + 'GET', + 'https://localhost/v1/id/' + segment.options.apiKey, + [ + 200, + { 'Content-Type': 'application/json' }, + '{ "id": null }' + ] + ); if (segment.options.saveCrossDomainIdInLocalStorage) { server.respondWith('GET', /https:\/\/localhost\/v1\/saveId/, [ 200, @@ -1237,12 +1226,17 @@ describe('Segment.io', function() { segment.options.apiKey, [500, { 'Content-Type': 'application/json' }, ''] ); + server.respondWith( + 'GET', + 'https://localhost/v1/id/' + segment.options.apiKey, + [500, { 'Content-Type': 'application/json' }, ''] + ); server.respond(); var identify = segment.onidentify.args[0]; analytics.assert(!identify); analytics.assert(!res); - analytics.assert(err === 'Internal Server Error'); + analytics.assert.equal(err, 'Internal Server Error'); assert.equal(segment.getCachedCrossDomainId(), null); }); @@ -1270,6 +1264,15 @@ describe('Segment.io', function() { '{ "id": null }' ] ); + server.respondWith( + 'GET', + 'https://localhost/v1/id/' + segment.options.apiKey, + [ + 200, + { 'Content-Type': 'application/json' }, + '{ "id": null }' + ] + ); server.respond(); var identify = segment.onidentify.args[0];