Skip to content

Commit

Permalink
Our API uses underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelreh committed Jul 9, 2015
1 parent f478382 commit f987d13
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
var clone = require('clone');
var cookie = require('cookie');
var extend = require('extend');
var integration = require('analytics.js-integration');
var integration = require('segmentio/analytics.js-integration@1.0.1');
var json = require('segmentio/[email protected]');
var localstorage = require('store');
var protocol = require('protocol');
var send = require('send-json');
var protocol = require('segmentio/protocol');
var send = require('yields/send-json');
var topDomain = require('top-domain');
var uuid = require('uuid');

Expand Down Expand Up @@ -87,6 +87,8 @@ Attribution.prototype.loaded = function() {
*/

Attribution.prototype.onpage = function(page) {
if(page.obj.event === undefined)
page.obj.event = page.event();
this.send('/track', page.json());
};

Expand Down Expand Up @@ -124,7 +126,7 @@ Attribution.prototype.ontrack = function(track) {
Attribution.prototype.onalias = function(alias) {
var json = alias.json();
var user = this.analytics.user();
json.previousId = json.previousId || json.from || user.id() || user.anonymousId();
json.previousId = json.previous_id = json.previousId || json.from || user.id() || user.anonymousId();
json.userId = json.userId || json.to;
delete json.from;
delete json.to;
Expand All @@ -146,8 +148,8 @@ Attribution.prototype.normalize = function(msg) {
var ctx = msg.context = msg.context || msg.options || {};
delete msg.options;
ctx.userAgent = navigator.userAgent;
msg.userId = msg.userId || user.id();
msg.anonymousId = user.anonymousId();
msg.userId = msg.user_id = msg.userId || user.id();
msg.anonymousId = msg.cookie_id = user.anonymousId();
msg.messageId = uuid();
msg.sentAt = new Date();
this.debug('normalized %o', msg);
Expand Down

0 comments on commit f987d13

Please sign in to comment.