coveo.analytics 2.30.55 → 2.31.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.
Files changed (86) hide show
  1. package/README.md +37 -43
  2. package/dist/browser.mjs +525 -357
  3. package/dist/coveoua.browser.js +1 -1
  4. package/dist/coveoua.browser.js.map +1 -1
  5. package/dist/coveoua.debug.js +559 -359
  6. package/dist/coveoua.debug.js.map +1 -1
  7. package/dist/coveoua.js +1 -1
  8. package/dist/coveoua.js.map +1 -1
  9. package/dist/definitions/client/analytics.d.ts +3 -2
  10. package/dist/definitions/client/runtimeEnvironment.d.ts +1 -1
  11. package/dist/definitions/donottrack.d.ts +1 -0
  12. package/dist/definitions/react-native/index.d.ts +1 -1
  13. package/dist/definitions/searchPage/searchPageClient.d.ts +3 -1
  14. package/dist/definitions/searchPage/searchPageEvents.d.ts +6 -0
  15. package/dist/definitions/version.d.ts +1 -1
  16. package/dist/library.cjs +15367 -3699
  17. package/dist/library.es.js +525 -357
  18. package/dist/library.js +15367 -3699
  19. package/dist/library.mjs +15367 -3699
  20. package/dist/react-native.es.js +646 -460
  21. package/modules/package.json +9 -9
  22. package/package.json +60 -91
  23. package/react-native/package.json +7 -7
  24. package/src/caseAssist/caseAssistActions.ts +51 -50
  25. package/src/caseAssist/caseAssistClient.spec.ts +328 -297
  26. package/src/caseAssist/caseAssistClient.ts +201 -185
  27. package/src/client/analytics.spec.ts +724 -703
  28. package/src/client/analytics.ts +677 -602
  29. package/src/client/analyticsBeaconClient.spec.ts +195 -188
  30. package/src/client/analyticsBeaconClient.ts +99 -88
  31. package/src/client/analyticsFetchClient.ts +77 -61
  32. package/src/client/analyticsRequestClient.ts +17 -17
  33. package/src/client/location.ts +3 -3
  34. package/src/client/measurementProtocolMapper.ts +54 -45
  35. package/src/client/measurementProtocolMapping/baseMeasurementProtocolMapper.ts +48 -44
  36. package/src/client/measurementProtocolMapping/commerceMeasurementProtocolMapper.ts +133 -121
  37. package/src/client/measurementProtocolMapping/serviceMeasurementProtocolMapper.ts +17 -17
  38. package/src/client/noopAnalytics.ts +80 -68
  39. package/src/client/runtimeEnvironment.ts +50 -41
  40. package/src/client/utils.spec.ts +112 -97
  41. package/src/client/utils.ts +39 -39
  42. package/src/cookieutils.spec.ts +59 -0
  43. package/src/cookieutils.ts +40 -39
  44. package/src/coveoua/browser.ts +14 -12
  45. package/src/coveoua/library.ts +4 -4
  46. package/src/coveoua/plugins.ts +36 -34
  47. package/src/coveoua/simpleanalytics.spec.ts +467 -452
  48. package/src/coveoua/simpleanalytics.ts +146 -140
  49. package/src/detector.ts +17 -17
  50. package/src/donottrack.spec.ts +199 -121
  51. package/src/donottrack.ts +31 -8
  52. package/src/events.ts +86 -79
  53. package/src/formatting/format-array-for-coveo-custom-data.spec.ts +13 -12
  54. package/src/formatting/format-array-for-coveo-custom-data.ts +18 -18
  55. package/src/formatting/format-omnibox-metadata.ts +16 -12
  56. package/src/history.spec.ts +197 -195
  57. package/src/history.ts +143 -133
  58. package/src/hook/addDefaultValues.ts +13 -8
  59. package/src/hook/enhanceViewEvent.ts +17 -17
  60. package/src/insight/insightClient.spec.ts +1848 -1717
  61. package/src/insight/insightClient.ts +866 -761
  62. package/src/insight/insightEvents.ts +57 -56
  63. package/src/plugins/BasePlugin.ts +125 -121
  64. package/src/plugins/ec.spec.ts +457 -429
  65. package/src/plugins/ec.ts +202 -199
  66. package/src/plugins/link.spec.ts +183 -159
  67. package/src/plugins/link.ts +88 -85
  68. package/src/plugins/svc.spec.ts +161 -155
  69. package/src/plugins/svc.ts +93 -91
  70. package/src/react-native/index.ts +5 -1
  71. package/src/react-native/react-native-runtime.ts +33 -33
  72. package/src/react-native/react-native-utils.ts +1 -1
  73. package/src/react-native/react-native.spec.ts +22 -21
  74. package/src/searchPage/searchPageClient.spec.ts +1944 -1766
  75. package/src/searchPage/searchPageClient.ts +1261 -1029
  76. package/src/searchPage/searchPageEvents.ts +529 -500
  77. package/src/storage.spec.ts +51 -51
  78. package/src/storage.ts +47 -47
  79. package/dist/definitions/bundle/browser-fetch.d.ts +0 -1
  80. package/dist/definitions/src/coveoua/browser.d.ts +0 -6
  81. package/dist/definitions/src/coveoua/headless.d.ts +0 -6
  82. package/dist/definitions/src/coveoua/library.d.ts +0 -17
  83. package/dist/definitions/src/coveoua/plugins.d.ts +0 -10
  84. package/dist/definitions/src/coveoua/simpleanalytics.d.ts +0 -33
  85. package/dist/definitions/src/react-native/index.d.ts +0 -3
  86. package/dist/definitions/src/react-native/react-native-runtime.d.ts +0 -19
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # ![coveo.analytics](./assets/coveo.analytics.js.png)
2
2
 
