-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'); | ||
|
||
|
@@ -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()); | ||
}; | ||
|
||
|
@@ -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; | ||
|
@@ -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); | ||
|