@@ -16,8 +16,7 @@ var tracker = {},
1616 server = "9c28c347849f2c03caf1b091ec7be8def435e85e" ,
1717 user = "fa6e9ae7b410cb6d756e8088c5f3936bf1fab5f3" ,
1818 url = "https://stats.count.ly" ,
19- plugins = require ( '../../../plugins/pluginManager.js' ) ,
20- domain = plugins . getConfig ( "api" ) . domain ;
19+ plugins = require ( '../../../plugins/pluginManager.js' ) ;
2120
2221var IS_FLEX = false ;
2322
@@ -51,26 +50,28 @@ tracker.enable = function() {
5150 storage_path : "../../../.sdk/" ,
5251 interval : 10000 ,
5352 fail_timeout : 600 ,
54- session_update : 120 ,
53+ session_update : 60 * 60 * 12 ,
5554 remote_config : true ,
5655 debug : ( logger . getLevel ( "tracker:server" ) === "debug" )
5756 } ;
57+
58+ var domain = plugins . getConfig ( "api" ) . domain ;
59+
5860 //set static device id if domain is defined
5961 if ( domain ) {
6062 config . device_id = stripTrailingSlash ( ( domain + "" ) . split ( "://" ) . pop ( ) ) ;
6163 }
62- Countly . init ( config ) ;
6364
64- //change device id if is it not domain
65- if ( domain && Countly . get_device_id ( ) !== domain ) {
66- Countly . change_id ( stripTrailingSlash ( ( domain + "" ) . split ( "://" ) . pop ( ) ) , true ) ;
67- }
68- else if ( ! domain ) {
69- checkDomain ( ) ;
70- }
71- isEnabled = true ;
72- Countly . user_details ( { "name" : config . device_id } ) ;
73- plugins . loadConfigs ( common . db , function ( ) {
65+ if ( config . device_id && config . device_id !== "localhost" ) {
66+ Countly . init ( config ) ;
67+
68+ //change device id if is it not domain
69+ if ( Countly . get_device_id ( ) !== domain ) {
70+ Countly . change_id ( stripTrailingSlash ( ( domain + "" ) . split ( "://" ) . pop ( ) ) , true ) ;
71+ }
72+
73+ isEnabled = true ;
74+ Countly . user_details ( { "name" : config . device_id } ) ;
7475 if ( plugins . getConfig ( "tracking" ) . server_sessions ) {
7576 Countly . begin_session ( true ) ;
7677 }
@@ -83,7 +84,7 @@ tracker.enable = function() {
8384 }
8485 collectServerData ( ) ;
8586 } , 20000 ) ;
86- } ) ;
87+ }
8788} ;
8889
8990/**
@@ -103,7 +104,10 @@ tracker.getBulkServer = function() {
103104 * @returns {Object } Countly Bulk User instance
104105 */
105106tracker . getBulkUser = function ( serverInstance ) {
106- return serverInstance . add_user ( { device_id : stripTrailingSlash ( ( plugins . getConfig ( "api" ) . domain + "" ) . split ( "://" ) . pop ( ) ) } ) ;
107+ var domain = stripTrailingSlash ( ( plugins . getConfig ( "api" ) . domain + "" ) . split ( "://" ) . pop ( ) ) ;
108+ if ( domain && domain !== "localhost" ) {
109+ return serverInstance . add_user ( { device_id : domain } ) ;
110+ }
107111} ;
108112
109113/**
@@ -224,20 +228,4 @@ function stripTrailingSlash(str) {
224228 return str ;
225229}
226230
227- //check every hour if domain was provided
228- var checkDomain = function ( ) {
229- if ( ! domain && domain !== plugins . getConfig ( "api" ) . domain ) {
230- domain = plugins . getConfig ( "api" ) . domain ;
231- if ( Countly && isEnabled ) {
232- Countly . change_id ( stripTrailingSlash ( ( domain + "" ) . split ( "://" ) . pop ( ) ) , true ) ;
233- Countly . userData . set ( "domain" , domain ) ;
234- Countly . user_details ( { "name" : stripTrailingSlash ( ( domain + "" ) . split ( "://" ) . pop ( ) ) } ) ;
235- Countly . userData . save ( ) ;
236- }
237- }
238- else if ( ! domain ) {
239- setTimeout ( checkDomain , 3600000 ) ;
240- }
241- } ;
242-
243231module . exports = tracker ;
0 commit comments