82c4a47e3b1f064695ee92bc529e41c7dad85cc1
[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 _0xa0e2=['result','catch','moment','bluebird','randomstring','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','AnalyticMetric,\x20%s,\x20%s','request\x20sent','AnalyticMetric,\x20%s,\x20%s,\x20%s','error','code','message'];(function(_0x3f3eda,_0x3885f0){var _0xd4278e=function(_0xdebb9e){while(--_0xdebb9e){_0x3f3eda['push'](_0x3f3eda['shift']());}};_0xd4278e(++_0x3885f0);}(_0xa0e2,0x74));var _0x2a0e=function(_0x2b729a,_0x21945a){_0x2b729a=_0x2b729a-0x0;var _0x4a398d=_0xa0e2[_0x2b729a];return _0x4a398d;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x2a0e('0x0'));var BPromise=require(_0x2a0e('0x1'));var rs=require(_0x2a0e('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x2a0e('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x2a0e('0x4'))(_0x2a0e('0x5'));var config=require(_0x2a0e('0x6'));var jayson=require(_0x2a0e('0x7'));var client=jayson['client'][_0x2a0e('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x44f975,_0x148dd6,_0x314778){return new BPromise(function(_0x5ee8e4,_0x3b597d){return client[_0x2a0e('0x9')](_0x44f975,_0x314778)[_0x2a0e('0xa')](function(_0x2343ba){logger['info'](_0x2a0e('0xb'),_0x148dd6,_0x2a0e('0xc'));logger['debug'](_0x2a0e('0xd'),_0x148dd6,'request\x20sent',JSON['stringify'](_0x2343ba));if(_0x2343ba[_0x2a0e('0xe')]){if(_0x2343ba[_0x2a0e('0xe')][_0x2a0e('0xf')]===0x1f4){logger['error']('AnalyticMetric,\x20%s,\x20%s',_0x148dd6,_0x2343ba[_0x2a0e('0xe')][_0x2a0e('0x10')]);return _0x3b597d(_0x2343ba[_0x2a0e('0xe')]['message']);}logger['error']('AnalyticMetric,\x20%s,\x20%s',_0x148dd6,_0x2343ba[_0x2a0e('0xe')][_0x2a0e('0x10')]);return _0x5ee8e4(_0x2343ba['error']['message']);}else{logger['info']('AnalyticMetric,\x20%s,\x20%s',_0x148dd6,_0x2a0e('0xc'));_0x5ee8e4(_0x2343ba[_0x2a0e('0x11')][_0x2a0e('0x10')]);}})[_0x2a0e('0x12')](function(_0x4cad72){logger[_0x2a0e('0xe')]('AnalyticMetric,\x20%s,\x20%s',_0x148dd6,_0x4cad72);_0x3b597d(_0x4cad72);});});}