@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.
- package/lib/alertsV2/alertInstances.repo.js +2 -26
- package/lib/alertsV2/alertsV2.helper.d.ts +4 -3
- package/lib/alertsV2/alertsV2.helper.js +3 -49
- package/lib/alertsV2/alertsV2.service.js +5 -14
- package/lib/auth/authMiddlewares.js +3 -68
- 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 +1 -2
- package/lib/auth/index.d.ts +0 -3
- package/lib/auth/index.js +0 -3
- package/lib/auth/secret-manager/env-variables/variables.list.d.ts +0 -3
- package/lib/auth/secret-manager/env-variables/variables.list.js +0 -3
- package/lib/chat-handover-protocol/chat-handover-protocol.js +41 -26
- package/lib/core/setup.d.ts +0 -3
- package/lib/core/setup.js +2 -24
- package/lib/elastic/counter/ingestion.js +0 -1
- package/lib/elastic/queries/campaign/getBroadcastDetailedStats.d.ts +0 -117
- package/lib/elastic/queries/campaign/getBroadcastDetailedStats.js +1 -94
- package/lib/elastic/queries/campaign/getUniqueCustomerCnt.d.ts +0 -1
- package/lib/elastic/queries/campaign/getUniqueCustomerCnt.js +0 -1
- 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 +0 -1
- package/lib/elastic/queries/chatbot/index.js +0 -1
- package/lib/elastic/queries/crm/getActivityTimelineByAgent.js +1 -1
- package/lib/elastic/queries/crm/getBreachedSLACount.d.ts +0 -1
- package/lib/elastic/queries/crm/getBreachedSLACount.js +5 -8
- package/lib/elastic/queries/crm/getFirstResponseTime.d.ts +0 -1
- package/lib/elastic/queries/crm/getFirstResponseTime.js +5 -8
- package/lib/elastic/queries/integrations/index.d.ts +0 -1
- package/lib/elastic/queries/integrations/index.js +0 -1
- package/lib/elastic/queries/openAi/addToCartSession.d.ts +0 -1
- package/lib/elastic/queries/openAi/addToCartSession.js +3 -11
- package/lib/elastic/queries/openAi/checkoutCompletedSession.d.ts +0 -1
- package/lib/elastic/queries/openAi/checkoutCompletedSession.js +3 -11
- package/lib/elastic/reports/crm/index.d.ts +0 -1
- package/lib/elastic/reports/crm/index.js +0 -1
- package/lib/elastic/reports/reports.service.js +8 -17
- package/lib/events/events.d.ts +0 -8
- package/lib/events/events.js +1 -25
- package/lib/events/schema/events.helper.d.ts +0 -1
- package/lib/events/schema/events.helper.js +6 -12
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/merchant-events/elastic.search.d.ts +0 -5
- package/lib/merchant-events/elastic.search.js +2 -23
- package/lib/merchant-events/merchant.service.d.ts +1 -1
- package/lib/merchant-events/merchant.service.js +11 -12
- package/lib/recordAnalytics/recordAnalytics.service.js +4 -5
- package/lib/redis/redisPubSubService.d.ts +6 -4
- package/lib/redis/redisPubSubService.js +123 -211
- package/lib/redis/redisService.js +8 -14
- package/lib/swagger/SwaggerSchemaHelper.js +17 -21
- package/lib/user-properties/userProperties.service.js +0 -1
- package/package.json +2 -2
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncDelay.d.ts +0 -1
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncDelay.js +0 -4
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncFailed.d.ts +0 -1
- package/lib/alerts/templates/campaign/campaignMovedToDraftSegmentSyncFailed.js +0 -4
- package/lib/alerts/templates/campaign/campaignScheduledTimeExceededDueToSyncDelay.d.ts +0 -1
- package/lib/alerts/templates/campaign/campaignScheduledTimeExceededDueToSyncDelay.js +0 -4
- package/lib/auth/secret-manager/configManager.firestore.d.ts +0 -22
- package/lib/auth/secret-manager/configManager.firestore.js +0 -166
- package/lib/auth/secret-manager/configManager.helper.d.ts +0 -13
- package/lib/auth/secret-manager/configManager.helper.js +0 -32
- package/lib/auth/secret-manager/configManager.model.d.ts +0 -38
- package/lib/auth/secret-manager/configManager.model.js +0 -2
- package/lib/auth/secret-manager/configManager.service.d.ts +0 -17
- package/lib/auth/secret-manager/configManager.service.js +0 -138
- package/lib/core/local_runner.d.ts +0 -1
- package/lib/core/local_runner.js +0 -60
- package/lib/database/database.model.d.ts +0 -95
- package/lib/database/database.model.js +0 -5
- package/lib/database/database.service.d.ts +0 -90
- package/lib/database/database.service.js +0 -382
- package/lib/database/index.d.ts +0 -7
- package/lib/database/index.js +0 -23
- package/lib/elastic/queries/chatbot/getAgentCostForBroadcast.d.ts +0 -117
- package/lib/elastic/queries/chatbot/getAgentCostForBroadcast.js +0 -98
- package/lib/elastic/queries/integrations/getOrdersShadowServices.d.ts +0 -76
- package/lib/elastic/queries/integrations/getOrdersShadowServices.js +0 -61
package/lib/core/setup.js
CHANGED
|
@@ -23,27 +23,7 @@ const auth_1 = require("../auth");
|
|
|
23
23
|
const deprecated_1 = require("./decorators/deprecated");
|
|
24
24
|
const refresh_pod_service_1 = require("../refresh/refresh-pod.service");
|
|
25
25
|
const setup_1 = __importDefault(require("../logger/setup"));
|
|
26
|
-
const local_1 = require("./local");
|
|
27
26
|
class BikBackendSetup {
|
|
28
|
-
static readPackageVersion(requireIdOrPath) {
|
|
29
|
-
try {
|
|
30
|
-
const pkg = require(requireIdOrPath);
|
|
31
|
-
const version = pkg === null || pkg === void 0 ? void 0 : pkg.version;
|
|
32
|
-
return typeof version === 'string' ? version : undefined;
|
|
33
|
-
}
|
|
34
|
-
catch (_a) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
static logPackageVersionsOnce() {
|
|
39
|
-
var _a, _b, _c, _d;
|
|
40
|
-
if (BikBackendSetup.didLogPackageVersions)
|
|
41
|
-
return;
|
|
42
|
-
BikBackendSetup.didLogPackageVersions = true;
|
|
43
|
-
const backendVersion = (_a = BikBackendSetup.readPackageVersion('../../package.json')) !== null && _a !== void 0 ? _a : 'unknown';
|
|
44
|
-
const bikModelsVersion = (_d = (_c = (_b = BikBackendSetup.readPackageVersion('@bikdotai/bik-models/package.json')) !== null && _b !== void 0 ? _b : BikBackendSetup.readPackageVersion('bik-models/package.json')) !== null && _c !== void 0 ? _c : BikBackendSetup.readPackageVersion(`${__dirname}/../../../bik-models/package.json`)) !== null && _d !== void 0 ? _d : 'unknown';
|
|
45
|
-
console.log(`[BikBackendSetup] versions: @bikdotai/bik-shared-backend=${backendVersion}, @bikdotai/bik-models=${bikModelsVersion}`);
|
|
46
|
-
}
|
|
47
27
|
static fetchServiceName() {
|
|
48
28
|
return auth_1.EnvVariableHelper.accessRaw('service_name');
|
|
49
29
|
}
|
|
@@ -68,7 +48,6 @@ class BikBackendSetup {
|
|
|
68
48
|
if (!options.serviceName) {
|
|
69
49
|
options.serviceName = this.fetchServiceName();
|
|
70
50
|
}
|
|
71
|
-
BikBackendSetup.logPackageVersionsOnce();
|
|
72
51
|
if (options.useSharedFirebase) {
|
|
73
52
|
BikBackendSetup.useSharedFirebase = options.useSharedFirebase;
|
|
74
53
|
(0, auth_1.initializeFirebaseConfig)(options.serviceAccountId);
|
|
@@ -85,17 +64,16 @@ class BikBackendSetup {
|
|
|
85
64
|
// Hot-reload listener is now keyed by pod (was service). All services in
|
|
86
65
|
// a pod share one `bik:refresh:{podName}` channel and one log-config secret.
|
|
87
66
|
// Non-fatal if Redis is unavailable.
|
|
88
|
-
if (options.podName
|
|
67
|
+
if (options.podName) {
|
|
89
68
|
refresh_pod_service_1.RefreshPodService.initialize(options.podName);
|
|
90
69
|
}
|
|
91
70
|
else {
|
|
92
|
-
console.warn('[BikBackendSetup] No podName provided
|
|
71
|
+
console.warn('[BikBackendSetup] No podName provided; hot-reload listener not started.');
|
|
93
72
|
}
|
|
94
73
|
});
|
|
95
74
|
}
|
|
96
75
|
}
|
|
97
76
|
BikBackendSetup.useSharedFirebase = false;
|
|
98
|
-
BikBackendSetup.didLogPackageVersions = false;
|
|
99
77
|
__decorate([
|
|
100
78
|
(0, deprecated_1.deprecated)('This method will be removed soon. Use setUpV2() instead.')
|
|
101
79
|
], BikBackendSetup, "setUp", null);
|
|
@@ -115,7 +115,6 @@ class CounterEventIngestionService {
|
|
|
115
115
|
for (const [compositeKey, eventKeyMap] of eventGroupMap.entries()) {
|
|
116
116
|
const [instanceId, indexName] = compositeKey.split('#');
|
|
117
117
|
const elasticService = yield merchant_events_1.ElasticSearchService.getInstance(instanceId);
|
|
118
|
-
console.log(`index ${indexName}, ${eventKeyMap.size} event(s)`);
|
|
119
118
|
yield elasticService.recordCounterEvents(indexName, eventKeyMap);
|
|
120
119
|
}
|
|
121
120
|
// Push events to new instance for migration (fire-and-forget to not block main workflow)
|
|
@@ -53,12 +53,6 @@ export type BroadcastDetailedStatsBucket = {
|
|
|
53
53
|
qrbClickedCount: Record<string, number>;
|
|
54
54
|
bounceRate: number;
|
|
55
55
|
retrySentCount: number;
|
|
56
|
-
aiRevenue: number;
|
|
57
|
-
aiOrderedCount: number;
|
|
58
|
-
aiConversationCount: number;
|
|
59
|
-
flowTriggeredCount: number;
|
|
60
|
-
aiReplyCount: number;
|
|
61
|
-
aiHandoverCount: number;
|
|
62
56
|
};
|
|
63
57
|
export type GetBroadcastDetailedStatsResponse = BroadcastDetailedStatsBucket[];
|
|
64
58
|
export declare class GetBroadcastDetailedStatsQuery implements QueryHelper<GetBroadcastDetailedStatsParams, GetBroadcastDetailedStatsResponse> {
|
|
@@ -572,117 +566,6 @@ export declare class GetBroadcastDetailedStatsQuery implements QueryHelper<GetBr
|
|
|
572
566
|
};
|
|
573
567
|
};
|
|
574
568
|
};
|
|
575
|
-
aiOrderedEvents: {
|
|
576
|
-
filter: {
|
|
577
|
-
bool: {
|
|
578
|
-
filter: ({
|
|
579
|
-
term: {
|
|
580
|
-
'eventName.keyword': Events;
|
|
581
|
-
};
|
|
582
|
-
exists?: undefined;
|
|
583
|
-
} | {
|
|
584
|
-
exists: {
|
|
585
|
-
field: string;
|
|
586
|
-
};
|
|
587
|
-
term?: undefined;
|
|
588
|
-
})[];
|
|
589
|
-
};
|
|
590
|
-
};
|
|
591
|
-
aggs: {
|
|
592
|
-
uniqueOrders: {
|
|
593
|
-
cardinality: {
|
|
594
|
-
field: string;
|
|
595
|
-
precision_threshold: number;
|
|
596
|
-
};
|
|
597
|
-
};
|
|
598
|
-
totalAiRevenue: {
|
|
599
|
-
sum: {
|
|
600
|
-
field: string;
|
|
601
|
-
};
|
|
602
|
-
};
|
|
603
|
-
};
|
|
604
|
-
};
|
|
605
|
-
aiSessionEvents: {
|
|
606
|
-
filter: {
|
|
607
|
-
bool: {
|
|
608
|
-
filter: ({
|
|
609
|
-
term: {
|
|
610
|
-
'eventName.keyword': Events;
|
|
611
|
-
};
|
|
612
|
-
terms?: undefined;
|
|
613
|
-
} | {
|
|
614
|
-
terms: {
|
|
615
|
-
'eventProperties.flowId.keyword': string[];
|
|
616
|
-
};
|
|
617
|
-
term?: undefined;
|
|
618
|
-
})[];
|
|
619
|
-
};
|
|
620
|
-
};
|
|
621
|
-
};
|
|
622
|
-
flowTriggeredEvents: {
|
|
623
|
-
filter: {
|
|
624
|
-
bool: {
|
|
625
|
-
filter: ({
|
|
626
|
-
term: {
|
|
627
|
-
'eventName.keyword': Events;
|
|
628
|
-
};
|
|
629
|
-
terms?: undefined;
|
|
630
|
-
} | {
|
|
631
|
-
terms: {
|
|
632
|
-
'eventProperties.flowId.keyword': string[];
|
|
633
|
-
};
|
|
634
|
-
term?: undefined;
|
|
635
|
-
})[];
|
|
636
|
-
};
|
|
637
|
-
};
|
|
638
|
-
};
|
|
639
|
-
aiReplyEvents: {
|
|
640
|
-
filter: {
|
|
641
|
-
bool: {
|
|
642
|
-
filter: ({
|
|
643
|
-
term: {
|
|
644
|
-
'eventName.keyword': Events;
|
|
645
|
-
};
|
|
646
|
-
exists?: undefined;
|
|
647
|
-
} | {
|
|
648
|
-
exists: {
|
|
649
|
-
field: string;
|
|
650
|
-
};
|
|
651
|
-
term?: undefined;
|
|
652
|
-
})[];
|
|
653
|
-
must_not: {
|
|
654
|
-
term: {
|
|
655
|
-
'eventProperties.messageType.keyword': string;
|
|
656
|
-
};
|
|
657
|
-
}[];
|
|
658
|
-
};
|
|
659
|
-
};
|
|
660
|
-
};
|
|
661
|
-
aiHandoverEvents: {
|
|
662
|
-
filter: {
|
|
663
|
-
bool: {
|
|
664
|
-
filter: ({
|
|
665
|
-
term: {
|
|
666
|
-
'eventName.keyword': Events;
|
|
667
|
-
'eventProperties.useCaseType.keyword'?: undefined;
|
|
668
|
-
'eventProperties.isSatisfactory'?: undefined;
|
|
669
|
-
};
|
|
670
|
-
} | {
|
|
671
|
-
term: {
|
|
672
|
-
'eventProperties.useCaseType.keyword': string;
|
|
673
|
-
"eventName.keyword"?: undefined;
|
|
674
|
-
'eventProperties.isSatisfactory'?: undefined;
|
|
675
|
-
};
|
|
676
|
-
} | {
|
|
677
|
-
term: {
|
|
678
|
-
'eventProperties.isSatisfactory': boolean;
|
|
679
|
-
"eventName.keyword"?: undefined;
|
|
680
|
-
'eventProperties.useCaseType.keyword'?: undefined;
|
|
681
|
-
};
|
|
682
|
-
})[];
|
|
683
|
-
};
|
|
684
|
-
};
|
|
685
|
-
};
|
|
686
569
|
};
|
|
687
570
|
};
|
|
688
571
|
transform(elasticOutput: any, input?: GetBroadcastDetailedStatsParams): GetBroadcastDetailedStatsResponse;
|
|
@@ -20,9 +20,6 @@ const RELEVANT_EVENTS = [
|
|
|
20
20
|
events_1.Events.PURCHASED_A_PRODUCT,
|
|
21
21
|
events_1.Events.MARKED_AS_SPAM,
|
|
22
22
|
events_1.Events.QRB_CLICKED,
|
|
23
|
-
events_1.Events.AI_SESSION,
|
|
24
|
-
events_1.Events.FLOW_TRIGGERED,
|
|
25
|
-
events_1.Events.GPT_RECEIVED,
|
|
26
23
|
];
|
|
27
24
|
/**
|
|
28
25
|
* Valid filter-agg body: ES ignores sibling `must_not` on filter aggs — nest under bool.
|
|
@@ -64,14 +61,6 @@ class GetBroadcastDetailedStatsQuery {
|
|
|
64
61
|
{ terms: { 'broadcastId.keyword': broadcastIds } },
|
|
65
62
|
{ terms: { 'eventProperties.broadcastId': broadcastIds } },
|
|
66
63
|
{ terms: { 'eventProperties.broadcastId.keyword': broadcastIds } },
|
|
67
|
-
// AI events (aiSession, flowTriggered) link to broadcast via flowId = "campaign{broadcastId}"
|
|
68
|
-
{
|
|
69
|
-
terms: {
|
|
70
|
-
'eventProperties.flowId.keyword': broadcastIds.map((id) => `campaign${id}`),
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
// gptReceived (handovers) and AI reply SENT events link via useCaseId = broadcastId
|
|
74
|
-
{ terms: { 'eventProperties.useCaseId.keyword': broadcastIds } },
|
|
75
64
|
],
|
|
76
65
|
minimum_should_match: 1,
|
|
77
66
|
},
|
|
@@ -356,87 +345,11 @@ class GetBroadcastDetailedStatsQuery {
|
|
|
356
345
|
},
|
|
357
346
|
},
|
|
358
347
|
},
|
|
359
|
-
// AI Revenue: ORDERED events where AI session is attributed (aiSessionId present).
|
|
360
|
-
// These orders already match the top-level broadcastId filter.
|
|
361
|
-
aiOrderedEvents: {
|
|
362
|
-
filter: {
|
|
363
|
-
bool: {
|
|
364
|
-
filter: [
|
|
365
|
-
{ term: { 'eventName.keyword': events_1.Events.ORDERED } },
|
|
366
|
-
{ exists: { field: 'eventProperties.aiSessionId' } },
|
|
367
|
-
],
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
aggs: {
|
|
371
|
-
uniqueOrders: {
|
|
372
|
-
cardinality: { field: 'eventProperties.orderId.keyword', precision_threshold: 10000 },
|
|
373
|
-
},
|
|
374
|
-
totalAiRevenue: {
|
|
375
|
-
sum: { field: 'eventProperties.orderValue' },
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
// AI Conversations: unique aiSession events for this campaign's flow.
|
|
380
|
-
aiSessionEvents: {
|
|
381
|
-
filter: {
|
|
382
|
-
bool: {
|
|
383
|
-
filter: [
|
|
384
|
-
{ term: { 'eventName.keyword': events_1.Events.AI_SESSION } },
|
|
385
|
-
{
|
|
386
|
-
terms: {
|
|
387
|
-
'eventProperties.flowId.keyword': broadcastIds.map((id) => `campaign${id}`),
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
],
|
|
391
|
-
},
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
// Total Journeys Triggered: flowTriggered events for this campaign's flow.
|
|
395
|
-
// Only surfaced in the API response when marketingControllerConfig.shouldTriggerAFlow === true.
|
|
396
|
-
flowTriggeredEvents: {
|
|
397
|
-
filter: {
|
|
398
|
-
bool: {
|
|
399
|
-
filter: [
|
|
400
|
-
{ term: { 'eventName.keyword': events_1.Events.FLOW_TRIGGERED } },
|
|
401
|
-
{
|
|
402
|
-
terms: {
|
|
403
|
-
'eventProperties.flowId.keyword': broadcastIds.map((id) => `campaign${id}`),
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
],
|
|
407
|
-
},
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
// AI Replies: SENT events where useCaseId is set (AI agent replies, not initial broadcast sends).
|
|
411
|
-
aiReplyEvents: {
|
|
412
|
-
filter: {
|
|
413
|
-
bool: {
|
|
414
|
-
filter: [
|
|
415
|
-
{ term: { 'eventName.keyword': events_1.Events.SENT } },
|
|
416
|
-
{ exists: { field: 'eventProperties.useCaseId' } },
|
|
417
|
-
],
|
|
418
|
-
must_not: [{ term: { 'eventProperties.messageType.keyword': 'OPT_OUT' } }],
|
|
419
|
-
},
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
// AI Handovers: gptReceived events for CAMPAIGN_ASSISTANT where conversation was unsatisfactory.
|
|
423
|
-
// useCaseId links this event to the specific broadcast campaign.
|
|
424
|
-
aiHandoverEvents: {
|
|
425
|
-
filter: {
|
|
426
|
-
bool: {
|
|
427
|
-
filter: [
|
|
428
|
-
{ term: { 'eventName.keyword': events_1.Events.GPT_RECEIVED } },
|
|
429
|
-
{ term: { 'eventProperties.useCaseType.keyword': 'CAMPAIGN_ASSISTANT' } },
|
|
430
|
-
{ term: { 'eventProperties.isSatisfactory': false } },
|
|
431
|
-
],
|
|
432
|
-
},
|
|
433
|
-
},
|
|
434
|
-
},
|
|
435
348
|
},
|
|
436
349
|
};
|
|
437
350
|
}
|
|
438
351
|
transform(elasticOutput, input) {
|
|
439
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16
|
|
352
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16;
|
|
440
353
|
const aggs = elasticOutput === null || elasticOutput === void 0 ? void 0 : elasticOutput.aggregations;
|
|
441
354
|
if (!aggs)
|
|
442
355
|
return [];
|
|
@@ -511,12 +424,6 @@ class GetBroadcastDetailedStatsQuery {
|
|
|
511
424
|
})(),
|
|
512
425
|
// Unique customers reached during smart retry phase (0 for non-smart-retry broadcasts)
|
|
513
426
|
retrySentCount: ((_16 = (_15 = aggs.retrySentEvents) === null || _15 === void 0 ? void 0 : _15.uniqueCustomers) === null || _16 === void 0 ? void 0 : _16.value) || 0,
|
|
514
|
-
aiRevenue: ((_18 = (_17 = aggs.aiOrderedEvents) === null || _17 === void 0 ? void 0 : _17.totalAiRevenue) === null || _18 === void 0 ? void 0 : _18.value) || 0,
|
|
515
|
-
aiOrderedCount: ((_20 = (_19 = aggs.aiOrderedEvents) === null || _19 === void 0 ? void 0 : _19.uniqueOrders) === null || _20 === void 0 ? void 0 : _20.value) || 0,
|
|
516
|
-
aiConversationCount: ((_21 = aggs.aiSessionEvents) === null || _21 === void 0 ? void 0 : _21.doc_count) || 0,
|
|
517
|
-
flowTriggeredCount: ((_22 = aggs.flowTriggeredEvents) === null || _22 === void 0 ? void 0 : _22.doc_count) || 0,
|
|
518
|
-
aiReplyCount: ((_23 = aggs.aiReplyEvents) === null || _23 === void 0 ? void 0 : _23.doc_count) || 0,
|
|
519
|
-
aiHandoverCount: ((_24 = aggs.aiHandoverEvents) === null || _24 === void 0 ? void 0 : _24.doc_count) || 0,
|
|
520
427
|
},
|
|
521
428
|
];
|
|
522
429
|
}
|
|
@@ -24,7 +24,7 @@ export interface ServiceUsedEventProperties {
|
|
|
24
24
|
usageType?: AiUsageType;
|
|
25
25
|
usageUnits?: number;
|
|
26
26
|
}
|
|
27
|
-
export interface
|
|
27
|
+
export interface GetAiOperationsParams {
|
|
28
28
|
startDate: string;
|
|
29
29
|
endDate: string;
|
|
30
30
|
storeId: string;
|
|
@@ -46,7 +46,7 @@ export interface AiOpsBucket {
|
|
|
46
46
|
key: AiOpsBucketKey;
|
|
47
47
|
usage: UsageMeasurement;
|
|
48
48
|
}
|
|
49
|
-
export interface
|
|
49
|
+
export interface GetAiOperationsResponse {
|
|
50
50
|
buckets: AiOpsBucket[];
|
|
51
51
|
}
|
|
52
52
|
interface RangeTimestampQuery {
|
|
@@ -133,8 +133,8 @@ interface AiOperationsSearchResponse {
|
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
export declare class
|
|
137
|
-
getQuery(params:
|
|
138
|
-
transform(elasticOutput: AiOperationsSearchResponse):
|
|
136
|
+
export declare class GetAiOperationsQuery implements QueryHelper<GetAiOperationsParams, GetAiOperationsResponse> {
|
|
137
|
+
getQuery(params: GetAiOperationsParams): AiOperationsSearchRequest;
|
|
138
|
+
transform(elasticOutput: AiOperationsSearchResponse): GetAiOperationsResponse;
|
|
139
139
|
}
|
|
140
140
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.GetAiOperationsQuery = exports.AiTier = exports.AiUsageType = void 0;
|
|
4
4
|
const events_1 = require("@bikdotai/bik-models/events");
|
|
5
5
|
const Channel_1 = require("@bikdotai/bik-models/campaigns/models/Channel");
|
|
6
6
|
var AiUsageType;
|
|
@@ -18,7 +18,7 @@ var AiTier;
|
|
|
18
18
|
AiTier["MODEL_TIER_3"] = "MODEL_TIER_3";
|
|
19
19
|
AiTier["MODEL_TIER_4"] = "MODEL_TIER_4";
|
|
20
20
|
})(AiTier = exports.AiTier || (exports.AiTier = {}));
|
|
21
|
-
class
|
|
21
|
+
class GetAiOperationsQuery {
|
|
22
22
|
getQuery(params) {
|
|
23
23
|
return {
|
|
24
24
|
index: params.indexName,
|
|
@@ -134,4 +134,4 @@ class GetAiOperationsV2Query {
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
exports.
|
|
137
|
+
exports.GetAiOperationsQuery = GetAiOperationsQuery;
|
|
@@ -115,4 +115,3 @@ export * from './getNewUserAcquiredReportChatbot';
|
|
|
115
115
|
export * from './getNewUserAcquiredReportNonAnalytics';
|
|
116
116
|
export * from './getEventsConversionReportCampaign';
|
|
117
117
|
export * from './getEventsConversionReportNonAnalytics';
|
|
118
|
-
export * from './getAgentCostForBroadcast';
|
|
@@ -131,4 +131,3 @@ __exportStar(require("./getNewUserAcquiredReportChatbot"), exports);
|
|
|
131
131
|
__exportStar(require("./getNewUserAcquiredReportNonAnalytics"), exports);
|
|
132
132
|
__exportStar(require("./getEventsConversionReportCampaign"), exports);
|
|
133
133
|
__exportStar(require("./getEventsConversionReportNonAnalytics"), exports);
|
|
134
|
-
__exportStar(require("./getAgentCostForBroadcast"), exports);
|
|
@@ -42,7 +42,7 @@ class GetActivityTimelineByAgentQuery {
|
|
|
42
42
|
group_by_agent: {
|
|
43
43
|
terms: {
|
|
44
44
|
field: 'eventProperties.agentId',
|
|
45
|
-
size:
|
|
45
|
+
size: ((_b = params.agentIds) === null || _b === void 0 ? void 0 : _b.length) || 10000, // Limit to provided agents or large number
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
};
|
|
@@ -15,7 +15,11 @@ class GetBreachedSLACountQuery {
|
|
|
15
15
|
? {
|
|
16
16
|
by_agent_id: {
|
|
17
17
|
terms: {
|
|
18
|
-
|
|
18
|
+
script: {
|
|
19
|
+
// to support both text and number fields for agentId depending on the source index of the event
|
|
20
|
+
source: "if (doc.containsKey('eventProperties.agentId.keyword') && !doc['eventProperties.agentId.keyword'].empty) { return doc['eventProperties.agentId.keyword'].value; } else if (doc.containsKey('eventProperties.agentId') && !doc['eventProperties.agentId'].empty) { return doc['eventProperties.agentId'].value; } else { return ''; }",
|
|
21
|
+
lang: 'painless',
|
|
22
|
+
},
|
|
19
23
|
size: ((_a = input.agentIds) === null || _a === void 0 ? void 0 : _a.length) || 500,
|
|
20
24
|
},
|
|
21
25
|
},
|
|
@@ -88,13 +92,6 @@ class GetBreachedSLACountQuery {
|
|
|
88
92
|
},
|
|
89
93
|
});
|
|
90
94
|
}
|
|
91
|
-
if (input.teamId) {
|
|
92
|
-
whereArray.push({
|
|
93
|
-
term: {
|
|
94
|
-
'eventProperties.teamId': input.teamId,
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
95
|
// if channel is a non-empty array, or a string, then add it to the query
|
|
99
96
|
if (!input.chatSessionIds &&
|
|
100
97
|
((Array.isArray(input.channel) && input.channel.length > 0) ||
|
|
@@ -30,7 +30,11 @@ class GetFirstResponseTimeQuery {
|
|
|
30
30
|
? {
|
|
31
31
|
tickets_by_agent_id: {
|
|
32
32
|
terms: {
|
|
33
|
-
|
|
33
|
+
script: {
|
|
34
|
+
// to support both text and number fields for agentId depending on the source index of the event
|
|
35
|
+
source: "if (doc.containsKey('eventProperties.agentId.keyword') && !doc['eventProperties.agentId.keyword'].empty) { return doc['eventProperties.agentId.keyword'].value; } else if (doc.containsKey('eventProperties.agentId') && !doc['eventProperties.agentId'].empty) { return doc['eventProperties.agentId'].value; } else { return ''; }",
|
|
36
|
+
lang: 'painless',
|
|
37
|
+
},
|
|
34
38
|
size: (_c = (_b = params.agentIds) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 500,
|
|
35
39
|
},
|
|
36
40
|
aggs: {
|
|
@@ -118,13 +122,6 @@ class GetFirstResponseTimeQuery {
|
|
|
118
122
|
},
|
|
119
123
|
});
|
|
120
124
|
}
|
|
121
|
-
if (params.teamId) {
|
|
122
|
-
whereArray.push({
|
|
123
|
-
term: {
|
|
124
|
-
'eventProperties.teamId': params.teamId,
|
|
125
|
-
},
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
125
|
whereArray.push({
|
|
129
126
|
range: {
|
|
130
127
|
createdAt: {
|
|
@@ -19,7 +19,6 @@ export type AddToCartSessionBucket = {
|
|
|
19
19
|
addToCartSessions: number;
|
|
20
20
|
};
|
|
21
21
|
export type AddToCartSessionQueryResponse = {
|
|
22
|
-
addToCartCount: number;
|
|
23
22
|
addToCartSessions: number;
|
|
24
23
|
/** Populated only when `graphInterval` param is supplied. */
|
|
25
24
|
addToCartBuckets?: AddToCartSessionBucket[];
|
|
@@ -9,14 +9,7 @@ class AddToCartSessionQuery {
|
|
|
9
9
|
field: 'eventProperties.visitorSessionId.keyword',
|
|
10
10
|
},
|
|
11
11
|
};
|
|
12
|
-
const aggs = {
|
|
13
|
-
total_count: {
|
|
14
|
-
value_count: {
|
|
15
|
-
field: 'eventName.keyword',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
unique_sessions: sessionCardinality,
|
|
19
|
-
};
|
|
12
|
+
const aggs = { unique_sessions: sessionCardinality };
|
|
20
13
|
if (params.graphInterval) {
|
|
21
14
|
aggs.graph = {
|
|
22
15
|
date_histogram: {
|
|
@@ -72,7 +65,7 @@ class AddToCartSessionQuery {
|
|
|
72
65
|
return query;
|
|
73
66
|
}
|
|
74
67
|
transform(elasticOutput) {
|
|
75
|
-
var _a, _b, _c
|
|
68
|
+
var _a, _b, _c;
|
|
76
69
|
const addToCartSessions = elasticOutput.aggregations.unique_sessions.value || 0;
|
|
77
70
|
const buckets = (_c = (_b = (_a = elasticOutput.aggregations) === null || _a === void 0 ? void 0 : _a.graph) === null || _b === void 0 ? void 0 : _b.buckets) !== null && _c !== void 0 ? _c : [];
|
|
78
71
|
const addToCartBuckets = buckets.map((b) => {
|
|
@@ -84,8 +77,7 @@ class AddToCartSessionQuery {
|
|
|
84
77
|
});
|
|
85
78
|
});
|
|
86
79
|
return {
|
|
87
|
-
|
|
88
|
-
addToCartSessions: ((_g = (_f = elasticOutput.aggregations) === null || _f === void 0 ? void 0 : _f.unique_sessions) === null || _g === void 0 ? void 0 : _g.value) || 0,
|
|
80
|
+
addToCartSessions,
|
|
89
81
|
addToCartBuckets: addToCartBuckets.length ? addToCartBuckets : undefined,
|
|
90
82
|
};
|
|
91
83
|
}
|
|
@@ -19,7 +19,6 @@ export type CheckoutCompletedSessionBucket = {
|
|
|
19
19
|
checkoutCompletedSessions: number;
|
|
20
20
|
};
|
|
21
21
|
export type CheckoutCompletedSessionQueryResponse = {
|
|
22
|
-
checkoutCompletedCount: number;
|
|
23
22
|
checkoutCompletedSessions: number;
|
|
24
23
|
/** Populated only when `graphInterval` param is supplied. */
|
|
25
24
|
checkoutCompletedBuckets?: CheckoutCompletedSessionBucket[];
|
|
@@ -9,14 +9,7 @@ class CheckoutCompletedSessionQuery {
|
|
|
9
9
|
field: 'eventProperties.visitorSessionId.keyword',
|
|
10
10
|
},
|
|
11
11
|
};
|
|
12
|
-
const aggs = {
|
|
13
|
-
total_count: {
|
|
14
|
-
value_count: {
|
|
15
|
-
field: 'eventName.keyword',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
unique_sessions: sessionCardinality,
|
|
19
|
-
};
|
|
12
|
+
const aggs = { unique_sessions: sessionCardinality };
|
|
20
13
|
if (params.graphInterval) {
|
|
21
14
|
aggs.graph = {
|
|
22
15
|
date_histogram: {
|
|
@@ -72,7 +65,7 @@ class CheckoutCompletedSessionQuery {
|
|
|
72
65
|
return query;
|
|
73
66
|
}
|
|
74
67
|
transform(elasticOutput) {
|
|
75
|
-
var _a, _b, _c
|
|
68
|
+
var _a, _b, _c;
|
|
76
69
|
const checkoutCompletedSessions = elasticOutput.aggregations.unique_sessions.value || 0;
|
|
77
70
|
const buckets = (_c = (_b = (_a = elasticOutput.aggregations) === null || _a === void 0 ? void 0 : _a.graph) === null || _b === void 0 ? void 0 : _b.buckets) !== null && _c !== void 0 ? _c : [];
|
|
78
71
|
const checkoutCompletedBuckets = buckets.map((b) => {
|
|
@@ -84,8 +77,7 @@ class CheckoutCompletedSessionQuery {
|
|
|
84
77
|
});
|
|
85
78
|
});
|
|
86
79
|
return {
|
|
87
|
-
|
|
88
|
-
checkoutCompletedSessions: ((_g = (_f = elasticOutput.aggregations) === null || _f === void 0 ? void 0 : _f.unique_sessions) === null || _g === void 0 ? void 0 : _g.value) || 0,
|
|
80
|
+
checkoutCompletedSessions,
|
|
89
81
|
checkoutCompletedBuckets: checkoutCompletedBuckets.length ? checkoutCompletedBuckets : undefined,
|
|
90
82
|
};
|
|
91
83
|
}
|
|
@@ -19,4 +19,3 @@ __exportStar(require("./agentEngagement"), exports);
|
|
|
19
19
|
__exportStar(require("./conversationsReport"), exports);
|
|
20
20
|
__exportStar(require("./overAllCSATNPSReport"), exports);
|
|
21
21
|
__exportStar(require("./chatSessionOverviewReport"), exports);
|
|
22
|
-
__exportStar(require("./teamEngagement"), exports);
|