b80b0abed7873ea0a044af081c2b8e8483c987b4
[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 _0xfcd6=['lodash','util','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','info','request\x20sent','debug','stringify','error','code','AnalyticMetric,\x20%s,\x20%s','message','result','catch'];(function(_0x4d87cf,_0x59f8fb){var _0x3816f1=function(_0x52aced){while(--_0x52aced){_0x4d87cf['push'](_0x4d87cf['shift']());}};_0x3816f1(++_0x59f8fb);}(_0xfcd6,0x187));var _0x6fcd=function(_0x3bda86,_0x3c45e5){_0x3bda86=_0x3bda86-0x0;var _0x4d7ffa=_0xfcd6[_0x3bda86];return _0x4d7ffa;};'use strict';var _=require(_0x6fcd('0x0'));var util=require(_0x6fcd('0x1'));var moment=require('moment');var BPromise=require(_0x6fcd('0x2'));var rs=require(_0x6fcd('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6fcd('0x4'))['db'];var utils=require(_0x6fcd('0x5'));var logger=require(_0x6fcd('0x6'))(_0x6fcd('0x7'));var config=require('../../config/environment');var jayson=require(_0x6fcd('0x8'));var client=jayson[_0x6fcd('0x9')][_0x6fcd('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x46d64f,_0x41fc75,_0x3162d2){return new BPromise(function(_0x2e975b,_0x339be6){return client[_0x6fcd('0xb')](_0x46d64f,_0x3162d2)[_0x6fcd('0xc')](function(_0x55b9d9){logger[_0x6fcd('0xd')]('AnalyticMetric,\x20%s,\x20%s',_0x41fc75,_0x6fcd('0xe'));logger[_0x6fcd('0xf')]('AnalyticMetric,\x20%s,\x20%s,\x20%s',_0x41fc75,'request\x20sent',JSON[_0x6fcd('0x10')](_0x55b9d9));if(_0x55b9d9['error']){if(_0x55b9d9[_0x6fcd('0x11')][_0x6fcd('0x12')]===0x1f4){logger[_0x6fcd('0x11')](_0x6fcd('0x13'),_0x41fc75,_0x55b9d9[_0x6fcd('0x11')][_0x6fcd('0x14')]);return _0x339be6(_0x55b9d9['error']['message']);}logger['error']('AnalyticMetric,\x20%s,\x20%s',_0x41fc75,_0x55b9d9[_0x6fcd('0x11')][_0x6fcd('0x14')]);return _0x2e975b(_0x55b9d9['error']['message']);}else{logger[_0x6fcd('0xd')](_0x6fcd('0x13'),_0x41fc75,_0x6fcd('0xe'));_0x2e975b(_0x55b9d9[_0x6fcd('0x15')][_0x6fcd('0x14')]);}})[_0x6fcd('0x16')](function(_0x222717){logger[_0x6fcd('0x11')](_0x6fcd('0x13'),_0x41fc75,_0x222717);_0x339be6(_0x222717);});});}