6e8f681010dd4ce160601efebc642c709291c3cf
[motion2.git] / server / api / analyticMetric / analyticMetric.rpc.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xa743=['moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','request','AnalyticMetric,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','lodash'];(function(_0x3ec122,_0x55150a){var _0x4ecf41=function(_0x1709cd){while(--_0x1709cd){_0x3ec122['push'](_0x3ec122['shift']());}};_0x4ecf41(++_0x55150a);}(_0xa743,0x13f));var _0x3a74=function(_0x5eca50,_0xc1e3f8){_0x5eca50=_0x5eca50-0x0;var _0x41fb84=_0xa743[_0x5eca50];return _0x41fb84;};'use strict';var _=require(_0x3a74('0x0'));var util=require('util');var moment=require(_0x3a74('0x1'));var BPromise=require(_0x3a74('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x3a74('0x3'))['db'];var utils=require(_0x3a74('0x4'));var logger=require(_0x3a74('0x5'))(_0x3a74('0x6'));var config=require(_0x3a74('0x7'));var jayson=require(_0x3a74('0x8'));var client=jayson[_0x3a74('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2183f9,_0x4cb9c6,_0x366a54){return new BPromise(function(_0x2927fa,_0x468a9d){return client[_0x3a74('0xa')](_0x2183f9,_0x366a54)['then'](function(_0xaf8703){logger['info'](_0x3a74('0xb'),_0x4cb9c6,_0x3a74('0xc'));logger[_0x3a74('0xd')]('AnalyticMetric,\x20%s,\x20%s,\x20%s',_0x4cb9c6,'request\x20sent',JSON[_0x3a74('0xe')](_0xaf8703));if(_0xaf8703[_0x3a74('0xf')]){if(_0xaf8703[_0x3a74('0xf')][_0x3a74('0x10')]===0x1f4){logger['error'](_0x3a74('0xb'),_0x4cb9c6,_0xaf8703['error'][_0x3a74('0x11')]);return _0x468a9d(_0xaf8703[_0x3a74('0xf')][_0x3a74('0x11')]);}logger['error'](_0x3a74('0xb'),_0x4cb9c6,_0xaf8703['error'][_0x3a74('0x11')]);return _0x2927fa(_0xaf8703['error'][_0x3a74('0x11')]);}else{logger['info'](_0x3a74('0xb'),_0x4cb9c6,'request\x20sent');_0x2927fa(_0xaf8703[_0x3a74('0x12')][_0x3a74('0x11')]);}})[_0x3a74('0x13')](function(_0x103fd0){logger['error'](_0x3a74('0xb'),_0x4cb9c6,_0x103fd0);_0x468a9d(_0x103fd0);});});}