tango-app-api-analysis-traffic 3.0.0-alpha.27 → 3.0.0-alpha.29
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-analysis-traffic",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.29",
|
|
4
4
|
"description": "Traffic Analysis",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"mongodb": "^6.8.0",
|
|
23
23
|
"nodemon": "^3.1.4",
|
|
24
24
|
"tango-api-schema": "^2.0.131",
|
|
25
|
-
"tango-app-api-middleware": "^3.1.
|
|
25
|
+
"tango-app-api-middleware": "^3.1.41",
|
|
26
26
|
"winston": "^3.13.1",
|
|
27
27
|
"winston-daily-rotate-file": "^5.0.0"
|
|
28
28
|
},
|
|
@@ -304,7 +304,7 @@ export const footfallDirectoryFoldersV1 = async ( req, res ) => {
|
|
|
304
304
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
305
305
|
if ( resultData ) {
|
|
306
306
|
if ( resultData.status_code == '200' ) {
|
|
307
|
-
return res.sendSuccess( resultData );
|
|
307
|
+
return res.sendSuccess( { ...resultData, isFootfallAuditStores: getClientData?.isFootfallAuditStores } );
|
|
308
308
|
} else {
|
|
309
309
|
return res.sendError( 'No Content', 204 );
|
|
310
310
|
}
|
|
@@ -329,7 +329,7 @@ export const footfallDirectoryV1 = async ( req, res ) => {
|
|
|
329
329
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
330
330
|
if ( resultData ) {
|
|
331
331
|
if ( resultData.status_code == '200' ) {
|
|
332
|
-
return res.sendSuccess( resultData );
|
|
332
|
+
return res.sendSuccess( { ...resultData, isFootfallAuditStores: getClientData?.isFootfallAuditStores } );
|
|
333
333
|
} else {
|
|
334
334
|
return res.sendError( 'No Content', 204 );
|
|
335
335
|
}
|
|
@@ -351,7 +351,29 @@ export const summaryTableV1 = async ( req, res ) => {
|
|
|
351
351
|
}
|
|
352
352
|
reqestData.featureConfigs = getClientData.featureConfigs;
|
|
353
353
|
let LamdaURL = 'https://fpmvquqpi7xw6hpaalxa5oa6pi0cvbql.lambda-url.ap-south-1.on.aws/';
|
|
354
|
-
let resultData
|
|
354
|
+
let resultData;
|
|
355
|
+
if ( reqestData.export ) {
|
|
356
|
+
let limit = 10000;
|
|
357
|
+
let count = 0;
|
|
358
|
+
for ( let i=0; i<=limit; i += 1000 ) {
|
|
359
|
+
reqestData.limit = 1000;
|
|
360
|
+
reqestData.offset = count;
|
|
361
|
+
let data = await LamdaServiceCall( LamdaURL, reqestData );
|
|
362
|
+
count ++;
|
|
363
|
+
if ( data.status_code == '200' && data.summaryData.length ) {
|
|
364
|
+
data = {
|
|
365
|
+
'status_code': '200',
|
|
366
|
+
'totalCount': resultData?.totalCount ? resultData?.totalCount + data.totalCount : data.totalCount,
|
|
367
|
+
'summaryData': resultData?.summaryData ? [ ...resultData?.summaryData, ...data.summaryData ] : data.summaryData,
|
|
368
|
+
};
|
|
369
|
+
resultData = data;
|
|
370
|
+
} else {
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
} else {
|
|
375
|
+
resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
376
|
+
}
|
|
355
377
|
if ( resultData ) {
|
|
356
378
|
if ( resultData.status_code == '200' ) {
|
|
357
379
|
if ( reqestData.export ) {
|
|
@@ -360,24 +382,24 @@ export const summaryTableV1 = async ( req, res ) => {
|
|
|
360
382
|
resultData.summaryData.forEach( ( element ) => {
|
|
361
383
|
exportdata.push( {
|
|
362
384
|
'Store Name': element.storeName,
|
|
363
|
-
'Store
|
|
364
|
-
|
|
385
|
+
'Store ID': element.storeId,
|
|
386
|
+
...( req.body.storeId.length ==1 ) ? { Date: element['date'] }:{},
|
|
387
|
+
'Footfall': element.footfallCount,
|
|
365
388
|
'Bounced Count': element.bouncedCount,
|
|
366
|
-
'Engagers
|
|
389
|
+
'Engagers': element.engagersCount,
|
|
390
|
+
'MissedOpportunity': element.missedOpportunityCount,
|
|
391
|
+
'Potential Buyers': element.potentialBuyersCount,
|
|
367
392
|
'Conversion Rate': element.conversionRate,
|
|
368
|
-
'
|
|
369
|
-
'
|
|
370
|
-
'
|
|
371
|
-
'AVG InfraDown Time': element.avgInfraDowntime,
|
|
372
|
-
'Male': element.male,
|
|
373
|
-
'Female': element.female,
|
|
374
|
-
'below12': element.below12,
|
|
393
|
+
'Avg.Dwell Time': element.avgDwellTime,
|
|
394
|
+
'Avg.Infra DownTime': element.avgInfraDowntime,
|
|
395
|
+
'Below12': element.below12,
|
|
375
396
|
'13-19': element['13-19'],
|
|
376
397
|
'20-30': element['20-30'],
|
|
377
|
-
'31-
|
|
378
|
-
'
|
|
379
|
-
'51-60': element['51-60'],
|
|
398
|
+
'31-45': element['31-45'],
|
|
399
|
+
'46-59': element['46-59'],
|
|
380
400
|
'60 above': element['60 above'],
|
|
401
|
+
'Male': element.male,
|
|
402
|
+
'Female': element.female,
|
|
381
403
|
} );
|
|
382
404
|
} );
|
|
383
405
|
return await download( exportdata, res );
|
|
@@ -461,21 +483,32 @@ export const performanceMatrixV1 = async ( req, res ) => {
|
|
|
461
483
|
let resultData = await LamdaServiceCall( LamdaURL, reqestData );
|
|
462
484
|
if ( resultData ) {
|
|
463
485
|
if ( resultData.status_code == '200' ) {
|
|
464
|
-
|
|
465
|
-
|
|
486
|
+
resultData.performanceData.forEach( ( item ) => {
|
|
487
|
+
delete item.top;
|
|
488
|
+
delete item.left;
|
|
489
|
+
} );
|
|
490
|
+
let data = [];
|
|
491
|
+
resultData.performanceData.forEach( ( item, index ) => {
|
|
492
|
+
data.push( item );
|
|
466
493
|
if ( item.position == 'High_Low' ) {
|
|
467
|
-
data[index].left =
|
|
468
|
-
data[index].top =
|
|
494
|
+
data[index].left = Math.floor( Math.random() * 40 );
|
|
495
|
+
data[index].top = Math.floor( Math.random() * 37 ) + 7;
|
|
469
496
|
} else if ( item.position == 'High_High' ) {
|
|
470
|
-
data[index].left =
|
|
471
|
-
data[index].top =
|
|
497
|
+
data[index].left = Math.floor( Math.random() * 40 ) + 50;
|
|
498
|
+
data[index].top = Math.floor( Math.random() * 37 ) + 7; ;
|
|
472
499
|
} else if ( item.position == 'Low_Low' ) {
|
|
473
|
-
data[index].left =
|
|
474
|
-
data[index].top =
|
|
475
|
-
console.log( data[index].left );
|
|
500
|
+
data[index].left = Math.floor( Math.random() * 40 );
|
|
501
|
+
data[index].top = Math.floor( Math.random() * 37 ) + 51;
|
|
476
502
|
} else {
|
|
477
|
-
data[index].left =
|
|
478
|
-
data[index].top =
|
|
503
|
+
data[index].left = Math.floor( Math.random() * 40 ) + 50;
|
|
504
|
+
data[index].top = Math.floor( Math.random() * 37 ) + 51;
|
|
505
|
+
}
|
|
506
|
+
let maxTop = data[index].top + 3;
|
|
507
|
+
let minTop = data[index].top - 3;
|
|
508
|
+
let checkNearest = data.filter( ( ele ) => ele.position == item.position && minTop <= ele.top && maxTop >= ele.top );
|
|
509
|
+
if ( checkNearest.length ) {
|
|
510
|
+
data[index].top = data[index].top + 3;
|
|
511
|
+
data[index].left = data[index].left + 5;
|
|
479
512
|
}
|
|
480
513
|
} );
|
|
481
514
|
resultData.performanceData = data;
|
|
@@ -1287,7 +1320,7 @@ async function getGroupStoresIds( userClientId, storeIds, getRole, getUserType,
|
|
|
1287
1320
|
|
|
1288
1321
|
async function getClientConfig( clientId ) {
|
|
1289
1322
|
try {
|
|
1290
|
-
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 } );
|
|
1323
|
+
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 } );
|
|
1291
1324
|
if ( !getClientData ) {
|
|
1292
1325
|
return false;
|
|
1293
1326
|
}
|
|
@@ -1298,44 +1331,6 @@ async function getClientConfig( clientId ) {
|
|
|
1298
1331
|
}
|
|
1299
1332
|
}
|
|
1300
1333
|
|
|
1301
|
-
export async function isAllowedClient( req, res, next ) {
|
|
1302
|
-
try {
|
|
1303
|
-
let reqestData = req.body;
|
|
1304
|
-
let getUserEmail = req.user.email;
|
|
1305
|
-
let getUserType = req.user.userType;
|
|
1306
|
-
let getClientId = req.user.clientId;
|
|
1307
|
-
let getRole = req.user.role;
|
|
1308
|
-
if ( getUserType == 'tango' ) {
|
|
1309
|
-
if ( getRole == 'superadmin' ) {
|
|
1310
|
-
next();
|
|
1311
|
-
} else {
|
|
1312
|
-
const assignedQuery = {
|
|
1313
|
-
userEmail: getUserEmail,
|
|
1314
|
-
assignedType: 'client',
|
|
1315
|
-
assignedValue: reqestData.clientId,
|
|
1316
|
-
};
|
|
1317
|
-
const getAssignedType = await findOneUserAssignedStore( assignedQuery );
|
|
1318
|
-
if ( getAssignedType ) {
|
|
1319
|
-
next();
|
|
1320
|
-
} else {
|
|
1321
|
-
return res.sendError( 'Client Not Assigned', 400 );
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
} else if ( getUserType == 'client' ) {
|
|
1325
|
-
if ( getClientId == reqestData.clientId ) {
|
|
1326
|
-
next();
|
|
1327
|
-
} else {
|
|
1328
|
-
return res.sendError( 'Client Not Assigned', 400 );
|
|
1329
|
-
}
|
|
1330
|
-
} else {
|
|
1331
|
-
return res.sendError( 'Client Not Assigned', 400 );
|
|
1332
|
-
}
|
|
1333
|
-
} catch ( error ) {
|
|
1334
|
-
logger.error( { error: error, function: 'isAllowedClient' } );
|
|
1335
|
-
return res.sendError( error, 500 );
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
1334
|
export const getMySubscription = async ( req, res ) => {
|
|
1340
1335
|
try {
|
|
1341
1336
|
let reqestData = req.body;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { validate,
|
|
2
|
+
import { validate, isAllowedMobileSessionHandler, authorize } from 'tango-app-api-middleware';
|
|
3
3
|
import * as validationDtos from '../dtos/validation.dtos.js';
|
|
4
4
|
export const mobileTrafficAnalysisRouter = express.Router();
|
|
5
5
|
import {
|
|
@@ -21,85 +21,85 @@ import {
|
|
|
21
21
|
} from '../controllers/mobileTraffic.controllers.js';
|
|
22
22
|
|
|
23
23
|
mobileTrafficAnalysisRouter
|
|
24
|
-
.post( '/cardsFunnel_v1',
|
|
24
|
+
.post( '/cardsFunnel_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
25
25
|
userType: [ 'tango', 'client' ], access: [
|
|
26
26
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
27
27
|
],
|
|
28
28
|
} ), validate( validationDtos.validateCardFunnelParams ), cardsFunnelV1 )
|
|
29
29
|
|
|
30
|
-
.post( '/cardsGraphs_v1',
|
|
30
|
+
.post( '/cardsGraphs_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
31
31
|
userType: [ 'tango', 'client' ], access: [
|
|
32
32
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
33
33
|
],
|
|
34
34
|
} ), validate( validationDtos.validateCardGraphParams ), cardsGraphsV1 )
|
|
35
35
|
|
|
36
|
-
.post( '/recapVideo_v1',
|
|
36
|
+
.post( '/recapVideo_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
37
37
|
userType: [ 'tango', 'client' ], access: [
|
|
38
38
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
39
39
|
],
|
|
40
40
|
} ), validate( validationDtos.validateRecapVideoParams ), recapVideoV1 )
|
|
41
41
|
|
|
42
|
-
.post( '/densityDwell_v1',
|
|
42
|
+
.post( '/densityDwell_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
43
43
|
userType: [ 'tango', 'client' ], access: [
|
|
44
44
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
45
45
|
],
|
|
46
46
|
} ), validate( validationDtos.validateDensityDwellParams ), densityDwellV1 )
|
|
47
47
|
|
|
48
|
-
.post( '/overallCards_v1',
|
|
48
|
+
.post( '/overallCards_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
49
49
|
userType: [ 'tango', 'client' ], access: [
|
|
50
50
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
51
51
|
],
|
|
52
52
|
} ), validate( validationDtos.validateOverallCharParams ), overallCardsV1 )
|
|
53
53
|
|
|
54
|
-
.post( '/overallChart_v1',
|
|
54
|
+
.post( '/overallChart_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
55
55
|
userType: [ 'tango', 'client' ], access: [
|
|
56
56
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
57
57
|
],
|
|
58
58
|
} ), validate( validationDtos.validateOverallCharParams ), overallChartV1 )
|
|
59
59
|
|
|
60
|
-
.post( '/singleStoreChart_v1',
|
|
60
|
+
.post( '/singleStoreChart_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
61
61
|
userType: [ 'tango', 'client' ], access: [
|
|
62
62
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
63
63
|
],
|
|
64
64
|
} ), validate( validationDtos.validateSingleStoreChartParams ), singleStoreChartV1 )
|
|
65
65
|
|
|
66
|
-
.post( '/demographicChart_v1',
|
|
66
|
+
.post( '/demographicChart_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
67
67
|
userType: [ 'tango', 'client' ], access: [
|
|
68
68
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
69
69
|
],
|
|
70
70
|
} ), validate( validationDtos.validateDemographicChartParams ), demographicChartV1 )
|
|
71
71
|
|
|
72
|
-
.post( '/buyerChart_v1',
|
|
72
|
+
.post( '/buyerChart_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
73
73
|
userType: [ 'tango', 'client' ], access: [
|
|
74
74
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
75
75
|
],
|
|
76
76
|
} ), validate( validationDtos.validateBuyerChartParams ), buyerChartV1 )
|
|
77
77
|
|
|
78
|
-
.post( '/footfallDirectoryFolders_v1',
|
|
78
|
+
.post( '/footfallDirectoryFolders_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
79
79
|
userType: [ 'tango', 'client' ], access: [
|
|
80
80
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
81
81
|
],
|
|
82
82
|
} ), validate( validationDtos.validateFootfallDirectoryFoldersParams ), footfallDirectoryFoldersV1 )
|
|
83
83
|
|
|
84
|
-
.post( '/footfallDirectory_v1',
|
|
84
|
+
.post( '/footfallDirectory_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
85
85
|
userType: [ 'tango', 'client' ], access: [
|
|
86
86
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
87
87
|
],
|
|
88
88
|
} ), validate( validationDtos.validateFootfallDirectoryParams ), footfallDirectoryV1 )
|
|
89
89
|
|
|
90
|
-
.post( '/storeOperation_v1',
|
|
90
|
+
.post( '/storeOperation_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
91
91
|
userType: [ 'tango', 'client' ], access: [
|
|
92
92
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
93
93
|
],
|
|
94
94
|
} ), validate( validationDtos.validateStoreOperationParams ), storeOperationV1 )
|
|
95
95
|
|
|
96
|
-
.post( '/zoneDwellTimeSplit_v1',
|
|
96
|
+
.post( '/zoneDwellTimeSplit_v1', isAllowedMobileSessionHandler, isAllowedClient, authorize( {
|
|
97
97
|
userType: [ 'tango', 'client' ], access: [
|
|
98
98
|
{ featureName: 'analytics', name: 'tangoTraffic', permissions: [ 'isView' ] },
|
|
99
99
|
],
|
|
100
100
|
} ), validate( validationDtos.validateStoreOperationParams ), zoneDwellTimeSplitV1 )
|
|
101
101
|
|
|
102
|
-
.post( '/getMySubscription_v1',
|
|
102
|
+
.post( '/getMySubscription_v1', isAllowedMobileSessionHandler, validate( validationDtos.getMyProductParams ), getMySubscription );
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
export default mobileTrafficAnalysisRouter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { validate, isAllowedSessionHandler, authorize } from 'tango-app-api-middleware';
|
|
2
|
+
import { validate, isAllowedSessionHandler, authorize, isAllowedClient } from 'tango-app-api-middleware';
|
|
3
3
|
import * as validationDtos from '../dtos/validation.dtos.js';
|
|
4
4
|
|
|
5
5
|
export const analysisTrafficRouter = express.Router();
|
|
@@ -51,7 +51,6 @@ import {
|
|
|
51
51
|
headerStoresV1,
|
|
52
52
|
headerLocationsV1,
|
|
53
53
|
headerGroupsV1,
|
|
54
|
-
isAllowedClient,
|
|
55
54
|
getMySubscription,
|
|
56
55
|
getStoreMapData,
|
|
57
56
|
} from '../controllers/tangoTrafficV1.controllers.js';
|