tango-app-api-analysis-traffic 3.3.1-alpha.12 → 3.3.1-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
 
2
2
 
3
3
  import { analysisTrafficRouter } from './src/routes/traffic.routes.js';
4
- import { revopRouter } from './src/routes/revop.routes.js';
5
4
  import { mobileTrafficAnalysisRouter } from './src/routes/mobileTraffic.routes.js';
6
5
  import { nobDocs } from './src/docs/nob.docs.js';
7
6
  import nobRouter from './src/routes/nob.routes.js';
8
7
 
9
- export { analysisTrafficRouter, mobileTrafficAnalysisRouter, nobDocs, nobRouter, revopRouter };
8
+ export { analysisTrafficRouter, mobileTrafficAnalysisRouter, nobDocs, nobRouter };
10
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-analysis-traffic",
3
- "version": "3.3.1-alpha.12",
3
+ "version": "3.3.1-alpha.14",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "mongodb": "^6.8.0",
24
24
  "nodemon": "^3.1.4",
25
25
  "swagger-ui-express": "^5.0.1",
26
- "tango-api-schema": "^2.2.109",
26
+ "tango-api-schema": "^2.2.7",
27
27
  "tango-app-api-middleware": "^3.1.55",
28
28
  "winston": "^3.13.1",
29
29
  "winston-daily-rotate-file": "^5.0.0"
