@bikdotai/bik-shared-backend 20.4.1-beta.0 → 20.5.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.
Files changed (81) hide show
  1. package/lib/alertsV2/alertInstances.repo.js +2 -26
  2. package/lib/alertsV2/alertsV2.helper.d.ts +4 -3
  3. package/lib/alertsV2/alertsV2.helper.js +3 -49
  4. package/lib/alertsV2/alertsV2.service.js +5 -14
  5. package/lib/auth/authMiddlewares.js +3 -68
  6. package/lib/auth/firebase-auth.service.js +3 -3
  7. package/lib/auth/implementations/bik-admin-auth-service.d.ts +1 -1
  8. package/lib/auth/implementations/bik-admin-auth-service.js +1 -2
  9. package/lib/auth/index.d.ts +0 -3
  10. package/lib/auth/index.js +0 -3
  11. package/lib/auth/secret-manager/env-variables/variables.list.d.ts +0 -3
  12. package/lib/auth/secret-manager/env-variables/variables.list.js +0 -3
  13. package/lib/chat-handover-protocol/chat-handover-protocol.js +41 -26
  14. package/lib/core/setup.d.ts +0 -3
  15. package/lib/core/setup.js +2 -24
  16. package/lib/elastic/counter/ingestion.js +0 -1
  17. package/lib/elastic/queries/campaign/getBroadcastDetailedStats.d.ts +0 -117
  18. package/lib/elastic/queries/campaign/getBroadcastDetailedStats.js +1 -94
  19. package/lib/elastic/queries/campaign/getUniqueCustomerCnt.d.ts +0 -1
  20. package/lib/elastic/queries/campaign/getUniqueCustomerCnt.js +0 -1
  21. package/lib/elastic/queries/chatbot/getAiOperations.d.ts +5 -5
  22. package/lib/elastic/queries/chatbot/getAiOperations.js +3 -3
  23. package/lib/elastic/queries/chatbot/index.d.ts +0 -1
  24. package/lib/elastic/queries/chatbot/index.js +0 -1
  25. package/lib/elastic/queries/crm/getActivityTimelineByAgent.js +1 -1
  26. package/lib/elastic/queries/crm/getBreachedSLACount.d.ts +0 -1
  27. package/lib/elastic/queries/crm/getBreachedSLACount.js +5 -8
  28. package/lib/elastic/queries/crm/getFirstResponseTime.d.ts +0 -1
  29. package/lib/elastic/queries/crm/getFirstResponseTime.js +5 -8
  30. package/lib/elastic/queries/integrations/index.d.ts +0 -1
  31. package/lib/elastic/queries/integrations/index.js +0 -1
  32. package/lib/elastic/queries/openAi/addToCartSession.d.ts +0 -1
  33. package/lib/elastic/queries/openAi/addToCartSession.js +3 -11
  34. package/lib/elastic/queries/openAi/checkoutCompletedSession.d.ts +0 -1
  35. package/lib/elastic/queries/openAi/checkoutCompletedSession.js +3 -11
  36. package/lib/elastic/reports/crm/index.d.ts +0 -1
  37. package/lib/elastic/reports/crm/index.js +0 -1
  38. package/lib/elastic/reports/reports.service.js +8 -17
  39. package/lib/events/events.d.ts +0 -8
  40. package/lib/events/events.js +1 -25
  41. package/lib/events/schema/events.helper.d.ts +0 -1
  42. package/lib/events/schema/events.helper.js +6 -12
  43. package/lib/index.d.ts +0 -1
  44. package/lib/index.js +0 -1
  45. package/lib/merchant-events/elastic.search.d.ts +0 -5
  46. package/lib/merchant-events/elastic.search.js +2 -23
  47. package/lib/merchant-events/merchant.service.d.ts +1 -1
  48. package/lib/merchant-events/merchant.service.js +11 -12
  49. package/lib/recordAnalytics/recordAnalytics.service.js +4 -5
  50. package/lib/redis/redisPubSubService.d.ts +6 -4
  51. package/lib/redis/redisPubSubService.js +123 -211
  52. package/lib/redis/redisService.js +8 -14
  53. package/lib/swagger/SwaggerSchemaHelper.js +17 -21
  54. package/lib/user-properties/userProperties.service.js +0 -1
  55. package/package.json +2 -2
  56. package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncDelay.d.ts +0 -1
  57. package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncDelay.js +0 -4
  58. package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncFailed.d.ts +0 -1
  59. package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncFailed.js +0 -4
  60. package/lib/alerts/templates/campaign/campaignScheduledTimeExceededDueToSyncDelay.d.ts +0 -1
  61. package/lib/alerts/templates/campaign/campaignScheduledTimeExceededDueToSyncDelay.js +0 -4
  62. package/lib/auth/secret-manager/configManager.firestore.d.ts +0 -22
  63. package/lib/auth/secret-manager/configManager.firestore.js +0 -166
  64. package/lib/auth/secret-manager/configManager.helper.d.ts +0 -13
  65. package/lib/auth/secret-manager/configManager.helper.js +0 -32
  66. package/lib/auth/secret-manager/configManager.model.d.ts +0 -38
  67. package/lib/auth/secret-manager/configManager.model.js +0 -2
  68. package/lib/auth/secret-manager/configManager.service.d.ts +0 -17
  69. package/lib/auth/secret-manager/configManager.service.js +0 -138
  70. package/lib/core/local_runner.d.ts +0 -1
  71. package/lib/core/local_runner.js +0 -60
  72. package/lib/database/database.model.d.ts +0 -95
  73. package/lib/database/database.model.js +0 -5
  74. package/lib/database/database.service.d.ts +0 -90
  75. package/lib/database/database.service.js +0 -382
  76. package/lib/database/index.d.ts +0 -7
  77. package/lib/database/index.js +0 -23
  78. package/lib/elastic/queries/chatbot/getAgentCostForBroadcast.d.ts +0 -117
  79. package/lib/elastic/queries/chatbot/getAgentCostForBroadcast.js +0 -98
  80. package/lib/elastic/queries/integrations/getOrdersShadowServices.d.ts +0 -76
  81. package/lib/elastic/queries/integrations/getOrdersShadowServices.js +0 -61
