coveo.analytics 2.21.27 → 2.22.2

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.
@@ -45,6 +45,7 @@ export interface BufferedRequest {
45
45
  eventType: EventType;
46
46
  payload: any;
47
47
  }
48
+ export declare function buildBaseUrl(endpoint?: string, apiVersion?: string): string;
48
49
  export declare class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider {
49
50
  private get defaultOptions();
50
51
  runtime: IRuntimeEnvironment;
@@ -1,6 +1,6 @@
1
1
  import { AnalyticsClient, ClientOptions } from '../client/analytics';
2
2
  import { SearchEventRequest } from '../events';
3
- import { FacetStateMetadata, SearchPageEvents } from '../searchPage/searchPageEvents';
3
+ import { DocumentIdentifier, FacetStateMetadata, PartialDocumentInformation, SearchPageEvents } from '../searchPage/searchPageEvents';
4
4
  import { ExpandToFullUIMetadata, InsightEvents, InsightFacetMetadata, InsightInterfaceChangeMetadata, InsightStaticFilterToggleValueMetadata, InsightFacetRangeMetadata, InsightCategoryFacetMetadata, CaseMetadata, InsightFacetSortMeta, InsightFacetBaseMeta, InsightQueryErrorMeta, InsightPagerMetadata, InsightResultsSortMetadata } from './insightEvents';
5
5
  export interface InsightClientProvider {
6
6
  getSearchEventRequestPayload: () => Omit<SearchEventRequest, 'actionCause' | 'searchQueryUid'>;
@@ -47,8 +47,10 @@ export declare class CoveoInsightClient {
47
47
  logSearchboxSubmit(metadata?: CaseMetadata): Promise<void | import("../events").SearchEventResponse>;
48
48
  logContextChanged(metadata: CaseMetadata): Promise<void | import("../events").SearchEventResponse>;
49
49
  logExpandToFullUI(metadata: ExpandToFullUIMetadata): Promise<void | import("../events").CustomEventResponse>;
50
+ logDocumentOpen(info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: CaseMetadata): Promise<void | import("../events").ClickEventResponse>;
50
51
  logCustomEvent(event: SearchPageEvents | InsightEvents, metadata?: Record<string, any>): Promise<void | import("../events").CustomEventResponse>;
51
52
  logSearchEvent(event: SearchPageEvents | InsightEvents, metadata?: Record<string, any>): Promise<void | import("../events").SearchEventResponse>;
53
+ logClickEvent(event: SearchPageEvents, info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: Record<string, any>): Promise<void | import("../events").ClickEventResponse>;
52
54
  private getBaseCustomEventRequest;
53
55
  private getBaseSearchEventRequest;
54
56
  private getBaseEventRequest;
@@ -1,2 +1,2 @@
1
- export { ReactNativeRuntime } from './react-native-runtime';
2
- export { ReactNativeStorage } from './react-native-storage';
1
+ export { ReactNativeRuntime, ReactNativeRuntimeOptions, ReactNativeStorage } from './react-native-runtime';
2
+ export * from '../coveoua/headless';
@@ -1,9 +1,18 @@
1
1
  import { WebStorage } from '../storage';
2
2
  import { AnalyticsFetchClient } from '../client/analyticsFetchClient';
3
3
  import { IRuntimeEnvironment } from '../client/runtimeEnvironment';
4
- import { IAnalyticsClientOptions } from '../client/analyticsRequestClient';
4
+ import { PreprocessAnalyticsRequest } from '../client/analyticsRequestClient';
5
+ export declare type ReactNativeStorage = WebStorage;
6
+ export interface ReactNativeRuntimeOptions {
7
+ storage: ReactNativeStorage;
8
+ visitorIdKey?: string;
9
+ token?: string;
10
+ version?: string;
11
+ endpoint?: string;
12
+ preprocessRequest?: PreprocessAnalyticsRequest;
13
+ }
5
14
  export declare class ReactNativeRuntime implements IRuntimeEnvironment {
6
- storage: WebStorage;
7
15
  client: AnalyticsFetchClient;
8
- constructor(clientOptions: IAnalyticsClientOptions);
16
+ storage: ReactNativeStorage;
17
+ constructor(options: ReactNativeRuntimeOptions);
9
18
  }
@@ -1,2 +1,2 @@
1
- export declare const ReactNativeRuntimeWarning = "\n We've detected you're using React Native but have not provided the corresponding runtime, \n for an optimal experience please install @react-native-async-storage/async-storage and instantiate \n your analytics client as follows:\n \n import {ReactNativeRuntime} from 'coveo.analytics/src/react-native';\n \n const analytics = new CoveoAnalyticsClient({\n ...your options,\n runtimeEnvironment: new ReactNativeRuntime({\n baseUrl: '...',\n });\n })\n ";
1
+ export declare const ReactNativeRuntimeWarning = "\n We've detected you're using React Native but have not provided the corresponding runtime, \n for an optimal experience please use the \"coveo.analytics/react-native\" subpackage.\n Follow the Readme on how to set it up: https://github.com/coveo/coveo.analytics.js#using-react-native\n ";
2
2
  export declare function isReactNative(): boolean;
@@ -1,2 +1,2 @@
1
- export { ReactNativeRuntime } from './react-native-runtime';
2
- export { ReactNativeStorage } from './react-native-storage';
1
+ export { ReactNativeRuntime, ReactNativeRuntimeOptions, ReactNativeStorage } from './react-native-runtime';
2
+ export * from '../coveoua/headless';
@@ -1,9 +1,18 @@
1
1
  import { WebStorage } from '../storage';
2
2
  import { AnalyticsFetchClient } from '../client/analyticsFetchClient';
3
3
  import { IRuntimeEnvironment } from '../client/runtimeEnvironment';
4
- import { IAnalyticsClientOptions } from '../client/analyticsRequestClient';
4
+ import { PreprocessAnalyticsRequest } from '../client/analyticsRequestClient';
5
+ export declare type ReactNativeStorage = WebStorage;
6
+ export interface ReactNativeRuntimeOptions {
7
+ storage: ReactNativeStorage;
8
+ visitorIdKey?: string;
9
+ token?: string;
10
+ version?: string;
11
+ endpoint?: string;
12
+ preprocessRequest?: PreprocessAnalyticsRequest;
13
+ }
5
14
  export declare class ReactNativeRuntime implements IRuntimeEnvironment {
6
- storage: WebStorage;
7
15
  client: AnalyticsFetchClient;
8
- constructor(clientOptions: IAnalyticsClientOptions);
16
+ storage: ReactNativeStorage;
17
+ constructor(options: ReactNativeRuntimeOptions);
9
18
  }
@@ -748,17 +748,8 @@ const isApiKey = (token) => (token === null || token === void 0 ? void 0 : token
748
748
 
749
749
  const ReactNativeRuntimeWarning = `
750
750
  We've detected you're using React Native but have not provided the corresponding runtime,
751
- for an optimal experience please install @react-native-async-storage/async-storage and instantiate
752
- your analytics client as follows:
753
-
754
- import {ReactNativeRuntime} from 'coveo.analytics/src/react-native';
755
-
756
- const analytics = new CoveoAnalyticsClient({
757
- ...your options,
758
- runtimeEnvironment: new ReactNativeRuntime({
759
- baseUrl: '...',
760
- });
761
- })
751
+ for an optimal experience please use the "coveo.analytics/react-native" subpackage.
752
+ Follow the Readme on how to set it up: https://github.com/coveo/coveo.analytics.js#using-react-native
762
753
  `;
763
754
  function isReactNative() {
764
755
  return typeof navigator != 'undefined' && navigator.product == 'ReactNative';
@@ -781,6 +772,10 @@ const Endpoints = {
781
772
  production: 'https://analytics.cloud.coveo.com/rest/ua',
782
773
  hipaa: 'https://analyticshipaa.cloud.coveo.com/rest/ua',
783
774
  };
775
+ function buildBaseUrl(endpoint = Endpoints.default, apiVersion = Version) {
776
+ const endpointIsCoveoProxy = endpoint.indexOf('.cloud.coveo.com') !== -1;
777
+ return `${endpoint}${endpointIsCoveoProxy ? '' : '/rest'}/${apiVersion}`;
778
+ }
784
779
  class CoveoAnalyticsClient {
785
780
  constructor(opts) {
786
781
  if (!opts) {
@@ -1077,9 +1072,7 @@ class CoveoAnalyticsClient {
1077
1072
  }
1078
1073
  }
1079
1074
  get baseUrl() {
1080
- const { version, endpoint } = this.options;
1081
- const endpointIsCoveoProxy = endpoint.indexOf('.cloud.coveo.com') !== -1;
1082
- return `${endpoint}${endpointIsCoveoProxy ? '' : '/rest'}/${version}`;
1075
+ return buildBaseUrl(this.options.endpoint, this.options.version);
1083
1076
  }
1084
1077
  }
1085
1078
 
@@ -2198,6 +2191,9 @@ class CoveoInsightClient {
2198
2191
  const metadataToSend = generateMetadataToSend(metadata);
2199
2192
  return this.logCustomEvent(InsightEvents.expandToFullUI, metadataToSend);
2200
2193
  }
2194
+ logDocumentOpen(info, identifier, metadata) {
2195
+ return this.logClickEvent(SearchPageEvents.documentOpen, info, identifier, metadata ? generateMetadataToSend(metadata, false) : undefined);
2196
+ }
2201
2197
  logCustomEvent(event, metadata) {
2202
2198
  return __awaiter(this, void 0, void 0, function* () {
2203
2199
  const customData = Object.assign(Object.assign({}, this.provider.getBaseMetadata()), metadata);
@@ -2210,6 +2206,12 @@ class CoveoInsightClient {
2210
2206
  return this.coveoAnalyticsClient.sendSearchEvent(yield this.getBaseSearchEventRequest(event, metadata));
2211
2207
  });
2212
2208
  }
2209
+ logClickEvent(event, info, identifier, metadata) {
2210
+ return __awaiter(this, void 0, void 0, function* () {
2211
+ const payload = Object.assign(Object.assign(Object.assign({}, info), (yield this.getBaseEventRequest(Object.assign(Object.assign({}, identifier), metadata)))), { searchQueryUid: this.provider.getSearchUID(), queryPipeline: this.provider.getPipeline(), actionCause: event });
2212
+ return this.coveoAnalyticsClient.sendClickEvent(payload);
2213
+ });
2214
+ }
2213
2215
  getBaseCustomEventRequest(metadata) {
2214
2216
  return __awaiter(this, void 0, void 0, function* () {
2215
2217
  return Object.assign(Object.assign({}, (yield this.getBaseEventRequest(metadata))), { lastSearchQueryUid: this.provider.getSearchUID() });
package/dist/library.js CHANGED
@@ -20,7 +20,7 @@ var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
20
20
  var require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5);
21
21
  var require$$6__default = /*#__PURE__*/_interopDefaultLegacy(require$$6);
22
22
 
23
- /*! *****************************************************************************
23
+ /******************************************************************************
24
24
  Copyright (c) Microsoft Corporation.
25
25
 
26
26
  Permission to use, copy, modify, and/or distribute this software for any
@@ -78840,6 +78840,7 @@ var combiningMarksRegex = /[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\
78840
78840
  function validateLabel(label, processing_option) {
78841
78841
  if (label.substr(0, 4) === "xn--") {
78842
78842
  label = punycode.toUnicode(label);
78843
+ PROCESSING_OPTIONS.NONTRANSITIONAL;
78843
78844
  }
78844
78845
 
78845
78846
  var error = false;
@@ -82507,7 +82508,7 @@ var NoopRuntime = (function () {
82507
82508
  var API_KEY_PREFIX = 'xx';
82508
82509
  var isApiKey = function (token) { return (token === null || token === void 0 ? void 0 : token.startsWith(API_KEY_PREFIX)) || false; };
82509
82510
 
82510
- var ReactNativeRuntimeWarning = "\n We've detected you're using React Native but have not provided the corresponding runtime, \n for an optimal experience please install @react-native-async-storage/async-storage and instantiate \n your analytics client as follows:\n \n import {ReactNativeRuntime} from 'coveo.analytics/src/react-native';\n \n const analytics = new CoveoAnalyticsClient({\n ...your options,\n runtimeEnvironment: new ReactNativeRuntime({\n baseUrl: '...',\n });\n })\n ";
82511
+ var ReactNativeRuntimeWarning = "\n We've detected you're using React Native but have not provided the corresponding runtime, \n for an optimal experience please use the \"coveo.analytics/react-native\" subpackage.\n Follow the Readme on how to set it up: https://github.com/coveo/coveo.analytics.js#using-react-native\n ";
82511
82512
  function isReactNative() {
82512
82513
  return typeof navigator != 'undefined' && navigator.product == 'ReactNative';
82513
82514
  }
@@ -82535,6 +82536,12 @@ var Endpoints = {
82535
82536
  production: 'https://analytics.cloud.coveo.com/rest/ua',
82536
82537
  hipaa: 'https://analyticshipaa.cloud.coveo.com/rest/ua',
82537
82538
  };
82539
+ function buildBaseUrl(endpoint, apiVersion) {
82540
+ if (endpoint === void 0) { endpoint = Endpoints.default; }
82541
+ if (apiVersion === void 0) { apiVersion = Version; }
82542
+ var endpointIsCoveoProxy = endpoint.indexOf('.cloud.coveo.com') !== -1;
82543
+ return "" + endpoint + (endpointIsCoveoProxy ? '' : '/rest') + "/" + apiVersion;
82544
+ }
82538
82545
  var CoveoAnalyticsClient = (function () {
82539
82546
  function CoveoAnalyticsClient(opts) {
82540
82547
  if (!opts) {
@@ -83034,9 +83041,7 @@ var CoveoAnalyticsClient = (function () {
83034
83041
  };
83035
83042
  Object.defineProperty(CoveoAnalyticsClient.prototype, "baseUrl", {
83036
83043
  get: function () {
83037
- var _a = this.options, version = _a.version, endpoint = _a.endpoint;
83038
- var endpointIsCoveoProxy = endpoint.indexOf('.cloud.coveo.com') !== -1;
83039
- return "" + endpoint + (endpointIsCoveoProxy ? '' : '/rest') + "/" + version;
83044
+ return buildBaseUrl(this.options.endpoint, this.options.version);
83040
83045
  },
83041
83046
  enumerable: false,
83042
83047
  configurable: true
@@ -83048,6 +83053,7 @@ var analytics = /*#__PURE__*/Object.freeze({
83048
83053
  __proto__: null,
83049
83054
  Version: Version,
83050
83055
  Endpoints: Endpoints,
83056
+ buildBaseUrl: buildBaseUrl,
83051
83057
  CoveoAnalyticsClient: CoveoAnalyticsClient,
83052
83058
  'default': CoveoAnalyticsClient
83053
83059
  });
@@ -84607,6 +84613,9 @@ var CoveoInsightClient = (function () {
84607
84613
  var metadataToSend = generateMetadataToSend(metadata);
84608
84614
  return this.logCustomEvent(InsightEvents.expandToFullUI, metadataToSend);
84609
84615
  };
84616
+ CoveoInsightClient.prototype.logDocumentOpen = function (info, identifier, metadata) {
84617
+ return this.logClickEvent(SearchPageEvents.documentOpen, info, identifier, metadata ? generateMetadataToSend(metadata, false) : undefined);
84618
+ };
84610
84619
  CoveoInsightClient.prototype.logCustomEvent = function (event, metadata) {
84611
84620
  return __awaiter(this, void 0, void 0, function () {
84612
84621
  var customData, payload, _a;
@@ -84636,6 +84645,21 @@ var CoveoInsightClient = (function () {
84636
84645
  });
84637
84646
  });
84638
84647
  };
84648
+ CoveoInsightClient.prototype.logClickEvent = function (event, info, identifier, metadata) {
84649
+ return __awaiter(this, void 0, void 0, function () {
84650
+ var payload, _a;
84651
+ return __generator(this, function (_b) {
84652
+ switch (_b.label) {
84653
+ case 0:
84654
+ _a = [__assign({}, info)];
84655
+ return [4, this.getBaseEventRequest(__assign(__assign({}, identifier), metadata))];
84656
+ case 1:
84657
+ payload = __assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_b.sent())])), { searchQueryUid: this.provider.getSearchUID(), queryPipeline: this.provider.getPipeline(), actionCause: event }]);
84658
+ return [2, this.coveoAnalyticsClient.sendClickEvent(payload)];
84659
+ }
84660
+ });
84661
+ });
84662
+ };
84639
84663
  CoveoInsightClient.prototype.getBaseCustomEventRequest = function (metadata) {
84640
84664
  return __awaiter(this, void 0, void 0, function () {
84641
84665
  var _a;