@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.
- package/CHANGELOG.md +22 -0
- package/core/index.js.map +1 -1
- package/design-system/full-theme.css +34 -34
- package/docs/API-reference/api/x-adapter.searchresponse.banners.md +1 -1
- package/docs/API-reference/api/x-adapter.searchresponse.md +5 -5
- package/docs/API-reference/api/x-adapter.searchresponse.partialresults.md +1 -1
- package/docs/API-reference/api/x-adapter.searchresponse.promoteds.md +1 -1
- package/docs/API-reference/api/x-adapter.searchresponse.redirections.md +1 -1
- package/docs/API-reference/api/x-adapter.searchresponse.spellcheck.md +1 -1
- package/docs/API-reference/api/x-components.increasepageappendingresults.md +2 -2
- package/docs/API-reference/api/x-components.increasepageappendingresultswire.md +13 -0
- package/docs/API-reference/api/x-components.md +7 -3
- package/docs/API-reference/api/x-components.resetstate.md +13 -0
- package/docs/API-reference/api/{x-components.saveorigin.md → x-components.saveidentifierresultsorigin.md} +2 -2
- package/docs/API-reference/api/x-components.savesearchorigin.md +13 -0
- package/docs/API-reference/api/x-components.savesearchresponse.md +13 -0
- package/docs/API-reference/api/x-components.searchactions.md +1 -0
- package/docs/API-reference/api/x-components.searchactions.savesearchresponse.md +24 -0
- package/docs/API-reference/api/x-components.setsearchurlparams.md +13 -0
- package/docs/API-reference/api/x-components.snippetconfigextraparams.excludedextraparams.md +13 -0
- package/docs/API-reference/api/x-components.snippetconfigextraparams.md +1 -0
- package/docs/API-reference/components/extra-params/x-components.snippet-config-extra-params.md +4 -3
- package/docs/build-search-ui/README.md +39 -34
- package/docs/build-search-ui/web-archetype-development-guide.md +28 -27
- package/docs/build-search-ui/web-archetype-integration-guide.md +159 -98
- package/docs/build-search-ui/web-how-to-use-x-components-guide.md +28 -37
- package/docs/build-search-ui/{x-architecture/README.md → web-x-architecture.md} +4 -52
- package/docs/build-search-ui/{web-x-components-integration-guide.md → web-x-components-development-guide.md} +27 -30
- package/identifier-results/index.js +1 -1
- package/js/components/decorators/injection.decorators.js.map +1 -1
- package/js/index.js +7 -2
- package/js/index.js.map +1 -1
- package/js/plugins/x-plugin.mixin.js.map +1 -1
- package/js/store/utils/fetch-and-save-action.utils.js +4 -2
- package/js/store/utils/fetch-and-save-action.utils.js.map +1 -1
- package/js/store/utils/store-emitters.utils.js.map +1 -1
- package/js/x-modules/empathize/components/empathize.vue.js.map +1 -1
- package/js/x-modules/empathize/components/empathize.vue_rollup-plugin-vue_script.vue.js +2 -2
- package/js/x-modules/empathize/components/empathize.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/extra-params/components/snippet-config-extra-params.vue.js.map +1 -1
- package/js/x-modules/extra-params/components/snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js +15 -129
- package/js/x-modules/extra-params/components/snippet-config-extra-params.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-queries-list.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-queries-list.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/search/store/actions/fetch-and-save-search-response.action.js +2 -19
- package/js/x-modules/search/store/actions/fetch-and-save-search-response.action.js.map +1 -1
- package/js/x-modules/search/store/actions/save-search-response.action.js +32 -0
- package/js/x-modules/search/store/actions/save-search-response.action.js.map +1 -0
- package/js/x-modules/search/store/module.js +2 -0
- package/js/x-modules/search/store/module.js.map +1 -1
- package/js/x-modules/search/wiring.js +3 -9
- package/js/x-modules/search/wiring.js.map +1 -1
- package/js/x-modules/url/components/url-handler.vue.js.map +1 -1
- package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js +2 -1
- package/js/x-modules/url/components/url-handler.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/package.json +4 -4
- package/report/x-adapter.api.json +10 -10
- package/report/x-components.api.json +238 -51
- package/report/x-components.api.md +22 -10
- package/search/index.js +6 -1
- package/types/plugins/x-plugin.mixin.d.ts.map +1 -1
- package/types/store/utils/fetch-and-save-action.utils.d.ts.map +1 -1
- package/types/x-modules/extra-params/components/snippet-config-extra-params.vue.d.ts +5 -4
- package/types/x-modules/extra-params/components/snippet-config-extra-params.vue.d.ts.map +1 -1
- package/types/x-modules/identifier-results/store/actions/index.d.ts +5 -0
- package/types/x-modules/identifier-results/store/actions/index.d.ts.map +1 -0
- package/types/x-modules/identifier-results/store/index.d.ts +1 -4
- package/types/x-modules/identifier-results/store/index.d.ts.map +1 -1
- package/types/x-modules/next-queries/components/next-queries-list.vue.d.ts +1 -0
- package/types/x-modules/next-queries/components/next-queries-list.vue.d.ts.map +1 -1
- package/types/x-modules/search/store/actions/fetch-and-save-search-response.action.d.ts.map +1 -1
- package/types/x-modules/search/store/actions/index.d.ts +8 -0
- package/types/x-modules/search/store/actions/index.d.ts.map +1 -0
- package/types/x-modules/search/store/actions/save-search-response.action.d.ts +12 -0
- package/types/x-modules/search/store/actions/save-search-response.action.d.ts.map +1 -0
- package/types/x-modules/search/store/getters/index.d.ts +3 -0
- package/types/x-modules/search/store/getters/index.d.ts.map +1 -0
- package/types/x-modules/search/store/index.d.ts +2 -4
- package/types/x-modules/search/store/index.d.ts.map +1 -1
- package/types/x-modules/search/store/module.d.ts.map +1 -1
- package/types/x-modules/search/store/types.d.ts +6 -0
- package/types/x-modules/search/store/types.d.ts.map +1 -1
- package/types/x-modules/search/wiring.d.ts +2 -8
- package/types/x-modules/search/wiring.d.ts.map +1 -1
- package/types/x-modules/url/components/url-handler.vue.d.ts.map +1 -1
- package/docs/API-reference/api/x-components.setpagesize.md +0 -13
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: Interface X Archetype
|
|
2
|
+
title: Develop using Interface X Archetype
|
|
3
3
|
tags:
|
|
4
4
|
- development
|
|
5
5
|
- archetype
|
|
6
|
-
- X
|
|
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
|
|
13
|
+
# Develop using Interface X Archetype
|
|
15
14
|
|
|
16
|
-
In this tutorial, you’ll learn how to
|
|
17
|
-
|
|
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
|
|
26
|
-
|
|
27
|
-
<br/>
|
|
23
|
+
To use Interface X 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 X Archetype as a search UI layer, you need:
|
|
|
32
28
|
|
|
33
29
|
:::
|
|
34
30
|
|
|
35
|
-
##### Steps to
|
|
31
|
+
##### Steps to build a search layer using the X Archetype project:
|
|
36
32
|
|
|
37
33
|
1. **Clone** the X Archetype project and **initialize** your repository.
|
|
38
|
-
2. Install the **project dependencies** and
|
|
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 X 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
|
|
113
|
-
|
|
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
|
|
130
|
-
|
|
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
|
-
|
|
173
|
+
Once you have your Interface X 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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
- [Integrate an Interface X 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 X Archetype project** into an existing website](web-archetype-integration-guide.md).
|
|
177
|
+
- Change the **configuration of [X 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)
|
|
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
|
-
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
In this tutorial, you'll learn how to integrate the Interface X Archetype project in your
|
|
15
|
+
commerce store in a matter of minutes. You can use the X 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 X Archetype layer in your commerce store, just **load** the
|
|
20
|
+
generated Interface X JavaScript file and **initialize** it.
|
|
21
|
+
|
|
22
|
+
::: note IMPORTANT If the X 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
|
-
|
|
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
|
-
|
|
22
|
-
|
|
31
|
+
:::
|
|
32
|
+
|
|
33
|
+
Depending on your business needs, Interface X supports two initialization types:
|
|
23
34
|
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
- **[Automatic initialization](#initializing-interface-x-project-automatically)**
|
|
36
|
+
- **[On-demand initialization](#initializing-interface-x-project-on-demand)**
|
|
26
37
|
|
|
27
|
-
:::
|
|
38
|
+
::: develop Frameworks & libraries integration
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
You can integrate the X 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
|
-
##
|
|
46
|
+
## Initializing Interface X project automatically
|
|
47
|
+
|
|
48
|
+
Automatic initialization is the easiest way to integrate the Interface X project in a website.
|
|
36
49
|
|
|
37
|
-
|
|
38
|
-
|
|
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 X script**.
|
|
40
52
|
|
|
41
|
-
### 1. Add
|
|
53
|
+
### 1. Add the snippet configuration
|
|
42
54
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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 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
|
-
|
|
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
|
-
|
|
91
|
+
::: note
|
|
77
92
|
|
|
78
|
-
|
|
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
|
-
|
|
81
|
-
|
|
98
|
+
:::
|
|
99
|
+
|
|
100
|
+
### 2. Load the script
|
|
101
|
+
|
|
102
|
+
Once the snippet configuration is ready, add the Interface 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,
|
|
85
|
-
|
|
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
|
-
|
|
102
|
-
|
|
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
|
-
|
|
119
|
-
|
|
140
|
+
Thus, when the Interface X JavaScript file is loaded, it retrieves the configuration from the
|
|
141
|
+
defined object or function.
|
|
120
142
|
|
|
121
|
-
##
|
|
143
|
+
## Initializing Interface X project on demand
|
|
122
144
|
|
|
123
|
-
|
|
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 X.
|
|
145
|
+
On-demand initialization allows you to control when Interface X is loaded.
|
|
127
146
|
|
|
128
|
-
|
|
147
|
+
You first **load the Interface X script**. Then, you invoke a function with the required
|
|
148
|
+
initialization options to **initialize Interface X**.
|
|
129
149
|
|
|
130
|
-
|
|
131
|
-
|
|
150
|
+
### 1. Load the script
|
|
151
|
+
|
|
152
|
+
Add the Interface X script hosted in a URL with the following syntax:
|
|
153
|
+
`https://x.<environment?>.empathy.co/<instance>/app.js`.
|
|
132
154
|
|
|
133
|
-
For example,
|
|
134
|
-
|
|
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
|
-
|
|
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.
|
|
169
|
+
### 2. Initialize Interface X
|
|
147
170
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
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 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 X in your commerce store using the X Archetype, check
|
|
203
|
+
out further information about:
|
|
204
|
+
|
|
205
|
+
- **Initialization options** supported in [snippet configuration](#snippet-configuration)
|
|
206
|
+
- **[Callbacks and X event types](#callbacks-and-interface-x-events-types)** available to
|
|
207
|
+
subscribe to when initializing
|
|
208
|
+
- **Functions supported by the [X API object](#x-api)** to initialize Interface 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 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
|
-
|
|
170
|
-
|
|
218
|
+
| Name | Type | Description |
|
|
219
|
+
| ------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
220
|
+
| `instance` | `string` | _Required._ ID of the API client instance. It's provided by Empathy. |
|
|
221
|
+
| `env` | `'live'` | `'staging'` | _Optional_. API environment to use. You can use the Interface 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'` | `'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 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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
247
|
+
#### Callbacks and Interface X events types
|
|
187
248
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
249
|
+
You can use a **callback** to subscribe to specific **X events 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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
|
236
|
-
|
|
|
237
|
-
|
|
|
238
|
-
| search | - query (Optional) - The query to open Interface X with | Opens Interface 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 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 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 events types can be triggered from different modules in the X 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 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 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 X. It supports multiple
|
|
293
|
+
functions to integrate Interface X in your website.
|
|
294
|
+
|
|
295
|
+
| Function | Parameters | Description |
|
|
296
|
+
| ------------------ | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
297
|
+
| `init` | [snippet configuration params](#snippet-configuration) - _Required_. Initialization options | [Initializes Interface X on demand](#initializing-interface-x-project-on-demand). |
|
|
298
|
+
| `search` | `query` - _Optional_. Query to open Interface X | Executes Interface 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. |
|