coveo.analytics 2.18.48 → 2.18.52

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.
@@ -1,6 +1,6 @@
1
1
  import { ClientOptions, AnalyticsClient } from '../client/analytics';
2
2
  import { SearchEventRequest } from '../events';
3
- import { SearchPageEvents, OmniboxSuggestionsMetadata, FacetMetadata, FacetRangeMetadata, CategoryFacetMetadata, DocumentIdentifier, InterfaceChangeMetadata, ResultsSortMetadata, PartialDocumentInformation, TriggerNotifyMetadata, TriggerExecuteMetadata, TriggerRedirectMetadata, PagerResizeMetadata, PagerMetadata, FacetBaseMeta, FacetSortMeta, QueryErrorMeta, FacetStateMetadata, SmartSnippetFeedbackReason, SmartSnippetSuggestionMeta } from './searchPageEvents';
3
+ import { SearchPageEvents, OmniboxSuggestionsMetadata, FacetMetadata, FacetRangeMetadata, CategoryFacetMetadata, DocumentIdentifier, InterfaceChangeMetadata, ResultsSortMetadata, PartialDocumentInformation, TriggerNotifyMetadata, TriggerExecuteMetadata, TriggerRedirectMetadata, PagerResizeMetadata, PagerMetadata, FacetBaseMeta, FacetSortMeta, QueryErrorMeta, FacetStateMetadata, SmartSnippetFeedbackReason, SmartSnippetSuggestionMeta, StaticFilterMetadata, StaticFilterToggleValueMetadata } from './searchPageEvents';
4
4
  export interface SearchPageClientProvider {
5
5
  getBaseMetadata: () => Record<string, any>;
6
6
  getSearchEventRequestPayload: () => Omit<SearchEventRequest, 'actionCause' | 'searchQueryUid'>;
@@ -27,6 +27,9 @@ export declare class CoveoSearchPageClient {
27
27
  logRecommendationInterfaceLoad(): Promise<void | import("../events").SearchEventResponse>;
28
28
  logRecommendation(): Promise<void | import("../events").CustomEventResponse>;
29
29
  logRecommendationOpen(info: PartialDocumentInformation, identifier: DocumentIdentifier): Promise<void | import("../events").ClickEventResponse>;
30
+ logStaticFilterClearAll(meta: StaticFilterMetadata): Promise<void | import("../events").SearchEventResponse>;
31
+ logStaticFilterSelect(meta: StaticFilterToggleValueMetadata): Promise<void | import("../events").SearchEventResponse>;
32
+ logStaticFilterDeselect(meta: StaticFilterToggleValueMetadata): Promise<void | import("../events").SearchEventResponse>;
30
33
  logFetchMoreResults(): Promise<void | import("../events").CustomEventResponse>;
31
34
  logInterfaceChange(metadata: InterfaceChangeMetadata): Promise<void | import("../events").SearchEventResponse>;
32
35
  logDidYouMeanAutomatic(): Promise<void | import("../events").SearchEventResponse>;
@@ -24,6 +24,9 @@ export declare enum SearchPageEvents {
24
24
  pagerNext = "pagerNext",
25
25
  pagerPrevious = "pagerPrevious",
26
26
  pagerScrolling = "pagerScrolling",
27
+ staticFilterClearAll = "staticFilterClearAll",
28
+ staticFilterSelect = "staticFilterSelect",
29
+ staticFilterDeselect = "staticFilterDeselect",
27
30
  facetClearAll = "facetClearAll",
28
31
  facetSearch = "facetSearch",
29
32
  facetSelect = "facetSelect",
@@ -57,6 +60,16 @@ export declare enum SearchPageEvents {
57
60
  noResultsBack = "noResultsBack"
58
61
  }
59
62
  export declare const CustomEventsTypes: Partial<Record<SearchPageEvents, string>>;
63
+ export interface StaticFilterMetadata {
64
+ staticFilterId: string;
65
+ }
66
+ export interface StaticFilterToggleValueMetadata extends StaticFilterMetadata {
67
+ staticFilterValue: StaticFilterValueMetadata;
68
+ }
69
+ interface StaticFilterValueMetadata {
70
+ caption: string;
71
+ expression: string;
72
+ }
60
73
  export interface FacetMetadata {
61
74
  facetId: string;
62
75
  facetField: string;
@@ -141,3 +154,4 @@ export interface SmartSnippetSuggestionMeta {
141
154
  contentIdValue: string;
142
155
  }
143
156
  export declare type PartialDocumentInformation = Omit<DocumentInformation, 'actionCause' | 'searchQueryUid'>;
157
+ export {};
@@ -54,10 +54,20 @@ function hasDocument() {
54
54
  return typeof document !== 'undefined';
55
55
  }
56
56
  function hasLocalStorage() {
57
- return typeof localStorage !== 'undefined';
57
+ try {
58
+ return typeof localStorage !== 'undefined';
59
+ }
60
+ catch (error) {
61
+ return false;
62
+ }
58
63
  }
59
64
  function hasSessionStorage() {
60
- return typeof sessionStorage !== 'undefined';
65
+ try {
66
+ return typeof sessionStorage !== 'undefined';
67
+ }
68
+ catch (error) {
69
+ return false;
70
+ }
61
71
  }
62
72
  function hasCookieStorage() {
63
73
  return hasNavigator() && navigator.cookieEnabled;
@@ -491,7 +501,16 @@ const contextInformationMapping = {
491
501
  eventId: 'z',
492
502
  time: 'tm',
493
503
  };
494
- const coveoExtensionsKeys = ['contentId', 'contentIdKey', 'contentType'];
504
+ const coveoExtensionsKeys = [
505
+ 'contentId',
506
+ 'contentIdKey',
507
+ 'contentType',
508
+ 'searchHub',
509
+ 'tab',
510
+ 'searchUid',
511
+ 'permanentId',
512
+ 'contentLocale',
513
+ ];
495
514
  const baseMeasurementProtocolKeysMapping = Object.assign(Object.assign(Object.assign(Object.assign({}, globalParamKeysMapping), eventKeysMapping), contextInformationMapping), coveoExtensionsKeys.reduce((all, key) => (Object.assign(Object.assign({}, all), { [key]: key })), {}));
496
515
 
497
516
  const measurementProtocolKeysMapping = Object.assign(Object.assign({}, baseMeasurementProtocolKeysMapping), serviceActionsKeysMapping);
@@ -1043,6 +1062,9 @@ var SearchPageEvents;
1043
1062
  SearchPageEvents["pagerNext"] = "pagerNext";
1044
1063
  SearchPageEvents["pagerPrevious"] = "pagerPrevious";
1045
1064
  SearchPageEvents["pagerScrolling"] = "pagerScrolling";
1065
+ SearchPageEvents["staticFilterClearAll"] = "staticFilterClearAll";
1066
+ SearchPageEvents["staticFilterSelect"] = "staticFilterSelect";
1067
+ SearchPageEvents["staticFilterDeselect"] = "staticFilterDeselect";
1046
1068
  SearchPageEvents["facetClearAll"] = "facetClearAll";
1047
1069
  SearchPageEvents["facetSearch"] = "facetSearch";
1048
1070
  SearchPageEvents["facetSelect"] = "facetSelect";
@@ -1215,6 +1237,15 @@ class CoveoSearchPageClient {
1215
1237
  logRecommendationOpen(info, identifier) {
1216
1238
  return this.logClickEvent(SearchPageEvents.recommendationOpen, info, identifier);
1217
1239
  }
1240
+ logStaticFilterClearAll(meta) {
1241
+ return this.logSearchEvent(SearchPageEvents.staticFilterClearAll, meta);
1242
+ }
1243
+ logStaticFilterSelect(meta) {
1244
+ return this.logSearchEvent(SearchPageEvents.staticFilterSelect, meta);
1245
+ }
1246
+ logStaticFilterDeselect(meta) {
1247
+ return this.logSearchEvent(SearchPageEvents.staticFilterDeselect, meta);
1248
+ }
1218
1249
  logFetchMoreResults() {
1219
1250
  return this.logCustomEvent(SearchPageEvents.pagerScrolling, { type: 'getMoreResults' });
1220
1251
  }
package/dist/library.js CHANGED
@@ -328,10 +328,20 @@ function hasDocument() {
328
328
  return typeof document !== 'undefined';
329
329
  }
330
330
  function hasLocalStorage() {
331
- return typeof localStorage !== 'undefined';
331
+ try {
332
+ return typeof localStorage !== 'undefined';
333
+ }
334
+ catch (error) {
335
+ return false;
336
+ }
332
337
  }
333
338
  function hasSessionStorage() {
334
- return typeof sessionStorage !== 'undefined';
339
+ try {
340
+ return typeof sessionStorage !== 'undefined';
341
+ }
342
+ catch (error) {
343
+ return false;
344
+ }
335
345
  }
336
346
  function hasCookieStorage() {
337
347
  return hasNavigator() && navigator.cookieEnabled;
@@ -858,7 +868,16 @@ var contextInformationMapping = {
858
868
  eventId: 'z',
859
869
  time: 'tm',
860
870
  };
861
- var coveoExtensionsKeys = ['contentId', 'contentIdKey', 'contentType'];
871
+ var coveoExtensionsKeys = [
872
+ 'contentId',
873
+ 'contentIdKey',
874
+ 'contentType',
875
+ 'searchHub',
876
+ 'tab',
877
+ 'searchUid',
878
+ 'permanentId',
879
+ 'contentLocale',
880
+ ];
862
881
  var baseMeasurementProtocolKeysMapping = tslib.exports.__assign(tslib.exports.__assign(tslib.exports.__assign(tslib.exports.__assign({}, globalParamKeysMapping), eventKeysMapping), contextInformationMapping), coveoExtensionsKeys.reduce(function (all, key) {
863
882
  var _a;
864
883
  return (tslib.exports.__assign(tslib.exports.__assign({}, all), (_a = {}, _a[key] = key, _a)));
@@ -3395,8 +3414,8 @@ var BasePlugin = (function () {
3395
3414
  this.currentLocation = location;
3396
3415
  if (eventType === BasePluginEventTypes.pageview) {
3397
3416
  this.nextPageViewId = this.uuidGenerator();
3417
+ this.hasSentFirstPageView = true;
3398
3418
  }
3399
- this.hasSentFirstPageView = true;
3400
3419
  };
3401
3420
  BasePlugin.prototype.getNextValues = function (eventType, payload) {
3402
3421
  return {
@@ -3850,6 +3869,9 @@ var SearchPageEvents;
3850
3869
  SearchPageEvents["pagerNext"] = "pagerNext";
3851
3870
  SearchPageEvents["pagerPrevious"] = "pagerPrevious";
3852
3871
  SearchPageEvents["pagerScrolling"] = "pagerScrolling";
3872
+ SearchPageEvents["staticFilterClearAll"] = "staticFilterClearAll";
3873
+ SearchPageEvents["staticFilterSelect"] = "staticFilterSelect";
3874
+ SearchPageEvents["staticFilterDeselect"] = "staticFilterDeselect";
3853
3875
  SearchPageEvents["facetClearAll"] = "facetClearAll";
3854
3876
  SearchPageEvents["facetSearch"] = "facetSearch";
3855
3877
  SearchPageEvents["facetSelect"] = "facetSelect";
@@ -4023,6 +4045,15 @@ var CoveoSearchPageClient = (function () {
4023
4045
  CoveoSearchPageClient.prototype.logRecommendationOpen = function (info, identifier) {
4024
4046
  return this.logClickEvent(SearchPageEvents.recommendationOpen, info, identifier);
4025
4047
  };
4048
+ CoveoSearchPageClient.prototype.logStaticFilterClearAll = function (meta) {
4049
+ return this.logSearchEvent(SearchPageEvents.staticFilterClearAll, meta);
4050
+ };
4051
+ CoveoSearchPageClient.prototype.logStaticFilterSelect = function (meta) {
4052
+ return this.logSearchEvent(SearchPageEvents.staticFilterSelect, meta);
4053
+ };
4054
+ CoveoSearchPageClient.prototype.logStaticFilterDeselect = function (meta) {
4055
+ return this.logSearchEvent(SearchPageEvents.staticFilterDeselect, meta);
4056
+ };
4026
4057
  CoveoSearchPageClient.prototype.logFetchMoreResults = function () {
4027
4058
  return this.logCustomEvent(SearchPageEvents.pagerScrolling, { type: 'getMoreResults' });
4028
4059
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coveo.analytics",
3
- "version": "2.18.48",
3
+ "version": "2.18.52",
4
4
  "description": "📈 Coveo analytics client (node and browser compatible) ",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.es.js",
@@ -34,8 +34,17 @@ const contextInformationMapping: {[key in keyof DefaultContextInformation]: stri
34
34
  time: 'tm',
35
35
  };
36
36
 
37
- /* Those are extension keys that are supported by the collect protocol. They will be forwarded as-is. */
38
- const coveoExtensionsKeys = ['contentId', 'contentIdKey', 'contentType'];
37
+ /* Those are extension keys that are supported by the Coveo collect protocol (but not Google's protocol). They will be forwarded as-is. */
38
+ const coveoExtensionsKeys = [
39
+ 'contentId',
40
+ 'contentIdKey',
41
+ 'contentType',
42
+ 'searchHub',
43
+ 'tab',
44
+ 'searchUid',
45
+ 'permanentId',
46
+ 'contentLocale',
47
+ ];
39
48
 
40
49
  export const baseMeasurementProtocolKeysMapping: {[name: string]: string} = {
41
50
  ...globalParamKeysMapping,
package/src/detector.ts CHANGED
@@ -11,11 +11,19 @@ export function hasDocument(): boolean {
11
11
  }
12
12
 
13
13
  export function hasLocalStorage(): boolean {
14
- return typeof localStorage !== 'undefined';
14
+ try {
15
+ return typeof localStorage !== 'undefined';
16
+ } catch (error) {
17
+ return false;
18
+ }
15
19
  }
16
20
 
17
21
  export function hasSessionStorage(): boolean {
18
- return typeof sessionStorage !== 'undefined';
22
+ try {
23
+ return typeof sessionStorage !== 'undefined';
24
+ } catch (error) {
25
+ return false;
26
+ }
19
27
  }
20
28
 
21
29
  export function hasCookieStorage(): boolean {
@@ -97,12 +97,11 @@ export abstract class BasePlugin {
97
97
 
98
98
  if (eventType === BasePluginEventTypes.pageview) {
99
99
  this.nextPageViewId = this.uuidGenerator();
100
+ this.hasSentFirstPageView = true;
100
101
  }
101
-
102
- this.hasSentFirstPageView = true;
103
102
  }
104
103
 
105
- /*
104
+ /*
106
105
  When calling getPayload or getParameters, we need to return what would be sent by the API without updating our internal reference.
107
106
  For instance, if you getPayload("pageview"), we want to return the same payload as if you did coveoua("send", "pageview").
108
107
  */
@@ -5,6 +5,7 @@ import {
5
5
  CustomEventsTypes,
6
6
  SmartSnippetFeedbackReason,
7
7
  OmniboxSuggestionsMetadata,
8
+ StaticFilterToggleValueMetadata,
8
9
  } from './searchPageEvents';
9
10
  import CoveoAnalyticsClient from '../client/analytics';
10
11
  import {NoopAnalytics} from '../client/noopAnalytics';
@@ -290,6 +291,39 @@ describe('SearchPageClient', () => {
290
291
  expectMatchCustomEventPayload(SearchPageEvents.pagerScrolling);
291
292
  });
292
293
 
294
+ it('should send the proper payload for #logStaticFilterClearAll', async () => {
295
+ const staticFilterId = 'filetypes';
296
+ await client.logStaticFilterClearAll({staticFilterId});
297
+
298
+ expectMatchPayload(SearchPageEvents.staticFilterClearAll, {staticFilterId});
299
+ });
300
+
301
+ it('should send the proper payload for #logStaticFilterSelect', async () => {
302
+ const meta: StaticFilterToggleValueMetadata = {
303
+ staticFilterId: 'filetypes',
304
+ staticFilterValue: {
305
+ caption: 'Youtube',
306
+ expression: '@filetype="youtubevideo"',
307
+ },
308
+ };
309
+ await client.logStaticFilterSelect(meta);
310
+
311
+ expectMatchPayload(SearchPageEvents.staticFilterSelect, meta);
312
+ });
313
+
314
+ it('should send the proper payload for #logStaticFilterDeselect', async () => {
315
+ const meta: StaticFilterToggleValueMetadata = {
316
+ staticFilterId: 'filetypes',
317
+ staticFilterValue: {
318
+ caption: 'Youtube',
319
+ expression: '@filetype="youtubevideo"',
320
+ },
321
+ };
322
+ await client.logStaticFilterDeselect(meta);
323
+
324
+ expectMatchPayload(SearchPageEvents.staticFilterDeselect, meta);
325
+ });
326
+
293
327
  it('should send proper payload for #logFacetSearch', async () => {
294
328
  const meta = {
295
329
  facetField: '@foo',
@@ -312,7 +346,7 @@ describe('SearchPageClient', () => {
312
346
  expectMatchPayload(SearchPageEvents.facetSelect, meta);
313
347
  });
314
348
 
315
- it('should send proper payload for #logFacetSelect', async () => {
349
+ it('should send proper payload for #logFacetDeselect', async () => {
316
350
  const meta = {
317
351
  facetField: '@foo',
318
352
  facetId: 'bar',
@@ -22,6 +22,8 @@ import {
22
22
  FacetStateMetadata,
23
23
  SmartSnippetFeedbackReason,
24
24
  SmartSnippetSuggestionMeta,
25
+ StaticFilterMetadata,
26
+ StaticFilterToggleValueMetadata,
25
27
  } from './searchPageEvents';
26
28
  import {NoopAnalytics} from '../client/noopAnalytics';
27
29
  import {formatOmniboxMetadata} from '../formatting/format-omnibox-metadata';
@@ -78,6 +80,18 @@ export class CoveoSearchPageClient {
78
80
  return this.logClickEvent(SearchPageEvents.recommendationOpen, info, identifier);
79
81
  }
80
82
 
83
+ public logStaticFilterClearAll(meta: StaticFilterMetadata) {
84
+ return this.logSearchEvent(SearchPageEvents.staticFilterClearAll, meta);
85
+ }
86
+
87
+ public logStaticFilterSelect(meta: StaticFilterToggleValueMetadata) {
88
+ return this.logSearchEvent(SearchPageEvents.staticFilterSelect, meta);
89
+ }
90
+
91
+ public logStaticFilterDeselect(meta: StaticFilterToggleValueMetadata) {
92
+ return this.logSearchEvent(SearchPageEvents.staticFilterDeselect, meta);
93
+ }
94
+
81
95
  public logFetchMoreResults() {
82
96
  return this.logCustomEvent(SearchPageEvents.pagerScrolling, {type: 'getMoreResults'});
83
97
  }
@@ -97,6 +97,18 @@ export enum SearchPageEvents {
97
97
  * Identifies the custom event that gets logged when the user scrolls to the bottom of the item page and more results are loaded.
98
98
  */
99
99
  pagerScrolling = 'pagerScrolling',
100
+ /**
101
+ * Identifies the search event that gets logged when the clearing all selected values of a static filter.
102
+ */
103
+ staticFilterClearAll = 'staticFilterClearAll',
104
+ /**
105
+ * Identifies the search event that gets logged when a static filter check box is selected and the query is updated.
106
+ */
107
+ staticFilterSelect = 'staticFilterSelect',
108
+ /**
109
+ * Identifies the search event that gets logged when a static filter check box is deselected and the query is updated.
110
+ */
111
+ staticFilterDeselect = 'staticFilterDeselect',
100
112
  /**
101
113
  * Identifies the search event that gets logged when the Clear Facet button is selected.
102
114
  */
@@ -255,6 +267,19 @@ export const CustomEventsTypes: Partial<Record<SearchPageEvents, string>> = {
255
267
  [SearchPageEvents.clearRecentResults]: 'recentlyClickedDocuments',
256
268
  };
257
269
 
270
+ export interface StaticFilterMetadata {
271
+ staticFilterId: string;
272
+ }
273
+
274
+ export interface StaticFilterToggleValueMetadata extends StaticFilterMetadata {
275
+ staticFilterValue: StaticFilterValueMetadata;
276
+ }
277
+
278
+ interface StaticFilterValueMetadata {
279
+ caption: string;
280
+ expression: string;
281
+ }
282
+
258
283
  export interface FacetMetadata {
259
284
  facetId: string;
260
285
  facetField: string;