33 * Module dependencies.
44 */
55
6- var ads = require ( 'ad-params' ) ;
76var clone = require ( 'clone' ) ;
87var cookie = require ( 'cookie' ) ;
98var extend = require ( 'extend' ) ;
@@ -13,7 +12,6 @@ var localstorage = require('store');
1312var protocol = require ( 'protocol' ) ;
1413var send = require ( 'send-json' ) ;
1514var topDomain = require ( 'top-domain' ) ;
16- var utm = require ( 'utm-params' ) ;
1715var uuid = require ( 'uuid' ) ;
1816
1917/**
@@ -28,10 +26,10 @@ var cookieOptions = {
2826} ;
2927
3028/**
31- * Expose `Segment ` integration.
29+ * Expose `Attribution ` integration.
3230 */
3331
34- var Segment = exports = module . exports = integration ( 'Segment.io ' )
32+ var Attribution = exports = module . exports = integration ( 'Attribution ' )
3533 . option ( 'apiKey' , '' ) ;
3634
3735/**
@@ -58,7 +56,7 @@ exports.global = window;
5856 * @api public
5957 */
6058
61- Segment . prototype . initialize = function ( ) {
59+ Attribution . prototype . initialize = function ( ) {
6260 var self = this ;
6361 this . ready ( ) ;
6462 this . analytics . on ( 'invoke' , function ( msg ) {
@@ -77,7 +75,7 @@ Segment.prototype.initialize = function() {
7775 * @return {boolean }
7876 */
7977
80- Segment . prototype . loaded = function ( ) {
78+ Attribution . prototype . loaded = function ( ) {
8179 return true ;
8280} ;
8381
@@ -88,7 +86,7 @@ Segment.prototype.loaded = function() {
8886 * @param {Page } page
8987 */
9088
91- Segment . prototype . onpage = function ( page ) {
89+ Attribution . prototype . onpage = function ( page ) {
9290 this . send ( '/p' , page . json ( ) ) ;
9391} ;
9492
@@ -99,7 +97,7 @@ Segment.prototype.onpage = function(page) {
9997 * @param {Identify } identify
10098 */
10199
102- Segment . prototype . onidentify = function ( identify ) {
100+ Attribution . prototype . onidentify = function ( identify ) {
103101 this . send ( '/i' , identify . json ( ) ) ;
104102} ;
105103
@@ -110,7 +108,7 @@ Segment.prototype.onidentify = function(identify) {
110108 * @param {Group } group
111109 */
112110
113- Segment . prototype . ongroup = function ( group ) {
111+ Attribution . prototype . ongroup = function ( group ) {
114112 this . send ( '/g' , group . json ( ) ) ;
115113} ;
116114
@@ -123,7 +121,7 @@ Segment.prototype.ongroup = function(group) {
123121 * @param {Track } track
124122 */
125123
126- Segment . prototype . ontrack = function ( track ) {
124+ Attribution . prototype . ontrack = function ( track ) {
127125 var json = track . json ( ) ;
128126 // TODO: figure out why we need traits.
129127 delete json . traits ;
@@ -137,7 +135,7 @@ Segment.prototype.ontrack = function(track) {
137135 * @param {Alias } alias
138136 */
139137
140- Segment . prototype . onalias = function ( alias ) {
138+ Attribution . prototype . onalias = function ( alias ) {
141139 var json = alias . json ( ) ;
142140 var user = this . analytics . user ( ) ;
143141 json . previousId = json . previousId || json . from || user . id ( ) || user . anonymousId ( ) ;
@@ -154,7 +152,7 @@ Segment.prototype.onalias = function(alias) {
154152 * @param {Object } msg
155153 */
156154
157- Segment . prototype . normalize = function ( msg ) {
155+ Attribution . prototype . normalize = function ( msg ) {
158156 this . debug ( 'normalize %o' , msg ) ;
159157 var user = this . analytics . user ( ) ;
160158 var global = exports . global ;
@@ -183,8 +181,8 @@ Segment.prototype.normalize = function(msg) {
183181 * @param {Function } fn
184182 */
185183
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 ;
188186 var headers = { 'Content-Type' : 'text/plain' } ;
189187 fn = fn || noop ;
190188 var self = this ;
@@ -209,8 +207,8 @@ Segment.prototype.send = function(path, msg, fn) {
209207 * @param {* } val
210208 */
211209
212- Segment . prototype . cookie = function ( name , val ) {
213- var store = Segment . storage ( ) ;
210+ Attribution . prototype . cookie = function ( name , val ) {
211+ var store = Attribution . storage ( ) ;
214212 if ( arguments . length === 1 ) return store ( name ) ;
215213 var global = exports . global ;
216214 var href = global . location . href ;
@@ -227,30 +225,6 @@ Segment.prototype.cookie = function(name, val) {
227225 store ( name , val , opts ) ;
228226} ;
229227
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-
254228/**
255229 * Get the scheme.
256230 *
0 commit comments