define("editor/assert/js/addon/logManager",["editor/assert/js/addon/urlCheck","share/assert/js/appcontext","share/assert/js/path","editor/assert/js/utils/logUtil"],function(require,exports){var a=window.require("./node_modules/logcenter/trackClient").TrackService,b=window.require("./node_modules/logcenter/paramType").TrackParam,c=window.require("./node_modules/logcenter/lib/uuid"),d=require("editor/assert/js/addon/urlCheck"),e=require("share/assert/js/appcontext").AppContext,f=window.require("fs"),g=require("editor/assert/js/utils/logUtil").logUtil,h={host:"usp.cycore.cn",port:80,path:"/logcenter_xf"},i=e.getBinPath()+"/logCenter.dat";g.TAG="LogManager.js";var j={sessionList:new Array,client:new a,paramFactor:new b,config:h,isOnline:!1,setAddEntryTrack:function(module){g.log("setAddEntryTrack:"+module),j.client.AddEntryTrack(module)},setAddQuiteTrack:function(module){g.log("setAddQuiteTrack:"+module),j.client.AddQuiteTrack(module)},setAddTiggerTrack:function(module,a,b,c){g.log("setAddTiggerTrack: module="+module+",action="+a+",params="+b),j.client.AddTiggerTrack(module,a,b,c)},manageConfigBaseInfo:function(a){j.paramFactor.ConfigBaseInfo(a)},upLoadLog:function(){this.client.UploadTrackLog(function(a,b){console.log(b)})},initConfig:function(){d.pingBaidu().done(function(a){g.log("isOnline:"+a),j.isOnline=a,j.client.Init(j.config,function(a,b){g.log(b)})})},statisticsMoudleTime:function(a,b,c){var d=new Date;d.setMinutes(d.getMinutes()-d.getTimezoneOffset());var e={product:"jhkj",app:"jhkj",user_id:"",timestamp:d.toISOString(),session_id:j.sessionManager(a,b)};return g.log("statisticsMoudleTime paramConfig:"+JSON.stringify(e)),j.isOnline?(j.manageConfigBaseInfo(e),"entry"==b?j.setAddEntryTrack(a):"quit"==b?j.setAddQuiteTrack(a):j.setAddTiggerTrack(a,b,c,""),void j.upLoadLog()):void j.saveLogToLocal(e,b,a,c)},saveLogToLocal:function(a,b,c,d){var e={param:a,action:b,id:c,extra:d},h=i;h=h.replace(/\\/gi,"/"),g.log("local log path:"+h);try{f.existsSync(h)||f.writeFileSync(h,"[]");var j=f.readFileSync(h),k=JSON.parse(j)||[];k.push(e),g.log("save to local:"+JSON.stringify(k)),f.writeFileSync(h,JSON.stringify(k))}catch(l){console.error(l.message)}},upLocalLog:function(){if(j.isOnline){var a=i;a=a.replace(/\\/gi,"/"),g.log("local log path:"+a);try{f.existsSync(a)||f.writeFileSync(a,"[]");var b=JSON.parse(f.readFileSync(a))||[];if(0==b.length)return;var c=[];f.writeFileSync(a,JSON.stringify(c));for(var d in b)j.manageConfigBaseInfo(b[d].param),"entry"==b[d].action?j.setAddEntryTrack(b[d].id):"quit"==b[d].action?j.setAddQuiteTrack(b[d].id):j.setAddTiggerTrack(b[d].id,b[d].action,b[d].extra,"");j.upLoadLog()}catch(e){console.error(e.message)}}},sessionManager:function(a,b){if("entry"==b||"quit"==b){for(var d in j.sessionList)if(j.sessionList[d].appId==a){var e=j.sessionList[d].sessionId;return"quit"==b&&j.sessionList.pop(j.sessionList[d]),e}var e={appId:a,sessionId:""};return c.create(),e.sessionId=c.create().toString(),j.sessionList.push(e),e.sessionId}return c.create(),c.create().toString()}};!function(){setTimeout(function(){var a=arguments.callee;d.pingBaidu().done(function(a){j.isOnline=a}),setTimeout(a,31e3)},31e3),setTimeout(function(){console.log("init log service......"),j.initConfig()},2e3)}(),exports.LogManager=j});