@@ -99,7 +99,7 @@ export const conversionCardsV3 = async ( req, res ) => {
99
99
  reqestData.featureConfigs = getClientData.featureConfigs;
100
100
  reqestData.currency = getClientData.paymentInvoice?.currencyType || 'inr';
101
101
  reqestData.revenue = getClientData.averageTransactionValue || '0';
102
- let LamdaURL = 'https://shi4an3zee5kvaiqfgslwjrupq0srglf.lambda-url.ap-south-1.on.aws/';
102
+ let LamdaURL = 'https://uprslxkz2qpd6xi76dqgzfc6gq0wsfnv.lambda-url.ap-south-1.on.aws/';
103
103
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
104
104
  if ( resultData ) {
105
105
  if ( resultData.status_code == '200' ) {
@@ -261,7 +261,7 @@ export const funnelV3 = async ( req, res ) => {
261
261
  reqestData.featureConfigs = getClientData.featureConfigs;
262
262
  reqestData.currency = getClientData.paymentInvoice?.currencyType || 'inr';
263
263
  reqestData.revenue = getClientData.averageTransactionValue || '0';
264
- let LamdaURL = 'https://oeewcchsgznkfr5qwgjtdj4vhu0amilj.lambda-url.ap-south-1.on.aws/';
264
+ let LamdaURL = 'https://qhv7egrhdg3rwdwy5ttkavobnq0lsekh.lambda-url.ap-south-1.on.aws/';
265
265
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
266
266
  if ( resultData ) {
267
267
  if ( resultData.status_code == '200' ) {
@@ -390,7 +390,7 @@ export const overallCardsV3 = async ( req, res ) => {
390
390
  reqestData.featureConfigs = getClientData.featureConfigs;
391
391
  reqestData.currency = getClientData.paymentInvoice?.currencyType || 'inr';
392
392
  reqestData.revenue = getClientData.averageTransactionValue || '0';
393
- let LamdaURL = 'https://s3wltaeo66nbj7udu5qraqqqvu0dhqao.lambda-url.ap-south-1.on.aws/';
393
+ let LamdaURL = 'https://psxusablnvqw3it6j7q6o4v2mq0yutqb.lambda-url.ap-south-1.on.aws/';
394
394
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
395
395
  if ( resultData ) {
396
396
  if ( resultData.status_code == '200' ) {
@@ -588,11 +588,24 @@ export const summaryTableV3 = async ( req, res ) => {
588
588
  try {
589
589
  let reqestData = req.body;
590
590
  let getClientData = await getClientConfig( reqestData.clientId );
591
+ let featureConfigs = getClientData?.featureConfigs || {};
592
+ const engagersLabel = featureConfigs?.bouncedLimit?.value ?
593
+ `More than ${featureConfigs.bouncedLimit.value} mins` :
594
+ 'Engagers';
595
+ const bouncedLabel = featureConfigs?.bouncedLimit?.value ?
596
+ `Less than ${featureConfigs.bouncedLimit.value} mins Count` :
597
+ 'Bounced Count';
598
+ const conversionLabel = featureConfigs?.conversion?.value ?
599
+ `More than ${featureConfigs.conversion.value} mins Rate` :
600
+ 'Conversion Rate';
601
+ const missedlabel = featureConfigs?.bouncedLimit?.value && featureConfigs?.conversion?.value ?
602
+ `${featureConfigs.bouncedLimit.value} - ${featureConfigs.conversion.value} mins` :
603
+ 'MissedOpportunity';
591
604
  if ( !getClientData ) {
592
605
  return res.sendError( 'Invalid Client Id', 400 );
593
606
  }
594
607
  reqestData.featureConfigs = getClientData.featureConfigs;
595
- let LamdaURL = 'https://ewen2vlmxmhieea4elztlbjuey0ddqee.lambda-url.ap-south-1.on.aws/';
608
+ let LamdaURL = 'https://lihe5wvikbgj6omqhgczd6g2cy0inwis.lambda-url.ap-south-1.on.aws/';
596
609
  let resultData;
597
610
  if ( reqestData.export ) {
598
611
  let limit = 10000;
@@ -632,7 +645,6 @@ export const summaryTableV3 = async ( req, res ) => {
632
645
  'Engagers': element.engagersCount,
633
646
  'MissedOpportunity': element.missedOpportunityCount,
634
647
  'Potential Buyers': element.potentialBuyersCount,
635
- 'Conversion Rate': element.conversionRate,
636
648
  'NOB Count': element.NOBCount,
637
649
  'Avg.Dwell Time': element.avgDwellTime,
638
650
  'Avg.Infra DownTime': element.avgInfraDowntime,
@@ -647,6 +659,29 @@ export const summaryTableV3 = async ( req, res ) => {
647
659
  'Male': element.male,
648
660
  'Female': element.female,
649
661
  } );
662
+ } else if ( reqestData.clientId === '452' ) {
663
+ exportdata.push( {
664
+ 'Store Name': element.storeName,
665
+ 'Store ID': element.storeId,
666
+ ...( req.body.storeId.length ==1 ) ? { Date: element['date'] }:{},
667
+ 'Footfall': element.footfallCount,
668
+ ...( bouncedLabel ? { [bouncedLabel]: element.bouncedCount } : {} ),
669
+ ...( engagersLabel ? { [engagersLabel]: element.engagersCount } : {} ),
670
+ ...( missedlabel ? { [missedlabel]: element.missedOpportunityCount } : {} ),
671
+ ...( conversionLabel ? { [conversionLabel]: element.conversionRate } : {} ),
672
+ 'NOB Count': element.NOBCount,
673
+ 'Avg.Dwell Time': element.avgDwellTime,
674
+ 'Avg.Infra DownTime': element.avgInfraDowntime,
675
+ ...( element.passerBy_count !== undefined ? { 'Passer By': element.passerBy_count } : {} ),
676
+ 'Below12': element.below12,
677
+ '13-19': element['13-19'],
678
+ '20-30': element['20-30'],
679
+ '31-45': element['31-45'],
680
+ '46-59': element['46-59'],
681
+ '60 above': element['60 above'],
682
+ 'Male': element.male,
683
+ 'Female': element.female,
684
+ } );
650
685
  } else {
651
686
  exportdata.push( {
652
687
  'Store Name': element.storeName,
@@ -700,7 +735,7 @@ export const footfallTrendV3 = async ( req, res ) => {
700
735
  return res.sendError( 'Invalid Client Id', 400 );
701
736
  }
702
737
  reqestData.featureConfigs = getClientData.featureConfigs;
703
- let LamdaURL = 'https://x6sjlqwaqd64kyioxhwrwfesbm0jjitx.lambda-url.ap-south-1.on.aws/';
738
+ let LamdaURL = 'https://srbukaxex4qhvquasdx5nsotsu0ywpwd.lambda-url.ap-south-1.on.aws/';
704
739
  let resultData = await LamdaServiceCall( LamdaURL, reqestData );
705
740
  if ( resultData ) {
706
741
  if ( resultData.status_code == '200' ) {
@@ -2007,7 +2042,7 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
2007
2042
 
2008
2043
  async function getClientConfig( clientId ) {
2009
2044
  try {
2010
- let getClientData = await clientService.findOne( { clientId: clientId }, { 'paymentInvoice.currencyType': 1, 'averageTransactionValue': 1, 'featureConfigs.billableCalculation': 1, 'featureConfigs.missedOpportunityCalculation': 1, 'featureConfigs.conversionCalculation': 1, 'featureConfigs.open': 1, 'featureConfigs.close': 1, 'isFootfallAuditStores': 1 } );
2045
+ let getClientData = await clientService.findOne( { clientId: clientId }, { 'paymentInvoice.currencyType': 1, 'averageTransactionValue': 1, 'featureConfigs.billableCalculation': 1, 'featureConfigs.missedOpportunityCalculation': 1, 'featureConfigs.conversionCalculation': 1, 'featureConfigs.open': 1, 'featureConfigs.close': 1, 'isFootfallAuditStores': 1, 'featureConfigs.bouncedLimit': 1, 'featureConfigs.conversion': 1 } );
2011
2046
  if ( !getClientData ) {
2012
2047
  return false;
2013
2048
  }
@@ -1,118 +0,0 @@
1
- import { logger, insertOpenSearchData, getOpenSearchData, updateOpenSearchData } from 'tango-app-api-middleware';
2
- import { findOnerevopConfig } from '../services/revopConfig.service.js';
3
-
4
- export async function getconfig( req, res ) {
5
- try {
6
- let result = await findOnerevopConfig( { clientId: req.query.clientId } );
7
- if ( result===null ) {
8
- return res.sendError( 'no data found', 204 );
9
- }
10
- return res.sendSuccess( result );
11
- } catch ( error ) {
12
- logger.error( { error: error, message: req.query, function: 'getconfig' } );
13
- return res.sendError( { error: error }, 500 );
14
- }
15
- }
16
-
17
- export async function revoptagging( req, res ) {
18
- try {
19
- const openSearch = JSON.parse( process.env.OPENSEARCH );
20
- for ( let item of req.body ) {
21
- let searchQuery={
22
- 'size': 1,
23
- 'query': {
24
- 'bool': {
25
- 'must': [
26
- {
27
- 'term': {
28
- 'storeId.keyword': item.storeId,
29
- },
30
- },
31
- {
32
- 'term': {
33
- 'processType': item.processType,
34
- },
35
- },
36
- {
37
- 'term': {
38
- 'dateString': item.dateString,
39
- },
40
- },
41
- {
42
- 'term': {
43
- 'tempId': item.tempId,
44
- },
45
- },
46
- ],
47
- },
48
- },
49
- };
50
- let respo= await getOpenSearchData( openSearch.revops, searchQuery );
51
- const revopData = respo?.body?.hits?.hits;
52
- console.log( revopData );
53
- if ( revopData&& revopData.length>0 ) {
54
- await updateOpenSearchData( openSearch.revops, revopData[0]._id, { doc: item } );
55
- return res.sendSuccess( 'Customer has been tagged successfully' );
56
- } else {
57
- item.createdAt = new Date();
58
- item.updatedAt = new Date();
59
- await insertOpenSearchData( openSearch.revops, item );
60
- return res.sendSuccess( 'Customer has been tagged successfully.' );
61
- }
62
- }
63
- } catch ( error ) {
64
- logger.error( { error: error, message: req.query, function: 'revoptagging' } );
65
- return res.sendError( { error: error }, 500 );
66
- }
67
- }
68
- export async function getrevoptagging( req, res ) {
69
- try {
70
- const openSearch = JSON.parse( process.env.OPENSEARCH );
71
- console.log( req.body );
72
- let searchQuery={
73
- 'size': 1,
74
- 'query': {
75
- 'bool': {
76
- 'must': [
77
- {
78
- 'term': {
79
- 'storeId.keyword': req.body.storeId,
80
- },
81
- },
82
- {
83
- 'term': {
84
- 'processType': req.body.processType,
85
- },
86
- },
87
- {
88
- 'term': {
89
- 'dateString': req.body.dateString,
90
- },
91
- },
92
- // {
93
- // 'term': {
94
- // 'timeStamp': req.body.timeStamp,
95
- // },
96
- // },
97
- {
98
- 'term': {
99
- 'tempId': req.body.tempId,
100
- },
101
- },
102
- ],
103
- },
104
- },
105
- };
106
- let respo= await getOpenSearchData( openSearch.revops, searchQuery );
107
- const revopData = respo?.body?.hits?.hits;
108
- console.log( revopData );
109
- if ( revopData.length>0 ) {
110
- return res.sendSuccess( revopData[0]._source );
111
- } else {
112
- return res.sendError( 'no data found', 204 );
113
- }
114
- } catch ( error ) {
115
- logger.error( { error: error, message: req.query, function: 'getrevoptagging' } );
116
- return res.sendError( { error: error }, 500 );
117
- }
118
- }
@@ -1,13 +0,0 @@
1
-
2
- import express from 'express';
3
- import { getconfig, revoptagging, getrevoptagging } from '../controllers/revop.controller.js';
4
- import { isAllowedSessionHandler, isAllowedClient } from 'tango-app-api-middleware';
5
-
6
- export const revopRouter = express.Router();
7
-
8
- revopRouter
9
- .get( '/getconfig', isAllowedSessionHandler, isAllowedClient, getconfig )
10
- .post( '/tagging', isAllowedSessionHandler, isAllowedClient, revoptagging )
11
- .post( '/getrevoptagging', isAllowedSessionHandler, isAllowedClient, getrevoptagging );
12
-
13
- export default revopRouter;
@@ -1,16 +0,0 @@
1
- import revopConfigModel from 'tango-api-schema/schema/revopConfig.model.js';
2
-
3
-
4
- export async function createrevopConfig( field = {} ) {
5
- return await revopConfigModel.create( field );
6
- };
7
- export async function findOnerevopConfig( query = {} ) {
8
- return await revopConfigModel.findOne( query );
9
- };
10
-
11
- export async function updaterevopConfig( data={}, field = {} ) {
12
- return await revopConfigModel.updateOne( data, { $set: field } );
13
- };
14
- export async function aggregaterevopconfig( data ) {
15
- return await revopConfigModel.aggregate( data );
16
- };