coveo.analytics 2.18.52 → 2.18.53
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/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/caseAssist/caseAssistActions.d.ts +72 -0
- package/dist/definitions/caseAssist/caseAssistClient.d.ts +24 -0
- package/dist/definitions/coveoua/headless.d.ts +1 -0
- package/dist/definitions/coveoua/library.d.ts +1 -0
- package/dist/definitions/src/coveoua/headless.d.ts +1 -0
- package/dist/definitions/src/coveoua/library.d.ts +1 -0
- package/dist/library.es.js +252 -1
- package/dist/library.js +103 -0
- package/package.json +1 -1
- package/src/caseAssist/caseAssistActions.ts +86 -0
- package/src/caseAssist/caseAssistClient.spec.ts +262 -0
- package/src/caseAssist/caseAssistClient.ts +117 -0
- package/src/coveoua/headless.ts +1 -0
- package/src/coveoua/library.ts +1 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { TicketProperties } from '../plugins/svc';
|
|
2
|
+
export declare enum CaseAssistEvents {
|
|
3
|
+
click = "click",
|
|
4
|
+
flowStart = "flowStart"
|
|
5
|
+
}
|
|
6
|
+
export declare enum CaseAssistActions {
|
|
7
|
+
enterInterface = "ticket_create_start",
|
|
8
|
+
fieldUpdate = "ticket_field_update",
|
|
9
|
+
fieldSuggestionClick = "ticket_classification_click",
|
|
10
|
+
suggestionClick = "suggestion_click",
|
|
11
|
+
suggestionRate = "suggestion_rate",
|
|
12
|
+
nextCaseStep = "ticket_next_stage",
|
|
13
|
+
caseCancelled = "ticket_cancel",
|
|
14
|
+
caseSolved = "ticket_cancel",
|
|
15
|
+
caseCreated = "ticket_create"
|
|
16
|
+
}
|
|
17
|
+
export declare enum CaseCancelledReasons {
|
|
18
|
+
quit = "Quit",
|
|
19
|
+
solved = "Solved"
|
|
20
|
+
}
|
|
21
|
+
export interface EnterInterfaceMetadata {
|
|
22
|
+
ticket: TicketProperties;
|
|
23
|
+
}
|
|
24
|
+
export interface UpdateCaseFieldMetadata {
|
|
25
|
+
fieldName: string;
|
|
26
|
+
ticket: TicketProperties;
|
|
27
|
+
}
|
|
28
|
+
export interface SelectFieldSuggestionMetadata {
|
|
29
|
+
suggestion: FieldSuggestion;
|
|
30
|
+
ticket: TicketProperties;
|
|
31
|
+
}
|
|
32
|
+
export interface SelectDocumentSuggestionMetadata {
|
|
33
|
+
suggestion: DocumentSuggestion;
|
|
34
|
+
ticket: TicketProperties;
|
|
35
|
+
}
|
|
36
|
+
export interface RateDocumentSuggestionMetadata {
|
|
37
|
+
rating: number;
|
|
38
|
+
suggestion: DocumentSuggestion;
|
|
39
|
+
ticket: TicketProperties;
|
|
40
|
+
}
|
|
41
|
+
export interface MoveToNextCaseStepMetadata {
|
|
42
|
+
ticket: TicketProperties;
|
|
43
|
+
}
|
|
44
|
+
export interface CaseCancelledMetadata {
|
|
45
|
+
ticket: TicketProperties;
|
|
46
|
+
}
|
|
47
|
+
export interface CaseSolvedMetadata {
|
|
48
|
+
ticket: TicketProperties;
|
|
49
|
+
}
|
|
50
|
+
export interface CaseCreatedMetadata {
|
|
51
|
+
ticket: TicketProperties;
|
|
52
|
+
}
|
|
53
|
+
export interface FieldSuggestion {
|
|
54
|
+
classificationId: string;
|
|
55
|
+
responseId: string;
|
|
56
|
+
fieldName: string;
|
|
57
|
+
classification: {
|
|
58
|
+
value: string;
|
|
59
|
+
confidence: number;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export interface DocumentSuggestion {
|
|
63
|
+
suggestionId: string;
|
|
64
|
+
responseId: string;
|
|
65
|
+
suggestion: {
|
|
66
|
+
documentUri: string;
|
|
67
|
+
documentUriHash: string;
|
|
68
|
+
documentTitle: string;
|
|
69
|
+
documentUrl: string;
|
|
70
|
+
documentPosition: number;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AnalyticsClient, ClientOptions } from '../client/analytics';
|
|
2
|
+
import { CaseCancelledMetadata, CaseCreatedMetadata, CaseSolvedMetadata, EnterInterfaceMetadata, MoveToNextCaseStepMetadata, RateDocumentSuggestionMetadata, SelectDocumentSuggestionMetadata, SelectFieldSuggestionMetadata, UpdateCaseFieldMetadata } from './caseAssistActions';
|
|
3
|
+
export interface CaseAssistClientOptions extends ClientOptions {
|
|
4
|
+
enableAnalytics?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class CaseAssistClient {
|
|
7
|
+
private options;
|
|
8
|
+
coveoAnalyticsClient: AnalyticsClient;
|
|
9
|
+
private svc;
|
|
10
|
+
constructor(options: Partial<CaseAssistClientOptions>);
|
|
11
|
+
disable(): void;
|
|
12
|
+
enable(): void;
|
|
13
|
+
logEnterInterface(meta: EnterInterfaceMetadata): Promise<void | import("../events").SearchEventResponse | import("../events").ClickEventResponse | import("../events").CustomEventResponse | import("../events").ViewEventResponse>;
|
|
14
|
+
logUpdateCaseField(meta: UpdateCaseFieldMetadata): Promise<void | import("../events").SearchEventResponse | import("../events").ClickEventResponse | import("../events").CustomEventResponse | import("../events").ViewEventResponse>;
|
|
15
|
+
logSelectFieldSuggestion(meta: SelectFieldSuggestionMetadata): Promise<void | import("../events").SearchEventResponse | import("../events").ClickEventResponse | import("../events").CustomEventResponse | import("../events").ViewEventResponse>;
|
|
16
|
+
logSelectDocumentSuggestion(meta: SelectDocumentSuggestionMetadata): Promise<void | import("../events").SearchEventResponse | import("../events").ClickEventResponse | import("../events").CustomEventResponse | import("../events").ViewEventResponse>;
|
|
17
|
+
logRateDocumentSuggestion(meta: RateDocumentSuggestionMetadata): Promise<void | import("../events").SearchEventResponse | import("../events").ClickEventResponse | import("../events").CustomEventResponse | import("../events").ViewEventResponse>;
|
|
18
|
+
logMoveToNextCaseStep(meta: MoveToNextCaseStepMetadata): Promise<void | import("../events").SearchEventResponse | import("../events").ClickEventResponse | import("../events").CustomEventResponse | import("../events").ViewEventResponse>;
|
|
19
|
+
logCaseCancelled(meta: CaseCancelledMetadata): Promise<void | import("../events").SearchEventResponse | import("../events").ClickEventResponse | import("../events").CustomEventResponse | import("../events").ViewEventResponse>;
|
|
20
|
+
logCaseSolved(meta: CaseSolvedMetadata): Promise<void | import("../events").SearchEventResponse | import("../events").ClickEventResponse | import("../events").CustomEventResponse | import("../events").ViewEventResponse>;
|
|
21
|
+
logCaseCreated(meta: CaseCreatedMetadata): Promise<void | import("../events").SearchEventResponse | import("../events").ClickEventResponse | import("../events").CustomEventResponse | import("../events").ViewEventResponse>;
|
|
22
|
+
private sendFlowStartEvent;
|
|
23
|
+
private sendClickEvent;
|
|
24
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { CoveoSearchPageClient, SearchPageClientProvider } from '../searchPage/searchPageClient';
|
|
2
|
+
export { CaseAssistClient } from '../caseAssist/caseAssistClient';
|
|
2
3
|
export { CoveoAnalyticsClient, AnalyticsClientSendEventHook } from '../client/analytics';
|
|
3
4
|
export { PreprocessAnalyticsRequest } from '../client/analyticsRequestClient';
|
|
4
5
|
export * as history from '../history';
|
|
@@ -8,4 +8,5 @@ export { PreprocessAnalyticsRequest } from '../client/analyticsRequestClient';
|
|
|
8
8
|
export { IRuntimeEnvironment } from '../client/runtimeEnvironment';
|
|
9
9
|
export { CoveoUA, getCurrentClient, handleOneAnalyticsEvent } from './simpleanalytics';
|
|
10
10
|
export { CoveoSearchPageClient, SearchPageClientProvider } from '../searchPage/searchPageClient';
|
|
11
|
+
export { CaseAssistClient } from '../caseAssist/caseAssistClient';
|
|
11
12
|
export { analytics, donottrack, history, SimpleAnalytics, storage };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { CoveoSearchPageClient, SearchPageClientProvider } from '../searchPage/searchPageClient';
|
|
2
|
+
export { CaseAssistClient } from '../caseAssist/caseAssistClient';
|
|
2
3
|
export { CoveoAnalyticsClient, AnalyticsClientSendEventHook } from '../client/analytics';
|
|
3
4
|
export { PreprocessAnalyticsRequest } from '../client/analyticsRequestClient';
|
|
4
5
|
export * as history from '../history';
|
|
@@ -8,4 +8,5 @@ export { PreprocessAnalyticsRequest } from '../client/analyticsRequestClient';
|
|
|
8
8
|
export { IRuntimeEnvironment } from '../client/runtimeEnvironment';
|
|
9
9
|
export { CoveoUA, getCurrentClient, handleOneAnalyticsEvent } from './simpleanalytics';
|
|
10
10
|
export { CoveoSearchPageClient, SearchPageClientProvider } from '../searchPage/searchPageClient';
|
|
11
|
+
export { CaseAssistClient } from '../caseAssist/caseAssistClient';
|
|
11
12
|
export { analytics, donottrack, history, SimpleAnalytics, storage };
|
package/dist/library.es.js
CHANGED
|
@@ -365,6 +365,14 @@ const serviceActionsKeysMapping = {
|
|
|
365
365
|
svcAction: 'svc_action',
|
|
366
366
|
svcActionData: 'svc_action_data',
|
|
367
367
|
};
|
|
368
|
+
const convertTicketToMeasurementProtocol = (ticket) => {
|
|
369
|
+
return keysOf(ticket)
|
|
370
|
+
.filter((key) => ticket[key] !== undefined)
|
|
371
|
+
.reduce((mappedTicket, key) => {
|
|
372
|
+
const newKey = ticketKeysMapping[key] || key;
|
|
373
|
+
return Object.assign(Object.assign({}, mappedTicket), { [newKey]: ticket[key] });
|
|
374
|
+
}, {});
|
|
375
|
+
};
|
|
368
376
|
const isTicketKey = (key) => ticketKeyRegex.test(key);
|
|
369
377
|
const isServiceKey = [isTicketKey];
|
|
370
378
|
|
|
@@ -1450,4 +1458,247 @@ class CoveoSearchPageClient {
|
|
|
1450
1458
|
}
|
|
1451
1459
|
}
|
|
1452
1460
|
|
|
1453
|
-
|
|
1461
|
+
const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
|
|
1462
|
+
|
|
1463
|
+
const BasePluginEventTypes = {
|
|
1464
|
+
pageview: 'pageview',
|
|
1465
|
+
event: 'event',
|
|
1466
|
+
};
|
|
1467
|
+
class BasePlugin {
|
|
1468
|
+
constructor({ client, uuidGenerator = uuidv4 }) {
|
|
1469
|
+
this.actionData = {};
|
|
1470
|
+
this.client = client;
|
|
1471
|
+
this.uuidGenerator = uuidGenerator;
|
|
1472
|
+
this.pageViewId = uuidGenerator();
|
|
1473
|
+
this.nextPageViewId = this.pageViewId;
|
|
1474
|
+
this.currentLocation = getFormattedLocation(window.location);
|
|
1475
|
+
this.lastReferrer = document.referrer;
|
|
1476
|
+
this.addHooks();
|
|
1477
|
+
}
|
|
1478
|
+
setAction(action, options) {
|
|
1479
|
+
this.action = action;
|
|
1480
|
+
this.actionData = options;
|
|
1481
|
+
}
|
|
1482
|
+
clearData() {
|
|
1483
|
+
this.clearPluginData();
|
|
1484
|
+
this.action = undefined;
|
|
1485
|
+
this.actionData = {};
|
|
1486
|
+
}
|
|
1487
|
+
getLocationInformation(eventType, payload) {
|
|
1488
|
+
return Object.assign({ hitType: eventType }, this.getNextValues(eventType, payload));
|
|
1489
|
+
}
|
|
1490
|
+
updateLocationInformation(eventType, payload) {
|
|
1491
|
+
this.updateLocationForNextPageView(eventType, payload);
|
|
1492
|
+
}
|
|
1493
|
+
getDefaultContextInformation(eventType) {
|
|
1494
|
+
const documentContext = {
|
|
1495
|
+
title: document.title,
|
|
1496
|
+
encoding: document.characterSet,
|
|
1497
|
+
};
|
|
1498
|
+
const screenContext = {
|
|
1499
|
+
screenResolution: `${screen.width}x${screen.height}`,
|
|
1500
|
+
screenColor: `${screen.colorDepth}-bit`,
|
|
1501
|
+
};
|
|
1502
|
+
const navigatorContext = {
|
|
1503
|
+
language: navigator.language,
|
|
1504
|
+
userAgent: navigator.userAgent,
|
|
1505
|
+
};
|
|
1506
|
+
const eventContext = {
|
|
1507
|
+
time: Date.now().toString(),
|
|
1508
|
+
eventId: this.uuidGenerator(),
|
|
1509
|
+
};
|
|
1510
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, eventContext), screenContext), navigatorContext), documentContext);
|
|
1511
|
+
}
|
|
1512
|
+
updateLocationForNextPageView(eventType, payload) {
|
|
1513
|
+
const { pageViewId, referrer, location } = this.getNextValues(eventType, payload);
|
|
1514
|
+
this.lastReferrer = referrer;
|
|
1515
|
+
this.pageViewId = pageViewId;
|
|
1516
|
+
this.currentLocation = location;
|
|
1517
|
+
if (eventType === BasePluginEventTypes.pageview) {
|
|
1518
|
+
this.nextPageViewId = this.uuidGenerator();
|
|
1519
|
+
this.hasSentFirstPageView = true;
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
getNextValues(eventType, payload) {
|
|
1523
|
+
return {
|
|
1524
|
+
pageViewId: eventType === BasePluginEventTypes.pageview ? this.nextPageViewId : this.pageViewId,
|
|
1525
|
+
referrer: eventType === BasePluginEventTypes.pageview && this.hasSentFirstPageView
|
|
1526
|
+
? this.currentLocation
|
|
1527
|
+
: this.lastReferrer,
|
|
1528
|
+
location: eventType === BasePluginEventTypes.pageview
|
|
1529
|
+
? this.getCurrentLocationFromPayload(payload)
|
|
1530
|
+
: this.currentLocation,
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
getCurrentLocationFromPayload(payload) {
|
|
1534
|
+
if (!!payload.page) {
|
|
1535
|
+
const removeStartingSlash = (page) => page.replace(/^\/?(.*)$/, '/$1');
|
|
1536
|
+
const extractHostnamePart = (location) => location.split('/').slice(0, 3).join('/');
|
|
1537
|
+
return `${extractHostnamePart(this.currentLocation)}${removeStartingSlash(payload.page)}`;
|
|
1538
|
+
}
|
|
1539
|
+
else {
|
|
1540
|
+
return getFormattedLocation(window.location);
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
const SVCPluginEventTypes = Object.assign({}, BasePluginEventTypes);
|
|
1546
|
+
const allSVCEventTypes = Object.keys(SVCPluginEventTypes).map((key) => SVCPluginEventTypes[key]);
|
|
1547
|
+
class SVCPlugin extends BasePlugin {
|
|
1548
|
+
constructor({ client, uuidGenerator = uuidv4 }) {
|
|
1549
|
+
super({ client, uuidGenerator });
|
|
1550
|
+
this.ticket = {};
|
|
1551
|
+
}
|
|
1552
|
+
addHooks() {
|
|
1553
|
+
this.addHooksForEvent();
|
|
1554
|
+
this.addHooksForPageView();
|
|
1555
|
+
this.addHooksForSVCEvents();
|
|
1556
|
+
}
|
|
1557
|
+
setTicket(ticket) {
|
|
1558
|
+
this.ticket = ticket;
|
|
1559
|
+
}
|
|
1560
|
+
clearPluginData() {
|
|
1561
|
+
this.ticket = {};
|
|
1562
|
+
}
|
|
1563
|
+
addHooksForSVCEvents() {
|
|
1564
|
+
this.client.registerBeforeSendEventHook((eventType, ...[payload]) => {
|
|
1565
|
+
return allSVCEventTypes.indexOf(eventType) !== -1 ? this.addSVCDataToPayload(eventType, payload) : payload;
|
|
1566
|
+
});
|
|
1567
|
+
this.client.registerAfterSendEventHook((eventType, ...[payload]) => {
|
|
1568
|
+
if (allSVCEventTypes.indexOf(eventType) !== -1) {
|
|
1569
|
+
this.updateLocationInformation(eventType, payload);
|
|
1570
|
+
}
|
|
1571
|
+
return payload;
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
addHooksForPageView() {
|
|
1575
|
+
this.client.addEventTypeMapping(SVCPluginEventTypes.pageview, {
|
|
1576
|
+
newEventType: EventType.collect,
|
|
1577
|
+
variableLengthArgumentsNames: ['page'],
|
|
1578
|
+
addVisitorIdParameter: true,
|
|
1579
|
+
usesMeasurementProtocol: true,
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
addHooksForEvent() {
|
|
1583
|
+
this.client.addEventTypeMapping(SVCPluginEventTypes.event, {
|
|
1584
|
+
newEventType: EventType.collect,
|
|
1585
|
+
variableLengthArgumentsNames: ['eventCategory', 'eventAction', 'eventLabel', 'eventValue'],
|
|
1586
|
+
addVisitorIdParameter: true,
|
|
1587
|
+
usesMeasurementProtocol: true,
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
addSVCDataToPayload(eventType, payload) {
|
|
1591
|
+
var _a;
|
|
1592
|
+
const svcPayload = Object.assign(Object.assign(Object.assign(Object.assign({}, this.getLocationInformation(eventType, payload)), this.getDefaultContextInformation(eventType)), (this.action ? { svcAction: this.action } : {})), (Object.keys((_a = this.actionData) !== null && _a !== void 0 ? _a : {}).length > 0 ? { svcActionData: this.actionData } : {}));
|
|
1593
|
+
const ticketPayload = this.getTicketPayload();
|
|
1594
|
+
this.clearData();
|
|
1595
|
+
return Object.assign(Object.assign(Object.assign({}, ticketPayload), svcPayload), payload);
|
|
1596
|
+
}
|
|
1597
|
+
getTicketPayload() {
|
|
1598
|
+
return convertTicketToMeasurementProtocol(this.ticket);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
SVCPlugin.Id = 'svc';
|
|
1602
|
+
|
|
1603
|
+
var CaseAssistEvents;
|
|
1604
|
+
(function (CaseAssistEvents) {
|
|
1605
|
+
CaseAssistEvents["click"] = "click";
|
|
1606
|
+
CaseAssistEvents["flowStart"] = "flowStart";
|
|
1607
|
+
})(CaseAssistEvents || (CaseAssistEvents = {}));
|
|
1608
|
+
var CaseAssistActions;
|
|
1609
|
+
(function (CaseAssistActions) {
|
|
1610
|
+
CaseAssistActions["enterInterface"] = "ticket_create_start";
|
|
1611
|
+
CaseAssistActions["fieldUpdate"] = "ticket_field_update";
|
|
1612
|
+
CaseAssistActions["fieldSuggestionClick"] = "ticket_classification_click";
|
|
1613
|
+
CaseAssistActions["suggestionClick"] = "suggestion_click";
|
|
1614
|
+
CaseAssistActions["suggestionRate"] = "suggestion_rate";
|
|
1615
|
+
CaseAssistActions["nextCaseStep"] = "ticket_next_stage";
|
|
1616
|
+
CaseAssistActions["caseCancelled"] = "ticket_cancel";
|
|
1617
|
+
CaseAssistActions["caseSolved"] = "ticket_cancel";
|
|
1618
|
+
CaseAssistActions["caseCreated"] = "ticket_create";
|
|
1619
|
+
})(CaseAssistActions || (CaseAssistActions = {}));
|
|
1620
|
+
var CaseCancelledReasons;
|
|
1621
|
+
(function (CaseCancelledReasons) {
|
|
1622
|
+
CaseCancelledReasons["quit"] = "Quit";
|
|
1623
|
+
CaseCancelledReasons["solved"] = "Solved";
|
|
1624
|
+
})(CaseCancelledReasons || (CaseCancelledReasons = {}));
|
|
1625
|
+
|
|
1626
|
+
class CaseAssistClient {
|
|
1627
|
+
constructor(options) {
|
|
1628
|
+
var _a;
|
|
1629
|
+
this.options = options;
|
|
1630
|
+
const analyticsEnabled = (_a = options.enableAnalytics) !== null && _a !== void 0 ? _a : true;
|
|
1631
|
+
this.coveoAnalyticsClient = analyticsEnabled ? new CoveoAnalyticsClient(options) : new NoopAnalytics();
|
|
1632
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
1633
|
+
}
|
|
1634
|
+
disable() {
|
|
1635
|
+
if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
|
|
1636
|
+
this.coveoAnalyticsClient.clear();
|
|
1637
|
+
}
|
|
1638
|
+
this.coveoAnalyticsClient = new NoopAnalytics();
|
|
1639
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
1640
|
+
}
|
|
1641
|
+
enable() {
|
|
1642
|
+
this.coveoAnalyticsClient = new CoveoAnalyticsClient(this.options);
|
|
1643
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
1644
|
+
}
|
|
1645
|
+
logEnterInterface(meta) {
|
|
1646
|
+
this.svc.setAction(CaseAssistActions.enterInterface);
|
|
1647
|
+
this.svc.setTicket(meta.ticket);
|
|
1648
|
+
return this.sendFlowStartEvent();
|
|
1649
|
+
}
|
|
1650
|
+
logUpdateCaseField(meta) {
|
|
1651
|
+
this.svc.setAction(CaseAssistActions.fieldUpdate, {
|
|
1652
|
+
fieldName: meta.fieldName,
|
|
1653
|
+
});
|
|
1654
|
+
this.svc.setTicket(meta.ticket);
|
|
1655
|
+
return this.sendClickEvent();
|
|
1656
|
+
}
|
|
1657
|
+
logSelectFieldSuggestion(meta) {
|
|
1658
|
+
this.svc.setAction(CaseAssistActions.fieldSuggestionClick, meta.suggestion);
|
|
1659
|
+
this.svc.setTicket(meta.ticket);
|
|
1660
|
+
return this.sendClickEvent();
|
|
1661
|
+
}
|
|
1662
|
+
logSelectDocumentSuggestion(meta) {
|
|
1663
|
+
this.svc.setAction(CaseAssistActions.suggestionClick, meta.suggestion);
|
|
1664
|
+
this.svc.setTicket(meta.ticket);
|
|
1665
|
+
return this.sendClickEvent();
|
|
1666
|
+
}
|
|
1667
|
+
logRateDocumentSuggestion(meta) {
|
|
1668
|
+
this.svc.setAction(CaseAssistActions.suggestionRate, Object.assign({ rate: meta.rating }, meta.suggestion));
|
|
1669
|
+
this.svc.setTicket(meta.ticket);
|
|
1670
|
+
return this.sendClickEvent();
|
|
1671
|
+
}
|
|
1672
|
+
logMoveToNextCaseStep(meta) {
|
|
1673
|
+
this.svc.setAction(CaseAssistActions.nextCaseStep);
|
|
1674
|
+
this.svc.setTicket(meta.ticket);
|
|
1675
|
+
return this.sendClickEvent();
|
|
1676
|
+
}
|
|
1677
|
+
logCaseCancelled(meta) {
|
|
1678
|
+
this.svc.setAction(CaseAssistActions.caseCancelled, {
|
|
1679
|
+
reason: CaseCancelledReasons.quit,
|
|
1680
|
+
});
|
|
1681
|
+
this.svc.setTicket(meta.ticket);
|
|
1682
|
+
return this.sendClickEvent();
|
|
1683
|
+
}
|
|
1684
|
+
logCaseSolved(meta) {
|
|
1685
|
+
this.svc.setAction(CaseAssistActions.caseSolved, {
|
|
1686
|
+
reason: CaseCancelledReasons.solved,
|
|
1687
|
+
});
|
|
1688
|
+
this.svc.setTicket(meta.ticket);
|
|
1689
|
+
return this.sendClickEvent();
|
|
1690
|
+
}
|
|
1691
|
+
logCaseCreated(meta) {
|
|
1692
|
+
this.svc.setAction(CaseAssistActions.caseCreated);
|
|
1693
|
+
this.svc.setTicket(meta.ticket);
|
|
1694
|
+
return this.sendClickEvent();
|
|
1695
|
+
}
|
|
1696
|
+
sendFlowStartEvent() {
|
|
1697
|
+
return this.coveoAnalyticsClient.sendEvent('event', 'svc', CaseAssistEvents.flowStart);
|
|
1698
|
+
}
|
|
1699
|
+
sendClickEvent() {
|
|
1700
|
+
return this.coveoAnalyticsClient.sendEvent('event', 'svc', CaseAssistEvents.click);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
export { CaseAssistClient, CoveoAnalyticsClient, CoveoSearchPageClient, history };
|
package/dist/library.js
CHANGED
|
@@ -4277,6 +4277,109 @@ var CoveoSearchPageClient = (function () {
|
|
|
4277
4277
|
return CoveoSearchPageClient;
|
|
4278
4278
|
}());
|
|
4279
4279
|
|
|
4280
|
+
var CaseAssistEvents;
|
|
4281
|
+
(function (CaseAssistEvents) {
|
|
4282
|
+
CaseAssistEvents["click"] = "click";
|
|
4283
|
+
CaseAssistEvents["flowStart"] = "flowStart";
|
|
4284
|
+
})(CaseAssistEvents || (CaseAssistEvents = {}));
|
|
4285
|
+
var CaseAssistActions;
|
|
4286
|
+
(function (CaseAssistActions) {
|
|
4287
|
+
CaseAssistActions["enterInterface"] = "ticket_create_start";
|
|
4288
|
+
CaseAssistActions["fieldUpdate"] = "ticket_field_update";
|
|
4289
|
+
CaseAssistActions["fieldSuggestionClick"] = "ticket_classification_click";
|
|
4290
|
+
CaseAssistActions["suggestionClick"] = "suggestion_click";
|
|
4291
|
+
CaseAssistActions["suggestionRate"] = "suggestion_rate";
|
|
4292
|
+
CaseAssistActions["nextCaseStep"] = "ticket_next_stage";
|
|
4293
|
+
CaseAssistActions["caseCancelled"] = "ticket_cancel";
|
|
4294
|
+
CaseAssistActions["caseSolved"] = "ticket_cancel";
|
|
4295
|
+
CaseAssistActions["caseCreated"] = "ticket_create";
|
|
4296
|
+
})(CaseAssistActions || (CaseAssistActions = {}));
|
|
4297
|
+
var CaseCancelledReasons;
|
|
4298
|
+
(function (CaseCancelledReasons) {
|
|
4299
|
+
CaseCancelledReasons["quit"] = "Quit";
|
|
4300
|
+
CaseCancelledReasons["solved"] = "Solved";
|
|
4301
|
+
})(CaseCancelledReasons || (CaseCancelledReasons = {}));
|
|
4302
|
+
|
|
4303
|
+
var CaseAssistClient = (function () {
|
|
4304
|
+
function CaseAssistClient(options) {
|
|
4305
|
+
var _a;
|
|
4306
|
+
this.options = options;
|
|
4307
|
+
var analyticsEnabled = (_a = options.enableAnalytics) !== null && _a !== void 0 ? _a : true;
|
|
4308
|
+
this.coveoAnalyticsClient = analyticsEnabled ? new CoveoAnalyticsClient(options) : new NoopAnalytics();
|
|
4309
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
4310
|
+
}
|
|
4311
|
+
CaseAssistClient.prototype.disable = function () {
|
|
4312
|
+
if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
|
|
4313
|
+
this.coveoAnalyticsClient.clear();
|
|
4314
|
+
}
|
|
4315
|
+
this.coveoAnalyticsClient = new NoopAnalytics();
|
|
4316
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
4317
|
+
};
|
|
4318
|
+
CaseAssistClient.prototype.enable = function () {
|
|
4319
|
+
this.coveoAnalyticsClient = new CoveoAnalyticsClient(this.options);
|
|
4320
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
4321
|
+
};
|
|
4322
|
+
CaseAssistClient.prototype.logEnterInterface = function (meta) {
|
|
4323
|
+
this.svc.setAction(CaseAssistActions.enterInterface);
|
|
4324
|
+
this.svc.setTicket(meta.ticket);
|
|
4325
|
+
return this.sendFlowStartEvent();
|
|
4326
|
+
};
|
|
4327
|
+
CaseAssistClient.prototype.logUpdateCaseField = function (meta) {
|
|
4328
|
+
this.svc.setAction(CaseAssistActions.fieldUpdate, {
|
|
4329
|
+
fieldName: meta.fieldName,
|
|
4330
|
+
});
|
|
4331
|
+
this.svc.setTicket(meta.ticket);
|
|
4332
|
+
return this.sendClickEvent();
|
|
4333
|
+
};
|
|
4334
|
+
CaseAssistClient.prototype.logSelectFieldSuggestion = function (meta) {
|
|
4335
|
+
this.svc.setAction(CaseAssistActions.fieldSuggestionClick, meta.suggestion);
|
|
4336
|
+
this.svc.setTicket(meta.ticket);
|
|
4337
|
+
return this.sendClickEvent();
|
|
4338
|
+
};
|
|
4339
|
+
CaseAssistClient.prototype.logSelectDocumentSuggestion = function (meta) {
|
|
4340
|
+
this.svc.setAction(CaseAssistActions.suggestionClick, meta.suggestion);
|
|
4341
|
+
this.svc.setTicket(meta.ticket);
|
|
4342
|
+
return this.sendClickEvent();
|
|
4343
|
+
};
|
|
4344
|
+
CaseAssistClient.prototype.logRateDocumentSuggestion = function (meta) {
|
|
4345
|
+
this.svc.setAction(CaseAssistActions.suggestionRate, tslib.exports.__assign({ rate: meta.rating }, meta.suggestion));
|
|
4346
|
+
this.svc.setTicket(meta.ticket);
|
|
4347
|
+
return this.sendClickEvent();
|
|
4348
|
+
};
|
|
4349
|
+
CaseAssistClient.prototype.logMoveToNextCaseStep = function (meta) {
|
|
4350
|
+
this.svc.setAction(CaseAssistActions.nextCaseStep);
|
|
4351
|
+
this.svc.setTicket(meta.ticket);
|
|
4352
|
+
return this.sendClickEvent();
|
|
4353
|
+
};
|
|
4354
|
+
CaseAssistClient.prototype.logCaseCancelled = function (meta) {
|
|
4355
|
+
this.svc.setAction(CaseAssistActions.caseCancelled, {
|
|
4356
|
+
reason: CaseCancelledReasons.quit,
|
|
4357
|
+
});
|
|
4358
|
+
this.svc.setTicket(meta.ticket);
|
|
4359
|
+
return this.sendClickEvent();
|
|
4360
|
+
};
|
|
4361
|
+
CaseAssistClient.prototype.logCaseSolved = function (meta) {
|
|
4362
|
+
this.svc.setAction(CaseAssistActions.caseSolved, {
|
|
4363
|
+
reason: CaseCancelledReasons.solved,
|
|
4364
|
+
});
|
|
4365
|
+
this.svc.setTicket(meta.ticket);
|
|
4366
|
+
return this.sendClickEvent();
|
|
4367
|
+
};
|
|
4368
|
+
CaseAssistClient.prototype.logCaseCreated = function (meta) {
|
|
4369
|
+
this.svc.setAction(CaseAssistActions.caseCreated);
|
|
4370
|
+
this.svc.setTicket(meta.ticket);
|
|
4371
|
+
return this.sendClickEvent();
|
|
4372
|
+
};
|
|
4373
|
+
CaseAssistClient.prototype.sendFlowStartEvent = function () {
|
|
4374
|
+
return this.coveoAnalyticsClient.sendEvent('event', 'svc', CaseAssistEvents.flowStart);
|
|
4375
|
+
};
|
|
4376
|
+
CaseAssistClient.prototype.sendClickEvent = function () {
|
|
4377
|
+
return this.coveoAnalyticsClient.sendEvent('event', 'svc', CaseAssistEvents.click);
|
|
4378
|
+
};
|
|
4379
|
+
return CaseAssistClient;
|
|
4380
|
+
}());
|
|
4381
|
+
|
|
4382
|
+
exports.CaseAssistClient = CaseAssistClient;
|
|
4280
4383
|
exports.CoveoAnalyticsClient = CoveoAnalyticsClient;
|
|
4281
4384
|
exports.CoveoSearchPageClient = CoveoSearchPageClient;
|
|
4282
4385
|
exports.CoveoUA = CoveoUA;
|
package/package.json
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {TicketProperties} from '../plugins/svc';
|
|
2
|
+
|
|
3
|
+
export enum CaseAssistEvents {
|
|
4
|
+
click = 'click',
|
|
5
|
+
flowStart = 'flowStart',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export enum CaseAssistActions {
|
|
9
|
+
enterInterface = 'ticket_create_start',
|
|
10
|
+
fieldUpdate = 'ticket_field_update',
|
|
11
|
+
fieldSuggestionClick = 'ticket_classification_click',
|
|
12
|
+
suggestionClick = 'suggestion_click',
|
|
13
|
+
suggestionRate = 'suggestion_rate',
|
|
14
|
+
nextCaseStep = 'ticket_next_stage',
|
|
15
|
+
caseCancelled = 'ticket_cancel',
|
|
16
|
+
caseSolved = 'ticket_cancel',
|
|
17
|
+
caseCreated = 'ticket_create',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export enum CaseCancelledReasons {
|
|
21
|
+
quit = 'Quit',
|
|
22
|
+
solved = 'Solved',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface EnterInterfaceMetadata {
|
|
26
|
+
ticket: TicketProperties;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface UpdateCaseFieldMetadata {
|
|
30
|
+
fieldName: string;
|
|
31
|
+
ticket: TicketProperties;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface SelectFieldSuggestionMetadata {
|
|
35
|
+
suggestion: FieldSuggestion;
|
|
36
|
+
ticket: TicketProperties;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface SelectDocumentSuggestionMetadata {
|
|
40
|
+
suggestion: DocumentSuggestion;
|
|
41
|
+
ticket: TicketProperties;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface RateDocumentSuggestionMetadata {
|
|
45
|
+
rating: number;
|
|
46
|
+
suggestion: DocumentSuggestion;
|
|
47
|
+
ticket: TicketProperties;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface MoveToNextCaseStepMetadata {
|
|
51
|
+
ticket: TicketProperties;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface CaseCancelledMetadata {
|
|
55
|
+
ticket: TicketProperties;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface CaseSolvedMetadata {
|
|
59
|
+
ticket: TicketProperties;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface CaseCreatedMetadata {
|
|
63
|
+
ticket: TicketProperties;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface FieldSuggestion {
|
|
67
|
+
classificationId: string;
|
|
68
|
+
responseId: string;
|
|
69
|
+
fieldName: string;
|
|
70
|
+
classification: {
|
|
71
|
+
value: string;
|
|
72
|
+
confidence: number;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface DocumentSuggestion {
|
|
77
|
+
suggestionId: string;
|
|
78
|
+
responseId: string;
|
|
79
|
+
suggestion: {
|
|
80
|
+
documentUri: string;
|
|
81
|
+
documentUriHash: string;
|
|
82
|
+
documentTitle: string;
|
|
83
|
+
documentUrl: string;
|
|
84
|
+
documentPosition: number;
|
|
85
|
+
};
|
|
86
|
+
}
|