coveo.analytics 2.18.52 → 2.18.56
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 +254 -2
- package/dist/library.js +105 -1
- 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
- package/src/donottrack.spec.ts +24 -0
- package/src/donottrack.ts +3 -1
- package/dist/definitions/src/plugins/BasePlugin.d.ts +0 -53
- package/dist/definitions/src/plugins/svc.d.ts +0 -31
|
@@ -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
|
|
|
@@ -728,6 +736,7 @@ function isReactNative() {
|
|
|
728
736
|
return typeof navigator != 'undefined' && navigator.product == 'ReactNative';
|
|
729
737
|
}
|
|
730
738
|
|
|
739
|
+
const doNotTrackValues = ['1', 1, 'yes', true];
|
|
731
740
|
function doNotTrack() {
|
|
732
741
|
return (hasNavigator() &&
|
|
733
742
|
[
|
|
@@ -735,7 +744,7 @@ function doNotTrack() {
|
|
|
735
744
|
navigator.doNotTrack,
|
|
736
745
|
navigator.msDoNotTrack,
|
|
737
746
|
window.doNotTrack,
|
|
738
|
-
].some((value) =>
|
|
747
|
+
].some((value) => doNotTrackValues.indexOf(value) !== -1));
|
|
739
748
|
}
|
|
740
749
|
|
|
741
750
|
const Version = 'v15';
|
|
@@ -1450,4 +1459,247 @@ class CoveoSearchPageClient {
|
|
|
1450
1459
|
}
|
|
1451
1460
|
}
|
|
1452
1461
|
|
|
1453
|
-
|
|
1462
|
+
const getFormattedLocation = (location) => `${location.protocol}//${location.hostname}${location.pathname.indexOf('/') === 0 ? location.pathname : `/${location.pathname}`}${location.search}`;
|
|
1463
|
+
|
|
1464
|
+
const BasePluginEventTypes = {
|
|
1465
|
+
pageview: 'pageview',
|
|
1466
|
+
event: 'event',
|
|
1467
|
+
};
|
|
1468
|
+
class BasePlugin {
|
|
1469
|
+
constructor({ client, uuidGenerator = uuidv4 }) {
|
|
1470
|
+
this.actionData = {};
|
|
1471
|
+
this.client = client;
|
|
1472
|
+
this.uuidGenerator = uuidGenerator;
|
|
1473
|
+
this.pageViewId = uuidGenerator();
|
|
1474
|
+
this.nextPageViewId = this.pageViewId;
|
|
1475
|
+
this.currentLocation = getFormattedLocation(window.location);
|
|
1476
|
+
this.lastReferrer = document.referrer;
|
|
1477
|
+
this.addHooks();
|
|
1478
|
+
}
|
|
1479
|
+
setAction(action, options) {
|
|
1480
|
+
this.action = action;
|
|
1481
|
+
this.actionData = options;
|
|
1482
|
+
}
|
|
1483
|
+
clearData() {
|
|
1484
|
+
this.clearPluginData();
|
|
1485
|
+
this.action = undefined;
|
|
1486
|
+
this.actionData = {};
|
|
1487
|
+
}
|
|
1488
|
+
getLocationInformation(eventType, payload) {
|
|
1489
|
+
return Object.assign({ hitType: eventType }, this.getNextValues(eventType, payload));
|
|
1490
|
+
}
|
|
1491
|
+
updateLocationInformation(eventType, payload) {
|
|
1492
|
+
this.updateLocationForNextPageView(eventType, payload);
|
|
1493
|
+
}
|
|
1494
|
+
getDefaultContextInformation(eventType) {
|
|
1495
|
+
const documentContext = {
|
|
1496
|
+
title: document.title,
|
|
1497
|
+
encoding: document.characterSet,
|
|
1498
|
+
};
|
|
1499
|
+
const screenContext = {
|
|
1500
|
+
screenResolution: `${screen.width}x${screen.height}`,
|
|
1501
|
+
screenColor: `${screen.colorDepth}-bit`,
|
|
1502
|
+
};
|
|
1503
|
+
const navigatorContext = {
|
|
1504
|
+
language: navigator.language,
|
|
1505
|
+
userAgent: navigator.userAgent,
|
|
1506
|
+
};
|
|
1507
|
+
const eventContext = {
|
|
1508
|
+
time: Date.now().toString(),
|
|
1509
|
+
eventId: this.uuidGenerator(),
|
|
1510
|
+
};
|
|
1511
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, eventContext), screenContext), navigatorContext), documentContext);
|
|
1512
|
+
}
|
|
1513
|
+
updateLocationForNextPageView(eventType, payload) {
|
|
1514
|
+
const { pageViewId, referrer, location } = this.getNextValues(eventType, payload);
|
|
1515
|
+
this.lastReferrer = referrer;
|
|
1516
|
+
this.pageViewId = pageViewId;
|
|
1517
|
+
this.currentLocation = location;
|
|
1518
|
+
if (eventType === BasePluginEventTypes.pageview) {
|
|
1519
|
+
this.nextPageViewId = this.uuidGenerator();
|
|
1520
|
+
this.hasSentFirstPageView = true;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
getNextValues(eventType, payload) {
|
|
1524
|
+
return {
|
|
1525
|
+
pageViewId: eventType === BasePluginEventTypes.pageview ? this.nextPageViewId : this.pageViewId,
|
|
1526
|
+
referrer: eventType === BasePluginEventTypes.pageview && this.hasSentFirstPageView
|
|
1527
|
+
? this.currentLocation
|
|
1528
|
+
: this.lastReferrer,
|
|
1529
|
+
location: eventType === BasePluginEventTypes.pageview
|
|
1530
|
+
? this.getCurrentLocationFromPayload(payload)
|
|
1531
|
+
: this.currentLocation,
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
getCurrentLocationFromPayload(payload) {
|
|
1535
|
+
if (!!payload.page) {
|
|
1536
|
+
const removeStartingSlash = (page) => page.replace(/^\/?(.*)$/, '/$1');
|
|
1537
|
+
const extractHostnamePart = (location) => location.split('/').slice(0, 3).join('/');
|
|
1538
|
+
return `${extractHostnamePart(this.currentLocation)}${removeStartingSlash(payload.page)}`;
|
|
1539
|
+
}
|
|
1540
|
+
else {
|
|
1541
|
+
return getFormattedLocation(window.location);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
const SVCPluginEventTypes = Object.assign({}, BasePluginEventTypes);
|
|
1547
|
+
const allSVCEventTypes = Object.keys(SVCPluginEventTypes).map((key) => SVCPluginEventTypes[key]);
|
|
1548
|
+
class SVCPlugin extends BasePlugin {
|
|
1549
|
+
constructor({ client, uuidGenerator = uuidv4 }) {
|
|
1550
|
+
super({ client, uuidGenerator });
|
|
1551
|
+
this.ticket = {};
|
|
1552
|
+
}
|
|
1553
|
+
addHooks() {
|
|
1554
|
+
this.addHooksForEvent();
|
|
1555
|
+
this.addHooksForPageView();
|
|
1556
|
+
this.addHooksForSVCEvents();
|
|
1557
|
+
}
|
|
1558
|
+
setTicket(ticket) {
|
|
1559
|
+
this.ticket = ticket;
|
|
1560
|
+
}
|
|
1561
|
+
clearPluginData() {
|
|
1562
|
+
this.ticket = {};
|
|
1563
|
+
}
|
|
1564
|
+
addHooksForSVCEvents() {
|
|
1565
|
+
this.client.registerBeforeSendEventHook((eventType, ...[payload]) => {
|
|
1566
|
+
return allSVCEventTypes.indexOf(eventType) !== -1 ? this.addSVCDataToPayload(eventType, payload) : payload;
|
|
1567
|
+
});
|
|
1568
|
+
this.client.registerAfterSendEventHook((eventType, ...[payload]) => {
|
|
1569
|
+
if (allSVCEventTypes.indexOf(eventType) !== -1) {
|
|
1570
|
+
this.updateLocationInformation(eventType, payload);
|
|
1571
|
+
}
|
|
1572
|
+
return payload;
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
addHooksForPageView() {
|
|
1576
|
+
this.client.addEventTypeMapping(SVCPluginEventTypes.pageview, {
|
|
1577
|
+
newEventType: EventType.collect,
|
|
1578
|
+
variableLengthArgumentsNames: ['page'],
|
|
1579
|
+
addVisitorIdParameter: true,
|
|
1580
|
+
usesMeasurementProtocol: true,
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
addHooksForEvent() {
|
|
1584
|
+
this.client.addEventTypeMapping(SVCPluginEventTypes.event, {
|
|
1585
|
+
newEventType: EventType.collect,
|
|
1586
|
+
variableLengthArgumentsNames: ['eventCategory', 'eventAction', 'eventLabel', 'eventValue'],
|
|
1587
|
+
addVisitorIdParameter: true,
|
|
1588
|
+
usesMeasurementProtocol: true,
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
addSVCDataToPayload(eventType, payload) {
|
|
1592
|
+
var _a;
|
|
1593
|
+
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 } : {}));
|
|
1594
|
+
const ticketPayload = this.getTicketPayload();
|
|
1595
|
+
this.clearData();
|
|
1596
|
+
return Object.assign(Object.assign(Object.assign({}, ticketPayload), svcPayload), payload);
|
|
1597
|
+
}
|
|
1598
|
+
getTicketPayload() {
|
|
1599
|
+
return convertTicketToMeasurementProtocol(this.ticket);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
SVCPlugin.Id = 'svc';
|
|
1603
|
+
|
|
1604
|
+
var CaseAssistEvents;
|
|
1605
|
+
(function (CaseAssistEvents) {
|
|
1606
|
+
CaseAssistEvents["click"] = "click";
|
|
1607
|
+
CaseAssistEvents["flowStart"] = "flowStart";
|
|
1608
|
+
})(CaseAssistEvents || (CaseAssistEvents = {}));
|
|
1609
|
+
var CaseAssistActions;
|
|
1610
|
+
(function (CaseAssistActions) {
|
|
1611
|
+
CaseAssistActions["enterInterface"] = "ticket_create_start";
|
|
1612
|
+
CaseAssistActions["fieldUpdate"] = "ticket_field_update";
|
|
1613
|
+
CaseAssistActions["fieldSuggestionClick"] = "ticket_classification_click";
|
|
1614
|
+
CaseAssistActions["suggestionClick"] = "suggestion_click";
|
|
1615
|
+
CaseAssistActions["suggestionRate"] = "suggestion_rate";
|
|
1616
|
+
CaseAssistActions["nextCaseStep"] = "ticket_next_stage";
|
|
1617
|
+
CaseAssistActions["caseCancelled"] = "ticket_cancel";
|
|
1618
|
+
CaseAssistActions["caseSolved"] = "ticket_cancel";
|
|
1619
|
+
CaseAssistActions["caseCreated"] = "ticket_create";
|
|
1620
|
+
})(CaseAssistActions || (CaseAssistActions = {}));
|
|
1621
|
+
var CaseCancelledReasons;
|
|
1622
|
+
(function (CaseCancelledReasons) {
|
|
1623
|
+
CaseCancelledReasons["quit"] = "Quit";
|
|
1624
|
+
CaseCancelledReasons["solved"] = "Solved";
|
|
1625
|
+
})(CaseCancelledReasons || (CaseCancelledReasons = {}));
|
|
1626
|
+
|
|
1627
|
+
class CaseAssistClient {
|
|
1628
|
+
constructor(options) {
|
|
1629
|
+
var _a;
|
|
1630
|
+
this.options = options;
|
|
1631
|
+
const analyticsEnabled = (_a = options.enableAnalytics) !== null && _a !== void 0 ? _a : true;
|
|
1632
|
+
this.coveoAnalyticsClient = analyticsEnabled ? new CoveoAnalyticsClient(options) : new NoopAnalytics();
|
|
1633
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
1634
|
+
}
|
|
1635
|
+
disable() {
|
|
1636
|
+
if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
|
|
1637
|
+
this.coveoAnalyticsClient.clear();
|
|
1638
|
+
}
|
|
1639
|
+
this.coveoAnalyticsClient = new NoopAnalytics();
|
|
1640
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
1641
|
+
}
|
|
1642
|
+
enable() {
|
|
1643
|
+
this.coveoAnalyticsClient = new CoveoAnalyticsClient(this.options);
|
|
1644
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
1645
|
+
}
|
|
1646
|
+
logEnterInterface(meta) {
|
|
1647
|
+
this.svc.setAction(CaseAssistActions.enterInterface);
|
|
1648
|
+
this.svc.setTicket(meta.ticket);
|
|
1649
|
+
return this.sendFlowStartEvent();
|
|
1650
|
+
}
|
|
1651
|
+
logUpdateCaseField(meta) {
|
|
1652
|
+
this.svc.setAction(CaseAssistActions.fieldUpdate, {
|
|
1653
|
+
fieldName: meta.fieldName,
|
|
1654
|
+
});
|
|
1655
|
+
this.svc.setTicket(meta.ticket);
|
|
1656
|
+
return this.sendClickEvent();
|
|
1657
|
+
}
|
|
1658
|
+
logSelectFieldSuggestion(meta) {
|
|
1659
|
+
this.svc.setAction(CaseAssistActions.fieldSuggestionClick, meta.suggestion);
|
|
1660
|
+
this.svc.setTicket(meta.ticket);
|
|
1661
|
+
return this.sendClickEvent();
|
|
1662
|
+
}
|
|
1663
|
+
logSelectDocumentSuggestion(meta) {
|
|
1664
|
+
this.svc.setAction(CaseAssistActions.suggestionClick, meta.suggestion);
|
|
1665
|
+
this.svc.setTicket(meta.ticket);
|
|
1666
|
+
return this.sendClickEvent();
|
|
1667
|
+
}
|
|
1668
|
+
logRateDocumentSuggestion(meta) {
|
|
1669
|
+
this.svc.setAction(CaseAssistActions.suggestionRate, Object.assign({ rate: meta.rating }, meta.suggestion));
|
|
1670
|
+
this.svc.setTicket(meta.ticket);
|
|
1671
|
+
return this.sendClickEvent();
|
|
1672
|
+
}
|
|
1673
|
+
logMoveToNextCaseStep(meta) {
|
|
1674
|
+
this.svc.setAction(CaseAssistActions.nextCaseStep);
|
|
1675
|
+
this.svc.setTicket(meta.ticket);
|
|
1676
|
+
return this.sendClickEvent();
|
|
1677
|
+
}
|
|
1678
|
+
logCaseCancelled(meta) {
|
|
1679
|
+
this.svc.setAction(CaseAssistActions.caseCancelled, {
|
|
1680
|
+
reason: CaseCancelledReasons.quit,
|
|
1681
|
+
});
|
|
1682
|
+
this.svc.setTicket(meta.ticket);
|
|
1683
|
+
return this.sendClickEvent();
|
|
1684
|
+
}
|
|
1685
|
+
logCaseSolved(meta) {
|
|
1686
|
+
this.svc.setAction(CaseAssistActions.caseSolved, {
|
|
1687
|
+
reason: CaseCancelledReasons.solved,
|
|
1688
|
+
});
|
|
1689
|
+
this.svc.setTicket(meta.ticket);
|
|
1690
|
+
return this.sendClickEvent();
|
|
1691
|
+
}
|
|
1692
|
+
logCaseCreated(meta) {
|
|
1693
|
+
this.svc.setAction(CaseAssistActions.caseCreated);
|
|
1694
|
+
this.svc.setTicket(meta.ticket);
|
|
1695
|
+
return this.sendClickEvent();
|
|
1696
|
+
}
|
|
1697
|
+
sendFlowStartEvent() {
|
|
1698
|
+
return this.coveoAnalyticsClient.sendEvent('event', 'svc', CaseAssistEvents.flowStart);
|
|
1699
|
+
}
|
|
1700
|
+
sendClickEvent() {
|
|
1701
|
+
return this.coveoAnalyticsClient.sendEvent('event', 'svc', CaseAssistEvents.click);
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
export { CaseAssistClient, CoveoAnalyticsClient, CoveoSearchPageClient, history };
|
package/dist/library.js
CHANGED
|
@@ -2832,6 +2832,7 @@ function isReactNative() {
|
|
|
2832
2832
|
return typeof navigator != 'undefined' && navigator.product == 'ReactNative';
|
|
2833
2833
|
}
|
|
2834
2834
|
|
|
2835
|
+
var doNotTrackValues = ['1', 1, 'yes', true];
|
|
2835
2836
|
function doNotTrack() {
|
|
2836
2837
|
return (hasNavigator() &&
|
|
2837
2838
|
[
|
|
@@ -2839,7 +2840,7 @@ function doNotTrack() {
|
|
|
2839
2840
|
navigator.doNotTrack,
|
|
2840
2841
|
navigator.msDoNotTrack,
|
|
2841
2842
|
window.doNotTrack,
|
|
2842
|
-
].some(function (value) { return
|
|
2843
|
+
].some(function (value) { return doNotTrackValues.indexOf(value) !== -1; }));
|
|
2843
2844
|
}
|
|
2844
2845
|
|
|
2845
2846
|
var donottrack = /*#__PURE__*/Object.freeze({
|
|
@@ -4277,6 +4278,109 @@ var CoveoSearchPageClient = (function () {
|
|
|
4277
4278
|
return CoveoSearchPageClient;
|
|
4278
4279
|
}());
|
|
4279
4280
|
|
|
4281
|
+
var CaseAssistEvents;
|
|
4282
|
+
(function (CaseAssistEvents) {
|
|
4283
|
+
CaseAssistEvents["click"] = "click";
|
|
4284
|
+
CaseAssistEvents["flowStart"] = "flowStart";
|
|
4285
|
+
})(CaseAssistEvents || (CaseAssistEvents = {}));
|
|
4286
|
+
var CaseAssistActions;
|
|
4287
|
+
(function (CaseAssistActions) {
|
|
4288
|
+
CaseAssistActions["enterInterface"] = "ticket_create_start";
|
|
4289
|
+
CaseAssistActions["fieldUpdate"] = "ticket_field_update";
|
|
4290
|
+
CaseAssistActions["fieldSuggestionClick"] = "ticket_classification_click";
|
|
4291
|
+
CaseAssistActions["suggestionClick"] = "suggestion_click";
|
|
4292
|
+
CaseAssistActions["suggestionRate"] = "suggestion_rate";
|
|
4293
|
+
CaseAssistActions["nextCaseStep"] = "ticket_next_stage";
|
|
4294
|
+
CaseAssistActions["caseCancelled"] = "ticket_cancel";
|
|
4295
|
+
CaseAssistActions["caseSolved"] = "ticket_cancel";
|
|
4296
|
+
CaseAssistActions["caseCreated"] = "ticket_create";
|
|
4297
|
+
})(CaseAssistActions || (CaseAssistActions = {}));
|
|
4298
|
+
var CaseCancelledReasons;
|
|
4299
|
+
(function (CaseCancelledReasons) {
|
|
4300
|
+
CaseCancelledReasons["quit"] = "Quit";
|
|
4301
|
+
CaseCancelledReasons["solved"] = "Solved";
|
|
4302
|
+
})(CaseCancelledReasons || (CaseCancelledReasons = {}));
|
|
4303
|
+
|
|
4304
|
+
var CaseAssistClient = (function () {
|
|
4305
|
+
function CaseAssistClient(options) {
|
|
4306
|
+
var _a;
|
|
4307
|
+
this.options = options;
|
|
4308
|
+
var analyticsEnabled = (_a = options.enableAnalytics) !== null && _a !== void 0 ? _a : true;
|
|
4309
|
+
this.coveoAnalyticsClient = analyticsEnabled ? new CoveoAnalyticsClient(options) : new NoopAnalytics();
|
|
4310
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
4311
|
+
}
|
|
4312
|
+
CaseAssistClient.prototype.disable = function () {
|
|
4313
|
+
if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
|
|
4314
|
+
this.coveoAnalyticsClient.clear();
|
|
4315
|
+
}
|
|
4316
|
+
this.coveoAnalyticsClient = new NoopAnalytics();
|
|
4317
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
4318
|
+
};
|
|
4319
|
+
CaseAssistClient.prototype.enable = function () {
|
|
4320
|
+
this.coveoAnalyticsClient = new CoveoAnalyticsClient(this.options);
|
|
4321
|
+
this.svc = new SVCPlugin({ client: this.coveoAnalyticsClient });
|
|
4322
|
+
};
|
|
4323
|
+
CaseAssistClient.prototype.logEnterInterface = function (meta) {
|
|
4324
|
+
this.svc.setAction(CaseAssistActions.enterInterface);
|
|
4325
|
+
this.svc.setTicket(meta.ticket);
|
|
4326
|
+
return this.sendFlowStartEvent();
|
|
4327
|
+
};
|
|
4328
|
+
CaseAssistClient.prototype.logUpdateCaseField = function (meta) {
|
|
4329
|
+
this.svc.setAction(CaseAssistActions.fieldUpdate, {
|
|
4330
|
+
fieldName: meta.fieldName,
|
|
4331
|
+
});
|
|
4332
|
+
this.svc.setTicket(meta.ticket);
|
|
4333
|
+
return this.sendClickEvent();
|
|
4334
|
+
};
|
|
4335
|
+
CaseAssistClient.prototype.logSelectFieldSuggestion = function (meta) {
|
|
4336
|
+
this.svc.setAction(CaseAssistActions.fieldSuggestionClick, meta.suggestion);
|
|
4337
|
+
this.svc.setTicket(meta.ticket);
|
|
4338
|
+
return this.sendClickEvent();
|
|
4339
|
+
};
|
|
4340
|
+
CaseAssistClient.prototype.logSelectDocumentSuggestion = function (meta) {
|
|
4341
|
+
this.svc.setAction(CaseAssistActions.suggestionClick, meta.suggestion);
|
|
4342
|
+
this.svc.setTicket(meta.ticket);
|
|
4343
|
+
return this.sendClickEvent();
|
|
4344
|
+
};
|
|
4345
|
+
CaseAssistClient.prototype.logRateDocumentSuggestion = function (meta) {
|
|
4346
|
+
this.svc.setAction(CaseAssistActions.suggestionRate, tslib.exports.__assign({ rate: meta.rating }, meta.suggestion));
|
|
4347
|
+
this.svc.setTicket(meta.ticket);
|
|
4348
|
+
return this.sendClickEvent();
|
|
4349
|
+
};
|
|
4350
|
+
CaseAssistClient.prototype.logMoveToNextCaseStep = function (meta) {
|
|
4351
|
+
this.svc.setAction(CaseAssistActions.nextCaseStep);
|
|
4352
|
+
this.svc.setTicket(meta.ticket);
|
|
4353
|
+
return this.sendClickEvent();
|
|
4354
|
+
};
|
|
4355
|
+
CaseAssistClient.prototype.logCaseCancelled = function (meta) {
|
|
4356
|
+
this.svc.setAction(CaseAssistActions.caseCancelled, {
|
|
4357
|
+
reason: CaseCancelledReasons.quit,
|
|
4358
|
+
});
|
|
4359
|
+
this.svc.setTicket(meta.ticket);
|
|
4360
|
+
return this.sendClickEvent();
|
|
4361
|
+
};
|
|
4362
|
+
CaseAssistClient.prototype.logCaseSolved = function (meta) {
|
|
4363
|
+
this.svc.setAction(CaseAssistActions.caseSolved, {
|
|
4364
|
+
reason: CaseCancelledReasons.solved,
|
|
4365
|
+
});
|
|
4366
|
+
this.svc.setTicket(meta.ticket);
|
|
4367
|
+
return this.sendClickEvent();
|
|
4368
|
+
};
|
|
4369
|
+
CaseAssistClient.prototype.logCaseCreated = function (meta) {
|
|
4370
|
+
this.svc.setAction(CaseAssistActions.caseCreated);
|
|
4371
|
+
this.svc.setTicket(meta.ticket);
|
|
4372
|
+
return this.sendClickEvent();
|
|
4373
|
+
};
|
|
4374
|
+
CaseAssistClient.prototype.sendFlowStartEvent = function () {
|
|
4375
|
+
return this.coveoAnalyticsClient.sendEvent('event', 'svc', CaseAssistEvents.flowStart);
|
|
4376
|
+
};
|
|
4377
|
+
CaseAssistClient.prototype.sendClickEvent = function () {
|
|
4378
|
+
return this.coveoAnalyticsClient.sendEvent('event', 'svc', CaseAssistEvents.click);
|
|
4379
|
+
};
|
|
4380
|
+
return CaseAssistClient;
|
|
4381
|
+
}());
|
|
4382
|
+
|
|
4383
|
+
exports.CaseAssistClient = CaseAssistClient;
|
|
4280
4384
|
exports.CoveoAnalyticsClient = CoveoAnalyticsClient;
|
|
4281
4385
|
exports.CoveoSearchPageClient = CoveoSearchPageClient;
|
|
4282
4386
|
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
|
+
}
|