Skip to content

Commit f987d13

Browse files
committed
Our API uses underscores
1 parent f478382 commit f987d13

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
var clone = require('clone');
77
var cookie = require('cookie');
88
var extend = require('extend');
9-
var integration = require('analytics.js-integration');
9+
var integration = require('segmentio/analytics.js-integration@1.0.1');
1010
var json = require('segmentio/[email protected]');
1111
var localstorage = require('store');
12-
var protocol = require('protocol');
13-
var send = require('send-json');
12+
var protocol = require('segmentio/protocol');
13+
var send = require('yields/send-json');
1414
var topDomain = require('top-domain');
1515
var uuid = require('uuid');
1616

@@ -87,6 +87,8 @@ Attribution.prototype.loaded = function() {
8787
*/
8888

8989
Attribution.prototype.onpage = function(page) {
90+
if(page.obj.event === undefined)
91+
page.obj.event = page.event();
9092
this.send('/track', page.json());
9193
};
9294

@@ -124,7 +126,7 @@ Attribution.prototype.ontrack = function(track) {
124126
Attribution.prototype.onalias = function(alias) {
125127
var json = alias.json();
126128
var user = this.analytics.user();
127-
json.previousId = json.previousId || json.from || user.id() || user.anonymousId();
129+
json.previousId = json.previous_id = json.previousId || json.from || user.id() || user.anonymousId();
128130
json.userId = json.userId || json.to;
129131
delete json.from;
130132
delete json.to;
@@ -146,8 +148,8 @@ Attribution.prototype.normalize = function(msg) {
146148
var ctx = msg.context = msg.context || msg.options || {};
147149
delete msg.options;
148150
ctx.userAgent = navigator.userAgent;
149-
msg.userId = msg.userId || user.id();
150-
msg.anonymousId = user.anonymousId();
151+
msg.userId = msg.user_id = msg.userId || user.id();
152+
msg.anonymousId = msg.cookie_id = user.anonymousId();
151153
msg.messageId = uuid();
152154
msg.sentAt = new Date();
153155
this.debug('normalized %o', msg);

0 commit comments

Comments
 (0)