@@ -74,6 +74,7 @@ _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();
77
78
  let { storeId, moduleName, reportName, payload, getSignedUrl } = args;
78
79
  const module = yield (_b = './' + moduleName + '/' + reportName, Promise.resolve().then(() => __importStar(require(_b))));
79
80
  const { exportFileName } = payload;
@@ -82,9 +83,6 @@ ReportService.generateReport = (args) => __awaiter(void 0, void 0, void 0, funct
82
83
  try {
83
84
  const reportInstance = new module[fileName]();
84
85
  const response = yield reportInstance.executeReport(storeId, payload);
85
- console.log(`@ReportService generateReport initial apiResponse for ${reportName}`, {
86
- response: JSON.stringify(response),
87
- });
88
86
  if (response.response &&
89
87
  (response.nextPage || Object.keys((_c = response.searchAfter) !== null && _c !== void 0 ? _c : {}).length)) {
90
88
  const uuid = (0, uuid_1.v4)();
@@ -93,7 +91,7 @@ ReportService.generateReport = (args) => __awaiter(void 0, void 0, void 0, funct
93
91
  yield file_helper_1.FileHelper.appendDataToLocalFileCSV(fileName, response.header, response.response, true);
94
92
  const timer = new timer_1.Timer();
95
93
  timer.startTimer();
96
- return yield ReportService.fetchDataAndSaveInFile({
94
+ const res = yield ReportService.fetchDataAndSaveInFile({
97
95
  args,
98
96
  reportInstance,
99
97
  nextPage: response.nextPage,
@@ -102,8 +100,13 @@ ReportService.generateReport = (args) => __awaiter(void 0, void 0, void 0, funct
102
100
  actionType: payload.actionType,
103
101
  timer,
104
102
  });
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;
105
106
  }
106
107
  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);
107
110
  return apis_1.FunctionResponseHelper.success(response);
108
111
  }
109
112
  catch (error) {
@@ -121,9 +124,6 @@ ReportService.fetchDataAndSaveInFile = (request) => __awaiter(void 0, void 0, vo
121
124
  let { nextPage, searchAfter } = request;
122
125
  const { storeId, reportName, payload } = args;
123
126
  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,19 +134,10 @@ 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
- }
147
137
  // Check file size limit
148
138
  [isFileSizeExceeded, fileSize] = yield file_helper_1.FileHelper.isFileSizeExceeded(localTempFile, actionType || 'download');
149
139
  if (isFileSizeExceeded) {
140
+ console.log('@generateReport File size exceeded', fileSize, reportName, storeId);
150
141
  break;
151
142
  }
152
143
  // Check time limit for view action
@@ -36,11 +36,3 @@ 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>;
@@ -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.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;
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;
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,7 +42,6 @@ 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");
46
45
  exports.REQUIRE_EVENT_VALIDATION = true;
47
46
  function getUatStoreIds() {
48
47
  return (auth_1.EnvVariableHelper.access(auth_1.ServiceName.CONSTANTS, auth_1.ConstantsKeys.UAT_STORE_IDS) || '')
@@ -446,26 +445,3 @@ function sanitizeEventPropertiesAndFixTypes(event, eventValidator) {
446
445
  const uniqueFixedErrors = [...new Set(fixedErrors)];
447
446
  return { correctedEvent, errors: uniqueErrors, fixedErrors: uniqueFixedErrors };
448
447
  }
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,7 +21,6 @@ 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;
25
24
  static getIndexOrAliasName(indexName?: string): string;
26
25
  static getDataStreamName(eventName: Events): string;
27
26
  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 || 'staging-campaign-analytics-ds',
70
- ANALYTICS_CHATBOT_DATA_STREAM: chatbotDs || 'staging-chatbot-analytics-ds',
71
- NON_ANALYTICS_DATA_STREAM: nonAnalyticsDs || 'staging-non-analytics-ds',
69
+ ANALYTICS_CAMPAIGN_DATA_STREAM: campaignDs || 'prod-campaign-analytics-ds',
70
+ ANALYTICS_CHATBOT_DATA_STREAM: chatbotDs || 'prod-chatbot-analytics-ds',
71
+ NON_ANALYTICS_DATA_STREAM: nonAnalyticsDs || 'prod-non-analytics-ds',
72
72
  };
73
73
  }
74
74
  static getIndexNameForStoreId(storeId) {
@@ -144,19 +144,14 @@ 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
149
147
  static isStaticIndexName(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-');
148
+ return exports.STATIC_INDEX_NAMES.includes(indexName);
154
149
  }
155
150
  static getIndexOrAliasName(indexName) {
156
151
  if (!indexName) {
157
152
  return exports.INDEX_ALIAS_NAME; //events-prod-alias
158
153
  }
159
- if (this.isStaticIndexName(indexName)) {
154
+ if (exports.STATIC_INDEX_NAMES.includes(indexName)) {
160
155
  return indexName; // static index names
161
156
  }
162
157
  if (indexName.includes('manifest')) {
@@ -183,9 +178,8 @@ class EventsHelper {
183
178
  const cacheKey = this.getIndexAndInstanceCacheKey(storeId);
184
179
  const centralCacheService = redis_1.CentralCacheService.getInstance();
185
180
  const { data: dataFromCache } = yield centralCacheService.retrieveData(cacheKey, {
186
- cachesToUse: [types_1.CacheTypes.LRU, types_1.CacheTypes.REDIS],
181
+ cachesToUse: [types_1.CacheTypes.REDIS],
187
182
  ttlMap: {
188
- [types_1.CacheTypes.LRU]: 60 * 5,
189
183
  [types_1.CacheTypes.REDIS]: 7 * 60 * 60 * 24, // 7 days
190
184
  },
191
185
  }, () => __awaiter(this, void 0, void 0, function* () {
package/lib/index.d.ts CHANGED
@@ -8,7 +8,6 @@ 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';
12
11
  export * from './alertsV2/alertsV2.service';
13
12
  export * from './index-filtering';
14
13
  export * from './messaging-transformer/messagingTransformer.service';
package/lib/index.js CHANGED
@@ -24,7 +24,6 @@ __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);
28
27
  __exportStar(require("./alertsV2/alertsV2.service"), exports);
29
28
  __exportStar(require("./index-filtering"), exports);
30
29
  __exportStar(require("./messaging-transformer/messagingTransformer.service"), exports);
@@ -34,10 +34,6 @@ 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;
41
37
  bulkInsertToES(index: string | undefined, bulkBody: Event[]): ResolvedFunctionResponse<BulkInsertToESResponse>;
42
38
  bulkInsertToElastic(index: string, bulkBody: any[]): Promise<{
43
39
  success: boolean;
@@ -45,7 +41,6 @@ export declare class ElasticSearchService {
45
41
  }>;
46
42
  rawSearch(query: any): Promise<any>;
47
43
  count(query: any): Promise<CountResponse>;
48
- private getDataStreamNameFromQuery;
49
44
  /**
50
45
  *
51
46
  * @param podName
@@ -310,12 +310,6 @@ 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
- }
319
313
  bulkInsertToES(index, bulkBody) {
320
314
  var _a, _b, _c;
321
315
  return __awaiter(this, void 0, void 0, function* () {
@@ -329,7 +323,6 @@ class ElasticSearchService {
329
323
  const eventIdsForCreateOrUpdate = [];
330
324
  const idToIndexMap = new Map();
331
325
  const isDataStreamTarget = events_helper_1.EventsHelper.isDataStream(index);
332
- const isStoreSpecificIndexName = events_helper_1.EventsHelper.isStoreSpecificIndexName(index);
333
326
  for (let data of bulkBody) {
334
327
  if ((data === null || data === void 0 ? void 0 : data.isMigrationEvent) && (data === null || data === void 0 ? void 0 : data.eventId)) {
335
328
  // events to be updated (only for non-data-stream targets)
@@ -355,13 +348,9 @@ class ElasticSearchService {
355
348
  }
356
349
  if (eventIdsForCreateOrUpdate.length > 0) {
357
350
  // 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
359
351
  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];
363
352
  const res = yield this.esClient.search({
364
- index: indexToSearch,
353
+ index: [events_helper_1.INDEX_ALIAS_NAME, NON_ANALYTICS_DATA_STREAM],
365
354
  _source: ['eventId'],
366
355
  track_scores: false,
367
356
  body: {
@@ -414,7 +403,7 @@ class ElasticSearchService {
414
403
  });
415
404
  }
416
405
  else {
417
- // new migration events will also go to the old alias
406
+ // create a new document
418
407
  const _id = (data === null || data === void 0 ? void 0 : data.eventId) || (0, uuid_1.v4)();
419
408
  documents.push({ index: { _index: events_helper_1.INDEX_ALIAS_NAME, _id } });
420
409
  documents.push(data);
@@ -435,7 +424,6 @@ class ElasticSearchService {
435
424
  });
436
425
  }
437
426
  else {
438
- // new migration events will also go to the old alias
439
427
  const _id = (data === null || data === void 0 ? void 0 : data.eventId) || (0, uuid_1.v4)();
440
428
  documents.push({ index: { _index: events_helper_1.INDEX_ALIAS_NAME, _id } });
441
429
  documents.push(data);
@@ -496,7 +484,6 @@ class ElasticSearchService {
496
484
  return currOutput;
497
485
  });
498
486
  }
499
- getDataStreamNameFromQuery() { }
500
487
  /**
501
488
  *
502
489
  * @param podName
@@ -520,14 +507,6 @@ class ElasticSearchService {
520
507
  var _d;
521
508
  logger_1.LogExecutionContextHelper.setCustomProperty('queryName', queryName);
522
509
  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
- });
531
510
  const executionStartTime = Date.now();
532
511
  if (!queryParams.storeId) {
533
512
  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 | undefined;
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, _j;
64
64
  const testEmail = [
65
65
  'dev@bikayi.com',
66
66
  'dev@bik.ai',
@@ -74,19 +74,18 @@ class BikInternalEventsService {
74
74
  'shrinkhla@bik.ai',
75
75
  'sumit.kumar1@bik.ai',
76
76
  ];
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
- // }
77
+ if (testEmail.includes((_a = bikStore === null || bikStore === void 0 ? void 0 : bikStore.bikLoginEmail) !== null && _a !== void 0 ? _a : '') || testEmail.includes(bikStore === null || bikStore === void 0 ? void 0 : bikStore.email)) {
78
+ // not logging events for internal test stores
79
+ return undefined;
80
+ }
82
81
  const commonEventsForBik = {
83
82
  'Store name': bikStore.storeName,
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
83
+ 'Store type': ((_b = bikStore === null || bikStore === void 0 ? void 0 : bikStore.shopifyStats) === null || _b === void 0 ? void 0 : _b.isBigStore) ? 'Big' : 'Small',
84
+ Country: (_c = bikStore === null || bikStore === void 0 ? void 0 : bikStore.countryCode) !== null && _c !== void 0 ? _c : 'INR',
85
+ 'Plan name': (_e = (_d = bikStore === null || bikStore === void 0 ? void 0 : bikStore.packageInformation) === null || _d === void 0 ? void 0 : _d.planType) !== null && _e !== void 0 ? _e : 'NA',
86
+ 'Shop Id': (_g = (_f = bikStore === null || bikStore === void 0 ? void 0 : bikStore.partnerStore) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : 'NA',
87
+ 'Free trial': ((_h = bikStore === null || bikStore === void 0 ? void 0 : bikStore.packageInformation) === null || _h === void 0 ? void 0 : _h.isFreeTrial)
88
+ ? (_j = bikStore === null || bikStore === void 0 ? void 0 : bikStore.packageInformation) === null || _j === void 0 ? void 0 : _j.isFreeTrial
90
89
  : false,
91
90
  };
92
91
  const bikMainEvent = bikStore.appType !== growth_1.AppType.GLOBAL && !skipCommonEvents
@@ -25,11 +25,10 @@ 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
- // 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
- // }
28
+ const isTestUser = this.checkForTestUsers(bikStore.bikLoginEmail || bikStore.email);
29
+ if (isTestUser) {
30
+ return apis_1.FunctionResponseHelper.success(true);
31
+ }
33
32
  for (const destination of destinations) {
34
33
  switch (destination) {
35
34
  case recordAnalytics_model_1.ServiceType.AMPLITUDE:
@@ -2,14 +2,16 @@ interface RedisConfig {
2
2
  channel: string;
3
3
  }
4
4
  export declare class RedisPubSubService {
5
+ private publisher;
6
+ private subscriber;
5
7
  private channel;
6
- private subscribed;
8
+ private readonly maxRetries;
9
+ private readonly baseDelayMs;
7
10
  constructor(config: RedisConfig);
8
- private get publisher();
9
- private get subscriber();
11
+ private isRetriableRedisError;
12
+ private retryWithBackoff;
10
13
  publish<T>(data: T): Promise<void>;
11
14
  subscribe<T>(callback: (message: T) => void): void;
12
15
  close(): Promise<void>;
13
- static closeAll(): Promise<void>;
14
16
  }
15
17
  export {};