coveo.analytics 2.20.26 → 2.22.1

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,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
 
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
  });