coveo.analytics 2.25.2 → 2.26.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.
package/README.md CHANGED
@@ -1,164 +1,209 @@
1
1
  # ![coveo.analytics](./assets/coveo.analytics.js.png)
2
2
 
3
3
  [![Build Status](https://travis-ci.org/coveo/coveo.analytics.js.svg?branch=master)](https://travis-ci.org/coveo/coveo.analytics.js)
4
- [![dependency status](https://david-dm.org/coveo/coveo.analytics.js.svg)](https://david-dm.org/coveo/coveo.analytics.js)
5
- [![dev dependency status](https://david-dm.org/coveo/coveo.analytics.js/dev-status.svg)](https://david-dm.org/coveo/coveo.analytics.js#info=devDependencies)
6
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)
7
5
  [![TypeScript](https://badges.frapsoft.com/typescript/code/typescript.png?v=100)](https://github.com/ellerbrock/typescript-badges/)
8
6
 
9
- ## Coveo Usage Analytic JavaScript client
7
+ # Coveo Analytics JavaScript client
10
8
 
11
- This project provides 2 ways to interact with the Coveo Usage Analytics service.
9
+ The Coveo analytics javascript client, also called coveo.analytics.js or coveoua for short, is responsible for logging analytics events to the Coveo platform. Analytics events may include basic Coveo web events such as pageviews, clicks or searches. For specific usecases, such as commerce and service, dedicated events may be defined and logged.
12
10
 
13
- - A JavaScript browser client
14
- - A code snippet to add in website pages
11
+ The analytics library is bundled with all Coveo provided UI components. Integrations which exclusively rely on these components, generally don't have to interact with coveoua directly. For Coveo integrations which integrate with an already existing UI and do not use headless, coveoua will be required to ensure events are logged correctly.
15
12
 
16
- ## Usage (Web analytics)
13
+ ## Loading and initializing the library in the browser
17
14
 
18
- This JavaScript client provides a code snippet that can easily be added to website pages to track events. The `pageview` events are stored in a Coveo Usage Analytics table which content currently cannot be viewed in Usage Analytics reports and the visit browser to prevent performance degradation.
15
+ In order to ensure the tracking code is available on your webpage, the following code snippet needs to be added to the top of each page on which analytics are required. This will load the latest major version of coveo.analytics.js from a Coveo CDN. As of writing, the current major version is 2.
19
16
 
20
- Initially, the `pageview` events data will be used exclusively by the Coveo ML Event Recommendations (ER) Feature (see [Event Recommendations (ER) Feature](https://docs.coveo.com/en/1671/coveo-machine-learning/coveo-machine-learning-features#ER)). It is recommended that you start sending `pageview` events to the Coveo Usage Analytics service as soon as possible so that you get relevant items recommended.
21
-
22
- On top of `pageview` events, generic and commerce events can also be tracked. See [Tracking Commerce Events](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events).
17
+ ```html
18
+ <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');
33
+ </script>
23
34
 
24
- **Note: This Coveo code snippet is similar to the Google analytics one (analytics.js).**
35
+ coveoua('init', #COVEO_API_KEY); // Replace #COVEO_API_KEY with your api key
36
+ ```
25
37
 
26
- ### Sending Coveo Analytics Page View Events for Recommendations
38
+ Since calls to the coveo analytics service need to be authenticated, the library needs to be initialized with a Coveo api key which has push access to the [Analytics Data Domain](https://docs.coveo.com/en/1707/cloud-v2-administrators/privilege-reference#analytics-data-domain). You can create an API key from the [administration console](https://platform.cloud.coveo.com/admin/#/organization/api-access/) selecting the **Push** option box for the **Analytics Data** domain (see [Adding and Managing API Keys](https://docs.coveo.com/en/1718/cloud-v2-administrators/adding-and-managing-api-keys)).
27
39
 
28
- 1. Get an API key.
40
+ ## Available actions
29
41
 
30
- You need a Coveo Cloud API key which has the [**Push** access level on the **Analytics Data** domain](https://docs.coveo.com/en/1707/cloud-v2-administrators/privilege-reference#analytics-data-domain) to send events (see [User Authentication](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#user-authentication)).
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:
31
43
 
32
- Create an API key from the [administration console](https://platform.cloud.coveo.com/admin/#/organization/api-access/) selecting the **Push** option box for the **Analytics Data** domain (see [Adding and Managing API Keys](https://docs.coveo.com/en/1718/cloud-v2-administrators/adding-and-managing-api-keys)).
44
+ ### Initialization
33
45
 
34
- 2. Add the code snippet to all your website pages.
46
+ - `coveoua('version')`: Returns the current version of the tracking library.
47
+ - `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.
50
+ - `coveoua('init', <COVEO_API_KEY>, {endpoint: <ENDPOINT>, plugins: <PLUGINS>})`: Initializes the library with the given api key, endpoint 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
+ - PLUGINS (optional): An array of known plugin names. See [plugins](#plugins) for more information.
54
+ - `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.
55
+ - `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.
56
+ - `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.
57
+ - `coveoua('onLoad', <CALLBACK>)`: Calls the specified function immediately, library initialization is not required.
58
+ - `coveoua('reset')`: Resets the state of the logger to the state before initialization.
35
59
 
36
- Add a code snippet like the following to all pages of your websites:
60
+ ### Sending events
37
61
 
38
- ```html
39
- <script>
40
- (function(c,o,v,e,O,u,a){
41
- a='coveoua';c[a]=c[a]||function(){(c[a].q=c[a].q|| []).push(arguments)};
42
- c[a].t=Date.now();u=o.createElement(v);u.async=1;u.src=e;
43
- O=o.getElementsByTagName(v)[0];O.parentNode.insertBefore(u,O)
44
- })(window,document,'script','https://static.cloud.coveo.com/coveo.analytics.js/2/coveoua.js')
45
- // Replace "2" in the script url with the latest release
62
+ - `coveoua('send', <EVENT_NAME>, <EVENT_PAYLOAD>)`: Sends an event with a given name and payload to the analytics endpoint.
46
63
 
47
- coveoua('init', <COVEO_API_KEY>); // Replace <COVEO_API_KEY> with your real key
48
- coveoua('send', 'view', {
49
- contentIdKey: '@permanentid',
50
- contentIdValue: <PERMANENT_ID_VALUE>, // Replace <PERMANENT_ID_VALUE> with a unique value from your page.
51
- contentType: 'product', // Optional
52
- // ... more information ...
53
- });
54
- </script>
55
- ```
64
+ ### Plugin control
56
65
 
57
- The code snippet must contain `contentIdKey` and `contentIdValue` in order to identify items in the Coveo index. When you want to recommend specific types of content, you also need to add a `contentType` parameter value.
66
+ - `coveoua('provide', <PLUGIN_NAME>, <PLUGINCLASS>)`: Registers a given pluginClass with the analytics library under the provided name.
67
+ - `coveoua('require', <PLUGIN_NAME>)`: Explicitly loads the plugin with the given name.
68
+ - `coveoua('callPlugin', <PLUGIN_NAME>, <FUNCTION>, <PARAMS>)`: Executes the specified function with given arguments on the given plugin name. Can be shorthanded using a plugin action prefix `coveoua(<PLUGINNAME>:<FUNCTION>, <PARAMS>)`.
58
69
 
59
- | Key | Value |
60
- | -------------- | ------------------------------------------------------------------- |
61
- | contentIdKey | The Coveo index field name that will be used to identify the item. |
62
- | contentIdValue | The Coveo index field value that will be used to identify the item. |
63
- | contentType | [Optional] The type of the item to be tracked (e.g., 'Article'). |
70
+ ## Plugins
64
71
 
65
- **Note: Do not copy the `coveoua.js` file as it can be updated anytime and you could experience compatibility issues.**
72
+ Coveoua is set up in a modular way with different plugins providing functionality that may be specific to a given usecase. This allows you to customize some of its behavior dynamically. By default, the following plugins are loaded at library initialization:
66
73
 
67
- 3. Validate `pageview` events are sent to the Coveo Usage Analytics service
74
+ - `ec`: eCommerce plugin which takes care of sending eCommerce specific events.
75
+ - `svc`: Service plugin which takes care of sending customer service specific events.
68
76
 
69
- a. In a web browser such as Chrome, navigate to a website page to which you added the code snippet.
77
+ Plugin actions extend the set of available actions. They can be executed either via the `callPlugin` action above, or via the shorthand. For example, to call the function `addImpression` on the `ec` plugin, you'd specify `coveoua('ec:addImpression', ...)`.
70
78
 
71
- b. In the browser developer tool, go the the **Network** tab.
79
+ It is possible to disable loading of any plugins by explicitly initializing the library with an empty list of plugins using `coveoua('init', <API_KEY>, {plugins:[]})`.
72
80
 
73
- c. Reload the page, in the **Name** panel, ensure that you see a **view** event sent to Coveo analytics.
81
+ ## Sending basic usage analytics events
74
82
 
75
- ### Sending Any Coveo Analytics Events
83
+ In most common integration usecases, you will be using Coveo pre-wired components (e.g. jsui, headless or atomic) to handle communication with the Coveo backend. These components have their own specific apis to handle event logging.
76
84
 
77
- Add the code snippet to all your website pages.
85
+ When you are not using any specific Coveo web component, you need to send these events payloads explicitly, use the `send` action to transmit an assembled payload to the usage analytics backend. See the [Usage Analytics Events](https://docs.coveo.com/en/2949/analyze-usage-data/usage-analytics-events) documentation for description of the payload contents. The following event types are supported in coveoua:
78
86
 
79
- ```html
80
- <script>
81
- (function(c,o,v,e,O,u,a){
82
- a='coveoua';c[a]=c[a]||function(){(c[a].q=c[a].q|| []).push(arguments)};
83
- c[a].t=Date.now();u=o.createElement(v);u.async=1;u.src=e;
84
- O=o.getElementsByTagName(v)[0];O.parentNode.insertBefore(u,O)
85
- })(window,document,'script','https://static.cloud.coveo.com/coveo.analytics.js/2/coveoua.js') // Replace "2" in the script url with the latest release
86
- coveoua('init', <COVEO_API_KEY>); // Replace <COVEO_API_KEY> with your real key
87
- </script>
88
- ```
87
+ - `search`: sends a [client side search](https://docs.coveo.com/en/1502/build-a-search-ui/log-search-events) event.
88
+ - `click`: sends a [click event](https://docs.coveo.com/en/2064/build-a-search-ui/log-click-events).
89
+ - `view`: sends a [view event](https://docs.coveo.com/en/2651/build-a-search-ui/log-view-events).
90
+ - `custom`: sends a [custom event](https://docs.coveo.com/en/2650/build-a-search-ui/log-custom-events).
91
+ - `collect`: sends a [collect event](https://docs.coveo.com/en/l41i0031/build-a-search-ui/log-collect-events) payload. We strongly recommend you use the simplified api in the ecommerce plugin [to send these events instead](#sending-commerce-specific-events).
89
92
 
90
- You can now call the script using the following line:
93
+ For example, in order to send a click event after a user has interacted with a Coveo provided result, first initialize the library with an api key and then send a click event with the appropriate payload. Refer to the [click event documentation](https://docs.coveo.com/en/2064/build-a-search-ui/log-click-events) for up to date information on event payloads.
91
94
 
92
95
  ```js
93
- coveoua('send', 'click', { ... });
96
+ coveoua('send', 'click', {...});
94
97
  ```
95
98
 
96
- Refer to the [Usage Analytics Write API](https://docs.coveo.com/en/1430/cloud-v2-developers/usage-analytics-write-api) section to see what types of events are supported and what payload you need to send.
99
+ You should be able to observe the click event being transmitted to the Coveo backend at `https://analytics.cloud.coveo.com/rest/ua/click` in the Developer tool's **Network** tab of your browser of choice.
97
100
 
98
- ### Sending Commerce Events
101
+ ## Sending commerce specific events
99
102
 
100
- Add the code snippet to all your website pages.
103
+ Commerce specific events such as product selections, shopping cart modifications and transactions are sent to Coveo in the compact [collect protocol](https://docs.coveo.com/en/l41i0031/build-a-search-ui/log-collect-events). Rather than explicitly assembling these payloads by hand, the eCommerce plugin provides apis to assemble and transmit the payloads. There are two event names that are specific to the eCommerce plugin:
101
104
 
102
- ```html
103
- <script>
104
- (function(c,o,v,e,O,u,a){
105
- a='coveoua';c[a]=c[a]||function(){(c[a].q=c[a].q|| []).push(arguments)};
106
- c[a].t=Date.now();u=o.createElement(v);u.async=1;u.src=e;
107
- O=o.getElementsByTagName(v)[0];O.parentNode.insertBefore(u,O)
108
- })(window,document,'script','https://static.cloud.coveo.com/coveo.analytics.js/2/coveoua.js') // Replace "2" in the script url with the latest release
109
- coveoua('init', <COVEO_API_KEY>); // Replace <COVEO_API_KEY> with your real key
110
- </script>
111
- ```
105
+ - `event`: A generic event, which has been assembled through different plugin actions.
106
+ - `pageview`: An ecommerce specific pageview event which is automatically populated with the current page context.
107
+
108
+ See the [Send an Event](https://docs.coveo.com/en/l3am0254/coveo-for-commerce/send-an-event) page for more information on the expected payloads for both of these.
112
109
 
113
- To send commerce events, call `coveoua` with the event name. Here is how an [addition to the cart interaction](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-an-addition-to-the-cart) is measured:
110
+ The eCommerce plugin supports adding product data (`ec:addProduct`), product impression data (`ec:addImpression`) as well as setting the [appropriate event action](https://docs.coveo.com/en/l29e0540/coveo-for-commerce/commerce-events-reference#product-action-type-reference) through `ec:setAction`. These calls can be used in series to assemble different types of payloads:
114
111
 
115
- 1. First use the `ec:addProduct` command to include the relevant product data in the event you’re about to send
112
+ - A [product detail view](https://docs.coveo.com/en/3188/coveo-for-commerce/commerce-data-health-implementation-guide#measuring-a-product-details-view)
113
+ - An [addition to the cart](https://docs.coveo.com/en/l3jg0266/coveo-for-commerce/measure-cart-page-events#measure-an-increase-in-item-quantity-in-cart)
114
+ - A [removal from the cart](https://docs.coveo.com/en/l3jg0266/coveo-for-commerce/measure-cart-page-events#measure-a-decrease-in-item-quantity-in-cart)
115
+ - A [cart purchase](https://docs.coveo.com/en/l39m0327/coveo-for-commerce/measure-a-purchase)
116
+ - An [event on a search-driven listing-page](https://docs.coveo.com/en/l41a1037/coveo-for-commerce/measure-events-on-a-listing-or-search-page)
117
+
118
+ As a sample, here is how an [addition to the cart interaction](https://docs.coveo.com/en/l3jg0266/coveo-for-commerce/measure-cart-page-events#measure-an-increase-in-item-quantity-in-cart) is measured:
119
+
120
+ 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
116
121
  ```js
117
122
  coveoua('ec:addProduct', <PRODUCT_DATA>);
118
123
  ```
119
- 2. Then use the `ec:setAction` command to specify that the action done on this data is an addition to the cart:
124
+ 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.
120
125
  ```js
121
126
  coveoua('ec:setAction', 'add');
122
127
  ```
123
- 3. Finally, use the `send` command to send the event to Coveo Usage Analytics.
128
+ 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.
124
129
  ```js
125
130
  coveoua('send', 'event');
126
131
  ```
127
132
 
128
- Refer to the [**Tracking Commerce Events** page](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events) to see how to measure [a product details view](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-a-product-details-view), [an addition to the cart](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-an-addition-to-the-cart), [a removal from the cart](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-a-removal-from-the-cart), [a purchase](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-purchases) or [an event on a search-driven listing-page](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-events-on-a-search-driven-listing-page) in more details.
133
+ ## Linking clientIds across different domains using a URL parameter
129
134
 
130
- All supported actions are also listed in the [**Possible Actions** section of the **Tracking Commerce Events** page](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#possible-actions).
135
+ To help track a visitor across different domains, the library offers functionality to initialize a clientId from a URL query parameter. The query parameter is named `cvo_cid` with value `<clientid>.<timestamp>`. The clientId is encoded without dashes and the timestamp is encoded in seconds since epoch, both to save space in the url. Both are separated by a period. A sample parameter could be `cvo_cid=c0b48880743e484f8044d7c37910c55b.1676298678`. This query parameter will be picked up by the target page if the following conditions hold:
131
136
 
132
- ### Usage (for developers)
137
+ - The target page has a equal or greater version of coveo.analytics.js loaded.
138
+ - The current URL contains a `cvo_cid` query parameter
139
+ - The parameter contains a valid uuid.
140
+ - The parameter contains a valid timestamp, and that timestamp is no more than 120 seconds in the past.
141
+ - The receiving page has specified a list of valid referrers and the current referrer host matches that list, using wildcards, including ports, specified using `coveoua('link:acceptFrom', [<referrers>])`.
133
142
 
134
- You need to provide your own `fetch` API compatible libraries in the global environment (see [Isomorphic TypeScript, fetch, promises, ava and coverage](https://source.coveo.com/2016/05/11/isomorphic-typescript-ava-w-coverage/)).
143
+ Given that you want to ensure the clientId remains consistent when you navigate from a source page on http://foo.com/index.html to a target page http://bar.com/index.html, the following steps are needed.
135
144
 
136
- ```bash
137
- npm install coveo.analytics isomorphic-fetch
145
+ 1. Ensure coveo.analytics.js is loaded on the source page.
146
+ 2. Modify the source page such that whenever a link to the target page is clicked, its `href` is replaced by `coveoua('link:decorate', 'http://bar.com/index.html')`. For example, by creating an onClick event listener on the element or on the page. It's important that the decorated link is generated at the moment the link is clicked, as it will be valid only for a short time after generation.
147
+
148
+ ```html
149
+ <script>
150
+ async function decorate(element) {
151
+ element.href = await coveoua('link:decorate', element.href);
152
+ }
153
+ </script>
154
+ <a onclick="decorate(this)" href="http://bar.com/index.html">Navigate</a>>
138
155
  ```
139
156
 
140
- ```js
141
- import {CoveoAnalyticsClient} from 'coveo.analytics';
157
+ 3. Ensure coveo.analytics.js is loaded on the target page.
158
+ 4. Ensure that the target page allows reception of links from the source page by adding `coveoua('link:acceptFrom', ['foo.com']);` immediately after script load.
142
159
 
143
- // Create an API client
144
- const client = new CoveoAnalyticsClient({token: 'YOUR_API_KEY'});
145
- // Send your event
146
- client.sendCustomEvent({
147
- eventType: 'dog',
148
- eventValue: 'Hello! Yes! This is Dog!',
149
- language: 'en',
150
- });
160
+ # Developer information
161
+
162
+ Information for contributors or Coveo developers developing or integrating coveoua.
163
+
164
+ ## Setup
165
+
166
+ ```bash
167
+ git clone
168
+ npm install
169
+ npm run build
151
170
  ```
152
171
 
153
- ## Using React Native
172
+ ## Running and observing the code
173
+
174
+ There are two ways to run your code locally:
175
+
176
+ 1. Run `npm run start` and open your browser on http://localhost:9001
177
+
178
+ 2. Debugging through VSCode debugger with the `Debug: Start Debugging` command, using the `Launch Chrome` configuration.
179
+
180
+ 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.
181
+
182
+ ## Running tests
183
+
184
+ 1. From the command line through `npm run test`.
185
+ 2. Debugging through VSCode debugger with the `Debug: Start Debugging` command, using the `Jest All` configuration.
186
+
187
+ ## Storage and persistence
188
+
189
+ Coveo.analytics.js tracks interactions from the same browser client, through a client side provided uuid called a `clientId`. This clientId is initialized on first use and there are multiple options for persisting it's value:
190
+
191
+ - Cookie storage, which supports top level domain storage. This means that the clientId for a.foo.com will be identical to the one on b.foo.com.
192
+ - Local storage, which allows to store much more information client side, but has the drawback of not being able to access data across multiple top level domains.
193
+ - Session storage, which has roughly the same limitation and capability as Local storage, except that it is cleared when the web browser tab is closed.
194
+
195
+ By default, coveoua will use both local storage and cookie storage to persist its clientId. If your environment does not support local persistence, it's possible to write your own storage abstraction.
196
+
197
+ ## Using coveo.analytics.js with React Native
154
198
 
155
- Since React Native does not run inside a browser, it cannot use cookies or the local/session storage that modern browsers provide.
156
- You must provide your own Storage implementation. Thankfully, there exist multiple packages to store data:
199
+ Since React Native does not run inside a browser, it cannot use cookies or the local/session storage that modern browsers provide. You must provide your own Storage implementation. Thankfully, there exist multiple packages to store data:
157
200
 
158
201
  - [React native community AsyncStorage](https://github.com/react-native-async-storage/async-storage) (recommended)
159
202
  - [React native AsyncStorage](https://reactnative.dev/docs/asyncstorage) (deprecated)
160
203
  - [Expo Secure Store](https://docs.expo.dev/versions/latest/sdk/securestore/)
161
204
 
205
+ A sample React native storage class implementation could look as follows
206
+
162
207
  ```js
163
208
  import {CoveoAnalyticsClient, ReactNativeRuntime} from 'coveo.analytics/react-native';
164
209
  // Use any React native storage library or implement your own.
@@ -177,7 +222,7 @@ class ReactNativeStorage implements WebStorage {
177
222
  }
178
223
  }
179
224
 
180
- // Create an API client
225
+ // Create an API client with a specific runtime
181
226
  const client = new CoveoAnalyticsClient({
182
227
  token: 'YOUR_API_KEY',
183
228
  runtimeEnvironment: new ReactNativeRuntime({
@@ -185,6 +230,7 @@ const client = new CoveoAnalyticsClient({
185
230
  storage: new ReactNativeStorage(),
186
231
  }),
187
232
  });
233
+
188
234
  // Send your event
189
235
  client.sendCustomEvent({
190
236
  eventType: 'dog',
@@ -193,47 +239,15 @@ client.sendCustomEvent({
193
239
  });
194
240
  ```
195
241
 
196
- ### Choosing the type of storage for page view events
242
+ ## Conformance
197
243
 
198
- There are 3 available storage types you can use to store view events client side.
199
-
200
- - Cookie storage, which supports top level domain storage. This means that events from a.foo.com will be available from b.foo.com. Cookies have the limitation of not being able to store a lot of data, especially if your stored page views are long.
201
-
202
- - Local storage, which allows to store much more information client side, but has the drawback of not being able to access data across multiple top level domains.
203
-
204
- - Session storage, which has roughly the same limitation and capability as Local storage, except that it is cleared when the web browser tab is closed.
244
+ Chrome, Firefox, Safari, Edge. IE11 support on a reasonable-effort basis.
205
245
 
206
- By default, the local storage option will automatically be chosen as the default storage, unless manually specified.
207
-
208
- ### Contributing
246
+ ## Contributing
209
247
 
210
248
  See [CONTRIBUTING.md](CONTRIBUTING.md)
211
249
 
212
- #### Setup
213
-
214
- ```bash
215
- git clone
216
- npm install
217
- npm run build
218
- ```
219
-
220
- #### Running the project
221
-
222
- There are two ways to run your code locally:
223
-
224
- 1. run `npm start` and open your browser on http://localhost:9001
225
-
226
- 2. run through VSCode debugger with the `Debug: Start Debugging` command, using the `Launch Chrome` configuration.
227
-
228
- 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.
229
-
230
- #### Running tests
231
-
232
- ```bash
233
- npm run test
234
- ```
235
-
236
- ### License
250
+ ## License
237
251
 
238
252
  MIT license (see [LICENSE](LICENSE)).
239
253