coveo.analytics 2.20.24 → 2.20.26
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/coveoua/library.d.ts +1 -1
- package/dist/definitions/insight/insightClient.d.ts +24 -24
- package/dist/definitions/insight/insightEvents.d.ts +25 -7
- package/dist/definitions/searchPage/searchPageClient.d.ts +154 -73
- package/dist/definitions/src/coveoua/library.d.ts +1 -1
- package/dist/library.es.js +432 -150
- package/dist/library.js +477 -186
- package/package.json +1 -1
- package/src/coveoua/library.ts +6 -1
- package/src/insight/insightClient.spec.ts +495 -151
- package/src/insight/insightClient.ts +131 -91
- package/src/insight/insightEvents.ts +37 -6
- package/src/searchPage/searchPageClient.spec.ts +650 -5
- package/src/searchPage/searchPageClient.ts +460 -97
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import CoveoAnalyticsClient, {ClientOptions, AnalyticsClient} from '../client/analytics';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
SearchEventRequest,
|
|
4
|
+
ClickEventRequest,
|
|
5
|
+
CustomEventRequest,
|
|
6
|
+
SearchEventResponse,
|
|
7
|
+
AnyEventResponse,
|
|
8
|
+
ClickEventResponse,
|
|
9
|
+
CustomEventResponse,
|
|
10
|
+
} from '../events';
|
|
3
11
|
import {
|
|
4
12
|
SearchPageEvents,
|
|
5
13
|
OmniboxSuggestionsMetadata,
|
|
@@ -52,6 +60,13 @@ export interface SearchPageClientOptions extends ClientOptions {
|
|
|
52
60
|
enableAnalytics: boolean;
|
|
53
61
|
}
|
|
54
62
|
|
|
63
|
+
export type EventDescription = Pick<SearchEventRequest, 'actionCause' | 'customData'>;
|
|
64
|
+
|
|
65
|
+
export interface EventBuilder<T extends AnyEventResponse = AnyEventResponse> {
|
|
66
|
+
description: EventDescription;
|
|
67
|
+
log: () => Promise<T | void>;
|
|
68
|
+
}
|
|
69
|
+
|
|
55
70
|
export class CoveoSearchPageClient {
|
|
56
71
|
public coveoAnalyticsClient: AnalyticsClient;
|
|
57
72
|
|
|
@@ -64,6 +79,7 @@ export class CoveoSearchPageClient {
|
|
|
64
79
|
if (this.coveoAnalyticsClient instanceof CoveoAnalyticsClient) {
|
|
65
80
|
this.coveoAnalyticsClient.clear();
|
|
66
81
|
}
|
|
82
|
+
|
|
67
83
|
this.coveoAnalyticsClient = new NoopAnalytics();
|
|
68
84
|
}
|
|
69
85
|
|
|
@@ -71,257 +87,515 @@ export class CoveoSearchPageClient {
|
|
|
71
87
|
this.coveoAnalyticsClient = new CoveoAnalyticsClient(this.opts);
|
|
72
88
|
}
|
|
73
89
|
|
|
90
|
+
public makeInterfaceLoad() {
|
|
91
|
+
return this.makeSearchEvent(SearchPageEvents.interfaceLoad);
|
|
92
|
+
}
|
|
93
|
+
|
|
74
94
|
public logInterfaceLoad() {
|
|
75
|
-
return this.
|
|
95
|
+
return this.makeInterfaceLoad().log();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public makeRecommendationInterfaceLoad() {
|
|
99
|
+
return this.makeSearchEvent(SearchPageEvents.recommendationInterfaceLoad);
|
|
76
100
|
}
|
|
77
101
|
|
|
78
102
|
public logRecommendationInterfaceLoad() {
|
|
79
|
-
return this.
|
|
103
|
+
return this.makeRecommendationInterfaceLoad().log();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public makeRecommendation() {
|
|
107
|
+
return this.makeCustomEvent(SearchPageEvents.recommendation);
|
|
80
108
|
}
|
|
81
109
|
|
|
82
110
|
public logRecommendation() {
|
|
83
|
-
return this.
|
|
111
|
+
return this.makeRecommendation().log();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public makeRecommendationOpen(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
115
|
+
return this.makeClickEvent(SearchPageEvents.recommendationOpen, info, identifier);
|
|
84
116
|
}
|
|
85
117
|
|
|
86
118
|
public logRecommendationOpen(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
87
|
-
return this.
|
|
119
|
+
return this.makeRecommendationOpen(info, identifier).log();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public makeStaticFilterClearAll(meta: StaticFilterMetadata) {
|
|
123
|
+
return this.makeSearchEvent(SearchPageEvents.staticFilterClearAll, meta);
|
|
88
124
|
}
|
|
89
125
|
|
|
90
126
|
public logStaticFilterClearAll(meta: StaticFilterMetadata) {
|
|
91
|
-
return this.
|
|
127
|
+
return this.makeStaticFilterClearAll(meta).log();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public makeStaticFilterSelect(meta: StaticFilterToggleValueMetadata) {
|
|
131
|
+
return this.makeSearchEvent(SearchPageEvents.staticFilterSelect, meta);
|
|
92
132
|
}
|
|
93
133
|
|
|
94
134
|
public logStaticFilterSelect(meta: StaticFilterToggleValueMetadata) {
|
|
95
|
-
return this.
|
|
135
|
+
return this.makeStaticFilterSelect(meta).log();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public makeStaticFilterDeselect(meta: StaticFilterToggleValueMetadata) {
|
|
139
|
+
return this.makeSearchEvent(SearchPageEvents.staticFilterDeselect, meta);
|
|
96
140
|
}
|
|
97
141
|
|
|
98
142
|
public logStaticFilterDeselect(meta: StaticFilterToggleValueMetadata) {
|
|
99
|
-
return this.
|
|
143
|
+
return this.makeStaticFilterDeselect(meta).log();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public makeFetchMoreResults() {
|
|
147
|
+
return this.makeCustomEvent(SearchPageEvents.pagerScrolling, {type: 'getMoreResults'});
|
|
100
148
|
}
|
|
101
149
|
|
|
102
150
|
public logFetchMoreResults() {
|
|
103
|
-
return this.
|
|
151
|
+
return this.makeFetchMoreResults().log();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public makeInterfaceChange(metadata: InterfaceChangeMetadata) {
|
|
155
|
+
return this.makeSearchEvent(SearchPageEvents.interfaceChange, metadata);
|
|
104
156
|
}
|
|
105
157
|
|
|
106
158
|
public logInterfaceChange(metadata: InterfaceChangeMetadata) {
|
|
107
|
-
return this.
|
|
159
|
+
return this.makeInterfaceChange(metadata).log();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public makeDidYouMeanAutomatic() {
|
|
163
|
+
return this.makeSearchEvent(SearchPageEvents.didyoumeanAutomatic);
|
|
108
164
|
}
|
|
109
165
|
|
|
110
166
|
public logDidYouMeanAutomatic() {
|
|
111
|
-
return this.
|
|
167
|
+
return this.makeDidYouMeanAutomatic().log();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public makeDidYouMeanClick() {
|
|
171
|
+
return this.makeSearchEvent(SearchPageEvents.didyoumeanClick);
|
|
112
172
|
}
|
|
113
173
|
|
|
114
174
|
public logDidYouMeanClick() {
|
|
115
|
-
return this.
|
|
175
|
+
return this.makeDidYouMeanClick().log();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
public makeResultsSort(metadata: ResultsSortMetadata) {
|
|
179
|
+
return this.makeSearchEvent(SearchPageEvents.resultsSort, metadata);
|
|
116
180
|
}
|
|
117
181
|
|
|
118
182
|
public logResultsSort(metadata: ResultsSortMetadata) {
|
|
119
|
-
return this.
|
|
183
|
+
return this.makeResultsSort(metadata).log();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public makeSearchboxSubmit() {
|
|
187
|
+
return this.makeSearchEvent(SearchPageEvents.searchboxSubmit);
|
|
120
188
|
}
|
|
121
189
|
|
|
122
190
|
public logSearchboxSubmit() {
|
|
123
|
-
return this.
|
|
191
|
+
return this.makeSearchboxSubmit().log();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public makeSearchboxClear() {
|
|
195
|
+
return this.makeSearchEvent(SearchPageEvents.searchboxClear);
|
|
124
196
|
}
|
|
125
197
|
|
|
126
198
|
public logSearchboxClear() {
|
|
127
|
-
return this.
|
|
199
|
+
return this.makeSearchboxClear().log();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public makeSearchboxAsYouType() {
|
|
203
|
+
return this.makeSearchEvent(SearchPageEvents.searchboxAsYouType);
|
|
128
204
|
}
|
|
129
205
|
|
|
130
206
|
public logSearchboxAsYouType() {
|
|
131
|
-
return this.
|
|
207
|
+
return this.makeSearchboxAsYouType().log();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public makeBreadcrumbFacet(metadata: FacetMetadata | FacetRangeMetadata | CategoryFacetMetadata) {
|
|
211
|
+
return this.makeSearchEvent(SearchPageEvents.breadcrumbFacet, metadata);
|
|
132
212
|
}
|
|
133
213
|
|
|
134
214
|
public logBreadcrumbFacet(metadata: FacetMetadata | FacetRangeMetadata | CategoryFacetMetadata) {
|
|
135
|
-
return this.
|
|
215
|
+
return this.makeBreadcrumbFacet(metadata).log();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public makeBreadcrumbResetAll() {
|
|
219
|
+
return this.makeSearchEvent(SearchPageEvents.breadcrumbResetAll);
|
|
136
220
|
}
|
|
137
221
|
|
|
138
222
|
public logBreadcrumbResetAll() {
|
|
139
|
-
return this.
|
|
223
|
+
return this.makeBreadcrumbResetAll().log();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
public makeDocumentQuickview(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
227
|
+
return this.makeClickEvent(SearchPageEvents.documentQuickview, info, identifier);
|
|
140
228
|
}
|
|
141
229
|
|
|
142
230
|
public logDocumentQuickview(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
143
|
-
return this.
|
|
231
|
+
return this.makeDocumentQuickview(info, identifier).log();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public makeDocumentOpen(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
235
|
+
return this.makeClickEvent(SearchPageEvents.documentOpen, info, identifier);
|
|
144
236
|
}
|
|
145
237
|
|
|
146
238
|
public logDocumentOpen(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
147
|
-
return this.
|
|
239
|
+
return this.makeDocumentOpen(info, identifier).log();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
public makeOmniboxAnalytics(meta: OmniboxSuggestionsMetadata) {
|
|
243
|
+
return this.makeSearchEvent(SearchPageEvents.omniboxAnalytics, formatOmniboxMetadata(meta));
|
|
148
244
|
}
|
|
149
245
|
|
|
150
246
|
public logOmniboxAnalytics(meta: OmniboxSuggestionsMetadata) {
|
|
151
|
-
return this.
|
|
247
|
+
return this.makeOmniboxAnalytics(meta).log();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
public makeOmniboxFromLink(meta: OmniboxSuggestionsMetadata) {
|
|
251
|
+
return this.makeSearchEvent(SearchPageEvents.omniboxFromLink, formatOmniboxMetadata(meta));
|
|
152
252
|
}
|
|
153
253
|
|
|
154
254
|
public logOmniboxFromLink(meta: OmniboxSuggestionsMetadata) {
|
|
155
|
-
return this.
|
|
255
|
+
return this.makeOmniboxFromLink(meta).log();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public makeSearchFromLink() {
|
|
259
|
+
return this.makeSearchEvent(SearchPageEvents.searchFromLink);
|
|
156
260
|
}
|
|
157
261
|
|
|
158
262
|
public logSearchFromLink() {
|
|
159
|
-
return this.
|
|
263
|
+
return this.makeSearchFromLink().log();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
public makeTriggerNotify(meta: TriggerNotifyMetadata) {
|
|
267
|
+
return this.makeCustomEvent(SearchPageEvents.triggerNotify, meta);
|
|
160
268
|
}
|
|
161
269
|
|
|
162
270
|
public logTriggerNotify(meta: TriggerNotifyMetadata) {
|
|
163
|
-
return this.
|
|
271
|
+
return this.makeTriggerNotify(meta).log();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
public makeTriggerExecute(meta: TriggerExecuteMetadata) {
|
|
275
|
+
return this.makeCustomEvent(SearchPageEvents.triggerExecute, meta);
|
|
164
276
|
}
|
|
165
277
|
|
|
166
278
|
public logTriggerExecute(meta: TriggerExecuteMetadata) {
|
|
167
|
-
return this.
|
|
279
|
+
return this.makeTriggerExecute(meta).log();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
public makeTriggerQuery() {
|
|
283
|
+
return this.makeCustomEvent(
|
|
284
|
+
SearchPageEvents.triggerQuery,
|
|
285
|
+
{query: this.provider.getSearchEventRequestPayload().queryText},
|
|
286
|
+
'queryPipelineTriggers'
|
|
287
|
+
);
|
|
168
288
|
}
|
|
169
289
|
|
|
170
290
|
public logTriggerQuery() {
|
|
171
|
-
|
|
172
|
-
|
|
291
|
+
return this.makeTriggerQuery().log();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public makeUndoTriggerQuery(meta: UndoTriggerRedirectMetadata) {
|
|
295
|
+
return this.makeSearchEvent(SearchPageEvents.undoTriggerQuery, meta);
|
|
173
296
|
}
|
|
174
297
|
|
|
175
298
|
public logUndoTriggerQuery(meta: UndoTriggerRedirectMetadata) {
|
|
176
|
-
return this.
|
|
299
|
+
return this.makeUndoTriggerQuery(meta).log();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public makeTriggerRedirect(meta: TriggerRedirectMetadata) {
|
|
303
|
+
return this.makeCustomEvent(SearchPageEvents.triggerRedirect, {
|
|
304
|
+
...meta,
|
|
305
|
+
query: this.provider.getSearchEventRequestPayload().queryText,
|
|
306
|
+
});
|
|
177
307
|
}
|
|
178
308
|
|
|
179
309
|
public logTriggerRedirect(meta: TriggerRedirectMetadata) {
|
|
180
|
-
|
|
181
|
-
|
|
310
|
+
return this.makeTriggerRedirect(meta).log();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
public makePagerResize(meta: PagerResizeMetadata) {
|
|
314
|
+
return this.makeCustomEvent(SearchPageEvents.pagerResize, meta);
|
|
182
315
|
}
|
|
183
316
|
|
|
184
317
|
public logPagerResize(meta: PagerResizeMetadata) {
|
|
185
|
-
return this.
|
|
318
|
+
return this.makePagerResize(meta).log();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
public makePagerNumber(meta: PagerMetadata) {
|
|
322
|
+
return this.makeCustomEvent(SearchPageEvents.pagerNumber, meta);
|
|
186
323
|
}
|
|
187
324
|
|
|
188
325
|
public logPagerNumber(meta: PagerMetadata) {
|
|
189
|
-
return this.
|
|
326
|
+
return this.makePagerNumber(meta).log();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
public makePagerNext(meta: PagerMetadata) {
|
|
330
|
+
return this.makeCustomEvent(SearchPageEvents.pagerNext, meta);
|
|
190
331
|
}
|
|
191
332
|
|
|
192
333
|
public logPagerNext(meta: PagerMetadata) {
|
|
193
|
-
return this.
|
|
334
|
+
return this.makePagerNext(meta).log();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
public makePagerPrevious(meta: PagerMetadata) {
|
|
338
|
+
return this.makeCustomEvent(SearchPageEvents.pagerPrevious, meta);
|
|
194
339
|
}
|
|
195
340
|
|
|
196
341
|
public logPagerPrevious(meta: PagerMetadata) {
|
|
197
|
-
return this.
|
|
342
|
+
return this.makePagerPrevious(meta).log();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
public makePagerScrolling() {
|
|
346
|
+
return this.makeCustomEvent(SearchPageEvents.pagerScrolling);
|
|
198
347
|
}
|
|
199
348
|
|
|
200
349
|
public logPagerScrolling() {
|
|
201
|
-
return this.
|
|
350
|
+
return this.makePagerScrolling().log();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
public makeFacetClearAll(meta: FacetBaseMeta) {
|
|
354
|
+
return this.makeSearchEvent(SearchPageEvents.facetClearAll, meta);
|
|
202
355
|
}
|
|
203
356
|
|
|
204
357
|
public logFacetClearAll(meta: FacetBaseMeta) {
|
|
205
|
-
return this.
|
|
358
|
+
return this.makeFacetClearAll(meta).log();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
public makeFacetSearch(meta: FacetBaseMeta) {
|
|
362
|
+
return this.makeSearchEvent(SearchPageEvents.facetSearch, meta);
|
|
206
363
|
}
|
|
207
364
|
|
|
208
365
|
public logFacetSearch(meta: FacetBaseMeta) {
|
|
209
|
-
return this.
|
|
366
|
+
return this.makeFacetSearch(meta).log();
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
public makeFacetSelect(meta: FacetMetadata) {
|
|
370
|
+
return this.makeSearchEvent(SearchPageEvents.facetSelect, meta);
|
|
210
371
|
}
|
|
211
372
|
|
|
212
373
|
public logFacetSelect(meta: FacetMetadata) {
|
|
213
|
-
return this.
|
|
374
|
+
return this.makeFacetSelect(meta).log();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
public makeFacetDeselect(meta: FacetMetadata) {
|
|
378
|
+
return this.makeSearchEvent(SearchPageEvents.facetDeselect, meta);
|
|
214
379
|
}
|
|
215
380
|
|
|
216
381
|
public logFacetDeselect(meta: FacetMetadata) {
|
|
217
|
-
return this.
|
|
382
|
+
return this.makeFacetDeselect(meta).log();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
public makeFacetExclude(meta: FacetMetadata) {
|
|
386
|
+
return this.makeSearchEvent(SearchPageEvents.facetExclude, meta);
|
|
218
387
|
}
|
|
219
388
|
|
|
220
389
|
public logFacetExclude(meta: FacetMetadata) {
|
|
221
|
-
return this.
|
|
390
|
+
return this.makeFacetExclude(meta).log();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
public makeFacetUnexclude(meta: FacetMetadata) {
|
|
394
|
+
return this.makeSearchEvent(SearchPageEvents.facetUnexclude, meta);
|
|
222
395
|
}
|
|
223
396
|
|
|
224
397
|
public logFacetUnexclude(meta: FacetMetadata) {
|
|
225
|
-
return this.
|
|
398
|
+
return this.makeFacetUnexclude(meta).log();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
public makeFacetSelectAll(meta: FacetBaseMeta) {
|
|
402
|
+
return this.makeSearchEvent(SearchPageEvents.facetSelectAll, meta);
|
|
226
403
|
}
|
|
227
404
|
|
|
228
405
|
public logFacetSelectAll(meta: FacetBaseMeta) {
|
|
229
|
-
return this.
|
|
406
|
+
return this.makeFacetSelectAll(meta).log();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
public makeFacetUpdateSort(meta: FacetSortMeta) {
|
|
410
|
+
return this.makeSearchEvent(SearchPageEvents.facetUpdateSort, meta);
|
|
230
411
|
}
|
|
231
412
|
|
|
232
413
|
public logFacetUpdateSort(meta: FacetSortMeta) {
|
|
233
|
-
return this.
|
|
414
|
+
return this.makeFacetUpdateSort(meta).log();
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
public makeFacetShowMore(meta: FacetBaseMeta) {
|
|
418
|
+
return this.makeCustomEvent(SearchPageEvents.facetShowMore, meta);
|
|
234
419
|
}
|
|
235
420
|
|
|
236
421
|
public logFacetShowMore(meta: FacetBaseMeta) {
|
|
237
|
-
return this.
|
|
422
|
+
return this.makeFacetShowMore(meta).log();
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
public makeFacetShowLess(meta: FacetBaseMeta) {
|
|
426
|
+
return this.makeCustomEvent(SearchPageEvents.facetShowLess, meta);
|
|
238
427
|
}
|
|
239
428
|
|
|
240
429
|
public logFacetShowLess(meta: FacetBaseMeta) {
|
|
241
|
-
return this.
|
|
430
|
+
return this.makeFacetShowLess(meta).log();
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
public makeQueryError(meta: QueryErrorMeta) {
|
|
434
|
+
return this.makeCustomEvent(SearchPageEvents.queryError, meta);
|
|
242
435
|
}
|
|
243
436
|
|
|
244
437
|
public logQueryError(meta: QueryErrorMeta) {
|
|
245
|
-
return this.
|
|
438
|
+
return this.makeQueryError(meta).log();
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
public makeQueryErrorBack(): EventBuilder<SearchEventResponse> {
|
|
442
|
+
return {
|
|
443
|
+
description: this.makeDescription(SearchPageEvents.queryErrorBack),
|
|
444
|
+
log: async () => {
|
|
445
|
+
await this.logCustomEvent(SearchPageEvents.queryErrorBack);
|
|
446
|
+
return this.logSearchEvent(SearchPageEvents.queryErrorBack);
|
|
447
|
+
},
|
|
448
|
+
};
|
|
246
449
|
}
|
|
247
450
|
|
|
248
|
-
public
|
|
249
|
-
|
|
250
|
-
return this.logSearchEvent(SearchPageEvents.queryErrorBack);
|
|
451
|
+
public logQueryErrorBack() {
|
|
452
|
+
return this.makeQueryErrorBack().log();
|
|
251
453
|
}
|
|
252
454
|
|
|
253
|
-
public
|
|
254
|
-
|
|
255
|
-
|
|
455
|
+
public makeQueryErrorRetry(): EventBuilder<SearchEventResponse> {
|
|
456
|
+
return {
|
|
457
|
+
description: this.makeDescription(SearchPageEvents.queryErrorRetry),
|
|
458
|
+
log: async () => {
|
|
459
|
+
await this.logCustomEvent(SearchPageEvents.queryErrorRetry);
|
|
460
|
+
return this.logSearchEvent(SearchPageEvents.queryErrorRetry);
|
|
461
|
+
},
|
|
462
|
+
};
|
|
256
463
|
}
|
|
257
464
|
|
|
258
|
-
public
|
|
259
|
-
|
|
260
|
-
|
|
465
|
+
public logQueryErrorRetry() {
|
|
466
|
+
return this.makeQueryErrorRetry().log();
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
public makeQueryErrorClear(): EventBuilder<SearchEventResponse> {
|
|
470
|
+
return {
|
|
471
|
+
description: this.makeDescription(SearchPageEvents.queryErrorClear),
|
|
472
|
+
log: async () => {
|
|
473
|
+
await this.logCustomEvent(SearchPageEvents.queryErrorClear);
|
|
474
|
+
return this.logSearchEvent(SearchPageEvents.queryErrorClear);
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
public logQueryErrorClear() {
|
|
480
|
+
return this.makeQueryErrorClear().log();
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
public makeLikeSmartSnippet() {
|
|
484
|
+
return this.makeCustomEvent(SearchPageEvents.likeSmartSnippet);
|
|
261
485
|
}
|
|
262
486
|
|
|
263
487
|
public logLikeSmartSnippet() {
|
|
264
|
-
return this.
|
|
488
|
+
return this.makeLikeSmartSnippet().log();
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
public makeDislikeSmartSnippet() {
|
|
492
|
+
return this.makeCustomEvent(SearchPageEvents.dislikeSmartSnippet);
|
|
265
493
|
}
|
|
266
494
|
|
|
267
495
|
public logDislikeSmartSnippet() {
|
|
268
|
-
return this.
|
|
496
|
+
return this.makeDislikeSmartSnippet().log();
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
public makeExpandSmartSnippet() {
|
|
500
|
+
return this.makeCustomEvent(SearchPageEvents.expandSmartSnippet);
|
|
269
501
|
}
|
|
270
502
|
|
|
271
503
|
public logExpandSmartSnippet() {
|
|
272
|
-
return this.
|
|
504
|
+
return this.makeExpandSmartSnippet().log();
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
public makeCollapseSmartSnippet() {
|
|
508
|
+
return this.makeCustomEvent(SearchPageEvents.collapseSmartSnippet);
|
|
273
509
|
}
|
|
274
510
|
|
|
275
511
|
public logCollapseSmartSnippet() {
|
|
276
|
-
return this.
|
|
512
|
+
return this.makeCollapseSmartSnippet().log();
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
public makeOpenSmartSnippetFeedbackModal() {
|
|
516
|
+
return this.makeCustomEvent(SearchPageEvents.openSmartSnippetFeedbackModal);
|
|
277
517
|
}
|
|
278
518
|
|
|
279
519
|
public logOpenSmartSnippetFeedbackModal() {
|
|
280
|
-
return this.
|
|
520
|
+
return this.makeOpenSmartSnippetFeedbackModal().log();
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
public makeCloseSmartSnippetFeedbackModal() {
|
|
524
|
+
return this.makeCustomEvent(SearchPageEvents.closeSmartSnippetFeedbackModal);
|
|
281
525
|
}
|
|
282
526
|
|
|
283
527
|
public logCloseSmartSnippetFeedbackModal() {
|
|
284
|
-
return this.
|
|
528
|
+
return this.makeCloseSmartSnippetFeedbackModal().log();
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
public makeSmartSnippetFeedbackReason(reason: SmartSnippetFeedbackReason, details?: string) {
|
|
532
|
+
return this.makeCustomEvent(SearchPageEvents.sendSmartSnippetReason, {reason, details});
|
|
285
533
|
}
|
|
286
534
|
|
|
287
535
|
public logSmartSnippetFeedbackReason(reason: SmartSnippetFeedbackReason, details?: string) {
|
|
288
|
-
return this.
|
|
536
|
+
return this.makeSmartSnippetFeedbackReason(reason, details).log();
|
|
289
537
|
}
|
|
290
538
|
|
|
291
|
-
public
|
|
292
|
-
return this.
|
|
539
|
+
public makeExpandSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier) {
|
|
540
|
+
return this.makeCustomEvent(
|
|
293
541
|
SearchPageEvents.expandSmartSnippetSuggestion,
|
|
294
542
|
'documentId' in snippet ? snippet : {documentId: snippet}
|
|
295
543
|
);
|
|
296
544
|
}
|
|
297
545
|
|
|
298
|
-
public
|
|
299
|
-
return this.
|
|
546
|
+
public logExpandSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier) {
|
|
547
|
+
return this.makeExpandSmartSnippetSuggestion(snippet).log();
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
public makeCollapseSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier) {
|
|
551
|
+
return this.makeCustomEvent(
|
|
300
552
|
SearchPageEvents.collapseSmartSnippetSuggestion,
|
|
301
553
|
'documentId' in snippet ? snippet : {documentId: snippet}
|
|
302
554
|
);
|
|
303
555
|
}
|
|
304
556
|
|
|
557
|
+
public logCollapseSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta | SmartSnippetDocumentIdentifier) {
|
|
558
|
+
return this.makeCollapseSmartSnippetSuggestion(snippet).log();
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* @deprecated
|
|
563
|
+
*/
|
|
564
|
+
private makeShowMoreSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta) {
|
|
565
|
+
return this.makeCustomEvent(SearchPageEvents.showMoreSmartSnippetSuggestion, snippet);
|
|
566
|
+
}
|
|
567
|
+
|
|
305
568
|
/**
|
|
306
569
|
* @deprecated
|
|
307
570
|
*/
|
|
308
571
|
public logShowMoreSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta) {
|
|
309
|
-
return this.
|
|
572
|
+
return this.makeShowMoreSmartSnippetSuggestion(snippet).log();
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* @deprecated
|
|
577
|
+
*/
|
|
578
|
+
private makeShowLessSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta) {
|
|
579
|
+
return this.makeCustomEvent(SearchPageEvents.showLessSmartSnippetSuggestion, snippet);
|
|
310
580
|
}
|
|
311
581
|
|
|
312
582
|
/**
|
|
313
583
|
* @deprecated
|
|
314
584
|
*/
|
|
315
585
|
public logShowLessSmartSnippetSuggestion(snippet: SmartSnippetSuggestionMeta) {
|
|
316
|
-
return this.
|
|
586
|
+
return this.makeShowLessSmartSnippetSuggestion(snippet).log();
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
public makeOpenSmartSnippetSource(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
590
|
+
return this.makeClickEvent(SearchPageEvents.openSmartSnippetSource, info, identifier);
|
|
317
591
|
}
|
|
318
592
|
|
|
319
593
|
public logOpenSmartSnippetSource(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
320
|
-
return this.
|
|
594
|
+
return this.makeOpenSmartSnippetSource(info, identifier).log();
|
|
321
595
|
}
|
|
322
596
|
|
|
323
|
-
public
|
|
324
|
-
return this.
|
|
597
|
+
public makeOpenSmartSnippetSuggestionSource(info: PartialDocumentInformation, snippet: SmartSnippetSuggestionMeta) {
|
|
598
|
+
return this.makeClickEvent(
|
|
325
599
|
SearchPageEvents.openSmartSnippetSuggestionSource,
|
|
326
600
|
info,
|
|
327
601
|
{contentIDKey: snippet.documentId.contentIdKey, contentIDValue: snippet.documentId.contentIdValue},
|
|
@@ -329,11 +603,15 @@ export class CoveoSearchPageClient {
|
|
|
329
603
|
);
|
|
330
604
|
}
|
|
331
605
|
|
|
332
|
-
public
|
|
606
|
+
public logOpenSmartSnippetSuggestionSource(info: PartialDocumentInformation, snippet: SmartSnippetSuggestionMeta) {
|
|
607
|
+
return this.makeOpenSmartSnippetSuggestionSource(info, snippet).log();
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
public makeOpenSmartSnippetInlineLink(
|
|
333
611
|
info: PartialDocumentInformation,
|
|
334
612
|
identifierAndLink: DocumentIdentifier & SmartSnippetLinkMeta
|
|
335
613
|
) {
|
|
336
|
-
return this.
|
|
614
|
+
return this.makeClickEvent(
|
|
337
615
|
SearchPageEvents.openSmartSnippetInlineLink,
|
|
338
616
|
info,
|
|
339
617
|
{contentIDKey: identifierAndLink.contentIDKey, contentIDValue: identifierAndLink.contentIDValue},
|
|
@@ -341,11 +619,18 @@ export class CoveoSearchPageClient {
|
|
|
341
619
|
);
|
|
342
620
|
}
|
|
343
621
|
|
|
344
|
-
public
|
|
622
|
+
public logOpenSmartSnippetInlineLink(
|
|
623
|
+
info: PartialDocumentInformation,
|
|
624
|
+
identifierAndLink: DocumentIdentifier & SmartSnippetLinkMeta
|
|
625
|
+
) {
|
|
626
|
+
return this.makeOpenSmartSnippetInlineLink(info, identifierAndLink).log();
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
public makeOpenSmartSnippetSuggestionInlineLink(
|
|
345
630
|
info: PartialDocumentInformation,
|
|
346
631
|
snippetAndLink: SmartSnippetSuggestionMeta & SmartSnippetLinkMeta
|
|
347
632
|
) {
|
|
348
|
-
return this.
|
|
633
|
+
return this.makeClickEvent(
|
|
349
634
|
SearchPageEvents.openSmartSnippetSuggestionInlineLink,
|
|
350
635
|
info,
|
|
351
636
|
{
|
|
@@ -356,65 +641,131 @@ export class CoveoSearchPageClient {
|
|
|
356
641
|
);
|
|
357
642
|
}
|
|
358
643
|
|
|
644
|
+
public logOpenSmartSnippetSuggestionInlineLink(
|
|
645
|
+
info: PartialDocumentInformation,
|
|
646
|
+
snippetAndLink: SmartSnippetSuggestionMeta & SmartSnippetLinkMeta
|
|
647
|
+
) {
|
|
648
|
+
return this.makeOpenSmartSnippetSuggestionInlineLink(info, snippetAndLink).log();
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
public makeRecentQueryClick() {
|
|
652
|
+
return this.makeSearchEvent(SearchPageEvents.recentQueryClick);
|
|
653
|
+
}
|
|
654
|
+
|
|
359
655
|
public logRecentQueryClick() {
|
|
360
|
-
return this.
|
|
656
|
+
return this.makeRecentQueryClick().log();
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
public makeClearRecentQueries() {
|
|
660
|
+
return this.makeCustomEvent(SearchPageEvents.clearRecentQueries);
|
|
361
661
|
}
|
|
362
662
|
|
|
363
663
|
public logClearRecentQueries() {
|
|
364
|
-
return this.
|
|
664
|
+
return this.makeClearRecentQueries().log();
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
public makeRecentResultClick(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
668
|
+
return this.makeCustomEvent(SearchPageEvents.recentResultClick, {info, identifier});
|
|
365
669
|
}
|
|
366
670
|
|
|
367
671
|
public logRecentResultClick(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
368
|
-
return this.
|
|
672
|
+
return this.makeRecentResultClick(info, identifier).log();
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
public makeClearRecentResults() {
|
|
676
|
+
return this.makeCustomEvent(SearchPageEvents.clearRecentResults);
|
|
369
677
|
}
|
|
370
678
|
|
|
371
679
|
public logClearRecentResults() {
|
|
372
|
-
return this.
|
|
680
|
+
return this.makeClearRecentResults().log();
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
public makeNoResultsBack() {
|
|
684
|
+
return this.makeSearchEvent(SearchPageEvents.noResultsBack);
|
|
373
685
|
}
|
|
374
686
|
|
|
375
687
|
public logNoResultsBack() {
|
|
376
|
-
return this.
|
|
688
|
+
return this.makeNoResultsBack().log();
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
public makeShowMoreFoldedResults(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
692
|
+
return this.makeClickEvent(SearchPageEvents.showMoreFoldedResults, info, identifier);
|
|
377
693
|
}
|
|
378
694
|
|
|
379
695
|
public logShowMoreFoldedResults(info: PartialDocumentInformation, identifier: DocumentIdentifier) {
|
|
380
|
-
return this.
|
|
696
|
+
return this.makeShowMoreFoldedResults(info, identifier).log();
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
public makeShowLessFoldedResults() {
|
|
700
|
+
return this.makeCustomEvent(SearchPageEvents.showLessFoldedResults);
|
|
381
701
|
}
|
|
382
702
|
|
|
383
703
|
public logShowLessFoldedResults() {
|
|
384
|
-
return this.
|
|
704
|
+
return this.makeShowLessFoldedResults().log();
|
|
385
705
|
}
|
|
386
706
|
|
|
387
|
-
public
|
|
707
|
+
public makeCustomEvent(
|
|
388
708
|
event: SearchPageEvents,
|
|
389
709
|
metadata?: Record<string, any>,
|
|
390
710
|
eventType: string = CustomEventsTypes[event]!
|
|
391
|
-
) {
|
|
711
|
+
): EventBuilder<CustomEventResponse> {
|
|
392
712
|
const customData = {...this.provider.getBaseMetadata(), ...metadata};
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
713
|
+
return {
|
|
714
|
+
description: this.makeDescription(event, metadata),
|
|
715
|
+
log: async () => {
|
|
716
|
+
const payload: CustomEventRequest = {
|
|
717
|
+
...(await this.getBaseCustomEventRequest(customData)),
|
|
718
|
+
eventType,
|
|
719
|
+
eventValue: event,
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
return this.coveoAnalyticsClient.sendCustomEvent(payload);
|
|
723
|
+
},
|
|
398
724
|
};
|
|
725
|
+
}
|
|
399
726
|
|
|
400
|
-
|
|
727
|
+
public logCustomEvent(
|
|
728
|
+
event: SearchPageEvents,
|
|
729
|
+
metadata?: Record<string, any>,
|
|
730
|
+
eventType: string = CustomEventsTypes[event]!
|
|
731
|
+
) {
|
|
732
|
+
return this.makeCustomEvent(event, metadata, eventType).log();
|
|
401
733
|
}
|
|
402
734
|
|
|
403
|
-
public
|
|
735
|
+
public makeCustomEventWithType(eventValue: string, eventType: string, metadata?: Record<string, any>) {
|
|
404
736
|
const customData = {...this.provider.getBaseMetadata(), ...metadata};
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
737
|
+
return {
|
|
738
|
+
description: <EventDescription>{actionCause: eventValue, customData},
|
|
739
|
+
log: async () => {
|
|
740
|
+
const payload: CustomEventRequest = {
|
|
741
|
+
...(await this.getBaseCustomEventRequest(customData)),
|
|
742
|
+
eventType,
|
|
743
|
+
eventValue,
|
|
744
|
+
};
|
|
745
|
+
return this.coveoAnalyticsClient.sendCustomEvent(payload);
|
|
746
|
+
},
|
|
410
747
|
};
|
|
411
|
-
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
public logCustomEventWithType(eventValue: string, eventType: string, metadata?: Record<string, any>) {
|
|
751
|
+
return this.makeCustomEventWithType(eventValue, eventType, metadata).log();
|
|
412
752
|
}
|
|
413
753
|
|
|
414
754
|
public async logSearchEvent(event: SearchPageEvents, metadata?: Record<string, any>) {
|
|
415
755
|
return this.coveoAnalyticsClient.sendSearchEvent(await this.getBaseSearchEventRequest(event, metadata));
|
|
416
756
|
}
|
|
417
757
|
|
|
758
|
+
private makeDescription(actionCause: SearchPageEvents, metadata?: Record<string, any>): EventDescription {
|
|
759
|
+
return {actionCause, customData: {...this.provider.getBaseMetadata(), ...metadata}};
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
public makeSearchEvent(event: SearchPageEvents, metadata?: Record<string, any>): EventBuilder<SearchEventResponse> {
|
|
763
|
+
return {
|
|
764
|
+
description: this.makeDescription(event, metadata),
|
|
765
|
+
log: () => this.logSearchEvent(event, metadata),
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
|
|
418
769
|
public async logClickEvent(
|
|
419
770
|
event: SearchPageEvents,
|
|
420
771
|
info: PartialDocumentInformation,
|
|
@@ -432,6 +783,18 @@ export class CoveoSearchPageClient {
|
|
|
432
783
|
return this.coveoAnalyticsClient.sendClickEvent(payload);
|
|
433
784
|
}
|
|
434
785
|
|
|
786
|
+
public makeClickEvent(
|
|
787
|
+
event: SearchPageEvents,
|
|
788
|
+
info: PartialDocumentInformation,
|
|
789
|
+
identifier: DocumentIdentifier,
|
|
790
|
+
metadata?: Record<string, any>
|
|
791
|
+
): EventBuilder<ClickEventResponse> {
|
|
792
|
+
return {
|
|
793
|
+
description: this.makeDescription(event, {...identifier, ...metadata}),
|
|
794
|
+
log: () => this.logClickEvent(event, info, identifier, metadata),
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
|
|
435
798
|
private async getBaseSearchEventRequest(
|
|
436
799
|
event: SearchPageEvents,
|
|
437
800
|
metadata?: Record<string, any>
|