@bikdotai/bik-shared-backend 20.3.1 → 20.3.2-beta.0
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/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncDelay.d.ts +1 -0
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncDelay.js +4 -0
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncFailed.d.ts +1 -0
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncFailed.js +4 -0
- package/lib/alerts/templates/campaign/campaignScheduledTimeExceededDueToSyncDelay.d.ts +1 -0
- package/lib/alerts/templates/campaign/campaignScheduledTimeExceededDueToSyncDelay.js +4 -0
- package/lib/alertsV2/alertInstances.repo.js +26 -2
- package/lib/alertsV2/alertsV2.helper.d.ts +3 -4
- package/lib/alertsV2/alertsV2.helper.js +49 -3
- package/lib/alertsV2/alertsV2.service.js +14 -5
- package/lib/auth/authMiddlewares.js +68 -3
- package/lib/auth/firebase-auth.service.js +3 -3
- package/lib/auth/implementations/bik-admin-auth-service.d.ts +1 -1
- package/lib/auth/implementations/bik-admin-auth-service.js +2 -1
- package/lib/auth/index.d.ts +3 -0
- package/lib/auth/index.js +3 -0
- package/lib/auth/secret-manager/configManager.firestore.d.ts +22 -0
- package/lib/auth/secret-manager/configManager.firestore.js +166 -0
- package/lib/auth/secret-manager/configManager.helper.d.ts +13 -0
- package/lib/auth/secret-manager/configManager.helper.js +32 -0
- package/lib/auth/secret-manager/configManager.model.d.ts +38 -0
- package/lib/auth/secret-manager/configManager.model.js +2 -0
- package/lib/auth/secret-manager/configManager.service.d.ts +17 -0
- package/lib/auth/secret-manager/configManager.service.js +138 -0
- package/lib/auth/secret-manager/env-variables/variables.list.d.ts +3 -0
- package/lib/auth/secret-manager/env-variables/variables.list.js +3 -0
- package/lib/chat-handover-protocol/chat-handover-protocol.js +26 -41
- package/lib/core/local_runner.js +28 -11
- package/lib/core/setup.d.ts +3 -0
- package/lib/core/setup.js +24 -2
- package/lib/database/database.model.d.ts +95 -0
- package/lib/database/database.model.js +5 -0
- package/lib/database/database.service.d.ts +90 -0
- package/lib/database/database.service.js +382 -0
- package/lib/database/index.d.ts +7 -0
- package/lib/database/index.js +23 -0
- package/lib/elastic/counter/ingestion.js +1 -0
- package/lib/elastic/queries/campaign/getBroadcastDetailedStats.d.ts +117 -0
- package/lib/elastic/queries/campaign/getBroadcastDetailedStats.js +94 -1
- package/lib/elastic/queries/campaign/getUniqueCustomerCnt.d.ts +1 -0
- package/lib/elastic/queries/campaign/getUniqueCustomerCnt.js +1 -0
- package/lib/elastic/queries/chatbot/getAgentCostForBroadcast.d.ts +117 -0
- package/lib/elastic/queries/chatbot/getAgentCostForBroadcast.js +98 -0
- package/lib/elastic/queries/chatbot/getAiOperations.d.ts +5 -5
- package/lib/elastic/queries/chatbot/getAiOperations.js +3 -3
- package/lib/elastic/queries/chatbot/index.d.ts +1 -0
- package/lib/elastic/queries/chatbot/index.js +1 -0
- package/lib/elastic/queries/crm/getActivityTimelineByAgent.js +1 -1
- package/lib/elastic/queries/crm/getBreachedSLACount.d.ts +1 -0
- package/lib/elastic/queries/crm/getBreachedSLACount.js +8 -5
- package/lib/elastic/queries/crm/getFirstResponseTime.d.ts +1 -0
- package/lib/elastic/queries/crm/getFirstResponseTime.js +8 -5
- package/lib/elastic/queries/integrations/getOrdersShadowServices.d.ts +76 -0
- package/lib/elastic/queries/integrations/getOrdersShadowServices.js +61 -0
- package/lib/elastic/queries/integrations/index.d.ts +1 -0
- package/lib/elastic/queries/integrations/index.js +1 -0
- package/lib/elastic/queries/openAi/addToCartSession.d.ts +1 -0
- package/lib/elastic/queries/openAi/addToCartSession.js +11 -3
- package/lib/elastic/queries/openAi/checkoutCompletedSession.d.ts +1 -0
- package/lib/elastic/queries/openAi/checkoutCompletedSession.js +11 -3
- package/lib/elastic/reports/crm/index.d.ts +1 -0
- package/lib/elastic/reports/crm/index.js +1 -0
- package/lib/elastic/reports/reports.service.js +17 -8
- package/lib/events/events.d.ts +8 -0
- package/lib/events/events.js +25 -1
- package/lib/events/schema/events.helper.d.ts +1 -0
- package/lib/events/schema/events.helper.js +12 -6
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/merchant-events/elastic.search.d.ts +5 -0
- package/lib/merchant-events/elastic.search.js +23 -2
- package/lib/merchant-events/merchant.service.d.ts +1 -1
- package/lib/merchant-events/merchant.service.js +12 -11
- package/lib/recordAnalytics/recordAnalytics.service.js +5 -4
- package/lib/redis/redisPubSubService.d.ts +4 -6
- package/lib/redis/redisPubSubService.js +211 -123
- package/lib/redis/redisService.js +14 -8
- package/lib/swagger/SwaggerSchemaHelper.js +21 -17
- package/lib/user-properties/userProperties.service.js +1 -0
- package/package.json +2 -2
|
@@ -74,7 +74,6 @@ _a = ReportService;
|
|
|
74
74
|
ReportService.generateReport = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
75
|
var _b;
|
|
76
76
|
var _c, _d;
|
|
77
|
-
const startTime = new Date().getTime();
|
|
78
77
|
let { storeId, moduleName, reportName, payload, getSignedUrl } = args;
|
|
79
78
|
const module = yield (_b = './' + moduleName + '/' + reportName, Promise.resolve().then(() => __importStar(require(_b))));
|
|
80
79
|
const { exportFileName } = payload;
|
|
@@ -83,6 +82,9 @@ ReportService.generateReport = (args) => __awaiter(void 0, void 0, void 0, funct
|
|
|
83
82
|
try {
|
|
84
83
|
const reportInstance = new module[fileName]();
|
|
85
84
|
const response = yield reportInstance.executeReport(storeId, payload);
|
|
85
|
+
console.log(`@ReportService generateReport initial apiResponse for ${reportName}`, {
|
|
86
|
+
response: JSON.stringify(response),
|
|
87
|
+
});
|
|
86
88
|
if (response.response &&
|
|
87
89
|
(response.nextPage || Object.keys((_c = response.searchAfter) !== null && _c !== void 0 ? _c : {}).length)) {
|
|
88
90
|
const uuid = (0, uuid_1.v4)();
|
|
@@ -91,7 +93,7 @@ ReportService.generateReport = (args) => __awaiter(void 0, void 0, void 0, funct
|
|
|
91
93
|
yield file_helper_1.FileHelper.appendDataToLocalFileCSV(fileName, response.header, response.response, true);
|
|
92
94
|
const timer = new timer_1.Timer();
|
|
93
95
|
timer.startTimer();
|
|
94
|
-
|
|
96
|
+
return yield ReportService.fetchDataAndSaveInFile({
|
|
95
97
|
args,
|
|
96
98
|
reportInstance,
|
|
97
99
|
nextPage: response.nextPage,
|
|
@@ -100,13 +102,8 @@ ReportService.generateReport = (args) => __awaiter(void 0, void 0, void 0, funct
|
|
|
100
102
|
actionType: payload.actionType,
|
|
101
103
|
timer,
|
|
102
104
|
});
|
|
103
|
-
const endTime = new Date().getTime();
|
|
104
|
-
console.log('@generateReport', 'Time taken to generate recur report in sec', reportName, (endTime - startTime) / 1000);
|
|
105
|
-
return res;
|
|
106
105
|
}
|
|
107
106
|
response.csvLink = yield reports_helper_1.ReportsServiceHelper.convertTableDataToCSV(response.response || [], response.header, storeId, exportFileName || reportName, getSignedUrl);
|
|
108
|
-
const endTime = new Date().getTime();
|
|
109
|
-
console.log('@generateReport', 'Time taken to generate report in sec', reportName, (endTime - startTime) / 1000);
|
|
110
107
|
return apis_1.FunctionResponseHelper.success(response);
|
|
111
108
|
}
|
|
112
109
|
catch (error) {
|
|
@@ -124,6 +121,9 @@ ReportService.fetchDataAndSaveInFile = (request) => __awaiter(void 0, void 0, vo
|
|
|
124
121
|
let { nextPage, searchAfter } = request;
|
|
125
122
|
const { storeId, reportName, payload } = args;
|
|
126
123
|
const { exportFileName } = payload;
|
|
124
|
+
if (!reportInstance) {
|
|
125
|
+
throw new Error('reportInstance is required for V2 implementation');
|
|
126
|
+
}
|
|
127
127
|
const firebaseStorageService = new firebaseStorageService_1.FirebaseStorageService();
|
|
128
128
|
const TIME_LIMIT = 25; // 25 sec
|
|
129
129
|
let iterationCount = 0;
|
|
@@ -134,10 +134,19 @@ ReportService.fetchDataAndSaveInFile = (request) => __awaiter(void 0, void 0, vo
|
|
|
134
134
|
// Iterative loop - allows GC to clean up each iteration
|
|
135
135
|
while (true) {
|
|
136
136
|
iterationCount++;
|
|
137
|
+
// Log memory usage every 10 iterations
|
|
138
|
+
if (iterationCount % 10 === 0) {
|
|
139
|
+
const memUsage = process.memoryUsage();
|
|
140
|
+
console.log(`@fetchDataAndSaveInFile [Iteration ${iterationCount}] Memory:`, {
|
|
141
|
+
heapUsed: `${(memUsage.heapUsed / 1024 / 1024).toFixed(2)} MB`,
|
|
142
|
+
heapTotal: `${(memUsage.heapTotal / 1024 / 1024).toFixed(2)} MB`,
|
|
143
|
+
rss: `${(memUsage.rss / 1024 / 1024).toFixed(2)} MB`,
|
|
144
|
+
external: `${(memUsage.external / 1024 / 1024).toFixed(2)} MB`,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
137
147
|
// Check file size limit
|
|
138
148
|
[isFileSizeExceeded, fileSize] = yield file_helper_1.FileHelper.isFileSizeExceeded(localTempFile, actionType || 'download');
|
|
139
149
|
if (isFileSizeExceeded) {
|
|
140
|
-
console.log('@generateReport File size exceeded', fileSize, reportName, storeId);
|
|
141
150
|
break;
|
|
142
151
|
}
|
|
143
152
|
// Check time limit for view action
|
package/lib/events/events.d.ts
CHANGED
|
@@ -36,3 +36,11 @@ export declare function forwardEventsToPod(params: {
|
|
|
36
36
|
requireEventValidation?: boolean;
|
|
37
37
|
logEvent?: boolean;
|
|
38
38
|
}): ResolvedFunctionResponse<PushEventsResponse>;
|
|
39
|
+
export declare function recordEventsInBulk(rawEvents: Event[], isMigration?: boolean): Promise<import("../apis").FunctionResponse<{
|
|
40
|
+
bulkResponse: {
|
|
41
|
+
items: never[];
|
|
42
|
+
errors: boolean;
|
|
43
|
+
took: number;
|
|
44
|
+
};
|
|
45
|
+
failedIds: never[];
|
|
46
|
+
}> | undefined>;
|
package/lib/events/events.js
CHANGED
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.forwardEventsToPod = exports.generateEventId = exports.validateEvent = exports.pushEventsWithoutCustomerId = exports.pushEvents = exports.pushEventWithoutCustomerId = exports.getUpdateEventSource = exports.pushEvent = exports.getUatStoreIds = exports.REQUIRE_EVENT_VALIDATION = void 0;
|
|
35
|
+
exports.recordEventsInBulk = exports.forwardEventsToPod = exports.generateEventId = exports.validateEvent = exports.pushEventsWithoutCustomerId = exports.pushEvents = exports.pushEventWithoutCustomerId = exports.getUpdateEventSource = exports.pushEvent = exports.getUatStoreIds = exports.REQUIRE_EVENT_VALIDATION = void 0;
|
|
36
36
|
const pubsub_listener_1 = require("../pubsub-listener");
|
|
37
37
|
const Events = __importStar(require("@bikdotai/bik-models/events"));
|
|
38
38
|
const string_1 = require("../utils/string");
|
|
@@ -42,6 +42,7 @@ const events_forwarding_1 = require("./forwarding/events-forwarding");
|
|
|
42
42
|
const uuid_1 = require("uuid");
|
|
43
43
|
const events_helper_1 = require("./events.helper");
|
|
44
44
|
const auth_1 = require("../auth");
|
|
45
|
+
const ingestion_1 = require("../elastic/counter/ingestion");
|
|
45
46
|
exports.REQUIRE_EVENT_VALIDATION = true;
|
|
46
47
|
function getUatStoreIds() {
|
|
47
48
|
return (auth_1.EnvVariableHelper.access(auth_1.ServiceName.CONSTANTS, auth_1.ConstantsKeys.UAT_STORE_IDS) || '')
|
|
@@ -445,3 +446,26 @@ function sanitizeEventPropertiesAndFixTypes(event, eventValidator) {
|
|
|
445
446
|
const uniqueFixedErrors = [...new Set(fixedErrors)];
|
|
446
447
|
return { correctedEvent, errors: uniqueErrors, fixedErrors: uniqueFixedErrors };
|
|
447
448
|
}
|
|
449
|
+
function recordEventsInBulk(rawEvents, isMigration) {
|
|
450
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
451
|
+
let events;
|
|
452
|
+
try {
|
|
453
|
+
events = (yield new ingestion_1.CounterEventIngestionService().pushCounterEventsAndGiveRest(rawEvents));
|
|
454
|
+
}
|
|
455
|
+
catch (e) {
|
|
456
|
+
console.error('Error in pushCounterEventsAndGiveRest', e, { postOnSlack: true });
|
|
457
|
+
events = rawEvents;
|
|
458
|
+
}
|
|
459
|
+
if (!events || events.length === 0) {
|
|
460
|
+
return apis_1.FunctionResponseHelper.success({
|
|
461
|
+
bulkResponse: {
|
|
462
|
+
items: [],
|
|
463
|
+
errors: false,
|
|
464
|
+
took: 0,
|
|
465
|
+
},
|
|
466
|
+
failedIds: [],
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
exports.recordEventsInBulk = recordEventsInBulk;
|
|
@@ -21,6 +21,7 @@ export declare class EventsHelper {
|
|
|
21
21
|
static getHistogramAggregation(startDate: string | Date, endDate: string | Date, timeZone?: string, useExactBounds?: boolean): any;
|
|
22
22
|
static identifyAndConvertDateString(str: string): string;
|
|
23
23
|
static isStaticIndexName(indexName: string): boolean;
|
|
24
|
+
static isStoreSpecificIndexName(indexName: string): boolean;
|
|
24
25
|
static getIndexOrAliasName(indexName?: string): string;
|
|
25
26
|
static getDataStreamName(eventName: Events): string;
|
|
26
27
|
static getIndexAndInstanceId(storeId: string, bikStore?: BikStore): Promise<GetIndexAndInstanceIdOutput>;
|
|
@@ -66,9 +66,9 @@ class EventsHelper {
|
|
|
66
66
|
// nonAnalyticsDs,
|
|
67
67
|
// });
|
|
68
68
|
return {
|
|
69
|
-
ANALYTICS_CAMPAIGN_DATA_STREAM: campaignDs || '
|
|
70
|
-
ANALYTICS_CHATBOT_DATA_STREAM: chatbotDs || '
|
|
71
|
-
NON_ANALYTICS_DATA_STREAM: nonAnalyticsDs || '
|
|
69
|
+
ANALYTICS_CAMPAIGN_DATA_STREAM: campaignDs || 'staging-campaign-analytics-ds',
|
|
70
|
+
ANALYTICS_CHATBOT_DATA_STREAM: chatbotDs || 'staging-chatbot-analytics-ds',
|
|
71
|
+
NON_ANALYTICS_DATA_STREAM: nonAnalyticsDs || 'staging-non-analytics-ds',
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
static getIndexNameForStoreId(storeId) {
|
|
@@ -144,14 +144,19 @@ class EventsHelper {
|
|
|
144
144
|
}
|
|
145
145
|
return str;
|
|
146
146
|
}
|
|
147
|
+
// `store-events-*-ds` data streams for a store are static indices
|
|
148
|
+
// ex: bik-internal-events, bsp-prod, store-events-group-1-analytics-ds
|
|
147
149
|
static isStaticIndexName(indexName) {
|
|
148
|
-
return exports.STATIC_INDEX_NAMES.includes(indexName);
|
|
150
|
+
return exports.STATIC_INDEX_NAMES.includes(indexName) || (indexName === null || indexName === void 0 ? void 0 : indexName.startsWith('store-events-'));
|
|
151
|
+
}
|
|
152
|
+
static isStoreSpecificIndexName(indexName) {
|
|
153
|
+
return indexName.startsWith('store-events-');
|
|
149
154
|
}
|
|
150
155
|
static getIndexOrAliasName(indexName) {
|
|
151
156
|
if (!indexName) {
|
|
152
157
|
return exports.INDEX_ALIAS_NAME; //events-prod-alias
|
|
153
158
|
}
|
|
154
|
-
if (
|
|
159
|
+
if (this.isStaticIndexName(indexName)) {
|
|
155
160
|
return indexName; // static index names
|
|
156
161
|
}
|
|
157
162
|
if (indexName.includes('manifest')) {
|
|
@@ -178,8 +183,9 @@ class EventsHelper {
|
|
|
178
183
|
const cacheKey = this.getIndexAndInstanceCacheKey(storeId);
|
|
179
184
|
const centralCacheService = redis_1.CentralCacheService.getInstance();
|
|
180
185
|
const { data: dataFromCache } = yield centralCacheService.retrieveData(cacheKey, {
|
|
181
|
-
cachesToUse: [types_1.CacheTypes.REDIS],
|
|
186
|
+
cachesToUse: [types_1.CacheTypes.LRU, types_1.CacheTypes.REDIS],
|
|
182
187
|
ttlMap: {
|
|
188
|
+
[types_1.CacheTypes.LRU]: 60 * 5,
|
|
183
189
|
[types_1.CacheTypes.REDIS]: 7 * 60 * 60 * 24, // 7 days
|
|
184
190
|
},
|
|
185
191
|
}, () => __awaiter(this, void 0, void 0, function* () {
|
package/lib/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from './variable-management';
|
|
|
8
8
|
export * from './cloudTasks';
|
|
9
9
|
export * from './releaseJet/index';
|
|
10
10
|
export * from './fastify/main';
|
|
11
|
+
export * from './database';
|
|
11
12
|
export * from './alertsV2/alertsV2.service';
|
|
12
13
|
export * from './index-filtering';
|
|
13
14
|
export * from './messaging-transformer/messagingTransformer.service';
|
package/lib/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./variable-management"), exports);
|
|
|
24
24
|
__exportStar(require("./cloudTasks"), exports);
|
|
25
25
|
__exportStar(require("./releaseJet/index"), exports);
|
|
26
26
|
__exportStar(require("./fastify/main"), exports);
|
|
27
|
+
__exportStar(require("./database"), exports);
|
|
27
28
|
__exportStar(require("./alertsV2/alertsV2.service"), exports);
|
|
28
29
|
__exportStar(require("./index-filtering"), exports);
|
|
29
30
|
__exportStar(require("./messaging-transformer/messagingTransformer.service"), exports);
|
|
@@ -34,6 +34,10 @@ export declare class ElasticSearchService {
|
|
|
34
34
|
deleteEventsFromElastic(index: string, documentIds: string[]): Promise<void>;
|
|
35
35
|
bulk(bulkUpdateOperations: any): Promise<boolean>;
|
|
36
36
|
recordCounterEvents(index: string, events: Map<string, CounterDbEvent>): ResolvedFunctionResponse<undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Helper method to check if an index name is a data stream
|
|
39
|
+
*/
|
|
40
|
+
private isDataStream;
|
|
37
41
|
bulkInsertToES(index: string | undefined, bulkBody: Event[]): ResolvedFunctionResponse<BulkInsertToESResponse>;
|
|
38
42
|
bulkInsertToElastic(index: string, bulkBody: any[]): Promise<{
|
|
39
43
|
success: boolean;
|
|
@@ -41,6 +45,7 @@ export declare class ElasticSearchService {
|
|
|
41
45
|
}>;
|
|
42
46
|
rawSearch(query: any): Promise<any>;
|
|
43
47
|
count(query: any): Promise<CountResponse>;
|
|
48
|
+
private getDataStreamNameFromQuery;
|
|
44
49
|
/**
|
|
45
50
|
*
|
|
46
51
|
* @param podName
|
|
@@ -310,6 +310,12 @@ class ElasticSearchService {
|
|
|
310
310
|
}
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Helper method to check if an index name is a data stream
|
|
315
|
+
*/
|
|
316
|
+
isDataStream(indexName) {
|
|
317
|
+
return indexName.includes('analytics-ds') || indexName.startsWith('.ds-');
|
|
318
|
+
}
|
|
313
319
|
bulkInsertToES(index, bulkBody) {
|
|
314
320
|
var _a, _b, _c;
|
|
315
321
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -323,6 +329,7 @@ class ElasticSearchService {
|
|
|
323
329
|
const eventIdsForCreateOrUpdate = [];
|
|
324
330
|
const idToIndexMap = new Map();
|
|
325
331
|
const isDataStreamTarget = events_helper_1.EventsHelper.isDataStream(index);
|
|
332
|
+
const isStoreSpecificIndexName = events_helper_1.EventsHelper.isStoreSpecificIndexName(index);
|
|
326
333
|
for (let data of bulkBody) {
|
|
327
334
|
if ((data === null || data === void 0 ? void 0 : data.isMigrationEvent) && (data === null || data === void 0 ? void 0 : data.eventId)) {
|
|
328
335
|
// events to be updated (only for non-data-stream targets)
|
|
@@ -348,9 +355,13 @@ class ElasticSearchService {
|
|
|
348
355
|
}
|
|
349
356
|
if (eventIdsForCreateOrUpdate.length > 0) {
|
|
350
357
|
// for migration events we need to find the exact index where the event is stored from the alias and non-analytics data stream
|
|
358
|
+
// for store specific index names, we only search in that index
|
|
351
359
|
const { NON_ANALYTICS_DATA_STREAM } = events_helper_1.EventsHelper.getDataStreamNamesFromEnv();
|
|
360
|
+
const indexToSearch = isStoreSpecificIndexName
|
|
361
|
+
? index
|
|
362
|
+
: [events_helper_1.INDEX_ALIAS_NAME, NON_ANALYTICS_DATA_STREAM];
|
|
352
363
|
const res = yield this.esClient.search({
|
|
353
|
-
index:
|
|
364
|
+
index: indexToSearch,
|
|
354
365
|
_source: ['eventId'],
|
|
355
366
|
track_scores: false,
|
|
356
367
|
body: {
|
|
@@ -403,7 +414,7 @@ class ElasticSearchService {
|
|
|
403
414
|
});
|
|
404
415
|
}
|
|
405
416
|
else {
|
|
406
|
-
//
|
|
417
|
+
// new migration events will also go to the old alias
|
|
407
418
|
const _id = (data === null || data === void 0 ? void 0 : data.eventId) || (0, uuid_1.v4)();
|
|
408
419
|
documents.push({ index: { _index: events_helper_1.INDEX_ALIAS_NAME, _id } });
|
|
409
420
|
documents.push(data);
|
|
@@ -424,6 +435,7 @@ class ElasticSearchService {
|
|
|
424
435
|
});
|
|
425
436
|
}
|
|
426
437
|
else {
|
|
438
|
+
// new migration events will also go to the old alias
|
|
427
439
|
const _id = (data === null || data === void 0 ? void 0 : data.eventId) || (0, uuid_1.v4)();
|
|
428
440
|
documents.push({ index: { _index: events_helper_1.INDEX_ALIAS_NAME, _id } });
|
|
429
441
|
documents.push(data);
|
|
@@ -484,6 +496,7 @@ class ElasticSearchService {
|
|
|
484
496
|
return currOutput;
|
|
485
497
|
});
|
|
486
498
|
}
|
|
499
|
+
getDataStreamNameFromQuery() { }
|
|
487
500
|
/**
|
|
488
501
|
*
|
|
489
502
|
* @param podName
|
|
@@ -507,6 +520,14 @@ class ElasticSearchService {
|
|
|
507
520
|
var _d;
|
|
508
521
|
logger_1.LogExecutionContextHelper.setCustomProperty('queryName', queryName);
|
|
509
522
|
try {
|
|
523
|
+
//TODO: remove after testing
|
|
524
|
+
const info = yield this.esClient.info();
|
|
525
|
+
console.log('esClient info', {
|
|
526
|
+
clusterName: info.cluster_name,
|
|
527
|
+
clusterUuid: info.cluster_uuid,
|
|
528
|
+
version: info.version.number,
|
|
529
|
+
storeId: queryParams.storeId,
|
|
530
|
+
});
|
|
510
531
|
const executionStartTime = Date.now();
|
|
511
532
|
if (!queryParams.storeId) {
|
|
512
533
|
return apis_1.FunctionResponseHelper.failed(apis_1.ErrorCodes.VALIDATION_FAILED, 'storeId not present in queryParams');
|
|
@@ -9,7 +9,7 @@ export declare class BikInternalEventsService {
|
|
|
9
9
|
static getInstance(): BikInternalEventsService;
|
|
10
10
|
private static getContextFromSession;
|
|
11
11
|
static logFunctionResponse(storeId: string, code: string, response: FunctionResponse<any>): Promise<FunctionResponse<undefined>>;
|
|
12
|
-
static preparePayloadForLogging(bikStore: BikStore, bikEvent: BikInternalEvent, skipCommonEvents?: boolean): BikInternalEvent
|
|
12
|
+
static preparePayloadForLogging(bikStore: BikStore, bikEvent: BikInternalEvent, skipCommonEvents?: boolean): BikInternalEvent;
|
|
13
13
|
static recordEventInMailModo(bikStore: BikStore, bikEvent: BikInternalEvent): ResolvedFunctionResponse<undefined>;
|
|
14
14
|
static recordEventInSlack(bikStore: BikStore, bikEvent: BikInternalEvent, slackChannelId: string, messageFormattingConfig?: MessageFormattingConfig): ResolvedFunctionResponse<undefined>;
|
|
15
15
|
static recordEventInElastic(bikStore: BikStore, bikEvent: BikInternalEvent, skipCommonEvents?: boolean): ResolvedFunctionResponse<undefined>;
|
|
@@ -60,7 +60,7 @@ class BikInternalEventsService {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
static preparePayloadForLogging(bikStore, bikEvent, skipCommonEvents) {
|
|
63
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
63
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
64
64
|
const testEmail = [
|
|
65
65
|
'dev@bikayi.com',
|
|
66
66
|
'dev@bik.ai',
|
|
@@ -74,18 +74,19 @@ class BikInternalEventsService {
|
|
|
74
74
|
'shrinkhla@bik.ai',
|
|
75
75
|
'sumit.kumar1@bik.ai',
|
|
76
76
|
];
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
// Removed Skip recording events for test users for testing
|
|
78
|
+
// if (testEmail.includes(bikStore?.bikLoginEmail ?? '') || testEmail.includes(bikStore?.email)) {
|
|
79
|
+
// // not logging events for internal test stores
|
|
80
|
+
// return undefined;
|
|
81
|
+
// }
|
|
81
82
|
const commonEventsForBik = {
|
|
82
83
|
'Store name': bikStore.storeName,
|
|
83
|
-
'Store type': ((
|
|
84
|
-
Country: (
|
|
85
|
-
'Plan name': (
|
|
86
|
-
'Shop Id': (
|
|
87
|
-
'Free trial': ((
|
|
88
|
-
? (
|
|
84
|
+
'Store type': ((_a = bikStore === null || bikStore === void 0 ? void 0 : bikStore.shopifyStats) === null || _a === void 0 ? void 0 : _a.isBigStore) ? 'Big' : 'Small',
|
|
85
|
+
Country: (_b = bikStore === null || bikStore === void 0 ? void 0 : bikStore.countryCode) !== null && _b !== void 0 ? _b : 'INR',
|
|
86
|
+
'Plan name': (_d = (_c = bikStore === null || bikStore === void 0 ? void 0 : bikStore.packageInformation) === null || _c === void 0 ? void 0 : _c.planType) !== null && _d !== void 0 ? _d : 'NA',
|
|
87
|
+
'Shop Id': (_f = (_e = bikStore === null || bikStore === void 0 ? void 0 : bikStore.partnerStore) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : 'NA',
|
|
88
|
+
'Free trial': ((_g = bikStore === null || bikStore === void 0 ? void 0 : bikStore.packageInformation) === null || _g === void 0 ? void 0 : _g.isFreeTrial)
|
|
89
|
+
? (_h = bikStore === null || bikStore === void 0 ? void 0 : bikStore.packageInformation) === null || _h === void 0 ? void 0 : _h.isFreeTrial
|
|
89
90
|
: false,
|
|
90
91
|
};
|
|
91
92
|
const bikMainEvent = bikStore.appType !== growth_1.AppType.GLOBAL && !skipCommonEvents
|
|
@@ -25,10 +25,11 @@ class RecordAnalyticsService {
|
|
|
25
25
|
if (!payload.appType) {
|
|
26
26
|
return apis_1.FunctionResponseHelper.failed(apis_1.ErrorCodes.MISSING_PARAMETERS, 'appType is missing');
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
// Removed Skip recording events for test users for testing
|
|
29
|
+
// const isTestUser = this.checkForTestUsers(bikStore.bikLoginEmail || bikStore.email);
|
|
30
|
+
// if (isTestUser) {
|
|
31
|
+
// return FunctionResponseHelper.success(true);
|
|
32
|
+
// }
|
|
32
33
|
for (const destination of destinations) {
|
|
33
34
|
switch (destination) {
|
|
34
35
|
case recordAnalytics_model_1.ServiceType.AMPLITUDE:
|
|
@@ -2,16 +2,14 @@ interface RedisConfig {
|
|
|
2
2
|
channel: string;
|
|
3
3
|
}
|
|
4
4
|
export declare class RedisPubSubService {
|
|
5
|
-
private publisher;
|
|
6
|
-
private subscriber;
|
|
7
5
|
private channel;
|
|
8
|
-
private
|
|
9
|
-
private readonly baseDelayMs;
|
|
6
|
+
private subscribed;
|
|
10
7
|
constructor(config: RedisConfig);
|
|
11
|
-
private
|
|
12
|
-
private
|
|
8
|
+
private get publisher();
|
|
9
|
+
private get subscriber();
|
|
13
10
|
publish<T>(data: T): Promise<void>;
|
|
14
11
|
subscribe<T>(callback: (message: T) => void): void;
|
|
15
12
|
close(): Promise<void>;
|
|
13
|
+
static closeAll(): Promise<void>;
|
|
16
14
|
}
|
|
17
15
|
export {};
|