3
3
* Module dependencies.
4
4
*/
5
5
6
- var ads = require ( 'ad-params' ) ;
7
6
var clone = require ( 'clone' ) ;
8
7
var cookie = require ( 'cookie' ) ;
9
8
var extend = require ( 'extend' ) ;
@@ -13,7 +12,6 @@ var localstorage = require('store');
13
12
var protocol = require ( 'protocol' ) ;
14
13
var send = require ( 'send-json' ) ;
15
14
var topDomain = require ( 'top-domain' ) ;
16
- var utm = require ( 'utm-params' ) ;
17
15
var uuid = require ( 'uuid' ) ;
18
16
19
17
/**
@@ -28,10 +26,10 @@ var cookieOptions = {
28
26
} ;
29
27
30
28
/**
31
- * Expose `Segment ` integration.
29
+ * Expose `Attribution ` integration.
32
30
*/
33
31
34
- var Segment = exports = module . exports = integration ( 'Segment.io ' )
32
+ var Attribution = exports = module . exports = integration ( 'Attribution ' )
35
33
. option ( 'apiKey' , '' ) ;
36
34
37
35
/**
@@ -58,7 +56,7 @@ exports.global = window;
58
56
* @api public
59
57
*/
60
58
61
- Segment . prototype . initialize = function ( ) {
59
+ Attribution . prototype . initialize = function ( ) {
62
60
var self = this ;
63
61
this . ready ( ) ;
64
62
this . analytics . on ( 'invoke' , function ( msg ) {
@@ -77,7 +75,7 @@ Segment.prototype.initialize = function() {
77
75
* @return {boolean }
78
76
*/
79
77
80
- Segment . prototype . loaded = function ( ) {
78
+ Attribution . prototype . loaded = function ( ) {
81
79
return true ;
82
80
} ;
83
81
@@ -88,7 +86,7 @@ Segment.prototype.loaded = function() {
88
86
* @param {Page } page
89
87
*/
90
88
91
- Segment . prototype . onpage = function ( page ) {
89
+ Attribution . prototype . onpage = function ( page ) {
92
90
this . send ( '/p' , page . json ( ) ) ;
93
91
} ;
94
92
@@ -99,7 +97,7 @@ Segment.prototype.onpage = function(page) {
99
97
* @param {Identify } identify
100
98
*/
101
99
102
- Segment . prototype . onidentify = function ( identify ) {
100
+ Attribution . prototype . onidentify = function ( identify ) {
103
101
this . send ( '/i' , identify . json ( ) ) ;
104
102
} ;
105
103
@@ -110,7 +108,7 @@ Segment.prototype.onidentify = function(identify) {
110
108
* @param {Group } group
111
109
*/
112
110
113
- Segment . prototype . ongroup = function ( group ) {
111
+ Attribution . prototype . ongroup = function ( group ) {
114
112
this . send ( '/g' , group . json ( ) ) ;
115
113
} ;
116
114
@@ -123,7 +121,7 @@ Segment.prototype.ongroup = function(group) {
123
121
* @param {Track } track
124
122
*/
125
123
126
- Segment . prototype . ontrack = function ( track ) {
124
+ Attribution . prototype . ontrack = function ( track ) {
127
125
var json = track . json ( ) ;
128
126
// TODO: figure out why we need traits.
129
127
delete json . traits ;
@@ -137,7 +135,7 @@ Segment.prototype.ontrack = function(track) {
137
135
* @param {Alias } alias
138
136
*/
139
137
140
- Segment . prototype . onalias = function ( alias ) {
138
+ Attribution . prototype . onalias = function ( alias ) {
141
139
var json = alias . json ( ) ;
142
140
var user = this . analytics . user ( ) ;
143
141
json . previousId = json . previousId || json . from || user . id ( ) || user . anonymousId ( ) ;
@@ -154,7 +152,7 @@ Segment.prototype.onalias = function(alias) {
154
152
* @param {Object } msg
155
153
*/
156
154
157
- Segment . prototype . normalize = function ( msg ) {
155
+ Attribution . prototype . normalize = function ( msg ) {
158
156
this . debug ( 'normalize %o' , msg ) ;
159
157
var user = this . analytics . user ( ) ;
160
158
var global = exports . global ;
@@ -183,8 +181,8 @@ Segment.prototype.normalize = function(msg) {
183
181
* @param {Function } fn
184
182
*/
185
183
186
- Segment . prototype . send = function ( path , msg , fn ) {
187
- var url = scheme ( ) + '//api.segment.io/v1 ' + path ;
184
+ Attribution . prototype . send = function ( path , msg , fn ) {
185
+ var url = scheme ( ) + '//track.attributionapp.com ' + path ;
188
186
var headers = { 'Content-Type' : 'text/plain' } ;
189
187
fn = fn || noop ;
190
188
var self = this ;
@@ -209,8 +207,8 @@ Segment.prototype.send = function(path, msg, fn) {
209
207
* @param {* } val
210
208
*/
211
209
212
- Segment . prototype . cookie = function ( name , val ) {
213
- var store = Segment . storage ( ) ;
210
+ Attribution . prototype . cookie = function ( name , val ) {
211
+ var store = Attribution . storage ( ) ;
214
212
if ( arguments . length === 1 ) return store ( name ) ;
215
213
var global = exports . global ;
216
214
var href = global . location . href ;
@@ -227,30 +225,6 @@ Segment.prototype.cookie = function(name, val) {
227
225
store ( name , val , opts ) ;
228
226
} ;
229
227
230
- /**
231
- * Add referrerId to context.
232
- *
233
- * TODO: remove.
234
- *
235
- * @api private
236
- * @param {Object } query
237
- * @param {Object } ctx
238
- */
239
-
240
- Segment . prototype . referrerId = function ( query , ctx ) {
241
- var stored = this . cookie ( 's:context.referrer' ) ;
242
- var ad ;
243
-
244
- if ( stored ) stored = json . parse ( stored ) ;
245
- if ( query ) ad = ads ( query ) ;
246
-
247
- ad = ad || stored ;
248
-
249
- if ( ! ad ) return ;
250
- ctx . referrer = extend ( ctx . referrer || { } , ad ) ;
251
- this . cookie ( 's:context.referrer' , json . stringify ( ad ) ) ;
252
- } ;
253
-
254
228
/**
255
229
* Get the scheme.
256
230
*
0 commit comments