6
6
var clone = require ( 'clone' ) ;
7
7
var cookie = require ( 'cookie' ) ;
8
8
var extend = require ( 'extend' ) ;
9
- var integration = require ( 'analytics.js-integration' ) ;
9
+ var integration = require ( 'segmentio/ analytics.js-integration@1.0.1 ' ) ;
10
10
var json = require ( 'segmentio/[email protected] ' ) ;
11
11
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' ) ;
14
14
var topDomain = require ( 'top-domain' ) ;
15
15
var uuid = require ( 'uuid' ) ;
16
16
@@ -87,6 +87,8 @@ Attribution.prototype.loaded = function() {
87
87
*/
88
88
89
89
Attribution . prototype . onpage = function ( page ) {
90
+ if ( page . obj . event === undefined )
91
+ page . obj . event = page . event ( ) ;
90
92
this . send ( '/track' , page . json ( ) ) ;
91
93
} ;
92
94
@@ -124,7 +126,7 @@ Attribution.prototype.ontrack = function(track) {
124
126
Attribution . prototype . onalias = function ( alias ) {
125
127
var json = alias . json ( ) ;
126
128
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 ( ) ;
128
130
json . userId = json . userId || json . to ;
129
131
delete json . from ;
130
132
delete json . to ;
@@ -146,8 +148,8 @@ Attribution.prototype.normalize = function(msg) {
146
148
var ctx = msg . context = msg . context || msg . options || { } ;
147
149
delete msg . options ;
148
150
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 ( ) ;
151
153
msg . messageId = uuid ( ) ;
152
154
msg . sentAt = new Date ( ) ;
153
155
this . debug ( 'normalized %o' , msg ) ;
0 commit comments