@segment/analytics.js-integration-cxense
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,1 +1,6 @@ | ||
1.0.1 / 08-24-2017 | ||
================== | ||
* Remove automatic sendPageView event. | ||
1.0.0 / 08-24-2017 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -19,2 +19,3 @@ 'use strict'; | ||
.option('origin', '') | ||
.option('setExternalId', false) | ||
.tag('<script src="//cdn.cxense.com/cx.js">'); | ||
@@ -33,3 +34,2 @@ | ||
window.cX.callQueue.push(['setSiteId', this.options.siteId]); | ||
window.cX.callQueue.push(['sendPageViewEvent']); | ||
window.cX.callQueue.push(['setEventAttributes', { | ||
@@ -88,26 +88,12 @@ origin: this.options.customerPrefix + '-' + this.options.origin, | ||
window.cX.callQueue.push(['sendPageViewEvent', { | ||
location: page.url(), | ||
referrer: page.referrer(), | ||
useAutoRefreshCheck: false | ||
}]); | ||
}; | ||
// Add external Id if user has a userId cached from a previous identify event. | ||
var id = this.analytics.user().id(); | ||
/** | ||
* Identify | ||
* | ||
* https://wiki.cxense.com/display/cust/Event+data#Eventdata-Externaluseridentifiers | ||
* @api public | ||
*/ | ||
if (id && this.options.setExternalId) { | ||
window.cX.callQueue.push(['addExternalId', { id: id, type: this.options.customerPrefix }]); | ||
} | ||
Cxense.prototype.identify = function(identify) { | ||
var customerPrefix = this.options.customerPrefix; | ||
window.cX.callQueue.push(['addExternalId', { | ||
id: identify.userId(), | ||
type: customerPrefix | ||
}]); | ||
var latitude = identify.proxy('context.location.latitude'); | ||
var longitude = identify.proxy('context.location.longitude'); | ||
// Add lat/long info if passed in the context. | ||
var latitude = page.proxy('context.location.latitude'); | ||
var longitude = page.proxy('context.location.longitude'); | ||
@@ -117,2 +103,8 @@ if (latitude && longitude) { | ||
} | ||
window.cX.callQueue.push(['sendPageViewEvent', { | ||
location: page.url(), | ||
referrer: page.referrer(), | ||
useAutoRefreshCheck: false | ||
}]); | ||
}; | ||
@@ -119,0 +111,0 @@ |
{ | ||
"name": "@segment/analytics.js-integration-cxense", | ||
"description": "The Cxense analytics.js integration.", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "analytics.js", |
@@ -37,2 +37,3 @@ 'use strict'; | ||
.option('origin', '') | ||
.option('setExternalId', false) | ||
.tag('<script src="//cdn.cxense.com/cx.js">')); | ||
@@ -81,28 +82,2 @@ }); | ||
}); | ||
it('should add an external id', function() { | ||
analytics.identify('userId'); | ||
analytics.called(window.cX.callQueue.push, ['addExternalId', { | ||
id: 'userId', | ||
type: options.customerPrefix | ||
}]); | ||
}); | ||
it('should add geolocation if available', function() { | ||
var latitude = '1234'; | ||
var longitude = '5678'; | ||
analytics.identify('userId', {}, { | ||
context: { | ||
location: { | ||
latitude: latitude, | ||
longitude: longitude | ||
} | ||
} | ||
}); | ||
analytics.calledTwice(window.cX.callQueue.push); | ||
analytics.called(window.cX.callQueue.push, ['setGeoPosition', latitude, longitude]); | ||
}); | ||
}); | ||
@@ -115,3 +90,3 @@ | ||
it('should call send a mapped page event', function() { | ||
it('should send a mapped page event', function() { | ||
analytics.page('Home', { | ||
@@ -177,2 +152,30 @@ title: 'Home Page', | ||
}); | ||
it('should add an external id', function() { | ||
cxense.options.setExternalId = true; | ||
analytics.user().id('userId'); | ||
analytics.page(); | ||
analytics.called(window.cX.callQueue.push, ['addExternalId', { | ||
id: 'userId', | ||
type: options.customerPrefix | ||
}]); | ||
}); | ||
it('should add geolocation if available', function() { | ||
var latitude = '1234'; | ||
var longitude = '5678'; | ||
analytics.page({}, { | ||
context: { | ||
location: { | ||
latitude: latitude, | ||
longitude: longitude | ||
} | ||
} | ||
}); | ||
analytics.called(window.cX.callQueue.push, ['setGeoPosition', latitude, longitude]); | ||
}); | ||
}); | ||
@@ -179,0 +182,0 @@ |
23331
497