diff --git a/README.md b/README.md
index 04f9407..966853d 100644
--- a/README.md
+++ b/README.md
@@ -431,6 +431,7 @@ search configuration options:
| `customEvents` | `Object` | To set the custom events, for e.g `{ "platform": mac }` |
| `filters` | `Object` | It allows to record the applied facets on the search query, for e.g `{ "year": 2018 }` |
| `hits` | `Array` | To set the search hits, a hit object can have the `id`, `type` & `source` properties . |
+| `impressions` | `Array` | To set the impressions, a hit object can have the `id` & `index` properties. |
Note:
@@ -627,16 +628,13 @@ deleteSavedSearch(savedSearchId: string, callback: Function)
An example with all possible options:
```ts
-deleteSavedSearch(
- 'analytics-js-test',
- (err, res) => {
- if (err) {
- // handle error
- } else if (res) {
- // handle response
- }
+deleteSavedSearch('analytics-js-test', (err, res) => {
+ if (err) {
+ // handle error
+ } else if (res) {
+ // handle response
}
-);
+});
```
#### Get saved searches
diff --git a/src/index.js b/src/index.js
index 7ce9549..77ab1fd 100644
--- a/src/index.js
+++ b/src/index.js
@@ -17,6 +17,11 @@ type Hit = {
source?: Object
};
+type Impression = {
+ id: string,
+ index: 'good-books-ds'
+};
+
type AnalyticsConfig = {
index: string,
url: string,
@@ -31,7 +36,8 @@ type SearchConfig = {
queryID?: string,
customEvents?: { [key: string]: string },
filters?: { [key: string]: string },
- hits?: Array
+ hits?: Array,
+ impressions?: Array
};
type SearchRequestBody = {
@@ -233,7 +239,8 @@ function initClient(config: AnalyticsConfig = {}) {
query_id: searchConfig.queryID,
custom_events: searchConfig.customEvents,
filters: searchConfig.filters,
- hits: searchConfig.hits
+ hits: searchConfig.hits,
+ impressions: searchConfig.impressions
};
metrics._request(
'PUT',
diff --git a/src/index.test.js b/src/index.test.js
index 4c67f83..01d5893 100644
--- a/src/index.test.js
+++ b/src/index.test.js
@@ -28,6 +28,24 @@ test('registerSearch', done => {
},
type: '_doc'
}
+ ],
+ impressions: [
+ {
+ id: '3DftXXEBdEU4aeo6Gdqs',
+ index: 'good-books-ds'
+ },
+ {
+ id: '3TftXXEBdEU4aeo6Gdqs',
+ index: 'good-books-ds'
+ },
+ {
+ id: '3jftXXEBdEU4aeo6Gdqs',
+ index: 'good-books-ds'
+ },
+ {
+ id: '3zftXXEBdEU4aeo6Gdqs',
+ index: 'good-books-ds'
+ }
]
},
(err, res) => {