@empathyco/x-components 3.0.0-alpha.86 → 3.0.0-alpha.89

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/CHANGELOG.md +22 -0
  2. package/core/index.js.map +1 -1
  3. package/design-system/full-theme.css +34 -34
  4. package/docs/API-reference/api/x-adapter.searchresponse.banners.md +1 -1
  5. package/docs/API-reference/api/x-adapter.searchresponse.md +5 -5
  6. package/docs/API-reference/api/x-adapter.searchresponse.partialresults.md +1 -1
  7. package/docs/API-reference/api/x-adapter.searchresponse.promoteds.md +1 -1
  8. package/docs/API-reference/api/x-adapter.searchresponse.redirections.md +1 -1
  9. package/docs/API-reference/api/x-adapter.searchresponse.spellcheck.md +1 -1
  10. package/docs/API-reference/api/x-components.increasepageappendingresults.md +2 -2
  11. package/docs/API-reference/api/x-components.increasepageappendingresultswire.md +13 -0
  12. package/docs/API-reference/api/x-components.md +7 -3
  13. package/docs/API-reference/api/x-components.resetstate.md +13 -0
  14. package/docs/API-reference/api/{x-components.saveorigin.md → x-components.saveidentifierresultsorigin.md} +2 -2
  15. package/docs/API-reference/api/x-components.savesearchorigin.md +13 -0
  16. package/docs/API-reference/api/x-components.savesearchresponse.md +13 -0
  17. package/docs/API-reference/api/x-components.searchactions.md +1 -0
  18. package/docs/API-reference/api/x-components.searchactions.savesearchresponse.md +24 -0
  19. package/docs/API-reference/api/x-components.setsearchurlparams.md +13 -0
  20. package/docs/API-reference/api/x-components.snippetconfigextraparams.excludedextraparams.md +13 -0
  21. package/docs/API-reference/api/x-components.snippetconfigextraparams.md +1 -0
  22. package/docs/API-reference/components/extra-params/x-components.snippet-config-extra-params.md +4 -3
  23. package/docs/build-search-ui/README.md +39 -34
  24. package/docs/build-search-ui/web-archetype-development-guide.md +28 -27
  25. package/docs/build-search-ui/web-archetype-integration-guide.md +159 -98
  26. package/docs/build-search-ui/web-how-to-use-x-components-guide.md +28 -37
  27. package/docs/build-search-ui/{x-architecture/README.md → web-x-architecture.md} +4 -52
  28. package/docs/build-search-ui/{web-x-components-integration-guide.md → web-x-components-development-guide.md} +27 -30
  29. package/identifier-results/index.js +1 -1
  30. package/js/components/decorators/injection.decorators.js.map +1 -1
  31. package/js/index.js +7 -2
  32. package/js/index.js.map +1 -1
  33. package/js/plugins/x-plugin.mixin.js.map +1 -1
  34. package/js/store/utils/fetch-and-save-action.utils.js +4 -2
  35. package/js/store/utils/fetch-and-save-action.utils.js.map +1 -1
  36. package/js/store/utils/store-emitters.utils.js.map +1 -1
  37. package/js/x-modules/empathize/components/empathize.vue.js.map +1 -1
  38. package/js/x-modules/empathize/components/empathize.vue_rollup-plugin-vue_script.vue.js +2 -2
  39. package/js/x-modules/empathize/components/empathize.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  40. package/js/x-modules/extra-params/components/snippet-config-extra-params.vue.js.map +1 -1
  41. package/js/x-modules/extra-params/components/snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js +15 -129
  42. package/js/x-modules/extra-params/components/snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  43. package/js/x-modules/next-queries/components/next-queries-list.vue.js.map +1 -1
  44. package/js/x-modules/next-queries/components/next-queries-list.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  45. package/js/x-modules/search/store/actions/fetch-and-save-search-response.action.js +2 -19
  46. package/js/x-modules/search/store/actions/fetch-and-save-search-response.action.js.map +1 -1
  47. package/js/x-modules/search/store/actions/save-search-response.action.js +32 -0
  48. package/js/x-modules/search/store/actions/save-search-response.action.js.map +1 -0
  49. package/js/x-modules/search/store/module.js +2 -0
  50. package/js/x-modules/search/store/module.js.map +1 -1
  51. package/js/x-modules/search/wiring.js +3 -9
  52. package/js/x-modules/search/wiring.js.map +1 -1
  53. package/js/x-modules/url/components/url-handler.vue.js.map +1 -1
  54. package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js +2 -1
  55. package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js.map +1 -1
  56. package/package.json +4 -4
  57. package/report/x-adapter.api.json +10 -10
  58. package/report/x-components.api.json +238 -51
  59. package/report/x-components.api.md +22 -10
  60. package/search/index.js +6 -1
  61. package/types/plugins/x-plugin.mixin.d.ts.map +1 -1
  62. package/types/store/utils/fetch-and-save-action.utils.d.ts.map +1 -1
  63. package/types/x-modules/extra-params/components/snippet-config-extra-params.vue.d.ts +5 -4
  64. package/types/x-modules/extra-params/components/snippet-config-extra-params.vue.d.ts.map +1 -1
  65. package/types/x-modules/identifier-results/store/actions/index.d.ts +5 -0
  66. package/types/x-modules/identifier-results/store/actions/index.d.ts.map +1 -0
  67. package/types/x-modules/identifier-results/store/index.d.ts +1 -4
  68. package/types/x-modules/identifier-results/store/index.d.ts.map +1 -1
  69. package/types/x-modules/next-queries/components/next-queries-list.vue.d.ts +1 -0
  70. package/types/x-modules/next-queries/components/next-queries-list.vue.d.ts.map +1 -1
  71. package/types/x-modules/search/store/actions/fetch-and-save-search-response.action.d.ts.map +1 -1
  72. package/types/x-modules/search/store/actions/index.d.ts +8 -0
  73. package/types/x-modules/search/store/actions/index.d.ts.map +1 -0
  74. package/types/x-modules/search/store/actions/save-search-response.action.d.ts +12 -0
  75. package/types/x-modules/search/store/actions/save-search-response.action.d.ts.map +1 -0
  76. package/types/x-modules/search/store/getters/index.d.ts +3 -0
  77. package/types/x-modules/search/store/getters/index.d.ts.map +1 -0
  78. package/types/x-modules/search/store/index.d.ts +2 -4
  79. package/types/x-modules/search/store/index.d.ts.map +1 -1
  80. package/types/x-modules/search/store/module.d.ts.map +1 -1
  81. package/types/x-modules/search/store/types.d.ts +6 -0
  82. package/types/x-modules/search/store/types.d.ts.map +1 -1
  83. package/types/x-modules/search/wiring.d.ts +2 -8
  84. package/types/x-modules/search/wiring.d.ts.map +1 -1
  85. package/types/x-modules/url/components/url-handler.vue.d.ts.map +1 -1
  86. package/docs/API-reference/api/x-components.setpagesize.md +0 -13
