Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 1 addition & 5 deletions integrations/segmentio/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion integrations/segmentio/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
45 changes: 24 additions & 21 deletions integrations/segmentio/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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];
Expand Down