coveo.analytics 2.30.56 → 2.32.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/README.md +37 -43
- package/dist/browser.mjs +513 -357
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +542 -359
- package/dist/coveoua.debug.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/client/analytics.d.ts +3 -2
- package/dist/definitions/client/runtimeEnvironment.d.ts +1 -1
- package/dist/definitions/donottrack.d.ts +1 -0
- package/dist/definitions/react-native/index.d.ts +1 -2
- package/dist/definitions/version.d.ts +1 -1
- package/dist/library.cjs +15350 -3699
- package/dist/library.es.js +513 -357
- package/dist/library.js +15350 -3699
- package/dist/library.mjs +15350 -3699
- package/dist/react-native.es.js +634 -460
- package/modules/package.json +9 -9
- package/package.json +60 -91
- package/react-native/package.json +7 -7
- package/src/caseAssist/caseAssistActions.ts +51 -50
- package/src/caseAssist/caseAssistClient.spec.ts +328 -297
- package/src/caseAssist/caseAssistClient.ts +201 -185
- package/src/client/analytics.spec.ts +724 -703
- package/src/client/analytics.ts +677 -602
- package/src/client/analyticsBeaconClient.spec.ts +195 -188
- package/src/client/analyticsBeaconClient.ts +99 -88
- package/src/client/analyticsFetchClient.ts +77 -61
- package/src/client/analyticsRequestClient.ts +17 -17
- package/src/client/location.ts +3 -3
- package/src/client/measurementProtocolMapper.ts +54 -45
- package/src/client/measurementProtocolMapping/baseMeasurementProtocolMapper.ts +48 -44
- package/src/client/measurementProtocolMapping/commerceMeasurementProtocolMapper.ts +133 -121
- package/src/client/measurementProtocolMapping/serviceMeasurementProtocolMapper.ts +17 -17
- package/src/client/noopAnalytics.ts +80 -68
- package/src/client/runtimeEnvironment.ts +50 -41
- package/src/client/utils.spec.ts +112 -97
- package/src/client/utils.ts +39 -39
- package/src/cookieutils.spec.ts +59 -0
- package/src/cookieutils.ts +40 -39
- package/src/coveoua/browser.ts +14 -12
- package/src/coveoua/library.ts +4 -4
- package/src/coveoua/plugins.ts +36 -34
- package/src/coveoua/simpleanalytics.spec.ts +467 -452
- package/src/coveoua/simpleanalytics.ts +146 -140
- package/src/detector.ts +17 -17
- package/src/donottrack.spec.ts +199 -121
- package/src/donottrack.ts +31 -8
- package/src/events.ts +86 -79
- package/src/formatting/format-array-for-coveo-custom-data.spec.ts +13 -12
- package/src/formatting/format-array-for-coveo-custom-data.ts +18 -18
- package/src/formatting/format-omnibox-metadata.ts +16 -12
- package/src/history.spec.ts +197 -195
- package/src/history.ts +143 -133
- package/src/hook/addDefaultValues.ts +13 -8
- package/src/hook/enhanceViewEvent.ts +17 -17
- package/src/insight/insightClient.spec.ts +1848 -1717
- package/src/insight/insightClient.ts +866 -761
- package/src/insight/insightEvents.ts +57 -56
- package/src/plugins/BasePlugin.ts +125 -121
- package/src/plugins/ec.spec.ts +457 -429
- package/src/plugins/ec.ts +202 -199
- package/src/plugins/link.spec.ts +183 -159
- package/src/plugins/link.ts +88 -85
- package/src/plugins/svc.spec.ts +161 -155
- package/src/plugins/svc.ts +93 -91
- package/src/react-native/index.ts +8 -1
- package/src/react-native/react-native-runtime.ts +33 -33
- package/src/react-native/react-native-utils.ts +1 -1
- package/src/react-native/react-native.spec.ts +31 -21
- package/src/searchPage/searchPageClient.spec.ts +1944 -1794
- package/src/searchPage/searchPageClient.ts +1261 -1040
- package/src/searchPage/searchPageEvents.ts +524 -511
- package/src/storage.spec.ts +51 -51
- package/src/storage.ts +47 -47
- package/dist/definitions/bundle/browser-fetch.d.ts +0 -1
- package/dist/definitions/src/coveoua/browser.d.ts +0 -6
- package/dist/definitions/src/coveoua/headless.d.ts +0 -6
- package/dist/definitions/src/coveoua/library.d.ts +0 -17
- package/dist/definitions/src/coveoua/plugins.d.ts +0 -10
- package/dist/definitions/src/coveoua/simpleanalytics.d.ts +0 -33
- package/dist/definitions/src/react-native/index.d.ts +0 -3
- package/dist/definitions/src/react-native/react-native-runtime.d.ts +0 -19
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import {vi} from 'vitest';
|
|
2
|
+
import type {Mock} from 'vitest';
|
|
1
3
|
import {CaseAssistClient, CaseAssistClientProvider} from './caseAssistClient';
|
|
2
4
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
CaseAssistActions,
|
|
6
|
+
CaseAssistEvents,
|
|
7
|
+
CaseCancelledReasons,
|
|
8
|
+
DocumentSuggestion,
|
|
9
|
+
FieldSuggestion,
|
|
8
10
|
} from './caseAssistActions';
|
|
9
11
|
import {mockFetch, lastCallBody} from '../../tests/fetchMock';
|
|
10
12
|
import {TicketProperties} from '../plugins/svc';
|
|
@@ -12,351 +14,380 @@ const {fetchMock, fetchMockBeforeEach} = mockFetch();
|
|
|
12
14
|
import doNotTrack from '../donottrack';
|
|
13
15
|
import {Cookie} from '../cookieutils';
|
|
14
16
|
import {PartialDocumentInformation} from '../searchPage/searchPageEvents';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
vi.mock('../donottrack', () => {
|
|
18
|
+
const doNotTrack = vi.fn();
|
|
19
|
+
return {
|
|
20
|
+
__esModule: true,
|
|
21
|
+
default: doNotTrack,
|
|
22
|
+
doNotTrack,
|
|
23
|
+
shouldDisableAnalyticsForPrivacy: (disableBrowserPrivacySignals?: boolean) =>
|
|
24
|
+
disableBrowserPrivacySignals === true ? false : doNotTrack(),
|
|
25
|
+
};
|
|
20
26
|
});
|
|
21
27
|
|
|
22
28
|
describe('CaseAssistClient', () => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
const exampleSearchHub = 'example origin-level-1';
|
|
30
|
+
const exampleOriginLevel2 = 'example origin-level-2';
|
|
31
|
+
const exampleOriginLevel3 = 'example origin-level-3';
|
|
32
|
+
const exampleOriginContext = 'example origin-context';
|
|
33
|
+
const exampleSearchUID = 'foo';
|
|
34
|
+
const exampleLanguage = 'en';
|
|
35
|
+
const exampleClientId = '123-456';
|
|
36
|
+
|
|
37
|
+
let client: CaseAssistClient;
|
|
38
|
+
|
|
39
|
+
const provider: CaseAssistClientProvider = {
|
|
40
|
+
getOriginLevel1: () => exampleSearchHub,
|
|
41
|
+
getOriginLevel2: () => exampleOriginLevel2,
|
|
42
|
+
getOriginLevel3: () => exampleOriginLevel3,
|
|
43
|
+
getOriginContext: () => exampleOriginContext,
|
|
44
|
+
getIsAnonymous: () => false,
|
|
45
|
+
getSearchUID: () => exampleSearchUID,
|
|
46
|
+
getLanguage: () => exampleLanguage,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
fetchMockBeforeEach();
|
|
51
|
+
|
|
52
|
+
client = initClient();
|
|
53
|
+
client.coveoAnalyticsClient.runtime.storage.setItem('visitorId', exampleClientId);
|
|
54
|
+
fetchMock.mock(/.*/, {
|
|
55
|
+
visitorId: 'visitor-id',
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
afterEach(() => {
|
|
60
|
+
fetchMock.reset();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const initClient = () => {
|
|
64
|
+
return new CaseAssistClient(
|
|
65
|
+
{
|
|
66
|
+
enableAnalytics: true,
|
|
67
|
+
},
|
|
68
|
+
provider
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const noTicket: Record<string, unknown> = undefined;
|
|
73
|
+
const noActionData: Record<string, unknown> = undefined;
|
|
74
|
+
const emptyTicket: TicketProperties = {};
|
|
75
|
+
|
|
76
|
+
const fakeTicket: TicketProperties = {
|
|
77
|
+
id: 'the-ticket-id',
|
|
78
|
+
subject: 'the ticket subject',
|
|
79
|
+
description: 'the ticket description',
|
|
80
|
+
category: 'ticket-category',
|
|
81
|
+
productId: 'some-product-id',
|
|
82
|
+
custom: {
|
|
83
|
+
customA: 'custom-a-value',
|
|
84
|
+
customB: 'custom-b-value',
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const fakeFieldSuggestion = (): FieldSuggestion => {
|
|
89
|
+
return {
|
|
90
|
+
classification: {
|
|
91
|
+
value: 'some-field-value',
|
|
92
|
+
confidence: 0.5,
|
|
93
|
+
},
|
|
94
|
+
classificationId: 'field-suggestion-id',
|
|
95
|
+
fieldName: 'some-field',
|
|
96
|
+
responseId: 'field-suggestion-response-id',
|
|
41
97
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const fakeDocumentSuggestion: DocumentSuggestion = {
|
|
101
|
+
responseId: 'document-suggestion-response-id',
|
|
102
|
+
suggestionId: 'document-suggestion-id',
|
|
103
|
+
permanentId: 'example permanent-id',
|
|
104
|
+
suggestion: {
|
|
105
|
+
documentPosition: 0,
|
|
106
|
+
documentTitle: 'the document title',
|
|
107
|
+
documentUri: 'some-document-uri',
|
|
108
|
+
documentUriHash: 'documenturihash',
|
|
109
|
+
documentUrl: 'some-document-url',
|
|
110
|
+
sourceName: 'example source-name',
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const expectMatchPayload = (
|
|
115
|
+
actionName: CaseAssistActions,
|
|
116
|
+
actionData: object,
|
|
117
|
+
ticket: TicketProperties
|
|
118
|
+
) => {
|
|
119
|
+
const body: string = lastCallBody(fetchMock);
|
|
120
|
+
const content = JSON.parse(body);
|
|
121
|
+
|
|
122
|
+
expectMatchActionPayload(content, actionName, actionData);
|
|
123
|
+
expectMatchTicketPayload(content, ticket);
|
|
124
|
+
expectMatchProperty(content, 'searchHub', exampleSearchHub);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const expectMatchDocumentPayload = (
|
|
128
|
+
actionCause: CaseAssistActions,
|
|
129
|
+
doc: PartialDocumentInformation,
|
|
130
|
+
meta = {}
|
|
131
|
+
) => {
|
|
132
|
+
const body: string = lastCallBody(fetchMock);
|
|
133
|
+
const customData = {...meta};
|
|
134
|
+
expect(JSON.parse(body.toString())).toMatchObject({
|
|
135
|
+
actionCause,
|
|
136
|
+
customData,
|
|
137
|
+
language: exampleLanguage,
|
|
138
|
+
clientId: exampleClientId,
|
|
139
|
+
originContext: exampleOriginContext,
|
|
140
|
+
originLevel1: exampleSearchHub,
|
|
141
|
+
originLevel2: exampleOriginLevel2,
|
|
142
|
+
originLevel3: exampleOriginLevel3,
|
|
143
|
+
...doc,
|
|
51
144
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const expectMatchActionPayload = (
|
|
148
|
+
content: Record<string, unknown>,
|
|
149
|
+
actionName: CaseAssistActions,
|
|
150
|
+
actionData: object
|
|
151
|
+
) => {
|
|
152
|
+
expectMatchProperty(content, 'ec', 'svc');
|
|
153
|
+
expectMatchProperty(content, 'svc_action', actionName);
|
|
154
|
+
expectMatchProperty(content, 'svc_action_data', actionData);
|
|
155
|
+
|
|
156
|
+
const expectedEvent =
|
|
157
|
+
actionName === CaseAssistActions.enterInterface
|
|
158
|
+
? CaseAssistEvents.flowStart
|
|
159
|
+
: CaseAssistEvents.click;
|
|
160
|
+
expectMatchProperty(content, 'ea', expectedEvent);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const expectMatchTicketPayload = (
|
|
164
|
+
content: Record<string, unknown>,
|
|
165
|
+
ticket?: TicketProperties
|
|
166
|
+
) => {
|
|
167
|
+
expectMatchProperty(content, 'svc_ticket_id', ticket?.id);
|
|
168
|
+
expectMatchProperty(content, 'svc_ticket_subject', ticket?.subject);
|
|
169
|
+
expectMatchProperty(content, 'svc_ticket_description', ticket?.description);
|
|
170
|
+
expectMatchProperty(content, 'svc_ticket_category', ticket?.category);
|
|
171
|
+
expectMatchProperty(content, 'svc_ticket_product_id', ticket?.productId);
|
|
172
|
+
expectMatchProperty(content, 'svc_ticket_custom', ticket?.custom);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const expectMatchProperty = (
|
|
176
|
+
content: Record<string, unknown>,
|
|
177
|
+
propName: string,
|
|
178
|
+
propValue: unknown
|
|
179
|
+
) => {
|
|
180
|
+
if (typeof propValue !== 'undefined') {
|
|
181
|
+
if (typeof propValue === 'object') {
|
|
182
|
+
expect(content).toHaveProperty(propName);
|
|
183
|
+
expect(content[propName]).toMatchObject(propValue as object);
|
|
184
|
+
} else {
|
|
185
|
+
expect(content).toHaveProperty(propName, propValue);
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
expect(content).not.toHaveProperty(propName);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
it('should have #enableAnalytics default to #true', async () => {
|
|
193
|
+
client = new CaseAssistClient({});
|
|
194
|
+
|
|
195
|
+
await client.logEnterInterface({
|
|
196
|
+
ticket: emptyTicket,
|
|
55
197
|
});
|
|
56
198
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
enableAnalytics: true,
|
|
61
|
-
},
|
|
62
|
-
provider,
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const noTicket: Record<string, unknown> = undefined;
|
|
67
|
-
const noActionData: Record<string, unknown> = undefined;
|
|
68
|
-
const emptyTicket: TicketProperties = {};
|
|
69
|
-
|
|
70
|
-
const fakeTicket: TicketProperties = {
|
|
71
|
-
id: 'the-ticket-id',
|
|
72
|
-
subject: 'the ticket subject',
|
|
73
|
-
description: 'the ticket description',
|
|
74
|
-
category: 'ticket-category',
|
|
75
|
-
productId: 'some-product-id',
|
|
76
|
-
custom: {
|
|
77
|
-
customA: 'custom-a-value',
|
|
78
|
-
customB: 'custom-b-value',
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const fakeFieldSuggestion = (): FieldSuggestion => {
|
|
83
|
-
return {
|
|
84
|
-
classification: {
|
|
85
|
-
value: 'some-field-value',
|
|
86
|
-
confidence: 0.5,
|
|
87
|
-
},
|
|
88
|
-
classificationId: 'field-suggestion-id',
|
|
89
|
-
fieldName: 'some-field',
|
|
90
|
-
responseId: 'field-suggestion-response-id',
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const fakeDocumentSuggestion: DocumentSuggestion = {
|
|
95
|
-
responseId: 'document-suggestion-response-id',
|
|
96
|
-
suggestionId: 'document-suggestion-id',
|
|
97
|
-
permanentId: 'example permanent-id',
|
|
98
|
-
suggestion: {
|
|
99
|
-
documentPosition: 0,
|
|
100
|
-
documentTitle: 'the document title',
|
|
101
|
-
documentUri: 'some-document-uri',
|
|
102
|
-
documentUriHash: 'documenturihash',
|
|
103
|
-
documentUrl: 'some-document-url',
|
|
104
|
-
sourceName: 'example source-name',
|
|
105
|
-
},
|
|
106
|
-
};
|
|
199
|
+
expect(fetchMock.called()).toBe(true);
|
|
200
|
+
});
|
|
107
201
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
expectMatchActionPayload(content, actionName, actionData);
|
|
113
|
-
expectMatchTicketPayload(content, ticket);
|
|
114
|
-
expectMatchProperty(content, 'searchHub', exampleSearchHub);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const expectMatchDocumentPayload = (actionCause: CaseAssistActions, doc: PartialDocumentInformation, meta = {}) => {
|
|
118
|
-
const body: string = lastCallBody(fetchMock);
|
|
119
|
-
const customData = {...meta};
|
|
120
|
-
expect(JSON.parse(body.toString())).toMatchObject({
|
|
121
|
-
actionCause,
|
|
122
|
-
customData,
|
|
123
|
-
language: exampleLanguage,
|
|
124
|
-
clientId: exampleClientId,
|
|
125
|
-
originContext: exampleOriginContext,
|
|
126
|
-
originLevel1: exampleSearchHub,
|
|
127
|
-
originLevel2: exampleOriginLevel2,
|
|
128
|
-
originLevel3: exampleOriginLevel3,
|
|
129
|
-
...doc,
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const expectMatchActionPayload = (
|
|
134
|
-
content: Record<string, unknown>,
|
|
135
|
-
actionName: CaseAssistActions,
|
|
136
|
-
actionData: Object,
|
|
137
|
-
) => {
|
|
138
|
-
expectMatchProperty(content, 'ec', 'svc');
|
|
139
|
-
expectMatchProperty(content, 'svc_action', actionName);
|
|
140
|
-
expectMatchProperty(content, 'svc_action_data', actionData);
|
|
141
|
-
|
|
142
|
-
const expectedEvent =
|
|
143
|
-
actionName === CaseAssistActions.enterInterface ? CaseAssistEvents.flowStart : CaseAssistEvents.click;
|
|
144
|
-
expectMatchProperty(content, 'ea', expectedEvent);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const expectMatchTicketPayload = (content: Record<string, unknown>, ticket?: TicketProperties) => {
|
|
148
|
-
expectMatchProperty(content, 'svc_ticket_id', ticket?.id);
|
|
149
|
-
expectMatchProperty(content, 'svc_ticket_subject', ticket?.subject);
|
|
150
|
-
expectMatchProperty(content, 'svc_ticket_description', ticket?.description);
|
|
151
|
-
expectMatchProperty(content, 'svc_ticket_category', ticket?.category);
|
|
152
|
-
expectMatchProperty(content, 'svc_ticket_product_id', ticket?.productId);
|
|
153
|
-
expectMatchProperty(content, 'svc_ticket_custom', ticket?.custom);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const expectMatchProperty = (content: Record<string, unknown>, propName: string, propValue: unknown) => {
|
|
157
|
-
if (typeof propValue !== 'undefined') {
|
|
158
|
-
if (typeof propValue === 'object') {
|
|
159
|
-
expect(content).toHaveProperty(propName);
|
|
160
|
-
expect(content[propName]).toMatchObject(propValue as object);
|
|
161
|
-
} else {
|
|
162
|
-
expect(content).toHaveProperty(propName, propValue);
|
|
163
|
-
}
|
|
164
|
-
} else {
|
|
165
|
-
expect(content).not.toHaveProperty(propName);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
it('should have #enableAnalytics default to #true', async () => {
|
|
170
|
-
client = new CaseAssistClient({});
|
|
171
|
-
|
|
172
|
-
await client.logEnterInterface({
|
|
173
|
-
ticket: emptyTicket,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
expect(fetchMock.called()).toBe(true);
|
|
202
|
+
it('should not send events when #enableAnalytics option is #false', async () => {
|
|
203
|
+
client = new CaseAssistClient({
|
|
204
|
+
enableAnalytics: false,
|
|
177
205
|
});
|
|
178
206
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
enableAnalytics: false,
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
await client.logEnterInterface({
|
|
185
|
-
ticket: emptyTicket,
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
expect(fetchMock.called()).toBe(false);
|
|
207
|
+
await client.logEnterInterface({
|
|
208
|
+
ticket: emptyTicket,
|
|
189
209
|
});
|
|
190
210
|
|
|
191
|
-
|
|
192
|
-
|
|
211
|
+
expect(fetchMock.called()).toBe(false);
|
|
212
|
+
});
|
|
193
213
|
|
|
194
|
-
|
|
214
|
+
it('should not send events when doNotTrack is enabled', async () => {
|
|
215
|
+
(doNotTrack as Mock).mockImplementationOnce(() => true);
|
|
195
216
|
|
|
196
|
-
|
|
197
|
-
ticket: emptyTicket,
|
|
198
|
-
});
|
|
217
|
+
client = new CaseAssistClient({});
|
|
199
218
|
|
|
200
|
-
|
|
219
|
+
await client.logEnterInterface({
|
|
220
|
+
ticket: emptyTicket,
|
|
201
221
|
});
|
|
202
222
|
|
|
203
|
-
|
|
204
|
-
|
|
223
|
+
expect(fetchMock.called()).toBe(false);
|
|
224
|
+
});
|
|
205
225
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
});
|
|
226
|
+
it('should not send events after #disable function is called', async () => {
|
|
227
|
+
client.disable();
|
|
209
228
|
|
|
210
|
-
|
|
229
|
+
await client.logEnterInterface({
|
|
230
|
+
ticket: emptyTicket,
|
|
211
231
|
});
|
|
212
232
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
Cookie.set('coveo_visitorId', visitorId);
|
|
233
|
+
expect(fetchMock.called()).toBe(false);
|
|
234
|
+
});
|
|
216
235
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
236
|
+
it('disabling does not delete the visitorId', () => {
|
|
237
|
+
const visitorId = 'uuid';
|
|
238
|
+
Cookie.set('coveo_visitorId', visitorId);
|
|
221
239
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
240
|
+
expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
|
|
241
|
+
client.disable();
|
|
242
|
+
expect(Cookie.get('coveo_visitorId')).toBe(visitorId);
|
|
243
|
+
});
|
|
226
244
|
|
|
227
|
-
|
|
245
|
+
it('should send events after #enable function is called', async () => {
|
|
246
|
+
client = new CaseAssistClient({
|
|
247
|
+
enableAnalytics: false,
|
|
248
|
+
});
|
|
228
249
|
|
|
229
|
-
|
|
230
|
-
ticket: emptyTicket,
|
|
231
|
-
});
|
|
250
|
+
client.enable();
|
|
232
251
|
|
|
233
|
-
|
|
252
|
+
await client.logEnterInterface({
|
|
253
|
+
ticket: emptyTicket,
|
|
234
254
|
});
|
|
235
255
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
ticket: emptyTicket,
|
|
239
|
-
});
|
|
256
|
+
expect(fetchMock.called()).toBe(true);
|
|
257
|
+
});
|
|
240
258
|
|
|
241
|
-
|
|
259
|
+
it('should send proper payload for #logEnterInterface', async () => {
|
|
260
|
+
await client.logEnterInterface({
|
|
261
|
+
ticket: emptyTicket,
|
|
242
262
|
});
|
|
243
263
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
fieldName: 'subject',
|
|
247
|
-
ticket: fakeTicket,
|
|
248
|
-
});
|
|
264
|
+
expectMatchPayload(CaseAssistActions.enterInterface, noActionData, noTicket);
|
|
265
|
+
});
|
|
249
266
|
|
|
250
|
-
|
|
267
|
+
it('should send proper payload for #logUpdateCaseField', async () => {
|
|
268
|
+
await client.logUpdateCaseField({
|
|
269
|
+
fieldName: 'subject',
|
|
270
|
+
ticket: fakeTicket,
|
|
251
271
|
});
|
|
252
272
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
suggestion: fakeFieldSuggestion(),
|
|
256
|
-
ticket: fakeTicket,
|
|
257
|
-
});
|
|
273
|
+
expectMatchPayload(CaseAssistActions.fieldUpdate, {fieldName: 'subject'}, fakeTicket);
|
|
274
|
+
});
|
|
258
275
|
|
|
259
|
-
|
|
276
|
+
it('should send proper payload for #logSelectFieldSuggestion', async () => {
|
|
277
|
+
await client.logSelectFieldSuggestion({
|
|
278
|
+
suggestion: fakeFieldSuggestion(),
|
|
279
|
+
ticket: fakeTicket,
|
|
260
280
|
});
|
|
261
281
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
myFakeFieldSuggestion.autoSelection = true;
|
|
265
|
-
await client.logSelectFieldSuggestion({
|
|
266
|
-
suggestion: myFakeFieldSuggestion,
|
|
267
|
-
ticket: fakeTicket,
|
|
268
|
-
});
|
|
282
|
+
expectMatchPayload(CaseAssistActions.fieldSuggestionClick, fakeFieldSuggestion(), fakeTicket);
|
|
283
|
+
});
|
|
269
284
|
|
|
270
|
-
|
|
285
|
+
it('should send proper payload for #logSelectFieldSuggestion when the autoSelection property is set to true', async () => {
|
|
286
|
+
const myFakeFieldSuggestion = fakeFieldSuggestion();
|
|
287
|
+
myFakeFieldSuggestion.autoSelection = true;
|
|
288
|
+
await client.logSelectFieldSuggestion({
|
|
289
|
+
suggestion: myFakeFieldSuggestion,
|
|
290
|
+
ticket: fakeTicket,
|
|
271
291
|
});
|
|
272
292
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
suggestion: fakeDocumentSuggestion,
|
|
276
|
-
ticket: fakeTicket,
|
|
277
|
-
});
|
|
293
|
+
expectMatchPayload(CaseAssistActions.fieldSuggestionClick, myFakeFieldSuggestion, fakeTicket);
|
|
294
|
+
});
|
|
278
295
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
296
|
+
it('should send proper payload for #logSelectDocumentSuggestion', async () => {
|
|
297
|
+
await client.logSelectDocumentSuggestion({
|
|
298
|
+
suggestion: fakeDocumentSuggestion,
|
|
299
|
+
ticket: fakeTicket,
|
|
283
300
|
});
|
|
284
301
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
302
|
+
expectMatchDocumentPayload(
|
|
303
|
+
CaseAssistActions.documentSuggestionClick,
|
|
304
|
+
fakeDocumentSuggestion.suggestion,
|
|
305
|
+
{
|
|
306
|
+
contentIDKey: 'permanentId',
|
|
307
|
+
contentIDValue: fakeDocumentSuggestion.permanentId,
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('should send proper payload for #logQuickviewDocumentSuggestion', async () => {
|
|
313
|
+
await client.logQuickviewDocumentSuggestion({
|
|
314
|
+
suggestion: fakeDocumentSuggestion,
|
|
315
|
+
ticket: fakeTicket,
|
|
295
316
|
});
|
|
296
317
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
318
|
+
expectMatchDocumentPayload(
|
|
319
|
+
CaseAssistActions.documentSuggestionQuickview,
|
|
320
|
+
fakeDocumentSuggestion.suggestion,
|
|
321
|
+
{
|
|
322
|
+
contentIDKey: 'permanentId',
|
|
323
|
+
contentIDValue: fakeDocumentSuggestion.permanentId,
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('should send proper payload for #logRateDocumentSuggestion', async () => {
|
|
329
|
+
const rating = 0.8;
|
|
330
|
+
|
|
331
|
+
await client.logRateDocumentSuggestion({
|
|
332
|
+
rating,
|
|
333
|
+
suggestion: fakeDocumentSuggestion,
|
|
334
|
+
ticket: fakeTicket,
|
|
314
335
|
});
|
|
315
336
|
|
|
316
|
-
|
|
317
|
-
|
|
337
|
+
expectMatchPayload(
|
|
338
|
+
CaseAssistActions.suggestionRate,
|
|
339
|
+
{
|
|
340
|
+
...fakeDocumentSuggestion,
|
|
341
|
+
rate: rating,
|
|
342
|
+
},
|
|
343
|
+
fakeTicket
|
|
344
|
+
);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('should send proper payload for #logMoveToNextCaseStep', async () => {
|
|
348
|
+
const stageName = 'stage 1';
|
|
349
|
+
|
|
350
|
+
await client.logMoveToNextCaseStep({
|
|
351
|
+
ticket: fakeTicket,
|
|
352
|
+
stage: stageName,
|
|
353
|
+
});
|
|
318
354
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
stage: stageName,
|
|
322
|
-
});
|
|
355
|
+
expectMatchPayload(CaseAssistActions.nextCaseStep, {stage: stageName}, fakeTicket);
|
|
356
|
+
});
|
|
323
357
|
|
|
324
|
-
|
|
358
|
+
it('should send proper payload for #logCaseCancelled', async () => {
|
|
359
|
+
await client.logCaseCancelled({
|
|
360
|
+
ticket: fakeTicket,
|
|
325
361
|
});
|
|
326
362
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
363
|
+
expectMatchPayload(
|
|
364
|
+
CaseAssistActions.caseCancelled,
|
|
365
|
+
{
|
|
366
|
+
reason: CaseCancelledReasons.quit,
|
|
367
|
+
},
|
|
368
|
+
fakeTicket
|
|
369
|
+
);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('should send proper payload for #logCaseSolved', async () => {
|
|
373
|
+
await client.logCaseSolved({
|
|
374
|
+
ticket: fakeTicket,
|
|
339
375
|
});
|
|
340
376
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
377
|
+
expectMatchPayload(
|
|
378
|
+
CaseAssistActions.caseSolved,
|
|
379
|
+
{
|
|
380
|
+
reason: CaseCancelledReasons.solved,
|
|
381
|
+
},
|
|
382
|
+
fakeTicket
|
|
383
|
+
);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('should send proper payload for #logCaseCreated', async () => {
|
|
387
|
+
await client.logCaseCreated({
|
|
388
|
+
ticket: fakeTicket,
|
|
353
389
|
});
|
|
354
390
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
ticket: fakeTicket,
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
expectMatchPayload(CaseAssistActions.caseCreated, noActionData, fakeTicket);
|
|
361
|
-
});
|
|
391
|
+
expectMatchPayload(CaseAssistActions.caseCreated, noActionData, fakeTicket);
|
|
392
|
+
});
|
|
362
393
|
});
|