@@ -7,11 +7,13 @@ var Settings = require('./settings');
77var util = require ( './util' ) ;
88var throttle = require ( './throttle' ) ;
99
10+ var API_HOSTNAME = 'api.addsearch.com' ;
1011var API_THROTTLE_TIME_MS = 200 ;
1112
1213var client = function ( sitekey , privatekey ) {
1314 this . sitekey = sitekey ;
1415 this . privatekey = privatekey ;
16+ this . apiHostname = API_HOSTNAME ;
1517 this . settings = new Settings ( ) ;
1618 this . sessionId = ( 'a-' + ( Math . random ( ) * 100000000 ) ) . substring ( 0 , 10 ) ;
1719
@@ -128,6 +130,7 @@ var client = function(sitekey, privatekey) {
128130 /**
129131 * Public functions
130132 */
133+ this . setApiHostname = function ( hostname ) { this . apiHostname = hostname ; }
131134 this . getSettings = function ( ) { return this . settings . getSettings ( ) ; }
132135 this . setLanguage = function ( lang ) { this . settings . setLanguage ( lang ) ; }
133136 this . setCategoryFilters = function ( categories ) { this . settings . setCategoryFilters ( categories ) ; }
@@ -165,7 +168,7 @@ var client = function(sitekey, privatekey) {
165168 keyword : keyword ,
166169 numberOfResults : data . numberOfResults
167170 } ;
168- sendStats ( this . sitekey , data ) ;
171+ sendStats ( this . apiHostname , this . sitekey , data ) ;
169172 }
170173
171174 else if ( type === 'click' ) {
@@ -176,7 +179,7 @@ var client = function(sitekey, privatekey) {
176179 docid : data . documentId ,
177180 position : data . position
178181 } ;
179- sendStats ( this . sitekey , data ) ;
182+ sendStats ( this . apiHostname , this . sitekey , data ) ;
180183 }
181184
182185 else {
0 commit comments