@@ -1,30 +1,26 @@
1
1
  ---
2
- title: Interface X Archetype Development
2
+ title: Develop using Interface X Archetype
3
3
  tags:
4
4
  - development
5
5
  - archetype
6
- - X Components archetype development
6
+ - X archetype development
7
7
  - x development
8
8
  - interface x
9
9
  - x components
10
10
  - archetype development
11
- - archetype integration
12
11
  ---
13
12
 
14
- # Interface X Archetype Development
13
+ # Develop using Interface X Archetype
15
14
 
16
- In this tutorial, you’ll learn how to start developing with the Interface X Archetype
17
- project in your store in a matter of minutes, so you can create a search interface layer based on
18
- predefined features and components.
15
+ In this tutorial, you’ll learn how to build a search and discovery layer based on predefined
16
+ features and components in a matter of minutes using the Interface X Archetype.
19
17
 
20
18
  For this tutorial, the Empathy Search API is used, but you can use any search API. This guide
21
19
  requires knowledge of JavaScript and Vue.js.
22
20
 
23
21
  ::: note Before you begin
24
22
 
25
- To integrate Interface X Archetype as a search UI layer, you need:
26
-
27
- <br/>
23
+ To use Interface&nbsp;X&nbsp;Archetype as a search UI layer, you need:
28
24
 
29
25
  - **Empathy Search API** (or any search API that you use to retrieve search data).