3
- [![Build Status](https://travis-ci.org/coveo/coveo.analytics.js.svg?branch=master)](https://travis-ci.org/coveo/coveo.analytics.js)
4
- [![Coverage Status](https://coveralls.io/repos/github/coveo/coveo.analytics.js/badge.svg?branch=master)](https://coveralls.io/github/coveo/coveo.analytics.js?branch=master)
5
3
  [![TypeScript](https://badges.frapsoft.com/typescript/code/typescript.png?v=100)](https://github.com/ellerbrock/typescript-badges/)
6
4
 
7
5
  # Coveo Analytics JavaScript client
@@ -16,20 +14,20 @@ In order to ensure the tracking code is available on your webpage, the following
16
14
 
17
15
  ```html
18
16
  <script>
19
- (function (c, o, v, e, O, u, a) {
20
- a = 'coveoua';
21
- c[a] =
22
- c[a] ||
23
- function () {
24
- (c[a].q = c[a].q || []).push(arguments);
25
- };
26
- c[a].t = Date.now();
27
- u = o.createElement(v);
28
- u.async = 1;
29
- u.src = e;
30
- O = o.getElementsByTagName(v)[0];
31
- O.parentNode.insertBefore(u, O);
32
- })(window, document, 'script', 'https://static.cloud.coveo.com/coveo.analytics.js/2/coveoua.js');
17
+ (function (c, o, v, e, O, u, a) {
18
+ a = 'coveoua';
19
+ c[a] =
20
+ c[a] ||
21
+ function () {
22
+ (c[a].q = c[a].q || []).push(arguments);
23
+ };
24
+ c[a].t = Date.now();
25
+ u = o.createElement(v);
26
+ u.async = 1;
27
+ u.src = e;
28
+ O = o.getElementsByTagName(v)[0];
29
+ O.parentNode.insertBefore(u, O);
30
+ })(window, document, 'script', 'https://static.cloud.coveo.com/coveo.analytics.js/2/coveoua.js');
33
31
  </script>
34
32
 
35
33
  coveoua('init', #COVEO_API_KEY); // Replace #COVEO_API_KEY with your api key
@@ -39,19 +37,19 @@ Since calls to the coveo analytics service need to be authenticated, the library
39
37
 
40
38
  ## Available actions
41
39
 
42
- After the library has loaded sucessfully, you can interact with coveoua through the global `coveoua` function. Any interaction with the library happens through this function by supplying both a action name, followed by an optional series of action arguments. The following actions are available:
40
+ After the library has loaded successfully, you can interact with coveoua through the global `coveoua` function. Any interaction with the library happens through this function by supplying both an action name, followed by an optional series of action arguments. The following actions are available:
43
41
 
44
42
  ### Initialization
45
43
 
46
44
  - `coveoua('version')`: Returns the current version of the tracking library.
47
45
  - `coveoua('init', <COVEO_API_KEY>, <ENDPOINT>)`: Initializes the library with the given api key and endpoint. The following parameters are accepted
48
- - COVEO_API_KEY (mandatory): A valid api key.
49
- - ENDPOINT (optional): A string specifying the desired analytics endpoint. The default value is https://analytics.cloud.coveo.com/rest/ua. In case your organization is HIPAA enabled, you should override with https://analyticshipaa.cloud.coveo.com/rest/ua.
46
+ - COVEO_API_KEY (mandatory): A valid api key.
47
+ - ENDPOINT (optional): A string specifying the desired analytics endpoint. The default value is https://analytics.cloud.coveo.com/rest/ua. In case your organization is HIPAA enabled, you should override with https://analyticshipaa.cloud.coveo.com/rest/ua.
50
48
  - `coveoua('init', <COVEO_API_KEY>, {endpoint: <ENDPOINT>, isCustomEndpoint: <IS_CUSTOM_ENDPOINT>, plugins: <PLUGINS>})`: Initializes the library with the given api key, endpoint, isCustomEndpoint option and plugins. The following parameters are accepted
51
- - COVEO_API_KEY (mandatory): A valid api key.
52
- - ENDPOINT (optional): An object string specifying the desired analytics endpoint. The default value is https://analytics.cloud.coveo.com/rest/ua. In case your organization is HIPAA enabled, you should override with https://analyticshipaa.cloud.coveo.com/rest/ua.
53
- - IS_CUSTOM_ENDPOINT (optional): An boolean specifying if the desired analytics endpoint is custom. This means the library will not try to add any prefix logic like /rest/ua at the end of the provided endpoint. This can be useful when implementing analytics through a reverse-proxy solution like cloudfront.
54
- - PLUGINS (optional): An array of known plugin names. See [plugins](#plugins) for more information.
49
+ - COVEO_API_KEY (mandatory): A valid api key.
50
+ - ENDPOINT (optional): An object string specifying the desired analytics endpoint. The default value is https://analytics.cloud.coveo.com/rest/ua. In case your organization is HIPAA enabled, you should override with https://analyticshipaa.cloud.coveo.com/rest/ua.
51
+ - IS_CUSTOM_ENDPOINT (optional): An boolean specifying if the desired analytics endpoint is custom. This means the library will not try to add any prefix logic like /rest/ua at the end of the provided endpoint. This can be useful when implementing analytics through a reverse-proxy solution like cloudfront.
52
+ - PLUGINS (optional): An array of known plugin names. See [plugins](#plugins) for more information.
55
53
  - `coveoua('set', <NAME>, <VALUE>)`: Attempts to inject an attribute with given name and value on every logged event, overriding any existing value. Some payloads may reject attributes they do not support.
56
54
  - `coveoua('set', <OBJECT>)`: Attempts to inject all attributes and values of the given object on every logged event, overriding any existing value. Some payloads may reject attributes they do not support.
57
55
  - `coveoua('set', 'custom', <OBJECT>)`: Attempts to inject all attributes and values of the given object in the custom section of an object, overriding any existing value. Use this call to pass customer specific parameters on the payload.
@@ -115,17 +113,17 @@ The eCommerce plugin supports adding product data (`ec:addProduct`) as well as s
115
113
  As a sample, here is how a [cart modification event](https://docs.coveo.com/en/l3jg0266/coveo-for-commerce/measure-cart-page-events#measure-an-increase-in-item-quantity-in-cart) is assembled:
116
114
 
117
115
  1. First use the `ec:addProduct` action to include the [relevant product data](https://docs.coveo.com/en/l29e0540/coveo-for-commerce/commerce-events-reference#product-data-fields-reference) in the event you’re about to send
118
- ```js
119
- coveoua('ec:addProduct', <PRODUCT_DATA>);
120
- ```
116
+ ```js
117
+ coveoua('ec:addProduct', <PRODUCT_DATA>);
118
+ ```
121
119
  2. Then use the `ec:setAction` action to specify that the [action done on this data](https://docs.coveo.com/en/l29e0540/coveo-for-commerce/commerce-events-reference#product-action-type-reference) is an addition to the cart.
122
- ```js
123
- coveoua('ec:setAction', 'add');
124
- ```
120
+ ```js
121
+ coveoua('ec:setAction', 'add');
122
+ ```
125
123
  3. Finally, use the `send` action to send the generic event to Coveo Usage Analytics. The payload is implicit in this case, and has been generated by the plugin.
126
- ```js
127
- coveoua('send', 'event');
128
- ```
124
+ ```js
125
+ coveoua('send', 'event');
126
+ ```
129
127
 
130
128
  ## Linking clientIds across different domains using a URL parameter
131
129
 
@@ -144,9 +142,9 @@ Given that you want to ensure the clientId remains consistent when you navigate
144
142
 
145
143
  ```html
146
144
  <script>
147
- async function decorate(element) {
148
- element.href = await coveoua('link:decorate', element.href);
149
- }
145
+ async function decorate(element) {
146
+ element.href = await coveoua('link:decorate', element.href);
147
+ }
150
148
  </script>
151
149
  <a onclick="decorate(this)" href="http://bar.com/index.html">Navigate</a>>
152
150
  ```
@@ -168,18 +166,14 @@ npm run build
168
166
 
169
167
  ## Running and observing the code
170
168
 
171
- There are two ways to run your code locally:
172
-
173
- 1. Run `npm run start` and open your browser on http://localhost:9001
174
-
175
- 2. Debugging through VSCode debugger with the `Debug: Start Debugging` command, using the `Launch Chrome` configuration.
169
+ Run `pnpm run start` and open your browser on http://localhost:9001.
176
170
 
177
- To test out your changes, add `coveoua` function calls in the `public/index.html` file and check the payload in the `Developer Console` section of your browser.
171
+ The dev server also serves this package's `public` directory, which is not checked in. To test out your changes, create a `public/index.html`, add `coveoua` function calls to it, and check the payload in the `Developer Console` section of your browser.
178
172
 
179
173
  ## Running tests
180
174
 
181
- 1. From the command line through `npm run test`.
182
- 2. Debugging through VSCode debugger with the `Debug: Start Debugging` command, using the `Jest All` configuration.
175
+ 1. From the command line through `pnpm run test`.
176
+ 2. Debugging in VSCode: start a JavaScript Debug Terminal and run `pnpm run test:watch` (Vitest watch mode), then set breakpoints as needed.
183
177
 
184
178
  ## Storage and persistence
185
179