coveo.analytics 2.30.56 → 2.32.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.
- package/README.md +37 -43
- package/dist/browser.mjs +513 -357
- package/dist/coveoua.browser.js +1 -1
- package/dist/coveoua.browser.js.map +1 -1
- package/dist/coveoua.debug.js +542 -359
- package/dist/coveoua.debug.js.map +1 -1
- package/dist/coveoua.js +1 -1
- package/dist/coveoua.js.map +1 -1
- package/dist/definitions/client/analytics.d.ts +3 -2
- package/dist/definitions/client/runtimeEnvironment.d.ts +1 -1
- package/dist/definitions/donottrack.d.ts +1 -0
- package/dist/definitions/react-native/index.d.ts +1 -2
- package/dist/definitions/version.d.ts +1 -1
- package/dist/library.cjs +15350 -3699
- package/dist/library.es.js +513 -357
- package/dist/library.js +15350 -3699
- package/dist/library.mjs +15350 -3699
- package/dist/react-native.es.js +634 -460
- package/modules/package.json +9 -9
- package/package.json +60 -91
- package/react-native/package.json +7 -7
- package/src/caseAssist/caseAssistActions.ts +51 -50
- package/src/caseAssist/caseAssistClient.spec.ts +328 -297
- package/src/caseAssist/caseAssistClient.ts +201 -185
- package/src/client/analytics.spec.ts +724 -703
- package/src/client/analytics.ts +677 -602
- package/src/client/analyticsBeaconClient.spec.ts +195 -188
- package/src/client/analyticsBeaconClient.ts +99 -88
- package/src/client/analyticsFetchClient.ts +77 -61
- package/src/client/analyticsRequestClient.ts +17 -17
- package/src/client/location.ts +3 -3
- package/src/client/measurementProtocolMapper.ts +54 -45
- package/src/client/measurementProtocolMapping/baseMeasurementProtocolMapper.ts +48 -44
- package/src/client/measurementProtocolMapping/commerceMeasurementProtocolMapper.ts +133 -121
- package/src/client/measurementProtocolMapping/serviceMeasurementProtocolMapper.ts +17 -17
- package/src/client/noopAnalytics.ts +80 -68
- package/src/client/runtimeEnvironment.ts +50 -41
- package/src/client/utils.spec.ts +112 -97
- package/src/client/utils.ts +39 -39
- package/src/cookieutils.spec.ts +59 -0
- package/src/cookieutils.ts +40 -39
- package/src/coveoua/browser.ts +14 -12
- package/src/coveoua/library.ts +4 -4
- package/src/coveoua/plugins.ts +36 -34
- package/src/coveoua/simpleanalytics.spec.ts +467 -452
- package/src/coveoua/simpleanalytics.ts +146 -140
- package/src/detector.ts +17 -17
- package/src/donottrack.spec.ts +199 -121
- package/src/donottrack.ts +31 -8
- package/src/events.ts +86 -79
- package/src/formatting/format-array-for-coveo-custom-data.spec.ts +13 -12
- package/src/formatting/format-array-for-coveo-custom-data.ts +18 -18
- package/src/formatting/format-omnibox-metadata.ts +16 -12
- package/src/history.spec.ts +197 -195
- package/src/history.ts +143 -133
- package/src/hook/addDefaultValues.ts +13 -8
- package/src/hook/enhanceViewEvent.ts +17 -17
- package/src/insight/insightClient.spec.ts +1848 -1717
- package/src/insight/insightClient.ts +866 -761
- package/src/insight/insightEvents.ts +57 -56
- package/src/plugins/BasePlugin.ts +125 -121
- package/src/plugins/ec.spec.ts +457 -429
- package/src/plugins/ec.ts +202 -199
- package/src/plugins/link.spec.ts +183 -159
- package/src/plugins/link.ts +88 -85
- package/src/plugins/svc.spec.ts +161 -155
- package/src/plugins/svc.ts +93 -91
- package/src/react-native/index.ts +8 -1
- package/src/react-native/react-native-runtime.ts +33 -33
- package/src/react-native/react-native-utils.ts +1 -1
- package/src/react-native/react-native.spec.ts +31 -21
- package/src/searchPage/searchPageClient.spec.ts +1944 -1794
- package/src/searchPage/searchPageClient.ts +1261 -1040
- package/src/searchPage/searchPageEvents.ts +524 -511
- package/src/storage.spec.ts +51 -51
- package/src/storage.ts +47 -47
- package/dist/definitions/bundle/browser-fetch.d.ts +0 -1
- package/dist/definitions/src/coveoua/browser.d.ts +0 -6
- package/dist/definitions/src/coveoua/headless.d.ts +0 -6
- package/dist/definitions/src/coveoua/library.d.ts +0 -17
- package/dist/definitions/src/coveoua/plugins.d.ts +0 -10
- package/dist/definitions/src/coveoua/simpleanalytics.d.ts +0 -33
- package/dist/definitions/src/react-native/index.d.ts +0 -3
- package/dist/definitions/src/react-native/react-native-runtime.d.ts +0 -19
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# 
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.org/coveo/coveo.analytics.js)
|
|
4
|
-
[](https://coveralls.io/github/coveo/coveo.analytics.js?branch=master)
|
|
5
3
|
[](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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
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
|
-
|
|
49
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
119
|
-
|
|
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
|
-
|
|
123
|
-
|
|
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
|
-
|
|
127
|
-
|
|
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
|
-
|
|
148
|
-
|
|
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
|
-
|
|
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
|
|
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 `
|
|
182
|
-
2. Debugging
|
|
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
|
|