30
26
  - **Empathy Search Adapter** to communicate with the Empathy Search API (or any search adapter to
@@ -32,10 +28,10 @@ To integrate Interface&nbsp;X&nbsp;Archetype as a search UI layer, you need:
32
28
 
33
29
  :::
34
30
 
35
- ##### Steps to start developing in a X Archetype project:
31
+ ##### Steps to build a search layer using the X Archetype project:
36
32
 
37
33
  1. **Clone** the X&nbsp;Archetype project and **initialize** your repository.
38
- 2. Install the **project dependencies** and execute the project.
34
+ 2. Install the **project dependencies** and run the project development server.
39
35
  3. Configure the **search adapter**.
40
36
  4. Configure the **xPlugin**.
41
37
 
@@ -109,8 +105,8 @@ Interface&nbsp;X&nbsp;Archetype repository.
109
105
  Before using your project, configure the Empathy Search Adapter in the
110
106
  `x-archetype/src/adapter/adapter.ts` file, using the Empathy Adapter Builder to make it work with
111
107
  the Empathy Search API. The Empathy Search Adapter contains a sample configuration for setup, global
112
- configurations, or mappers that points to a demo environment. You need to make some adjustments in
113
- the configuration according to the search features you use in your project.
108
+ configurations, or mappers that points to a demo environment. You need to adjust the configuration
109
+ according to the search features you use in your project.
114
110
 
115
111
  Export the required search adapter with your configuration as you will need it for the search
116
112
  [xPlugin configuration](#4-configure-the-plugin).
@@ -126,13 +122,18 @@ For detailed information about other configuration options in the Empathy Search
126
122
 
127
123
  Although you configure the values for the `instance`, `language`, `scope`, and `endpoint` options
128
124
  when integrating the project, you can still change these values when the project is deployed. Use
129
- the `/x-archetype/public/snippet-script.js` file to perform hot changes for `lang`, `store`,
130
- `device`, and `catalog` parameters.
125
+ the `/x-archetype/public/snippet-script.js` file to initialize values for `lang`, `store`, `device`,
126
+ and `catalog` parameters.
131
127
 
132
128
  For example, you may configure the adapter to use EN as `lang` so that when you search, the results
133
129
  are displayed in English. However, if you want to deploy the application in Spain, you want the
134
130
  `lang` to be ES. You change these values in the `snippet-script.js` file.
135
131
 
132
+ </br>
133
+
134
+ For detailed information, see
135
+ [Snippet configuration](web-archetype-integration-guide.md#snippet-configuration)
136
+
136
137
  :::
137
138
 
138
139
  ## 4. Configure the plugin
@@ -167,21 +168,21 @@ new XInstaller(installXOptions).init({
167
168
  });
168
169
  ```
169
170
 
170
- ---
171
+ ::: develop Next steps
171
172
 
172
- ### Next steps
173
+ Once you have your Interface&nbsp;X&nbsp;Archetype project, you're ready to **integrate** it in your
174
+ store or **extend** the search and discovery experience to meet your business needs:
173
175
 
174
- Once you have your Interface&nbsp;X&nbsp;Archetype project, you're ready to integrate it in your
175
- store, or extend the search and discovery experience to meet your business needs:
176
-
177
- - [Integrate an Interface&nbsp;X&nbsp;Archetype project into an existing website](web-archetype-integration-guide.md).
178
- - Change the configuration of [X Components](web-how-to-use-x-components-guide.md) or create new
179
- ones.
176
+ - [**Integrate an Interface&nbsp;X&nbsp;Archetype project** into an existing website](web-archetype-integration-guide.md).
177
+ - Change the **configuration of [X&nbsp;Components](web-how-to-use-x-components-guide.md)** or
178
+ create new ones.
180
179
  - Adapt the
181
- [design system](https://github.com/empathyco/x/blob/main/packages/x-components/contributing/design-system.md)
180
+ **[design system](https://github.com/empathyco/x/blob/main/packages/x-components/contributing/design-system.md)**
182
181
  to your branding.
183
182
  - Manage
184
- [internationalization options](https://github.com/empathyco/x-archetype/blob/main/docs/i18n.md) to
185
- support different languages.
183
+ **[internationalization options](https://github.com/empathyco/x-archetype/blob/main/docs/i18n.md)**
184
+ to support different languages.
185
+
186
+ :::
186
187
 
187
188
  <!-- add links to design system and internationalization content pages when ready-->
@@ -3,48 +3,64 @@ title: Integrate Interface X Archetype into an existing website
3
3
  tags:
4
4
  - integration
5
5
  - archetype
6
- - X Components archetype integration
6
+ - archetype integration
7
7
  - x integration
8
8
  - interface x
9
9
  - x components
10
- - archetype integration
11
10
  ---
12
11
 
13
12
  # Integrate Interface X Archetype into an existing website
14
13
 
15
- Once you have finished developing or extending your search interface using the
16
- Interface&nbsp;X&nbsp;Archetype project you will probably want to integrate it into your current
17
- store.
14
+ In this tutorial, you'll learn how to integrate the Interface&nbsp;X&nbsp;Archetype project in your
15
+ commerce store in a matter of minutes. You can use the X&nbsp;Archetype **as is** or you can
16
+ **[extend](web-archetype-development-guide.md)** the search and discovery interface experience to
17
+ meet your business needs.
18
+
19
+ To integrate the Interface&nbsp;X&nbsp;Archetype layer in your commerce store, just **load** the
20
+ generated Interface&nbsp;X JavaScript file and **initialize** it.
21
+
22
+ ::: note IMPORTANT If the X&nbsp;Archetype script is hosted by Empathy, all the X resources are
23
+ provided by a CDN through the following environment URLs:
24
+
25
+ - **Production**: https://x.empathy.co/{INSTANCE}/app.js
26
+ - **Staging**: https://x.staging.empathy.co/{INSTANCE}/app.js
18
27
 
19
- The integration is a 2-steps process:
28
+ Where `{INSTANCE}` is the name of your commerce store. If you require any assistance, contact
29
+ [Empathy Support](mailto:support@empathy.co).
20
30
 
21
- - Load Interface&nbsp;X script.
22
- - Initialise the Interface&nbsp;X.
31
+ :::
32
+
33
+ Depending on your business needs, Interface&nbsp;X supports two initialization types:
23
34
 
24
- Depending on your business needs, there are 2 different ways of making this integration process:
25
- auto initialising, or initialising on demand.
35
+ - **[Automatic initialization](#initializing-interface-x-project-automatically)**
36
+ - **[On-demand initialization](#initializing-interface-x-project-on-demand)**
26
37
 
27
- ::: note Frameworks & Libraries Integration
38
+ ::: develop Frameworks & libraries integration
28
39
 
29
- As the Archetype is bundled including all the needed dependencies, then it is possible to integrate
30
- on top of any existing website, regardless of the technologies that it has been built with:
31
- **React**, **Vue**, **Svelte**...
40
+ You can integrate the X&nbsp;Archetype into any existing website regardless of the technology used
41
+ (i.e. **React**, **Vue**, **Svelte**, etc.), as the bundle includes all the dependencies you need
42
+ for a correct implementation.
32
43
 
33
44
  :::
34
45
 
35
- ## Auto initialisation
46
+ ## Initializing Interface X project automatically
47
+
48
+ Automatic initialization is the easiest way to integrate the Interface&nbsp;X project in a website.
36
49
 
37
- This is the easiest way to integrate the Interface&nbsp;X project in a website. The way to do so is
38
- by first defining an initialisation object or function, and then loading the Interface&nbsp;X
39
- script.
50
+ You first **configure the JavaScript snippet** to define either an initialization object or a
51
+ function. Then, you **load and initialize the Interface&nbsp;X script**.
40
52
 
41
- ### 1. Add a snippet configuration
53
+ ### 1. Add the snippet configuration
42
54
 
43
- The snippet configuration is needed by Interface&nbsp;X to know the API it must use, the language or
44
- currency it should display the texts in, or tagging parameters to enrich the data and provide better
45
- insights on how users search.
55
+ First, configure the JavaScript snippet to define multiple initialization options, i.e. the API to
56
+ use, the language or currency to display, or even the tagging parameters to collect search-related
57
+ data to generate conversational search features and analytics.
46
58
 
47
- If your configuration values are easy to retrieve or static, you can simply use an object.
59
+ Depending on whether you are retrieving **static or dynamic configuration values** in your
60
+ [snippet configuration](#snippet-configuration), you define an **object** or a **function** to
61
+ initialize Interface&nbsp;X:
62
+
63
+ - To retrieve **static** configuration values, define an initialization object as follows:
48
64
 
49
65
  ```js
50
66
  window.initX = {
@@ -57,8 +73,7 @@ window.initX = {
57
73
  };
58
74
  ```
59
75
 
60
- Otherwise, if you need to retrieve values dynamically, or execute any kind of logic before the
61
- initialisation you can also use a function:
76
+ - To retrieve configuration values **dynamically**, use an initialization function:
62
77
 
63
78
  ```js
64
79
  window.initX = function () {
@@ -73,16 +88,23 @@ window.initX = function () {
73
88
  };
74
89
  ```
75
90
 
76
- You can read more about the [Snippet Configuration](#snippet-configuration) below.
91
+ ::: note
77
92
 
78
- ### 2. Load the Interface&nbsp;X script
93
+ You can change the snippet configuration values once the project is deployed. Use the
94
+ `/x-archetype/public/snippet-script.js` file to perform hot changes for the snippet parameters. For
95
+ more information on the supported parameters, check out
96
+ [Snippet configuration](#snippet-configuration).
79
97
 
80
- Once you have defined your snippet configuration either as an object or a function, you can insert
81
- the Interface&nbsp;X script. This script is hosted in a URL of this shape
98
+ :::
99
+
100
+ ### 2. Load the script
101
+
102
+ Once the snippet configuration is ready, add the Interface&nbsp;X script to your webpage. The script
103
+ is hosted in a URL with the following syntax:
82
104
  `https://x.<environment?>.empathy.co/<instance>/app.js`.
83
105
 
84
- For example, supposing that `my-store` is the instance, and you want to load the production script,
85
- you can add to your HTML the following scripts.
106
+ For example, to load the production version script for the instance _my-store_, you need to add the
107
+ following scripts to your HTML:
86
108
 
87
109
  ```html
88
110
  <script>
@@ -98,14 +120,14 @@ you can add to your HTML the following scripts.
98
120
  <script src="https://x.empathy.co/my-store/app.js"></script>
99
121
  ```
100
122
 
101
- Or if you want to load the staging version, you just have to change the script `src` attribute to
102
- point to the staging environment:
123
+ In the case you want to load the script for the staging environment, you just modify the script
124
+ attribute `src` so that it points to the staging environment as follows:
103
125
 
104
126
  ```html
105
127
  <script>
106
128
  window.initX = {
107
129
  instance: 'my-store',
108
- env: 'live', // Note that here you are using production API with the staging version of Interface X
130
+ env: 'live', // Note that here you are using a production API with the staging version of Interface X
109
131
  scope: 'desktop',
110
132
  lang: 'en',
111
133
  currency: 'EUR',
@@ -115,40 +137,41 @@ point to the staging environment:
115
137
  <script src="https://x.staging.empathy.co/my-store/app.js"></script>
116
138
  ```
117
139
 
118
- This way, when the Interface&nbsp;X JavaScript file is loaded, it will retrieve the configuration
119
- from the object or function that you defined before. Nothing else is required.
140
+ Thus, when the Interface&nbsp;X JavaScript file is loaded, it retrieves the configuration from the
141
+ defined object or function.
120
142
 
121
- ## Initialise on demand
143
+ ## Initializing Interface X project on demand
122
144
 
123
- If you want to have more manual control on when the Interface&nbsp;X is loaded, you can still do so.
124
- Instead of defining an initialisation object or function upfront like in
125
- [Auto initialisation](#auto-initialisation), you can invoke a function with these options that will
126
- initialise Interface&nbsp;X.
145
+ On-demand initialization allows you to control when Interface&nbsp;X is loaded.
127
146
 
128
- ### 1. Load the Interface&nbsp;X script
147
+ You first **load the Interface&nbsp;X script**. Then, you invoke a function with the required
148
+ initialization options to **initialize Interface&nbsp;X**.
129
149
 
130
- First, load the Interface&nbsp;X script. As you may already know, it is hosted in a URL of this
131
- shape: `https://x.<environment?>.empathy.co/<instance>/app.js`.
150
+ ### 1. Load the script
151
+
152
+ Add the Interface&nbsp;X script hosted in a URL with the following syntax:
153
+ `https://x.<environment?>.empathy.co/<instance>/app.js`.
132
154
 
133
- For example, supposing that `my-store` is the instance, and you want to load the production script,
134
- you can add to your HTML the following scripts:
155
+ For example, to load the production version script for the instance _my-store_, you need to add the
156
+ following script to your HTML:
135
157
 
136
158
  ```html
137
159
  <script src="https://x.empathy.co/my-store/app.js"></script>
138
160
  ```
139
161
 
140
- For loading the staging version simply change the `src` attribute to the staging environment:
162
+ In the case you want to load the script for the staging environment, you just modify the script
163
+ attribute `src` so that it points to the staging environment as follows:
141
164
 
142
165
  ```html
143
166
  <script src="https://x.staging.empathy.co/my-store/app.js"></script>
144
167
  ```
145
168
 
146
- ### 2. Initialise Interface&nbsp;X
169
+ ### 2. Initialize Interface&nbsp;X
147
170
 
148
- Loading the Interface&nbsp;X script and not providing a `initX` configuration will make it create an
149
- initialisation function in the [X API](#x-api) object that you can invoke whenever you want. In this
150
- example we are calling it immediately after loading the Interface&nbsp;X script, but it can be
151
- invoked at any time. Note that you should only call this function **once**.
171
+ Since no initialization configuration was defined when loading the script, you need to **invoke the
172
+ initialization function** created automatically in the
173
+ [X API](https://github.com/empathyco/x/blob/main/packages/x-components/src/x-installer/api/base-api.ts)
174
+ object to provide the initialization options:
152
175
 
153
176
  ```html
154
177
  <script src="https://x.empathy.co/my-store/app.js"></script>
@@ -164,30 +187,70 @@ invoked at any time. Note that you should only call this function **once**.
164
187
  </script>
165
188
  ```
166
189
 
167
- ## Snippet configuration
190
+ For this example, the initialization function is called immediately after loading the script, but it
191
+ can be called at any time. Note that you need to call this function only **once**.
192
+
193
+ ::: interact
194
+
195
+ Check out the [X&nbsp;API](#x-api) section to learn more about the functions and parameters
196
+ supported.
197
+
198
+ :::
199
+
200
+ ## Notes on X Archetype integration
201
+
202
+ To successfully integrate Interface&nbsp;X in your commerce store using the X&nbsp;Archetype, check
203
+ out further information about:
204
+
205
+ - **Initialization options** supported in [snippet configuration](#snippet-configuration)
206
+ - **[Callbacks and X&nbsp;event&nbsp;types](#callbacks-and-interface-x-events-types)** available to
207
+ subscribe to when initializing
208
+ - **Functions supported by the [X&nbsp;API object](#x-api)** to initialize Interface&nbsp;X
209
+
210
+ #### Snippet configuration
211
+
212
+ The
213
+ [snippet configuration](https://github.com/empathyco/x-archetype/blob/main/public/snippet-script.js)
214
+ allows you to configure multiple initialization options for the Interface&nbsp;X project such as
215
+ language, currency, and shopper's personal data consent. The snippet configuration supports the
216
+ following configuration options:
168
217
 
169
- The snippet configuration allows you to configure certain parts of the Interface&nbsp;X project like
170
- language, the currency, inform whether the user has given us his consent to process personal data.
218
+ | Name | Type | Description |
219
+ | ------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
220
+ | `instance` | `string` | _Required._ ID of the API client instance. It's provided by Empathy. |
221
+ | `env` | `'live'` &#124; `'staging'` | _Optional_. API environment to use. You can use the Interface&nbsp;X production version with the staging API, and vice versa. |
222
+ | `scope` | `string` | _Optional_. Context where the search interface is executed, i.e. `mobile`, `mobile-app`, `tablet`, `desktop`. |
223
+ | `lang` | `string` | _Required._ Language to use. By default, it's used for both the frontend and the API requests. |
224
+ | `searchLang` | `string` | _Optional_. Language to use for the API requests **only**. |
225
+ | `consent` | `boolean` | _Required._ Determines whether the shopper has accepted the use of cookies so that the `sessionId` is sent to the Empathy's Search and Tagging APIs or not. |
226
+ | `documentDirection` | `'ltr'` &#124; `'rtl'` | _Optional_. Writing direction script that the X Components should, i.e. left-to-right or right-to-left. |
227
+ | `currency` | `string` | _Required._ Currency identifier to configure how prices are displayed. |
228
+ | [`callbacks`](#callbacks-and-interface-x-events-types) | `Record<XEventName, (payload: XEventPayload<Event>, metadata: WireMetadata) => void` | _Optional_. Callback record where the _key_ is the event to listen and the _value_ is the callback to be executed whenever the event is emitted. E.g. to listen to the `UserAcceptedAQuery` event: `{ UserAcceptedAQuery({ eventPayload }) { console.log('UserAcceptedAQuery', eventPayload); }` |
229
+ | `isSpa` | `boolean` | _Optional_. Enables single-page application model. You set it to `true` when the X&nbsp;Archetype runs on top of a SPA website. |
230
+ | `<extra parameters>` | `any` | _Optional_. Any other parameters to sent to the API calls directly. E.g. to filter the search catalogue with a warehouse parameter, you add `warehouse: <your-warehouse-identifier>` to the snippet configuration. |
171
231
 
172
- | Name | Type | Required | Description |
173
- | ----------------------- | ------------------------------------------------------------------------------------ | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
174
- | instance | `string` | ✅ | The identifier of the API client instance. Should be provided by Empathy |
175
- | env | `'live'` &#124; `'staging'` | | The API environment to use. Note that you can use the production version of your Interface&nbsp;X with the staging API, or viceversa. |
176
- | scope | `string` | | The context name where the search interface is being executed. I.e. `mobile`, `mobile-app`, `tablet`, `desktop` |
177
- | lang | `string` | ✅ | The language to use. By default this lang is used for both the front-end and the API requests |
178
- | searchLang | `string` | | A language to use only for the API requests |
179
- | consent | `boolean` | ✅ | Used to let X know whether the user has accepted the usage of cookies and therefore the sessionId can be used and sent to the Search and Tagging API. If this parameter is configured with false value, then the sessionId in not generated nor sent to the Tagging API. No consent means the wisdom of the crowd signals (Related Tags, Next Queries, etc.) will not be inferred from that session. This parameter should be set to true as soon as the user accepts the usage of Customer cookies but note that Empathy not uses any cookie in its libraries, although we tie the cookie acceptance to the sessionID generation in Local Storage. If accepting the cookies does not trigger a page reload, please consider using `window.initX.consent = true` to update the consent parameter so that the current session is tracked already. |
180
- | documentDirection | `'ltr'` &#124; `'rtl'` | | The writing direction that the X Components should use |
181
- | currency | `string` | ✅ | The currency identifier. Used to configure how prices are shown |
182
- | [callbacks](#callbacks) | `Record<XEventName, (payload: XEventPayload<Event>, metadata: WireMetadata) => void` | | A record of callbacks where the key is the event to listen, and the value is the callback to be executed whenever the event is emitted. For example, to listen to the `UserAcceptedAQuery` event: `{ UserAcceptedAQuery({ eventPayload }) { console.log('UserAcceptedAQuery', eventPayload); }` |
183
- | isSpa | `boolean` | | True when the X Components archetype is being run on top of an SPA. |
184
- | &lt;extra parameters> | `any` | | Any other parameter to be sent directly to the API calls. For example, some times is needed to filter the search catalog with a warehouse parameter. In that case you can just add `warehouse: <your-warehouse-identifier>` to the snippet config. |
232
+ ::: note Consent parameter
233
+
234
+ When the `Consent` parameter is set to `false`, the `sessionId` is not generated nor sent to the
235
+ Tagging API. Only shoppers' behavioral data (wisdom of the crowd) is inferred from the current
236
+ session. The `consent` parameter is set to `true` as soon as the shopper accepts the use of cookies.
237
+ If page reload is not triggered after accepting cookies, update the `consent` parameter
238
+ (`window.initX.consent = true`) to start tracking the current session.
239
+
240
+ </br>
241
+
242
+ Although cookie acceptance is bound to the generation of the `sessionID` in local storage, Empathy
243
+ does **not use any cookies** in its libraries.
244
+
245
+ :::
185
246
 
186
- ### Callbacks
247
+ #### Callbacks and Interface X events types
187
248
 
188
- As the callbacks are a powerful tool in the initialisation options, we provide this section to get
189
- deep in their use. This is an example of initialisation providing callbacks to subscribe to certain
190
- events.
249
+ You can use a **callback** to subscribe to specific **X&nbsp;events&nbsp;types** to perform
250
+ particular actions when triggered.
251
+
252
+ For example, you subscribe to the `UserClickedResultAddToCart` event to add a product result to the
253
+ shopping cart:
191
254
 
192
255
  ```html
193
256
  <script src="https://x.empathy.co/my-store/app.js"></script>
@@ -211,29 +274,27 @@ events.
211
274
  </script>
212
275
  ```
213
276
 
214
- In this example we are subscribing to `UserAcceptedAQuery` and `UserClickedResultAddToCart` so in
215
- this way we can perform an action inside our application when these events are triggered. Even
216
- though we have subscribed to two events, as Interface X Components is an event based architecture
217
- there are more than one hundred of events available to be subscribed to. The complete list is not
218
- yet part of this documentation, but you may access to the
219
- [XEventsTypes](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)
220
- where all of them are defined.
221
-
222
- ::: note
223
-
224
- The XEventsTypes are those that can be triggered from different modules inside the X Components, but
225
- have in mind that every module has its own sort of components. So have a look to DeviceXEvents,
226
- EmpathizeXEvents, SearchBoxXEvents, etc.
227
-
228
- :::
229
-
230
- ## X API
231
-
232
- The X API allows your website to communicate with Interface X. It is a set of utilities that helps
233
- to integrate Interface X into your website.
234
-
235
- | Function | Parameters | Description |
236
- | ---------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
237
- | init | - [Snippet Configuration](#snippet-configuration) - The initialisation options | [Initialises Interface X on demand](#initialise-on-demand). |
238
- | search | - query (Optional) - The query to open Interface&nbsp;X with | Opens Interface&nbsp;X and triggers a search with the given query. |
239
- | setSnippetConfig | - [Snippet Configuration](#snippet-configuration) - The Initialisation options | Changes the options and all components react to the changes. Useful, for example, to change both search engine and displayed language without reloading the page. |
277
+ Interface&nbsp;X is built on an [event-based architecture](web-x-architecture.md). There are more
278
+ than one hundred of events available to subscribe to via callbacks to trigger different actions in
279
+ your app. Check out the complete
280
+ **[X&nbsp;events types list](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts)**
281
+ in the open source repository in GitHub.
282
+
283
+ X&nbsp;events types can be triggered from different modules in the X&nbsp;Components project.
284
+ However, every module has its own sort of components (e.g. Empathize X events, Search Box X events,
285
+ etc.). See the corresponding `events.types.ts` file for each module in the
286
+ [X&nbsp;Components library in GitHub](https://github.com/empathyco/x/tree/main/packages/x-components/src/x-modules).
287
+
288
+ #### X API
289
+
290
+ The
291
+ [X&nbsp;API](https://github.com/empathyco/x/blob/main/packages/x-components/src/x-installer/api/base-api.ts)
292
+ object allows your commerce store to communicate with Interface&nbsp;X. It supports multiple
293
+ functions to integrate Interface&nbsp;X in your website.
294
+
295
+ | Function | Parameters | Description |
296
+ | ------------------ | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
297
+ | `init` | [snippet configuration params](#snippet-configuration) - _Required_. Initialization options | [Initializes Interface&nbsp;X on demand](#initializing-interface-x-project-on-demand). |
298
+ | `search` | `query` - _Optional_. Query to open Interface&nbsp;X | Executes Interface&nbsp;X and triggers a search with the given query. |
299
+ | `setSnippetConfig` | [snippet configuration params](#snippet-configuration) - _Required_. Initialization options | Changes initialization options so that all components react to the changes, i.e. changing both search engine and language without reloading the page. |
300
+ | `addProductToCart` | `productId` - _Optional._ Id of the product added to cart | Sends tracking of the `AddToCart` event to the [Empathy Tagging microservice](https://docs.empathy.co/develop-empathy-platform/capture-interaction-signals/tagging-api-guide.html) for the product displayed on screen. This function is called from the product detail page (PDP) when the shopper clicks on the add-to-cart button. If the `productId` is not provided, the URL detects whether the shopper found the product via a search session or not. |