@algolia/client-analytics 5.0.0-alpha.10 → 5.0.0-alpha.100

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 (146) hide show
  1. package/dist/builds/browser.d.ts +5 -5
  2. package/dist/builds/browser.d.ts.map +1 -1
  3. package/dist/builds/node.d.ts +5 -5
  4. package/dist/builds/node.d.ts.map +1 -1
  5. package/dist/{client-analytics.cjs.js → client-analytics.cjs} +952 -924
  6. package/dist/client-analytics.esm.browser.js +1163 -1159
  7. package/dist/client-analytics.esm.node.js +952 -922
  8. package/dist/client-analytics.umd.js +2 -2
  9. package/dist/model/averageClickEvent.d.ts +14 -14
  10. package/dist/model/averageClickEvent.d.ts.map +1 -1
  11. package/dist/model/clickPosition.d.ts +10 -10
  12. package/dist/model/clickPosition.d.ts.map +1 -1
  13. package/dist/model/clickThroughRateEvent.d.ts +18 -18
  14. package/dist/model/clickThroughRateEvent.d.ts.map +1 -1
  15. package/dist/model/clientMethodProps.d.ts +507 -507
  16. package/dist/model/clientMethodProps.d.ts.map +1 -1
  17. package/dist/model/conversionRateEvent.d.ts +18 -18
  18. package/dist/model/conversionRateEvent.d.ts.map +1 -1
  19. package/dist/model/direction.d.ts +1 -1
  20. package/dist/model/direction.d.ts.map +1 -1
  21. package/dist/model/errorBase.d.ts +6 -6
  22. package/dist/model/errorBase.d.ts.map +1 -1
  23. package/dist/model/getAverageClickPositionResponse.d.ts +15 -15
  24. package/dist/model/getAverageClickPositionResponse.d.ts.map +1 -1
  25. package/dist/model/getClickPositionsResponse.d.ts +7 -7
  26. package/dist/model/getClickPositionsResponse.d.ts.map +1 -1
  27. package/dist/model/getClickThroughRateResponse.d.ts +19 -19
  28. package/dist/model/getClickThroughRateResponse.d.ts.map +1 -1
  29. package/dist/model/getConversationRateResponse.d.ts +19 -19
  30. package/dist/model/getConversationRateResponse.d.ts.map +1 -1
  31. package/dist/model/getNoClickRateResponse.d.ts +19 -19
  32. package/dist/model/getNoClickRateResponse.d.ts.map +1 -1
  33. package/dist/model/getNoResultsRateResponse.d.ts +19 -19
  34. package/dist/model/getNoResultsRateResponse.d.ts.map +1 -1
  35. package/dist/model/getSearchesCountResponse.d.ts +11 -11
  36. package/dist/model/getSearchesCountResponse.d.ts.map +1 -1
  37. package/dist/model/getSearchesNoClicksResponse.d.ts +7 -7
  38. package/dist/model/getSearchesNoClicksResponse.d.ts.map +1 -1
  39. package/dist/model/getSearchesNoResultsResponse.d.ts +7 -7
  40. package/dist/model/getSearchesNoResultsResponse.d.ts.map +1 -1
  41. package/dist/model/getStatusResponse.d.ts +6 -6
  42. package/dist/model/getStatusResponse.d.ts.map +1 -1
  43. package/dist/model/getTopCountriesResponse.d.ts +7 -7
  44. package/dist/model/getTopCountriesResponse.d.ts.map +1 -1
  45. package/dist/model/getTopFilterAttribute.d.ts +10 -10
  46. package/dist/model/getTopFilterAttribute.d.ts.map +1 -1
  47. package/dist/model/getTopFilterAttributesResponse.d.ts +7 -7
  48. package/dist/model/getTopFilterAttributesResponse.d.ts.map +1 -1
  49. package/dist/model/getTopFilterForAttribute.d.ts +18 -18
  50. package/dist/model/getTopFilterForAttribute.d.ts.map +1 -1
  51. package/dist/model/getTopFilterForAttributeResponse.d.ts +7 -7
  52. package/dist/model/getTopFilterForAttributeResponse.d.ts.map +1 -1
  53. package/dist/model/getTopFiltersNoResultsResponse.d.ts +7 -7
  54. package/dist/model/getTopFiltersNoResultsResponse.d.ts.map +1 -1
  55. package/dist/model/getTopFiltersNoResultsValue.d.ts +14 -14
  56. package/dist/model/getTopFiltersNoResultsValue.d.ts.map +1 -1
  57. package/dist/model/getTopFiltersNoResultsValues.d.ts +11 -11
  58. package/dist/model/getTopFiltersNoResultsValues.d.ts.map +1 -1
  59. package/dist/model/getTopHitsResponse.d.ts +3 -3
  60. package/dist/model/getTopHitsResponse.d.ts.map +1 -1
  61. package/dist/model/getTopSearchesResponse.d.ts +3 -3
  62. package/dist/model/getTopSearchesResponse.d.ts.map +1 -1
  63. package/dist/model/getUsersCountResponse.d.ts +11 -11
  64. package/dist/model/getUsersCountResponse.d.ts.map +1 -1
  65. package/dist/model/index.d.ts +44 -44
  66. package/dist/model/noClickRateEvent.d.ts +18 -18
  67. package/dist/model/noClickRateEvent.d.ts.map +1 -1
  68. package/dist/model/noResultsRateEvent.d.ts +18 -18
  69. package/dist/model/noResultsRateEvent.d.ts.map +1 -1
  70. package/dist/model/orderBy.d.ts +4 -1
  71. package/dist/model/orderBy.d.ts.map +1 -1
  72. package/dist/model/searchEvent.d.ts +10 -10
  73. package/dist/model/searchEvent.d.ts.map +1 -1
  74. package/dist/model/searchNoClickEvent.d.ts +14 -14
  75. package/dist/model/searchNoClickEvent.d.ts.map +1 -1
  76. package/dist/model/searchNoResultEvent.d.ts +14 -14
  77. package/dist/model/searchNoResultEvent.d.ts.map +1 -1
  78. package/dist/model/topCountry.d.ts +10 -10
  79. package/dist/model/topCountry.d.ts.map +1 -1
  80. package/dist/model/topHit.d.ts +10 -10
  81. package/dist/model/topHit.d.ts.map +1 -1
  82. package/dist/model/topHitWithAnalytics.d.ts +30 -30
  83. package/dist/model/topHitWithAnalytics.d.ts.map +1 -1
  84. package/dist/model/topHitsResponse.d.ts +7 -7
  85. package/dist/model/topHitsResponse.d.ts.map +1 -1
  86. package/dist/model/topHitsResponseWithAnalytics.d.ts +7 -7
  87. package/dist/model/topHitsResponseWithAnalytics.d.ts.map +1 -1
  88. package/dist/model/topSearch.d.ts +14 -14
  89. package/dist/model/topSearch.d.ts.map +1 -1
  90. package/dist/model/topSearchWithAnalytics.d.ts +38 -38
  91. package/dist/model/topSearchWithAnalytics.d.ts.map +1 -1
  92. package/dist/model/topSearchesResponse.d.ts +7 -7
  93. package/dist/model/topSearchesResponse.d.ts.map +1 -1
  94. package/dist/model/topSearchesResponseWithAnalytics.d.ts +7 -7
  95. package/dist/model/topSearchesResponseWithAnalytics.d.ts.map +1 -1
  96. package/dist/model/userWithDate.d.ts +10 -10
  97. package/dist/model/userWithDate.d.ts.map +1 -1
  98. package/dist/src/analyticsClient.d.ts +348 -318
  99. package/dist/src/analyticsClient.d.ts.map +1 -1
  100. package/index.js +1 -1
  101. package/model/averageClickEvent.ts +4 -4
  102. package/model/clickPosition.ts +3 -3
  103. package/model/clickThroughRateEvent.ts +5 -5
  104. package/model/clientMethodProps.ts +126 -126
  105. package/model/conversionRateEvent.ts +5 -5
  106. package/model/direction.ts +1 -1
  107. package/model/errorBase.ts +1 -1
  108. package/model/getAverageClickPositionResponse.ts +4 -4
  109. package/model/getClickPositionsResponse.ts +2 -2
  110. package/model/getClickThroughRateResponse.ts +5 -5
  111. package/model/getConversationRateResponse.ts +5 -5
  112. package/model/getNoClickRateResponse.ts +5 -5
  113. package/model/getNoResultsRateResponse.ts +5 -5
  114. package/model/getSearchesCountResponse.ts +3 -3
  115. package/model/getSearchesNoClicksResponse.ts +2 -2
  116. package/model/getSearchesNoResultsResponse.ts +2 -2
  117. package/model/getStatusResponse.ts +2 -2
  118. package/model/getTopCountriesResponse.ts +2 -2
  119. package/model/getTopFilterAttribute.ts +3 -3
  120. package/model/getTopFilterAttributesResponse.ts +2 -2
  121. package/model/getTopFilterForAttribute.ts +5 -5
  122. package/model/getTopFilterForAttributeResponse.ts +2 -2
  123. package/model/getTopFiltersNoResultsResponse.ts +2 -2
  124. package/model/getTopFiltersNoResultsValue.ts +4 -4
  125. package/model/getTopFiltersNoResultsValues.ts +3 -3
  126. package/model/getTopHitsResponse.ts +1 -1
  127. package/model/getTopSearchesResponse.ts +1 -1
  128. package/model/getUsersCountResponse.ts +3 -3
  129. package/model/index.ts +1 -1
  130. package/model/noClickRateEvent.ts +5 -5
  131. package/model/noResultsRateEvent.ts +5 -5
  132. package/model/orderBy.ts +4 -1
  133. package/model/searchEvent.ts +3 -3
  134. package/model/searchNoClickEvent.ts +4 -4
  135. package/model/searchNoResultEvent.ts +4 -4
  136. package/model/topCountry.ts +3 -3
  137. package/model/topHit.ts +3 -3
  138. package/model/topHitWithAnalytics.ts +8 -8
  139. package/model/topHitsResponse.ts +2 -2
  140. package/model/topHitsResponseWithAnalytics.ts +2 -2
  141. package/model/topSearch.ts +4 -4
  142. package/model/topSearchWithAnalytics.ts +10 -10
  143. package/model/topSearchesResponse.ts +2 -2
  144. package/model/topSearchesResponseWithAnalytics.ts +2 -2
  145. package/model/userWithDate.ts +3 -3
  146. package/package.json +30 -13
@@ -7,53 +7,69 @@ function createAuth(appId, apiKey, authMode = 'WithinHeaders') {
7
7
  headers() {
8
8
  return authMode === 'WithinHeaders' ? credentials : {};
9
9
  },
10
-
11
10
  queryParameters() {
12
11
  return authMode === 'WithinQueryParameters' ? credentials : {};
13
12
  }
14
-
15
13
  };
16
14
  }
17
15
 
18
16
  function createBrowserLocalStorageCache(options) {
19
- let storage; // We've changed the namespace to avoid conflicts with v4, as this version is a huge breaking change
20
-
17
+ let storage;
18
+ // We've changed the namespace to avoid conflicts with v4, as this version is a huge breaking change
21
19
  const namespaceKey = `algolia-client-js-${options.key}`;
22
-
23
20
  function getStorage() {
24
21
  if (storage === undefined) {
25
22
  storage = options.localStorage || window.localStorage;
26
23
  }
27
-
28
24
  return storage;
29
25
  }
30
-
31
26
  function getNamespace() {
32
27
  return JSON.parse(getStorage().getItem(namespaceKey) || '{}');
33
28
  }
34
-
29
+ function setNamespace(namespace) {
30
+ getStorage().setItem(namespaceKey, JSON.stringify(namespace));
31
+ }
32
+ function removeOutdatedCacheItems() {
33
+ const timeToLive = options.timeToLive ? options.timeToLive * 1000 : null;
34
+ const namespace = getNamespace();
35
+ const filteredNamespaceWithoutOldFormattedCacheItems = Object.fromEntries(Object.entries(namespace).filter(([, cacheItem]) => {
36
+ return cacheItem.timestamp !== undefined;
37
+ }));
38
+ setNamespace(filteredNamespaceWithoutOldFormattedCacheItems);
39
+ if (!timeToLive) {
40
+ return;
41
+ }
42
+ const filteredNamespaceWithoutExpiredItems = Object.fromEntries(Object.entries(filteredNamespaceWithoutOldFormattedCacheItems).filter(([, cacheItem]) => {
43
+ const currentTimestamp = new Date().getTime();
44
+ const isExpired = cacheItem.timestamp + timeToLive < currentTimestamp;
45
+ return !isExpired;
46
+ }));
47
+ setNamespace(filteredNamespaceWithoutExpiredItems);
48
+ }
35
49
  return {
36
50
  get(key, defaultValue, events = {
37
51
  miss: () => Promise.resolve()
38
52
  }) {
39
53
  return Promise.resolve().then(() => {
40
- const keyAsString = JSON.stringify(key);
41
- const value = getNamespace()[keyAsString];
42
- return Promise.all([value || defaultValue(), value !== undefined]);
54
+ removeOutdatedCacheItems();
55
+ return getNamespace()[JSON.stringify(key)];
56
+ }).then(value => {
57
+ return Promise.all([value ? value.value : defaultValue(), value !== undefined]);
43
58
  }).then(([value, exists]) => {
44
59
  return Promise.all([value, exists || events.miss(value)]);
45
60
  }).then(([value]) => value);
46
61
  },
47
-
48
62
  set(key, value) {
49
63
  return Promise.resolve().then(() => {
50
64
  const namespace = getNamespace();
51
- namespace[JSON.stringify(key)] = value;
65
+ namespace[JSON.stringify(key)] = {
66
+ timestamp: new Date().getTime(),
67
+ value
68
+ };
52
69
  getStorage().setItem(namespaceKey, JSON.stringify(namespace));
53
70
  return value;
54
71
  });
55
72
  },
56
-
57
73
  delete(key) {
58
74
  return Promise.resolve().then(() => {
59
75
  const namespace = getNamespace();
@@ -61,13 +77,11 @@ function createBrowserLocalStorageCache(options) {
61
77
  getStorage().setItem(namespaceKey, JSON.stringify(namespace));
62
78
  });
63
79
  },
64
-
65
80
  clear() {
66
81
  return Promise.resolve().then(() => {
67
82
  getStorage().removeItem(namespaceKey);
68
83
  });
69
84
  }
70
-
71
85
  };
72
86
  }
73
87
 
@@ -79,30 +93,24 @@ function createNullCache() {
79
93
  const value = defaultValue();
80
94
  return value.then(result => Promise.all([result, events.miss(result)])).then(([result]) => result);
81
95
  },
82
-
83
96
  set(_key, value) {
84
97
  return Promise.resolve(value);
85
98
  },
86
-
87
99
  delete(_key) {
88
100
  return Promise.resolve();
89
101
  },
90
-
91
102
  clear() {
92
103
  return Promise.resolve();
93
104
  }
94
-
95
105
  };
96
106
  }
97
107
 
98
108
  function createFallbackableCache(options) {
99
109
  const caches = [...options.caches];
100
110
  const current = caches.shift();
101
-
102
111
  if (current === undefined) {
103
112
  return createNullCache();
104
113
  }
105
-
106
114
  return {
107
115
  get(key, defaultValue, events = {
108
116
  miss: () => Promise.resolve()
@@ -113,7 +121,6 @@ function createFallbackableCache(options) {
113
121
  }).get(key, defaultValue, events);
114
122
  });
115
123
  },
116
-
117
124
  set(key, value) {
118
125
  return current.set(key, value).catch(() => {
119
126
  return createFallbackableCache({
@@ -121,7 +128,6 @@ function createFallbackableCache(options) {
121
128
  }).set(key, value);
122
129
  });
123
130
  },
124
-
125
131
  delete(key) {
126
132
  return current.delete(key).catch(() => {
127
133
  return createFallbackableCache({
@@ -129,7 +135,6 @@ function createFallbackableCache(options) {
129
135
  }).delete(key);
130
136
  });
131
137
  },
132
-
133
138
  clear() {
134
139
  return current.clear().catch(() => {
135
140
  return createFallbackableCache({
@@ -137,7 +142,6 @@ function createFallbackableCache(options) {
137
142
  }).clear();
138
143
  });
139
144
  }
140
-
141
145
  };
142
146
  }
143
147
 
@@ -150,30 +154,24 @@ function createMemoryCache(options = {
150
154
  miss: () => Promise.resolve()
151
155
  }) {
152
156
  const keyAsString = JSON.stringify(key);
153
-
154
157
  if (keyAsString in cache) {
155
158
  return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]);
156
159
  }
157
-
158
160
  const promise = defaultValue();
159
161
  return promise.then(value => events.miss(value)).then(() => promise);
160
162
  },
161
-
162
163
  set(key, value) {
163
164
  cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value;
164
165
  return Promise.resolve(value);
165
166
  },
166
-
167
167
  delete(key) {
168
168
  delete cache[JSON.stringify(key)];
169
169
  return Promise.resolve();
170
170
  },
171
-
172
171
  clear() {
173
172
  cache = {};
174
173
  return Promise.resolve();
175
174
  }
176
-
177
175
  };
178
176
  }
179
177
 
@@ -182,16 +180,14 @@ function createMemoryCache(options = {
182
180
  const EXPIRATION_DELAY = 2 * 60 * 1000;
183
181
  function createStatefulHost(host, status = 'up') {
184
182
  const lastUpdate = Date.now();
185
-
186
183
  function isUp() {
187
184
  return status === 'up' || Date.now() - lastUpdate > EXPIRATION_DELAY;
188
185
  }
189
-
190
186
  function isTimedOut() {
191
187
  return status === 'timed out' && Date.now() - lastUpdate <= EXPIRATION_DELAY;
192
188
  }
193
-
194
- return { ...host,
189
+ return {
190
+ ...host,
195
191
  status,
196
192
  lastUpdate,
197
193
  isUp,
@@ -199,7 +195,22 @@ function createStatefulHost(host, status = 'up') {
199
195
  };
200
196
  }
201
197
 
198
+ function _toPrimitive(t, r) {
199
+ if ("object" != typeof t || !t) return t;
200
+ var e = t[Symbol.toPrimitive];
201
+ if (void 0 !== e) {
202
+ var i = e.call(t, r || "default");
203
+ if ("object" != typeof i) return i;
204
+ throw new TypeError("@@toPrimitive must return a primitive value.");
205
+ }
206
+ return ("string" === r ? String : Number)(t);
207
+ }
208
+ function _toPropertyKey(t) {
209
+ var i = _toPrimitive(t, "string");
210
+ return "symbol" == typeof i ? i : String(i);
211
+ }
202
212
  function _defineProperty(obj, key, value) {
213
+ key = _toPropertyKey(key);
203
214
  if (key in obj) {
204
215
  Object.defineProperty(obj, key, {
205
216
  value: value,
@@ -210,79 +221,71 @@ function _defineProperty(obj, key, value) {
210
221
  } else {
211
222
  obj[key] = value;
212
223
  }
213
-
214
224
  return obj;
215
225
  }
216
226
 
217
227
  class AlgoliaError extends Error {
218
228
  constructor(message, name) {
219
229
  super(message);
220
-
221
230
  _defineProperty(this, "name", 'AlgoliaError');
222
-
223
231
  if (name) {
224
232
  this.name = name;
225
233
  }
226
234
  }
227
-
228
235
  }
229
236
  class ErrorWithStackTrace extends AlgoliaError {
230
237
  constructor(message, stackTrace, name) {
231
- super(message, name); // the array and object should be frozen to reflect the stackTrace at the time of the error
232
-
238
+ super(message, name);
239
+ // the array and object should be frozen to reflect the stackTrace at the time of the error
233
240
  _defineProperty(this, "stackTrace", void 0);
234
-
235
241
  this.stackTrace = stackTrace;
236
242
  }
237
-
238
243
  }
239
244
  class RetryError extends ErrorWithStackTrace {
240
245
  constructor(stackTrace) {
241
- super('Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.', stackTrace, 'RetryError');
246
+ super('Unreachable hosts - your application id may be incorrect. If the error persists, please create a ticket at https://support.algolia.com/ sharing steps we can use to reproduce the issue.', stackTrace, 'RetryError');
242
247
  }
243
-
244
248
  }
245
249
  class ApiError extends ErrorWithStackTrace {
246
- constructor(message, status, stackTrace) {
247
- super(message, stackTrace, 'ApiError');
248
-
250
+ constructor(message, status, stackTrace, name = 'ApiError') {
251
+ super(message, stackTrace, name);
249
252
  _defineProperty(this, "status", void 0);
250
-
251
253
  this.status = status;
252
254
  }
253
-
254
255
  }
255
256
  class DeserializationError extends AlgoliaError {
256
257
  constructor(message, response) {
257
258
  super(message, 'DeserializationError');
258
-
259
259
  _defineProperty(this, "response", void 0);
260
-
261
260
  this.response = response;
262
261
  }
263
-
262
+ }
263
+ // DetailedApiError is only used by the ingestion client to return more informative error, other clients will use ApiClient.
264
+ class DetailedApiError extends ApiError {
265
+ constructor(message, status, error, stackTrace) {
266
+ super(message, status, stackTrace, 'DetailedApiError');
267
+ _defineProperty(this, "error", void 0);
268
+ this.error = error;
269
+ }
264
270
  }
265
271
  function serializeUrl(host, path, queryParameters) {
266
272
  const queryParametersAsString = serializeQueryParameters(queryParameters);
267
273
  let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.substr(1) : path}`;
268
-
269
274
  if (queryParametersAsString.length) {
270
275
  url += `?${queryParametersAsString}`;
271
276
  }
272
-
273
277
  return url;
274
278
  }
275
279
  function serializeQueryParameters(parameters) {
276
280
  const isObjectOrArray = value => Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
277
-
278
- return Object.keys(parameters).map(key => `${key}=${isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key]}`).join('&');
281
+ return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key])}`).join('&');
279
282
  }
280
283
  function serializeData(request, requestOptions) {
281
284
  if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
282
285
  return undefined;
283
286
  }
284
-
285
- const data = Array.isArray(request.data) ? request.data : { ...request.data,
287
+ const data = Array.isArray(request.data) ? request.data : {
288
+ ...request.data,
286
289
  ...requestOptions.data
287
290
  };
288
291
  return JSON.stringify(data);
@@ -312,14 +315,16 @@ function deserializeFailure({
312
315
  content,
313
316
  status
314
317
  }, stackFrame) {
315
- let message = content;
316
-
317
318
  try {
318
- message = JSON.parse(content).message;
319
- } catch (e) {// ..
319
+ const parsed = JSON.parse(content);
320
+ if ('error' in parsed) {
321
+ return new DetailedApiError(parsed.message, status, parsed.error, stackFrame);
322
+ }
323
+ return new ApiError(parsed.message, status, stackFrame);
324
+ } catch (e) {
325
+ // ..
320
326
  }
321
-
322
- return new ApiError(message, status, stackFrame);
327
+ return new ApiError(content, status, stackFrame);
323
328
  }
324
329
 
325
330
  function isNetworkError({
@@ -350,9 +355,12 @@ function stackFrameWithoutCredentials(stackFrame) {
350
355
  const modifiedHeaders = stackFrame.request.headers['x-algolia-api-key'] ? {
351
356
  'x-algolia-api-key': '*****'
352
357
  } : {};
353
- return { ...stackFrame,
354
- request: { ...stackFrame.request,
355
- headers: { ...stackFrame.request.headers,
358
+ return {
359
+ ...stackFrame,
360
+ request: {
361
+ ...stackFrame.request,
362
+ headers: {
363
+ ...stackFrame.request.headers,
356
364
  ...modifiedHeaders
357
365
  }
358
366
  }
@@ -377,53 +385,49 @@ function createTransporter({
377
385
  });
378
386
  }));
379
387
  const hostsUp = statefulHosts.filter(host => host.isUp());
380
- const hostsTimedOut = statefulHosts.filter(host => host.isTimedOut()); // Note, we put the hosts that previously timed out on the end of the list.
381
-
388
+ const hostsTimedOut = statefulHosts.filter(host => host.isTimedOut());
389
+ // Note, we put the hosts that previously timed out on the end of the list.
382
390
  const hostsAvailable = [...hostsUp, ...hostsTimedOut];
383
391
  const compatibleHostsAvailable = hostsAvailable.length > 0 ? hostsAvailable : compatibleHosts;
384
392
  return {
385
393
  hosts: compatibleHostsAvailable,
386
-
387
394
  getTimeout(timeoutsCount, baseTimeout) {
388
- /**
389
- * Imagine that you have 4 hosts, if timeouts will increase
390
- * on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
391
- *
392
- * Note that, the very next request, we start from the previous timeout.
393
- *
394
- * 5 (timed out) > 6 (timed out) > 7 ...
395
- *
396
- * This strategy may need to be reviewed, but is the strategy on the our
397
- * current v3 version.
395
+ /**
396
+ * Imagine that you have 4 hosts, if timeouts will increase
397
+ * on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
398
+ *
399
+ * Note that, the very next request, we start from the previous timeout.
400
+ *
401
+ * 5 (timed out) > 6 (timed out) > 7 ...
402
+ *
403
+ * This strategy may need to be reviewed, but is the strategy on the our
404
+ * current v3 version.
398
405
  */
399
406
  const timeoutMultiplier = hostsTimedOut.length === 0 && timeoutsCount === 0 ? 1 : hostsTimedOut.length + 3 + timeoutsCount;
400
407
  return timeoutMultiplier * baseTimeout;
401
408
  }
402
-
403
409
  };
404
410
  }
405
-
406
411
  async function retryableRequest(request, requestOptions, isRead = true) {
407
412
  const stackTrace = [];
408
- /**
409
- * First we prepare the payload that do not depend from hosts.
413
+ /**
414
+ * First we prepare the payload that do not depend from hosts.
410
415
  */
411
-
412
416
  const data = serializeData(request, requestOptions);
413
- const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers); // On `GET`, the data is proxied to query parameters.
414
-
415
- const dataQueryParameters = request.method === 'GET' ? { ...request.data,
417
+ const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
418
+ // On `GET`, the data is proxied to query parameters.
419
+ const dataQueryParameters = request.method === 'GET' ? {
420
+ ...request.data,
416
421
  ...requestOptions.data
417
422
  } : {};
418
- const queryParameters = { ...baseQueryParameters,
423
+ const queryParameters = {
424
+ ...baseQueryParameters,
419
425
  ...request.queryParameters,
420
426
  ...dataQueryParameters
421
427
  };
422
-
423
428
  if (algoliaAgent.value) {
424
429
  queryParameters['x-algolia-agent'] = algoliaAgent.value;
425
430
  }
426
-
427
431
  if (requestOptions && requestOptions.queryParameters) {
428
432
  for (const key of Object.keys(requestOptions.queryParameters)) {
429
433
  // We want to keep `undefined` and `null` values,
@@ -436,25 +440,19 @@ function createTransporter({
436
440
  }
437
441
  }
438
442
  }
439
-
440
443
  let timeoutsCount = 0;
441
-
442
444
  const retry = async (retryableHosts, getTimeout) => {
443
- /**
444
- * We iterate on each host, until there is no host left.
445
+ /**
446
+ * We iterate on each host, until there is no host left.
445
447
  */
446
448
  const host = retryableHosts.pop();
447
-
448
449
  if (host === undefined) {
449
450
  throw new RetryError(stackTraceWithoutCredentials(stackTrace));
450
451
  }
451
-
452
452
  let responseTimeout = requestOptions.timeout;
453
-
454
453
  if (responseTimeout === undefined) {
455
454
  responseTimeout = isRead ? timeouts.read : timeouts.write;
456
455
  }
457
-
458
456
  const payload = {
459
457
  data,
460
458
  headers,
@@ -463,12 +461,11 @@ function createTransporter({
463
461
  connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
464
462
  responseTimeout: getTimeout(timeoutsCount, responseTimeout)
465
463
  };
466
- /**
467
- * The stackFrame is pushed to the stackTrace so we
468
- * can have information about onRetry and onFailure
469
- * decisions.
464
+ /**
465
+ * The stackFrame is pushed to the stackTrace so we
466
+ * can have information about onRetry and onFailure
467
+ * decisions.
470
468
  */
471
-
472
469
  const pushToStackTrace = response => {
473
470
  const stackFrame = {
474
471
  request: payload,
@@ -479,102 +476,85 @@ function createTransporter({
479
476
  stackTrace.push(stackFrame);
480
477
  return stackFrame;
481
478
  };
482
-
483
479
  const response = await requester.send(payload);
484
-
485
480
  if (isRetryable(response)) {
486
- const stackFrame = pushToStackTrace(response); // If response is a timeout, we increase the number of timeouts so we can increase the timeout later.
487
-
481
+ const stackFrame = pushToStackTrace(response);
482
+ // If response is a timeout, we increase the number of timeouts so we can increase the timeout later.
488
483
  if (response.isTimedOut) {
489
484
  timeoutsCount++;
490
485
  }
491
- /**
492
- * Failures are individually sent to the logger, allowing
493
- * the end user to debug / store stack frames even
494
- * when a retry error does not happen.
486
+ /**
487
+ * Failures are individually sent to the logger, allowing
488
+ * the end user to debug / store stack frames even
489
+ * when a retry error does not happen.
495
490
  */
496
491
  // eslint-disable-next-line no-console -- this will be fixed by exposing a `logger` to the transporter
497
-
498
-
499
492
  console.log('Retryable failure', stackFrameWithoutCredentials(stackFrame));
500
- /**
501
- * We also store the state of the host in failure cases. If the host, is
502
- * down it will remain down for the next 2 minutes. In a timeout situation,
503
- * this host will be added end of the list of hosts on the next request.
493
+ /**
494
+ * We also store the state of the host in failure cases. If the host, is
495
+ * down it will remain down for the next 2 minutes. In a timeout situation,
496
+ * this host will be added end of the list of hosts on the next request.
504
497
  */
505
-
506
498
  await hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down'));
507
499
  return retry(retryableHosts, getTimeout);
508
500
  }
509
-
510
501
  if (isSuccess(response)) {
511
502
  return deserializeSuccess(response);
512
503
  }
513
-
514
504
  pushToStackTrace(response);
515
505
  throw deserializeFailure(response, stackTrace);
516
506
  };
517
- /**
518
- * Finally, for each retryable host perform request until we got a non
519
- * retryable response. Some notes here:
520
- *
521
- * 1. The reverse here is applied so we can apply a `pop` later on => more performant.
522
- * 2. We also get from the retryable options a timeout multiplier that is tailored
523
- * for the current context.
507
+ /**
508
+ * Finally, for each retryable host perform request until we got a non
509
+ * retryable response. Some notes here:
510
+ *
511
+ * 1. The reverse here is applied so we can apply a `pop` later on => more performant.
512
+ * 2. We also get from the retryable options a timeout multiplier that is tailored
513
+ * for the current context.
524
514
  */
525
-
526
-
527
515
  const compatibleHosts = hosts.filter(host => host.accept === 'readWrite' || (isRead ? host.accept === 'read' : host.accept === 'write'));
528
516
  const options = await createRetryableOptions(compatibleHosts);
529
517
  return retry([...options.hosts].reverse(), options.getTimeout);
530
518
  }
531
-
532
519
  function createRequest(request, requestOptions = {}) {
533
- /**
534
- * A read request is either a `GET` request, or a request that we make
535
- * via the `read` transporter (e.g. `search`).
520
+ /**
521
+ * A read request is either a `GET` request, or a request that we make
522
+ * via the `read` transporter (e.g. `search`).
536
523
  */
537
524
  const isRead = request.useReadTransporter || request.method === 'GET';
538
-
539
525
  if (!isRead) {
540
- /**
541
- * On write requests, no cache mechanisms are applied, and we
542
- * proxy the request immediately to the requester.
526
+ /**
527
+ * On write requests, no cache mechanisms are applied, and we
528
+ * proxy the request immediately to the requester.
543
529
  */
544
530
  return retryableRequest(request, requestOptions, isRead);
545
531
  }
546
-
547
532
  const createRetryableRequest = () => {
548
- /**
549
- * Then, we prepare a function factory that contains the construction of
550
- * the retryable request. At this point, we may *not* perform the actual
551
- * request. But we want to have the function factory ready.
533
+ /**
534
+ * Then, we prepare a function factory that contains the construction of
535
+ * the retryable request. At this point, we may *not* perform the actual
536
+ * request. But we want to have the function factory ready.
552
537
  */
553
538
  return retryableRequest(request, requestOptions);
554
539
  };
555
- /**
556
- * Once we have the function factory ready, we need to determine of the
557
- * request is "cacheable" - should be cached. Note that, once again,
558
- * the user can force this option.
540
+ /**
541
+ * Once we have the function factory ready, we need to determine of the
542
+ * request is "cacheable" - should be cached. Note that, once again,
543
+ * the user can force this option.
559
544
  */
560
-
561
-
562
545
  const cacheable = requestOptions.cacheable || request.cacheable;
563
- /**
564
- * If is not "cacheable", we immediately trigger the retryable request, no
565
- * need to check cache implementations.
546
+ /**
547
+ * If is not "cacheable", we immediately trigger the retryable request, no
548
+ * need to check cache implementations.
566
549
  */
567
-
568
550
  if (cacheable !== true) {
569
551
  return createRetryableRequest();
570
552
  }
571
- /**
572
- * If the request is "cacheable", we need to first compute the key to ask
573
- * the cache implementations if this request is on progress or if the
574
- * response already exists on the cache.
553
+ /**
554
+ * If the request is "cacheable", we need to first compute the key to ask
555
+ * the cache implementations if this request is on progress or if the
556
+ * response already exists on the cache.
575
557
  */
576
-
577
-
578
558
  const key = {
579
559
  request,
580
560
  requestOptions,
@@ -583,33 +563,31 @@ function createTransporter({
583
563
  headers: baseHeaders
584
564
  }
585
565
  };
586
- /**
587
- * With the computed key, we first ask the responses cache
588
- * implementation if this request was been resolved before.
566
+ /**
567
+ * With the computed key, we first ask the responses cache
568
+ * implementation if this request was been resolved before.
589
569
  */
590
-
591
570
  return responsesCache.get(key, () => {
592
- /**
593
- * If the request has never resolved before, we actually ask if there
594
- * is a current request with the same key on progress.
571
+ /**
572
+ * If the request has never resolved before, we actually ask if there
573
+ * is a current request with the same key on progress.
595
574
  */
596
575
  return requestsCache.get(key, () =>
597
- /**
598
- * Finally, if there is no request in progress with the same key,
599
- * this `createRetryableRequest()` will actually trigger the
600
- * retryable request.
576
+ /**
577
+ * Finally, if there is no request in progress with the same key,
578
+ * this `createRetryableRequest()` will actually trigger the
579
+ * retryable request.
601
580
  */
602
581
  requestsCache.set(key, createRetryableRequest()).then(response => Promise.all([requestsCache.delete(key), response]), err => Promise.all([requestsCache.delete(key), Promise.reject(err)])).then(([_, response]) => response));
603
582
  }, {
604
- /**
605
- * Of course, once we get this response back from the server, we
606
- * tell response cache to actually store the received response
607
- * to be used later.
583
+ /**
584
+ * Of course, once we get this response back from the server, we
585
+ * tell response cache to actually store the received response
586
+ * to be used later.
608
587
  */
609
588
  miss: response => responsesCache.set(key, response)
610
589
  });
611
590
  }
612
-
613
591
  return {
614
592
  hostsCache,
615
593
  requester,
@@ -627,17 +605,13 @@ function createTransporter({
627
605
  function createAlgoliaAgent(version) {
628
606
  const algoliaAgent = {
629
607
  value: `Algolia for JavaScript (${version})`,
630
-
631
608
  add(options) {
632
609
  const addedAlgoliaAgent = `; ${options.segment}${options.version !== undefined ? ` (${options.version})` : ''}`;
633
-
634
610
  if (algoliaAgent.value.indexOf(addedAlgoliaAgent) === -1) {
635
611
  algoliaAgent.value = `${algoliaAgent.value}${addedAlgoliaAgent}`;
636
612
  }
637
-
638
613
  return algoliaAgent;
639
614
  }
640
-
641
615
  };
642
616
  return algoliaAgent;
643
617
  }
@@ -659,988 +633,1018 @@ const DEFAULT_CONNECT_TIMEOUT_BROWSER = 1000;
659
633
  const DEFAULT_READ_TIMEOUT_BROWSER = 2000;
660
634
  const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
661
635
 
662
- function createXhrRequester() {
663
- function send(request) {
664
- return new Promise((resolve) => {
665
- const baseRequester = new XMLHttpRequest();
666
- baseRequester.open(request.method, request.url, true);
667
- Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
668
- const createTimeout = (timeout, content) => {
669
- return setTimeout(() => {
670
- baseRequester.abort();
671
- resolve({
672
- status: 0,
673
- content,
674
- isTimedOut: true,
675
- });
676
- }, timeout);
677
- };
678
- const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
679
- let responseTimeout;
680
- baseRequester.onreadystatechange = () => {
681
- if (baseRequester.readyState > baseRequester.OPENED &&
682
- responseTimeout === undefined) {
683
- clearTimeout(connectTimeout);
684
- responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
685
- }
686
- };
687
- baseRequester.onerror = () => {
688
- // istanbul ignore next
689
- if (baseRequester.status === 0) {
690
- clearTimeout(connectTimeout);
691
- clearTimeout(responseTimeout);
692
- resolve({
693
- content: baseRequester.responseText || 'Network request failed',
694
- status: baseRequester.status,
695
- isTimedOut: false,
696
- });
697
- }
698
- };
699
- baseRequester.onload = () => {
700
- clearTimeout(connectTimeout);
701
- clearTimeout(responseTimeout);
702
- resolve({
703
- content: baseRequester.responseText,
704
- status: baseRequester.status,
705
- isTimedOut: false,
706
- });
707
- };
708
- baseRequester.send(request.data);
709
- });
710
- }
711
- return { send };
636
+ function createXhrRequester() {
637
+ function send(request) {
638
+ return new Promise((resolve) => {
639
+ const baseRequester = new XMLHttpRequest();
640
+ baseRequester.open(request.method, request.url, true);
641
+ Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
642
+ const createTimeout = (timeout, content) => {
643
+ return setTimeout(() => {
644
+ baseRequester.abort();
645
+ resolve({
646
+ status: 0,
647
+ content,
648
+ isTimedOut: true,
649
+ });
650
+ }, timeout);
651
+ };
652
+ const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
653
+ let responseTimeout;
654
+ baseRequester.onreadystatechange = () => {
655
+ if (baseRequester.readyState > baseRequester.OPENED &&
656
+ responseTimeout === undefined) {
657
+ clearTimeout(connectTimeout);
658
+ responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
659
+ }
660
+ };
661
+ baseRequester.onerror = () => {
662
+ // istanbul ignore next
663
+ if (baseRequester.status === 0) {
664
+ clearTimeout(connectTimeout);
665
+ clearTimeout(responseTimeout);
666
+ resolve({
667
+ content: baseRequester.responseText || 'Network request failed',
668
+ status: baseRequester.status,
669
+ isTimedOut: false,
670
+ });
671
+ }
672
+ };
673
+ baseRequester.onload = () => {
674
+ clearTimeout(connectTimeout);
675
+ clearTimeout(responseTimeout);
676
+ resolve({
677
+ content: baseRequester.responseText,
678
+ status: baseRequester.status,
679
+ isTimedOut: false,
680
+ });
681
+ };
682
+ baseRequester.send(request.data);
683
+ });
684
+ }
685
+ return { send };
712
686
  }
713
687
 
714
- // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
715
- const apiClientVersion = '5.0.0-alpha.10';
716
- const REGIONS = ['de', 'us'];
717
- function getDefaultHosts(region) {
718
- const url = !region
719
- ? 'analytics.algolia.com'
720
- : 'analytics.{region}.algolia.com'.replace('{region}', region);
721
- return [{ url, accept: 'readWrite', protocol: 'https' }];
722
- }
723
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
724
- function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
725
- const auth = createAuth(appIdOption, apiKeyOption, authMode);
726
- const transporter = createTransporter({
727
- hosts: getDefaultHosts(regionOption),
728
- ...options,
729
- algoliaAgent: getAlgoliaAgent({
730
- algoliaAgents,
731
- client: 'Analytics',
732
- version: apiClientVersion,
733
- }),
734
- baseHeaders: {
735
- 'content-type': 'text/plain',
736
- ...auth.headers(),
737
- ...options.baseHeaders,
738
- },
739
- baseQueryParameters: {
740
- ...auth.queryParameters(),
741
- ...options.baseQueryParameters,
742
- },
743
- });
744
- return {
745
- transporter,
746
- /**
747
- * The `appId` currently in use.
748
- */
749
- appId: appIdOption,
750
- /**
751
- * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
752
- */
753
- clearCache() {
754
- return Promise.all([
755
- transporter.requestsCache.clear(),
756
- transporter.responsesCache.clear(),
757
- ]).then(() => undefined);
758
- },
759
- /**
760
- * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
761
- */
762
- get _ua() {
763
- return transporter.algoliaAgent.value;
764
- },
765
- /**
766
- * Adds a `segment` to the `x-algolia-agent` sent with every requests.
767
- *
768
- * @param segment - The algolia agent (user-agent) segment to add.
769
- * @param version - The version of the agent.
770
- */
771
- addAlgoliaAgent(segment, version) {
772
- transporter.algoliaAgent.add({ segment, version });
773
- },
774
- /**
775
- * This method allow you to send requests to the Algolia REST API.
776
- *
777
- * @summary Send requests to the Algolia REST API.
778
- * @param del - The del object.
779
- * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
780
- * @param del.parameters - Query parameters to be applied to the current query.
781
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
782
- */
783
- del({ path, parameters }, requestOptions) {
784
- if (!path) {
785
- throw new Error('Parameter `path` is required when calling `del`.');
786
- }
787
- const requestPath = '/1{path}'.replace('{path}', path);
788
- const headers = {};
789
- const queryParameters = parameters ? parameters : {};
790
- const request = {
791
- method: 'DELETE',
792
- path: requestPath,
793
- queryParameters,
794
- headers,
795
- };
796
- return transporter.request(request, requestOptions);
797
- },
798
- /**
799
- * This method allow you to send requests to the Algolia REST API.
800
- *
801
- * @summary Send requests to the Algolia REST API.
802
- * @param get - The get object.
803
- * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
804
- * @param get.parameters - Query parameters to be applied to the current query.
805
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
806
- */
807
- get({ path, parameters }, requestOptions) {
808
- if (!path) {
809
- throw new Error('Parameter `path` is required when calling `get`.');
810
- }
811
- const requestPath = '/1{path}'.replace('{path}', path);
812
- const headers = {};
813
- const queryParameters = parameters ? parameters : {};
814
- const request = {
815
- method: 'GET',
816
- path: requestPath,
817
- queryParameters,
818
- headers,
819
- };
820
- return transporter.request(request, requestOptions);
821
- },
822
- /**
823
- * Returns the average click position. The endpoint returns a value for the complete given time range, as well as a value per day.
824
- *
825
- * @summary Get average click position.
826
- * @param getAverageClickPosition - The getAverageClickPosition object.
827
- * @param getAverageClickPosition.index - The index name to target.
828
- * @param getAverageClickPosition.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
829
- * @param getAverageClickPosition.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
830
- * @param getAverageClickPosition.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
831
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
832
- */
833
- getAverageClickPosition({ index, startDate, endDate, tags }, requestOptions) {
834
- if (!index) {
835
- throw new Error('Parameter `index` is required when calling `getAverageClickPosition`.');
836
- }
837
- const requestPath = '/2/clicks/averageClickPosition';
838
- const headers = {};
839
- const queryParameters = {};
840
- if (index !== undefined) {
841
- queryParameters.index = index.toString();
842
- }
843
- if (startDate !== undefined) {
844
- queryParameters.startDate = startDate.toString();
845
- }
846
- if (endDate !== undefined) {
847
- queryParameters.endDate = endDate.toString();
848
- }
849
- if (tags !== undefined) {
850
- queryParameters.tags = tags.toString();
851
- }
852
- const request = {
853
- method: 'GET',
854
- path: requestPath,
855
- queryParameters,
856
- headers,
857
- };
858
- return transporter.request(request, requestOptions);
859
- },
860
- /**
861
- * Returns the distribution of clicks per range of positions. If the groups all have a count of 0, it means Algolia didn’t receive any click events for the queries with the clickAnalytics search parameter set to true. The count is 0 until Algolia receives at least one click event.
862
- *
863
- * @summary Get clicks per positions.
864
- * @param getClickPositions - The getClickPositions object.
865
- * @param getClickPositions.index - The index name to target.
866
- * @param getClickPositions.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
867
- * @param getClickPositions.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
868
- * @param getClickPositions.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
869
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
870
- */
871
- getClickPositions({ index, startDate, endDate, tags }, requestOptions) {
872
- if (!index) {
873
- throw new Error('Parameter `index` is required when calling `getClickPositions`.');
874
- }
875
- const requestPath = '/2/clicks/positions';
876
- const headers = {};
877
- const queryParameters = {};
878
- if (index !== undefined) {
879
- queryParameters.index = index.toString();
880
- }
881
- if (startDate !== undefined) {
882
- queryParameters.startDate = startDate.toString();
883
- }
884
- if (endDate !== undefined) {
885
- queryParameters.endDate = endDate.toString();
886
- }
887
- if (tags !== undefined) {
888
- queryParameters.tags = tags.toString();
889
- }
890
- const request = {
891
- method: 'GET',
892
- path: requestPath,
893
- queryParameters,
894
- headers,
895
- };
896
- return transporter.request(request, requestOptions);
897
- },
898
- /**
899
- * Returns a click-through rate (CTR). The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of clicks and searches used to compute the rates.
900
- *
901
- * @summary Get click-through rate (CTR).
902
- * @param getClickThroughRate - The getClickThroughRate object.
903
- * @param getClickThroughRate.index - The index name to target.
904
- * @param getClickThroughRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
905
- * @param getClickThroughRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
906
- * @param getClickThroughRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
907
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
908
- */
909
- getClickThroughRate({ index, startDate, endDate, tags }, requestOptions) {
910
- if (!index) {
911
- throw new Error('Parameter `index` is required when calling `getClickThroughRate`.');
912
- }
913
- const requestPath = '/2/clicks/clickThroughRate';
914
- const headers = {};
915
- const queryParameters = {};
916
- if (index !== undefined) {
917
- queryParameters.index = index.toString();
918
- }
919
- if (startDate !== undefined) {
920
- queryParameters.startDate = startDate.toString();
921
- }
922
- if (endDate !== undefined) {
923
- queryParameters.endDate = endDate.toString();
924
- }
925
- if (tags !== undefined) {
926
- queryParameters.tags = tags.toString();
927
- }
928
- const request = {
929
- method: 'GET',
930
- path: requestPath,
931
- queryParameters,
932
- headers,
933
- };
934
- return transporter.request(request, requestOptions);
935
- },
936
- /**
937
- * Returns a conversion rate (CR). The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of conversion and searches used to compute the rates.
938
- *
939
- * @summary Get conversion rate (CR).
940
- * @param getConversationRate - The getConversationRate object.
941
- * @param getConversationRate.index - The index name to target.
942
- * @param getConversationRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
943
- * @param getConversationRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
944
- * @param getConversationRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
945
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
946
- */
947
- getConversationRate({ index, startDate, endDate, tags }, requestOptions) {
948
- if (!index) {
949
- throw new Error('Parameter `index` is required when calling `getConversationRate`.');
950
- }
951
- const requestPath = '/2/conversions/conversionRate';
952
- const headers = {};
953
- const queryParameters = {};
954
- if (index !== undefined) {
955
- queryParameters.index = index.toString();
956
- }
957
- if (startDate !== undefined) {
958
- queryParameters.startDate = startDate.toString();
959
- }
960
- if (endDate !== undefined) {
961
- queryParameters.endDate = endDate.toString();
962
- }
963
- if (tags !== undefined) {
964
- queryParameters.tags = tags.toString();
965
- }
966
- const request = {
967
- method: 'GET',
968
- path: requestPath,
969
- queryParameters,
970
- headers,
971
- };
972
- return transporter.request(request, requestOptions);
973
- },
974
- /**
975
- * Returns the rate at which searches didn\'t lead to any clicks. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without clicks.
976
- *
977
- * @summary Get no click rate.
978
- * @param getNoClickRate - The getNoClickRate object.
979
- * @param getNoClickRate.index - The index name to target.
980
- * @param getNoClickRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
981
- * @param getNoClickRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
982
- * @param getNoClickRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
983
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
984
- */
985
- getNoClickRate({ index, startDate, endDate, tags }, requestOptions) {
986
- if (!index) {
987
- throw new Error('Parameter `index` is required when calling `getNoClickRate`.');
988
- }
989
- const requestPath = '/2/searches/noClickRate';
990
- const headers = {};
991
- const queryParameters = {};
992
- if (index !== undefined) {
993
- queryParameters.index = index.toString();
994
- }
995
- if (startDate !== undefined) {
996
- queryParameters.startDate = startDate.toString();
997
- }
998
- if (endDate !== undefined) {
999
- queryParameters.endDate = endDate.toString();
1000
- }
1001
- if (tags !== undefined) {
1002
- queryParameters.tags = tags.toString();
1003
- }
1004
- const request = {
1005
- method: 'GET',
1006
- path: requestPath,
1007
- queryParameters,
1008
- headers,
1009
- };
1010
- return transporter.request(request, requestOptions);
1011
- },
1012
- /**
1013
- * Returns the rate at which searches didn\'t return any results. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without results used to compute the rates.
1014
- *
1015
- * @summary Get no results rate.
1016
- * @param getNoResultsRate - The getNoResultsRate object.
1017
- * @param getNoResultsRate.index - The index name to target.
1018
- * @param getNoResultsRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1019
- * @param getNoResultsRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1020
- * @param getNoResultsRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1021
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1022
- */
1023
- getNoResultsRate({ index, startDate, endDate, tags }, requestOptions) {
1024
- if (!index) {
1025
- throw new Error('Parameter `index` is required when calling `getNoResultsRate`.');
1026
- }
1027
- const requestPath = '/2/searches/noResultRate';
1028
- const headers = {};
1029
- const queryParameters = {};
1030
- if (index !== undefined) {
1031
- queryParameters.index = index.toString();
1032
- }
1033
- if (startDate !== undefined) {
1034
- queryParameters.startDate = startDate.toString();
1035
- }
1036
- if (endDate !== undefined) {
1037
- queryParameters.endDate = endDate.toString();
1038
- }
1039
- if (tags !== undefined) {
1040
- queryParameters.tags = tags.toString();
1041
- }
1042
- const request = {
1043
- method: 'GET',
1044
- path: requestPath,
1045
- queryParameters,
1046
- headers,
1047
- };
1048
- return transporter.request(request, requestOptions);
1049
- },
1050
- /**
1051
- * Returns the number of searches across the given time range. The endpoint returns a value for the complete given time range, as well as a value per day.
1052
- *
1053
- * @summary Get searches count.
1054
- * @param getSearchesCount - The getSearchesCount object.
1055
- * @param getSearchesCount.index - The index name to target.
1056
- * @param getSearchesCount.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1057
- * @param getSearchesCount.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1058
- * @param getSearchesCount.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1059
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1060
- */
1061
- getSearchesCount({ index, startDate, endDate, tags }, requestOptions) {
1062
- if (!index) {
1063
- throw new Error('Parameter `index` is required when calling `getSearchesCount`.');
1064
- }
1065
- const requestPath = '/2/searches/count';
1066
- const headers = {};
1067
- const queryParameters = {};
1068
- if (index !== undefined) {
1069
- queryParameters.index = index.toString();
1070
- }
1071
- if (startDate !== undefined) {
1072
- queryParameters.startDate = startDate.toString();
1073
- }
1074
- if (endDate !== undefined) {
1075
- queryParameters.endDate = endDate.toString();
1076
- }
1077
- if (tags !== undefined) {
1078
- queryParameters.tags = tags.toString();
1079
- }
1080
- const request = {
1081
- method: 'GET',
1082
- path: requestPath,
1083
- queryParameters,
1084
- headers,
1085
- };
1086
- return transporter.request(request, requestOptions);
1087
- },
1088
- /**
1089
- * Returns top searches that didn\'t lead to any clicks. Limited to the 1000 most frequent ones. For each search, also returns the average number of found hits.
1090
- *
1091
- * @summary Get top searches with no clicks.
1092
- * @param getSearchesNoClicks - The getSearchesNoClicks object.
1093
- * @param getSearchesNoClicks.index - The index name to target.
1094
- * @param getSearchesNoClicks.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1095
- * @param getSearchesNoClicks.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1096
- * @param getSearchesNoClicks.limit - Number of records to return. Limit is the size of the page.
1097
- * @param getSearchesNoClicks.offset - Position of the starting record. Used for paging. 0 is the first record.
1098
- * @param getSearchesNoClicks.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1099
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1100
- */
1101
- getSearchesNoClicks({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
1102
- if (!index) {
1103
- throw new Error('Parameter `index` is required when calling `getSearchesNoClicks`.');
1104
- }
1105
- const requestPath = '/2/searches/noClicks';
1106
- const headers = {};
1107
- const queryParameters = {};
1108
- if (index !== undefined) {
1109
- queryParameters.index = index.toString();
1110
- }
1111
- if (startDate !== undefined) {
1112
- queryParameters.startDate = startDate.toString();
1113
- }
1114
- if (endDate !== undefined) {
1115
- queryParameters.endDate = endDate.toString();
1116
- }
1117
- if (limit !== undefined) {
1118
- queryParameters.limit = limit.toString();
1119
- }
1120
- if (offset !== undefined) {
1121
- queryParameters.offset = offset.toString();
1122
- }
1123
- if (tags !== undefined) {
1124
- queryParameters.tags = tags.toString();
1125
- }
1126
- const request = {
1127
- method: 'GET',
1128
- path: requestPath,
1129
- queryParameters,
1130
- headers,
1131
- };
1132
- return transporter.request(request, requestOptions);
1133
- },
1134
- /**
1135
- * Returns top searches that didn\'t return any results. Limited to the 1000 most frequent ones.
1136
- *
1137
- * @summary Get top searches with no results.
1138
- * @param getSearchesNoResults - The getSearchesNoResults object.
1139
- * @param getSearchesNoResults.index - The index name to target.
1140
- * @param getSearchesNoResults.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1141
- * @param getSearchesNoResults.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1142
- * @param getSearchesNoResults.limit - Number of records to return. Limit is the size of the page.
1143
- * @param getSearchesNoResults.offset - Position of the starting record. Used for paging. 0 is the first record.
1144
- * @param getSearchesNoResults.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1145
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1146
- */
1147
- getSearchesNoResults({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
1148
- if (!index) {
1149
- throw new Error('Parameter `index` is required when calling `getSearchesNoResults`.');
1150
- }
1151
- const requestPath = '/2/searches/noResults';
1152
- const headers = {};
1153
- const queryParameters = {};
1154
- if (index !== undefined) {
1155
- queryParameters.index = index.toString();
1156
- }
1157
- if (startDate !== undefined) {
1158
- queryParameters.startDate = startDate.toString();
1159
- }
1160
- if (endDate !== undefined) {
1161
- queryParameters.endDate = endDate.toString();
1162
- }
1163
- if (limit !== undefined) {
1164
- queryParameters.limit = limit.toString();
1165
- }
1166
- if (offset !== undefined) {
1167
- queryParameters.offset = offset.toString();
1168
- }
1169
- if (tags !== undefined) {
1170
- queryParameters.tags = tags.toString();
1171
- }
1172
- const request = {
1173
- method: 'GET',
1174
- path: requestPath,
1175
- queryParameters,
1176
- headers,
1177
- };
1178
- return transporter.request(request, requestOptions);
1179
- },
1180
- /**
1181
- * Returns the latest update time of the analytics API for a given index. If the index has been recently created and/or no search has been performed yet the updated time will be null.
1182
- *
1183
- * @summary Get Analytics API status.
1184
- * @param getStatus - The getStatus object.
1185
- * @param getStatus.index - The index name to target.
1186
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1187
- */
1188
- getStatus({ index }, requestOptions) {
1189
- if (!index) {
1190
- throw new Error('Parameter `index` is required when calling `getStatus`.');
1191
- }
1192
- const requestPath = '/2/status';
1193
- const headers = {};
1194
- const queryParameters = {};
1195
- if (index !== undefined) {
1196
- queryParameters.index = index.toString();
1197
- }
1198
- const request = {
1199
- method: 'GET',
1200
- path: requestPath,
1201
- queryParameters,
1202
- headers,
1203
- };
1204
- return transporter.request(request, requestOptions);
1205
- },
1206
- /**
1207
- * Returns top countries. Limited to the 1000 most frequent ones.
1208
- *
1209
- * @summary Get top countries.
1210
- * @param getTopCountries - The getTopCountries object.
1211
- * @param getTopCountries.index - The index name to target.
1212
- * @param getTopCountries.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1213
- * @param getTopCountries.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1214
- * @param getTopCountries.limit - Number of records to return. Limit is the size of the page.
1215
- * @param getTopCountries.offset - Position of the starting record. Used for paging. 0 is the first record.
1216
- * @param getTopCountries.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1217
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1218
- */
1219
- getTopCountries({ index, startDate, endDate, limit, offset, tags }, requestOptions) {
1220
- if (!index) {
1221
- throw new Error('Parameter `index` is required when calling `getTopCountries`.');
1222
- }
1223
- const requestPath = '/2/countries';
1224
- const headers = {};
1225
- const queryParameters = {};
1226
- if (index !== undefined) {
1227
- queryParameters.index = index.toString();
1228
- }
1229
- if (startDate !== undefined) {
1230
- queryParameters.startDate = startDate.toString();
1231
- }
1232
- if (endDate !== undefined) {
1233
- queryParameters.endDate = endDate.toString();
1234
- }
1235
- if (limit !== undefined) {
1236
- queryParameters.limit = limit.toString();
1237
- }
1238
- if (offset !== undefined) {
1239
- queryParameters.offset = offset.toString();
1240
- }
1241
- if (tags !== undefined) {
1242
- queryParameters.tags = tags.toString();
1243
- }
1244
- const request = {
1245
- method: 'GET',
1246
- path: requestPath,
1247
- queryParameters,
1248
- headers,
1249
- };
1250
- return transporter.request(request, requestOptions);
1251
- },
1252
- /**
1253
- * Returns top filter attributes. Limited to the 1000 most used filters.
1254
- *
1255
- * @summary Get top filter attributes.
1256
- * @param getTopFilterAttributes - The getTopFilterAttributes object.
1257
- * @param getTopFilterAttributes.index - The index name to target.
1258
- * @param getTopFilterAttributes.search - The query term to search for. Must match the exact user input.
1259
- * @param getTopFilterAttributes.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1260
- * @param getTopFilterAttributes.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1261
- * @param getTopFilterAttributes.limit - Number of records to return. Limit is the size of the page.
1262
- * @param getTopFilterAttributes.offset - Position of the starting record. Used for paging. 0 is the first record.
1263
- * @param getTopFilterAttributes.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1264
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1265
- */
1266
- getTopFilterAttributes({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1267
- if (!index) {
1268
- throw new Error('Parameter `index` is required when calling `getTopFilterAttributes`.');
1269
- }
1270
- const requestPath = '/2/filters';
1271
- const headers = {};
1272
- const queryParameters = {};
1273
- if (index !== undefined) {
1274
- queryParameters.index = index.toString();
1275
- }
1276
- if (search !== undefined) {
1277
- queryParameters.search = search.toString();
1278
- }
1279
- if (startDate !== undefined) {
1280
- queryParameters.startDate = startDate.toString();
1281
- }
1282
- if (endDate !== undefined) {
1283
- queryParameters.endDate = endDate.toString();
1284
- }
1285
- if (limit !== undefined) {
1286
- queryParameters.limit = limit.toString();
1287
- }
1288
- if (offset !== undefined) {
1289
- queryParameters.offset = offset.toString();
1290
- }
1291
- if (tags !== undefined) {
1292
- queryParameters.tags = tags.toString();
1293
- }
1294
- const request = {
1295
- method: 'GET',
1296
- path: requestPath,
1297
- queryParameters,
1298
- headers,
1299
- };
1300
- return transporter.request(request, requestOptions);
1301
- },
1302
- /**
1303
- * Returns top filters for the given attribute. Limited to the 1000 most used filters.
1304
- *
1305
- * @summary Get top filters for the an attribute.
1306
- * @param getTopFilterForAttribute - The getTopFilterForAttribute object.
1307
- * @param getTopFilterForAttribute.attribute - The exact name of the attribute.
1308
- * @param getTopFilterForAttribute.index - The index name to target.
1309
- * @param getTopFilterForAttribute.search - The query term to search for. Must match the exact user input.
1310
- * @param getTopFilterForAttribute.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1311
- * @param getTopFilterForAttribute.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1312
- * @param getTopFilterForAttribute.limit - Number of records to return. Limit is the size of the page.
1313
- * @param getTopFilterForAttribute.offset - Position of the starting record. Used for paging. 0 is the first record.
1314
- * @param getTopFilterForAttribute.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1315
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1316
- */
1317
- getTopFilterForAttribute({ attribute, index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1318
- if (!attribute) {
1319
- throw new Error('Parameter `attribute` is required when calling `getTopFilterForAttribute`.');
1320
- }
1321
- if (!index) {
1322
- throw new Error('Parameter `index` is required when calling `getTopFilterForAttribute`.');
1323
- }
1324
- const requestPath = '/2/filters/{attribute}'.replace('{attribute}', encodeURIComponent(attribute));
1325
- const headers = {};
1326
- const queryParameters = {};
1327
- if (index !== undefined) {
1328
- queryParameters.index = index.toString();
1329
- }
1330
- if (search !== undefined) {
1331
- queryParameters.search = search.toString();
1332
- }
1333
- if (startDate !== undefined) {
1334
- queryParameters.startDate = startDate.toString();
1335
- }
1336
- if (endDate !== undefined) {
1337
- queryParameters.endDate = endDate.toString();
1338
- }
1339
- if (limit !== undefined) {
1340
- queryParameters.limit = limit.toString();
1341
- }
1342
- if (offset !== undefined) {
1343
- queryParameters.offset = offset.toString();
1344
- }
1345
- if (tags !== undefined) {
1346
- queryParameters.tags = tags.toString();
1347
- }
1348
- const request = {
1349
- method: 'GET',
1350
- path: requestPath,
1351
- queryParameters,
1352
- headers,
1353
- };
1354
- return transporter.request(request, requestOptions);
1355
- },
1356
- /**
1357
- * Returns top filters with no results. Limited to the 1000 most used filters.
1358
- *
1359
- * @summary Get top filters for a no result search.
1360
- * @param getTopFiltersNoResults - The getTopFiltersNoResults object.
1361
- * @param getTopFiltersNoResults.index - The index name to target.
1362
- * @param getTopFiltersNoResults.search - The query term to search for. Must match the exact user input.
1363
- * @param getTopFiltersNoResults.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1364
- * @param getTopFiltersNoResults.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1365
- * @param getTopFiltersNoResults.limit - Number of records to return. Limit is the size of the page.
1366
- * @param getTopFiltersNoResults.offset - Position of the starting record. Used for paging. 0 is the first record.
1367
- * @param getTopFiltersNoResults.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1368
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1369
- */
1370
- getTopFiltersNoResults({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1371
- if (!index) {
1372
- throw new Error('Parameter `index` is required when calling `getTopFiltersNoResults`.');
1373
- }
1374
- const requestPath = '/2/filters/noResults';
1375
- const headers = {};
1376
- const queryParameters = {};
1377
- if (index !== undefined) {
1378
- queryParameters.index = index.toString();
1379
- }
1380
- if (search !== undefined) {
1381
- queryParameters.search = search.toString();
1382
- }
1383
- if (startDate !== undefined) {
1384
- queryParameters.startDate = startDate.toString();
1385
- }
1386
- if (endDate !== undefined) {
1387
- queryParameters.endDate = endDate.toString();
1388
- }
1389
- if (limit !== undefined) {
1390
- queryParameters.limit = limit.toString();
1391
- }
1392
- if (offset !== undefined) {
1393
- queryParameters.offset = offset.toString();
1394
- }
1395
- if (tags !== undefined) {
1396
- queryParameters.tags = tags.toString();
1397
- }
1398
- const request = {
1399
- method: 'GET',
1400
- path: requestPath,
1401
- queryParameters,
1402
- headers,
1403
- };
1404
- return transporter.request(request, requestOptions);
1405
- },
1406
- /**
1407
- * Returns top hits. Limited to the 1000 most frequent ones.
1408
- *
1409
- * @summary Get top hits.
1410
- * @param getTopHits - The getTopHits object.
1411
- * @param getTopHits.index - The index name to target.
1412
- * @param getTopHits.search - The query term to search for. Must match the exact user input.
1413
- * @param getTopHits.clickAnalytics - Whether to include the click-through and conversion rates for a search.
1414
- * @param getTopHits.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1415
- * @param getTopHits.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1416
- * @param getTopHits.limit - Number of records to return. Limit is the size of the page.
1417
- * @param getTopHits.offset - Position of the starting record. Used for paging. 0 is the first record.
1418
- * @param getTopHits.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1419
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1420
- */
1421
- getTopHits({ index, search, clickAnalytics, startDate, endDate, limit, offset, tags, }, requestOptions) {
1422
- if (!index) {
1423
- throw new Error('Parameter `index` is required when calling `getTopHits`.');
1424
- }
1425
- const requestPath = '/2/hits';
1426
- const headers = {};
1427
- const queryParameters = {};
1428
- if (index !== undefined) {
1429
- queryParameters.index = index.toString();
1430
- }
1431
- if (search !== undefined) {
1432
- queryParameters.search = search.toString();
1433
- }
1434
- if (clickAnalytics !== undefined) {
1435
- queryParameters.clickAnalytics = clickAnalytics.toString();
1436
- }
1437
- if (startDate !== undefined) {
1438
- queryParameters.startDate = startDate.toString();
1439
- }
1440
- if (endDate !== undefined) {
1441
- queryParameters.endDate = endDate.toString();
1442
- }
1443
- if (limit !== undefined) {
1444
- queryParameters.limit = limit.toString();
1445
- }
1446
- if (offset !== undefined) {
1447
- queryParameters.offset = offset.toString();
1448
- }
1449
- if (tags !== undefined) {
1450
- queryParameters.tags = tags.toString();
1451
- }
1452
- const request = {
1453
- method: 'GET',
1454
- path: requestPath,
1455
- queryParameters,
1456
- headers,
1457
- };
1458
- return transporter.request(request, requestOptions);
1459
- },
1460
- /**
1461
- * Returns top searches. Limited to the 1000 most frequent ones. For each search, also returns the average number of hits returned.
1462
- *
1463
- * @summary Get top searches.
1464
- * @param getTopSearches - The getTopSearches object.
1465
- * @param getTopSearches.index - The index name to target.
1466
- * @param getTopSearches.clickAnalytics - Whether to include the click-through and conversion rates for a search.
1467
- * @param getTopSearches.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1468
- * @param getTopSearches.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1469
- * @param getTopSearches.orderBy - Reorder the results.
1470
- * @param getTopSearches.direction - The sorting of the result.
1471
- * @param getTopSearches.limit - Number of records to return. Limit is the size of the page.
1472
- * @param getTopSearches.offset - Position of the starting record. Used for paging. 0 is the first record.
1473
- * @param getTopSearches.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1474
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1475
- */
1476
- getTopSearches({ index, clickAnalytics, startDate, endDate, orderBy, direction, limit, offset, tags, }, requestOptions) {
1477
- if (!index) {
1478
- throw new Error('Parameter `index` is required when calling `getTopSearches`.');
1479
- }
1480
- const requestPath = '/2/searches';
1481
- const headers = {};
1482
- const queryParameters = {};
1483
- if (index !== undefined) {
1484
- queryParameters.index = index.toString();
1485
- }
1486
- if (clickAnalytics !== undefined) {
1487
- queryParameters.clickAnalytics = clickAnalytics.toString();
1488
- }
1489
- if (startDate !== undefined) {
1490
- queryParameters.startDate = startDate.toString();
1491
- }
1492
- if (endDate !== undefined) {
1493
- queryParameters.endDate = endDate.toString();
1494
- }
1495
- if (orderBy !== undefined) {
1496
- queryParameters.orderBy = orderBy.toString();
1497
- }
1498
- if (direction !== undefined) {
1499
- queryParameters.direction = direction.toString();
1500
- }
1501
- if (limit !== undefined) {
1502
- queryParameters.limit = limit.toString();
1503
- }
1504
- if (offset !== undefined) {
1505
- queryParameters.offset = offset.toString();
1506
- }
1507
- if (tags !== undefined) {
1508
- queryParameters.tags = tags.toString();
1509
- }
1510
- const request = {
1511
- method: 'GET',
1512
- path: requestPath,
1513
- queryParameters,
1514
- headers,
1515
- };
1516
- return transporter.request(request, requestOptions);
1517
- },
1518
- /**
1519
- * Returns the distinct count of users across the given time range. The endpoint returns a value for the complete given time range, as well as a value per day.
1520
- *
1521
- * @summary Get users count.
1522
- * @param getUsersCount - The getUsersCount object.
1523
- * @param getUsersCount.index - The index name to target.
1524
- * @param getUsersCount.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1525
- * @param getUsersCount.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1526
- * @param getUsersCount.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1527
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1528
- */
1529
- getUsersCount({ index, startDate, endDate, tags }, requestOptions) {
1530
- if (!index) {
1531
- throw new Error('Parameter `index` is required when calling `getUsersCount`.');
1532
- }
1533
- const requestPath = '/2/users/count';
1534
- const headers = {};
1535
- const queryParameters = {};
1536
- if (index !== undefined) {
1537
- queryParameters.index = index.toString();
1538
- }
1539
- if (startDate !== undefined) {
1540
- queryParameters.startDate = startDate.toString();
1541
- }
1542
- if (endDate !== undefined) {
1543
- queryParameters.endDate = endDate.toString();
1544
- }
1545
- if (tags !== undefined) {
1546
- queryParameters.tags = tags.toString();
1547
- }
1548
- const request = {
1549
- method: 'GET',
1550
- path: requestPath,
1551
- queryParameters,
1552
- headers,
1553
- };
1554
- return transporter.request(request, requestOptions);
1555
- },
1556
- /**
1557
- * This method allow you to send requests to the Algolia REST API.
1558
- *
1559
- * @summary Send requests to the Algolia REST API.
1560
- * @param post - The post object.
1561
- * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1562
- * @param post.parameters - Query parameters to be applied to the current query.
1563
- * @param post.body - The parameters to send with the custom request.
1564
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1565
- */
1566
- post({ path, parameters, body }, requestOptions) {
1567
- if (!path) {
1568
- throw new Error('Parameter `path` is required when calling `post`.');
1569
- }
1570
- const requestPath = '/1{path}'.replace('{path}', path);
1571
- const headers = {};
1572
- const queryParameters = parameters ? parameters : {};
1573
- const request = {
1574
- method: 'POST',
1575
- path: requestPath,
1576
- queryParameters,
1577
- headers,
1578
- data: body ? body : {},
1579
- };
1580
- return transporter.request(request, requestOptions);
1581
- },
1582
- /**
1583
- * This method allow you to send requests to the Algolia REST API.
1584
- *
1585
- * @summary Send requests to the Algolia REST API.
1586
- * @param put - The put object.
1587
- * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1588
- * @param put.parameters - Query parameters to be applied to the current query.
1589
- * @param put.body - The parameters to send with the custom request.
1590
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1591
- */
1592
- put({ path, parameters, body }, requestOptions) {
1593
- if (!path) {
1594
- throw new Error('Parameter `path` is required when calling `put`.');
1595
- }
1596
- const requestPath = '/1{path}'.replace('{path}', path);
1597
- const headers = {};
1598
- const queryParameters = parameters ? parameters : {};
1599
- const request = {
1600
- method: 'PUT',
1601
- path: requestPath,
1602
- queryParameters,
1603
- headers,
1604
- data: body ? body : {},
1605
- };
1606
- return transporter.request(request, requestOptions);
1607
- },
1608
- };
688
+ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
689
+ const apiClientVersion = '5.0.0-alpha.100';
690
+ const REGIONS = ['de', 'us'];
691
+ function getDefaultHosts(region) {
692
+ const url = !region
693
+ ? 'analytics.algolia.com'
694
+ : 'analytics.{region}.algolia.com'.replace('{region}', region);
695
+ return [{ url, accept: 'readWrite', protocol: 'https' }];
696
+ }
697
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
698
+ function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
699
+ const auth = createAuth(appIdOption, apiKeyOption, authMode);
700
+ const transporter = createTransporter({
701
+ hosts: getDefaultHosts(regionOption),
702
+ ...options,
703
+ algoliaAgent: getAlgoliaAgent({
704
+ algoliaAgents,
705
+ client: 'Analytics',
706
+ version: apiClientVersion,
707
+ }),
708
+ baseHeaders: {
709
+ 'content-type': 'text/plain',
710
+ ...auth.headers(),
711
+ ...options.baseHeaders,
712
+ },
713
+ baseQueryParameters: {
714
+ ...auth.queryParameters(),
715
+ ...options.baseQueryParameters,
716
+ },
717
+ });
718
+ return {
719
+ transporter,
720
+ /**
721
+ * The `appId` currently in use.
722
+ */
723
+ appId: appIdOption,
724
+ /**
725
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
726
+ */
727
+ clearCache() {
728
+ return Promise.all([
729
+ transporter.requestsCache.clear(),
730
+ transporter.responsesCache.clear(),
731
+ ]).then(() => undefined);
732
+ },
733
+ /**
734
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
735
+ */
736
+ get _ua() {
737
+ return transporter.algoliaAgent.value;
738
+ },
739
+ /**
740
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
741
+ *
742
+ * @param segment - The algolia agent (user-agent) segment to add.
743
+ * @param version - The version of the agent.
744
+ */
745
+ addAlgoliaAgent(segment, version) {
746
+ transporter.algoliaAgent.add({ segment, version });
747
+ },
748
+ /**
749
+ * This method allow you to send requests to the Algolia REST API.
750
+ *
751
+ * @param customDelete - The customDelete object.
752
+ * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
753
+ * @param customDelete.parameters - Query parameters to apply to the current query.
754
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
755
+ */
756
+ customDelete({ path, parameters }, requestOptions) {
757
+ if (!path) {
758
+ throw new Error('Parameter `path` is required when calling `customDelete`.');
759
+ }
760
+ const requestPath = '/1{path}'.replace('{path}', path);
761
+ const headers = {};
762
+ const queryParameters = parameters ? parameters : {};
763
+ const request = {
764
+ method: 'DELETE',
765
+ path: requestPath,
766
+ queryParameters,
767
+ headers,
768
+ };
769
+ return transporter.request(request, requestOptions);
770
+ },
771
+ /**
772
+ * This method allow you to send requests to the Algolia REST API.
773
+ *
774
+ * @param customGet - The customGet object.
775
+ * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
776
+ * @param customGet.parameters - Query parameters to apply to the current query.
777
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
778
+ */
779
+ customGet({ path, parameters }, requestOptions) {
780
+ if (!path) {
781
+ throw new Error('Parameter `path` is required when calling `customGet`.');
782
+ }
783
+ const requestPath = '/1{path}'.replace('{path}', path);
784
+ const headers = {};
785
+ const queryParameters = parameters ? parameters : {};
786
+ const request = {
787
+ method: 'GET',
788
+ path: requestPath,
789
+ queryParameters,
790
+ headers,
791
+ };
792
+ return transporter.request(request, requestOptions);
793
+ },
794
+ /**
795
+ * This method allow you to send requests to the Algolia REST API.
796
+ *
797
+ * @param customPost - The customPost object.
798
+ * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
799
+ * @param customPost.parameters - Query parameters to apply to the current query.
800
+ * @param customPost.body - Parameters to send with the custom request.
801
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
802
+ */
803
+ customPost({ path, parameters, body }, requestOptions) {
804
+ if (!path) {
805
+ throw new Error('Parameter `path` is required when calling `customPost`.');
806
+ }
807
+ const requestPath = '/1{path}'.replace('{path}', path);
808
+ const headers = {};
809
+ const queryParameters = parameters ? parameters : {};
810
+ const request = {
811
+ method: 'POST',
812
+ path: requestPath,
813
+ queryParameters,
814
+ headers,
815
+ data: body ? body : {},
816
+ };
817
+ return transporter.request(request, requestOptions);
818
+ },
819
+ /**
820
+ * This method allow you to send requests to the Algolia REST API.
821
+ *
822
+ * @param customPut - The customPut object.
823
+ * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
824
+ * @param customPut.parameters - Query parameters to apply to the current query.
825
+ * @param customPut.body - Parameters to send with the custom request.
826
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
827
+ */
828
+ customPut({ path, parameters, body }, requestOptions) {
829
+ if (!path) {
830
+ throw new Error('Parameter `path` is required when calling `customPut`.');
831
+ }
832
+ const requestPath = '/1{path}'.replace('{path}', path);
833
+ const headers = {};
834
+ const queryParameters = parameters ? parameters : {};
835
+ const request = {
836
+ method: 'PUT',
837
+ path: requestPath,
838
+ queryParameters,
839
+ headers,
840
+ data: body ? body : {},
841
+ };
842
+ return transporter.request(request, requestOptions);
843
+ },
844
+ /**
845
+ * Return the average click position for the complete time range and for individual days. > **Note**: If all `positions` have a `clickCount` of `0` or `null`, it means Algolia didn\'t receive any click events for tracked searches. A _tracked_ search is a search request where the `clickAnalytics` parameter is `true`.
846
+ *
847
+ * Required API Key ACLs:
848
+ * - analytics.
849
+ *
850
+ * @param getAverageClickPosition - The getAverageClickPosition object.
851
+ * @param getAverageClickPosition.index - Index name to target.
852
+ * @param getAverageClickPosition.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
853
+ * @param getAverageClickPosition.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
854
+ * @param getAverageClickPosition.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
855
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
856
+ */
857
+ getAverageClickPosition({ index, startDate, endDate, tags }, requestOptions) {
858
+ if (!index) {
859
+ throw new Error('Parameter `index` is required when calling `getAverageClickPosition`.');
860
+ }
861
+ const requestPath = '/2/clicks/averageClickPosition';
862
+ const headers = {};
863
+ const queryParameters = {};
864
+ if (index !== undefined) {
865
+ queryParameters.index = index.toString();
866
+ }
867
+ if (startDate !== undefined) {
868
+ queryParameters.startDate = startDate.toString();
869
+ }
870
+ if (endDate !== undefined) {
871
+ queryParameters.endDate = endDate.toString();
872
+ }
873
+ if (tags !== undefined) {
874
+ queryParameters.tags = tags.toString();
875
+ }
876
+ const request = {
877
+ method: 'GET',
878
+ path: requestPath,
879
+ queryParameters,
880
+ headers,
881
+ };
882
+ return transporter.request(request, requestOptions);
883
+ },
884
+ /**
885
+ * Show the number of clicks events and their associated position in the search results. > **Note**: If all `positions` have a `clickCount` of `0` or `null`, it means Algolia didn\'t receive any click events for tracked searches. A _tracked_ search is a search request where the `clickAnalytics` parameter is `true`.
886
+ *
887
+ * Required API Key ACLs:
888
+ * - analytics.
889
+ *
890
+ * @param getClickPositions - The getClickPositions object.
891
+ * @param getClickPositions.index - Index name to target.
892
+ * @param getClickPositions.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
893
+ * @param getClickPositions.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
894
+ * @param getClickPositions.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
895
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
896
+ */
897
+ getClickPositions({ index, startDate, endDate, tags }, requestOptions) {
898
+ if (!index) {
899
+ throw new Error('Parameter `index` is required when calling `getClickPositions`.');
900
+ }
901
+ const requestPath = '/2/clicks/positions';
902
+ const headers = {};
903
+ const queryParameters = {};
904
+ if (index !== undefined) {
905
+ queryParameters.index = index.toString();
906
+ }
907
+ if (startDate !== undefined) {
908
+ queryParameters.startDate = startDate.toString();
909
+ }
910
+ if (endDate !== undefined) {
911
+ queryParameters.endDate = endDate.toString();
912
+ }
913
+ if (tags !== undefined) {
914
+ queryParameters.tags = tags.toString();
915
+ }
916
+ const request = {
917
+ method: 'GET',
918
+ path: requestPath,
919
+ queryParameters,
920
+ headers,
921
+ };
922
+ return transporter.request(request, requestOptions);
923
+ },
924
+ /**
925
+ * Returns a [click-through rate (CTR)](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#click-through-rate).
926
+ *
927
+ * Required API Key ACLs:
928
+ * - analytics.
929
+ *
930
+ * @param getClickThroughRate - The getClickThroughRate object.
931
+ * @param getClickThroughRate.index - Index name to target.
932
+ * @param getClickThroughRate.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
933
+ * @param getClickThroughRate.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
934
+ * @param getClickThroughRate.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
935
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
936
+ */
937
+ getClickThroughRate({ index, startDate, endDate, tags }, requestOptions) {
938
+ if (!index) {
939
+ throw new Error('Parameter `index` is required when calling `getClickThroughRate`.');
940
+ }
941
+ const requestPath = '/2/clicks/clickThroughRate';
942
+ const headers = {};
943
+ const queryParameters = {};
944
+ if (index !== undefined) {
945
+ queryParameters.index = index.toString();
946
+ }
947
+ if (startDate !== undefined) {
948
+ queryParameters.startDate = startDate.toString();
949
+ }
950
+ if (endDate !== undefined) {
951
+ queryParameters.endDate = endDate.toString();
952
+ }
953
+ if (tags !== undefined) {
954
+ queryParameters.tags = tags.toString();
955
+ }
956
+ const request = {
957
+ method: 'GET',
958
+ path: requestPath,
959
+ queryParameters,
960
+ headers,
961
+ };
962
+ return transporter.request(request, requestOptions);
963
+ },
964
+ /**
965
+ * Return a [conversion rate](https://www.algolia.com/doc/guides/search-analytics/concepts/metrics/#conversion-rate).
966
+ *
967
+ * Required API Key ACLs:
968
+ * - analytics.
969
+ *
970
+ * @param getConversationRate - The getConversationRate object.
971
+ * @param getConversationRate.index - Index name to target.
972
+ * @param getConversationRate.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
973
+ * @param getConversationRate.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
974
+ * @param getConversationRate.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
975
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
976
+ */
977
+ getConversationRate({ index, startDate, endDate, tags }, requestOptions) {
978
+ if (!index) {
979
+ throw new Error('Parameter `index` is required when calling `getConversationRate`.');
980
+ }
981
+ const requestPath = '/2/conversions/conversionRate';
982
+ const headers = {};
983
+ const queryParameters = {};
984
+ if (index !== undefined) {
985
+ queryParameters.index = index.toString();
986
+ }
987
+ if (startDate !== undefined) {
988
+ queryParameters.startDate = startDate.toString();
989
+ }
990
+ if (endDate !== undefined) {
991
+ queryParameters.endDate = endDate.toString();
992
+ }
993
+ if (tags !== undefined) {
994
+ queryParameters.tags = tags.toString();
995
+ }
996
+ const request = {
997
+ method: 'GET',
998
+ path: requestPath,
999
+ queryParameters,
1000
+ headers,
1001
+ };
1002
+ return transporter.request(request, requestOptions);
1003
+ },
1004
+ /**
1005
+ * Returns the rate at which searches don\'t lead to any clicks. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without clicks.
1006
+ *
1007
+ * Required API Key ACLs:
1008
+ * - analytics.
1009
+ *
1010
+ * @param getNoClickRate - The getNoClickRate object.
1011
+ * @param getNoClickRate.index - Index name to target.
1012
+ * @param getNoClickRate.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1013
+ * @param getNoClickRate.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1014
+ * @param getNoClickRate.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1015
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1016
+ */
1017
+ getNoClickRate({ index, startDate, endDate, tags }, requestOptions) {
1018
+ if (!index) {
1019
+ throw new Error('Parameter `index` is required when calling `getNoClickRate`.');
1020
+ }
1021
+ const requestPath = '/2/searches/noClickRate';
1022
+ const headers = {};
1023
+ const queryParameters = {};
1024
+ if (index !== undefined) {
1025
+ queryParameters.index = index.toString();
1026
+ }
1027
+ if (startDate !== undefined) {
1028
+ queryParameters.startDate = startDate.toString();
1029
+ }
1030
+ if (endDate !== undefined) {
1031
+ queryParameters.endDate = endDate.toString();
1032
+ }
1033
+ if (tags !== undefined) {
1034
+ queryParameters.tags = tags.toString();
1035
+ }
1036
+ const request = {
1037
+ method: 'GET',
1038
+ path: requestPath,
1039
+ queryParameters,
1040
+ headers,
1041
+ };
1042
+ return transporter.request(request, requestOptions);
1043
+ },
1044
+ /**
1045
+ * Returns the rate at which searches didn\'t return any results.
1046
+ *
1047
+ * Required API Key ACLs:
1048
+ * - analytics.
1049
+ *
1050
+ * @param getNoResultsRate - The getNoResultsRate object.
1051
+ * @param getNoResultsRate.index - Index name to target.
1052
+ * @param getNoResultsRate.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1053
+ * @param getNoResultsRate.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1054
+ * @param getNoResultsRate.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1055
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1056
+ */
1057
+ getNoResultsRate({ index, startDate, endDate, tags }, requestOptions) {
1058
+ if (!index) {
1059
+ throw new Error('Parameter `index` is required when calling `getNoResultsRate`.');
1060
+ }
1061
+ const requestPath = '/2/searches/noResultRate';
1062
+ const headers = {};
1063
+ const queryParameters = {};
1064
+ if (index !== undefined) {
1065
+ queryParameters.index = index.toString();
1066
+ }
1067
+ if (startDate !== undefined) {
1068
+ queryParameters.startDate = startDate.toString();
1069
+ }
1070
+ if (endDate !== undefined) {
1071
+ queryParameters.endDate = endDate.toString();
1072
+ }
1073
+ if (tags !== undefined) {
1074
+ queryParameters.tags = tags.toString();
1075
+ }
1076
+ const request = {
1077
+ method: 'GET',
1078
+ path: requestPath,
1079
+ queryParameters,
1080
+ headers,
1081
+ };
1082
+ return transporter.request(request, requestOptions);
1083
+ },
1084
+ /**
1085
+ * Returns the number of searches within a time range.
1086
+ *
1087
+ * Required API Key ACLs:
1088
+ * - analytics.
1089
+ *
1090
+ * @param getSearchesCount - The getSearchesCount object.
1091
+ * @param getSearchesCount.index - Index name to target.
1092
+ * @param getSearchesCount.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1093
+ * @param getSearchesCount.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1094
+ * @param getSearchesCount.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1095
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1096
+ */
1097
+ getSearchesCount({ index, startDate, endDate, tags }, requestOptions) {
1098
+ if (!index) {
1099
+ throw new Error('Parameter `index` is required when calling `getSearchesCount`.');
1100
+ }
1101
+ const requestPath = '/2/searches/count';
1102
+ const headers = {};
1103
+ const queryParameters = {};
1104
+ if (index !== undefined) {
1105
+ queryParameters.index = index.toString();
1106
+ }
1107
+ if (startDate !== undefined) {
1108
+ queryParameters.startDate = startDate.toString();
1109
+ }
1110
+ if (endDate !== undefined) {
1111
+ queryParameters.endDate = endDate.toString();
1112
+ }
1113
+ if (tags !== undefined) {
1114
+ queryParameters.tags = tags.toString();
1115
+ }
1116
+ const request = {
1117
+ method: 'GET',
1118
+ path: requestPath,
1119
+ queryParameters,
1120
+ headers,
1121
+ };
1122
+ return transporter.request(request, requestOptions);
1123
+ },
1124
+ /**
1125
+ * Return the most popular of the last 1,000 searches that didn\'t lead to any clicks.
1126
+ *
1127
+ * Required API Key ACLs:
1128
+ * - analytics.
1129
+ *
1130
+ * @param getSearchesNoClicks - The getSearchesNoClicks object.
1131
+ * @param getSearchesNoClicks.index - Index name to target.
1132
+ * @param getSearchesNoClicks.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1133
+ * @param getSearchesNoClicks.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1134
+ * @param getSearchesNoClicks.limit - Number of records to return (page size).
1135
+ * @param getSearchesNoClicks.offset - Position of the starting record. Used for paging. 0 is the first record.
1136
+ * @param getSearchesNoClicks.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1137
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1138
+ */
1139
+ getSearchesNoClicks({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
1140
+ if (!index) {
1141
+ throw new Error('Parameter `index` is required when calling `getSearchesNoClicks`.');
1142
+ }
1143
+ const requestPath = '/2/searches/noClicks';
1144
+ const headers = {};
1145
+ const queryParameters = {};
1146
+ if (index !== undefined) {
1147
+ queryParameters.index = index.toString();
1148
+ }
1149
+ if (startDate !== undefined) {
1150
+ queryParameters.startDate = startDate.toString();
1151
+ }
1152
+ if (endDate !== undefined) {
1153
+ queryParameters.endDate = endDate.toString();
1154
+ }
1155
+ if (limit !== undefined) {
1156
+ queryParameters.limit = limit.toString();
1157
+ }
1158
+ if (offset !== undefined) {
1159
+ queryParameters.offset = offset.toString();
1160
+ }
1161
+ if (tags !== undefined) {
1162
+ queryParameters.tags = tags.toString();
1163
+ }
1164
+ const request = {
1165
+ method: 'GET',
1166
+ path: requestPath,
1167
+ queryParameters,
1168
+ headers,
1169
+ };
1170
+ return transporter.request(request, requestOptions);
1171
+ },
1172
+ /**
1173
+ * Returns the most popular of the latest 1,000 searches that didn\'t return any results.
1174
+ *
1175
+ * Required API Key ACLs:
1176
+ * - analytics.
1177
+ *
1178
+ * @param getSearchesNoResults - The getSearchesNoResults object.
1179
+ * @param getSearchesNoResults.index - Index name to target.
1180
+ * @param getSearchesNoResults.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1181
+ * @param getSearchesNoResults.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1182
+ * @param getSearchesNoResults.limit - Number of records to return (page size).
1183
+ * @param getSearchesNoResults.offset - Position of the starting record. Used for paging. 0 is the first record.
1184
+ * @param getSearchesNoResults.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1185
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1186
+ */
1187
+ getSearchesNoResults({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
1188
+ if (!index) {
1189
+ throw new Error('Parameter `index` is required when calling `getSearchesNoResults`.');
1190
+ }
1191
+ const requestPath = '/2/searches/noResults';
1192
+ const headers = {};
1193
+ const queryParameters = {};
1194
+ if (index !== undefined) {
1195
+ queryParameters.index = index.toString();
1196
+ }
1197
+ if (startDate !== undefined) {
1198
+ queryParameters.startDate = startDate.toString();
1199
+ }
1200
+ if (endDate !== undefined) {
1201
+ queryParameters.endDate = endDate.toString();
1202
+ }
1203
+ if (limit !== undefined) {
1204
+ queryParameters.limit = limit.toString();
1205
+ }
1206
+ if (offset !== undefined) {
1207
+ queryParameters.offset = offset.toString();
1208
+ }
1209
+ if (tags !== undefined) {
1210
+ queryParameters.tags = tags.toString();
1211
+ }
1212
+ const request = {
1213
+ method: 'GET',
1214
+ path: requestPath,
1215
+ queryParameters,
1216
+ headers,
1217
+ };
1218
+ return transporter.request(request, requestOptions);
1219
+ },
1220
+ /**
1221
+ * Return the latest update time of the Analytics API for an index. If the index has been recently created or no search has been performed yet, `updatedAt` will be `null`. > **Note**: The Analytics API is updated every 5&nbsp;minutes.
1222
+ *
1223
+ * Required API Key ACLs:
1224
+ * - analytics.
1225
+ *
1226
+ * @param getStatus - The getStatus object.
1227
+ * @param getStatus.index - Index name to target.
1228
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1229
+ */
1230
+ getStatus({ index }, requestOptions) {
1231
+ if (!index) {
1232
+ throw new Error('Parameter `index` is required when calling `getStatus`.');
1233
+ }
1234
+ const requestPath = '/2/status';
1235
+ const headers = {};
1236
+ const queryParameters = {};
1237
+ if (index !== undefined) {
1238
+ queryParameters.index = index.toString();
1239
+ }
1240
+ const request = {
1241
+ method: 'GET',
1242
+ path: requestPath,
1243
+ queryParameters,
1244
+ headers,
1245
+ };
1246
+ return transporter.request(request, requestOptions);
1247
+ },
1248
+ /**
1249
+ * Returns top countries. Limited to the 1,000 most frequent ones.
1250
+ *
1251
+ * Required API Key ACLs:
1252
+ * - analytics.
1253
+ *
1254
+ * @param getTopCountries - The getTopCountries object.
1255
+ * @param getTopCountries.index - Index name to target.
1256
+ * @param getTopCountries.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1257
+ * @param getTopCountries.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1258
+ * @param getTopCountries.limit - Number of records to return (page size).
1259
+ * @param getTopCountries.offset - Position of the starting record. Used for paging. 0 is the first record.
1260
+ * @param getTopCountries.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1261
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1262
+ */
1263
+ getTopCountries({ index, startDate, endDate, limit, offset, tags }, requestOptions) {
1264
+ if (!index) {
1265
+ throw new Error('Parameter `index` is required when calling `getTopCountries`.');
1266
+ }
1267
+ const requestPath = '/2/countries';
1268
+ const headers = {};
1269
+ const queryParameters = {};
1270
+ if (index !== undefined) {
1271
+ queryParameters.index = index.toString();
1272
+ }
1273
+ if (startDate !== undefined) {
1274
+ queryParameters.startDate = startDate.toString();
1275
+ }
1276
+ if (endDate !== undefined) {
1277
+ queryParameters.endDate = endDate.toString();
1278
+ }
1279
+ if (limit !== undefined) {
1280
+ queryParameters.limit = limit.toString();
1281
+ }
1282
+ if (offset !== undefined) {
1283
+ queryParameters.offset = offset.toString();
1284
+ }
1285
+ if (tags !== undefined) {
1286
+ queryParameters.tags = tags.toString();
1287
+ }
1288
+ const request = {
1289
+ method: 'GET',
1290
+ path: requestPath,
1291
+ queryParameters,
1292
+ headers,
1293
+ };
1294
+ return transporter.request(request, requestOptions);
1295
+ },
1296
+ /**
1297
+ * Return the most popular [filterable attributes](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/) in the 1,000 most recently used filters.
1298
+ *
1299
+ * Required API Key ACLs:
1300
+ * - analytics.
1301
+ *
1302
+ * @param getTopFilterAttributes - The getTopFilterAttributes object.
1303
+ * @param getTopFilterAttributes.index - Index name to target.
1304
+ * @param getTopFilterAttributes.search - User query.
1305
+ * @param getTopFilterAttributes.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1306
+ * @param getTopFilterAttributes.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1307
+ * @param getTopFilterAttributes.limit - Number of records to return (page size).
1308
+ * @param getTopFilterAttributes.offset - Position of the starting record. Used for paging. 0 is the first record.
1309
+ * @param getTopFilterAttributes.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1310
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1311
+ */
1312
+ getTopFilterAttributes({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1313
+ if (!index) {
1314
+ throw new Error('Parameter `index` is required when calling `getTopFilterAttributes`.');
1315
+ }
1316
+ const requestPath = '/2/filters';
1317
+ const headers = {};
1318
+ const queryParameters = {};
1319
+ if (index !== undefined) {
1320
+ queryParameters.index = index.toString();
1321
+ }
1322
+ if (search !== undefined) {
1323
+ queryParameters.search = search.toString();
1324
+ }
1325
+ if (startDate !== undefined) {
1326
+ queryParameters.startDate = startDate.toString();
1327
+ }
1328
+ if (endDate !== undefined) {
1329
+ queryParameters.endDate = endDate.toString();
1330
+ }
1331
+ if (limit !== undefined) {
1332
+ queryParameters.limit = limit.toString();
1333
+ }
1334
+ if (offset !== undefined) {
1335
+ queryParameters.offset = offset.toString();
1336
+ }
1337
+ if (tags !== undefined) {
1338
+ queryParameters.tags = tags.toString();
1339
+ }
1340
+ const request = {
1341
+ method: 'GET',
1342
+ path: requestPath,
1343
+ queryParameters,
1344
+ headers,
1345
+ };
1346
+ return transporter.request(request, requestOptions);
1347
+ },
1348
+ /**
1349
+ * Returns the most popular filter values for an attribute in the 1,000 most recently used filters.
1350
+ *
1351
+ * Required API Key ACLs:
1352
+ * - analytics.
1353
+ *
1354
+ * @param getTopFilterForAttribute - The getTopFilterForAttribute object.
1355
+ * @param getTopFilterForAttribute.attribute - Attribute name.
1356
+ * @param getTopFilterForAttribute.index - Index name to target.
1357
+ * @param getTopFilterForAttribute.search - User query.
1358
+ * @param getTopFilterForAttribute.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1359
+ * @param getTopFilterForAttribute.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1360
+ * @param getTopFilterForAttribute.limit - Number of records to return (page size).
1361
+ * @param getTopFilterForAttribute.offset - Position of the starting record. Used for paging. 0 is the first record.
1362
+ * @param getTopFilterForAttribute.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1363
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1364
+ */
1365
+ getTopFilterForAttribute({ attribute, index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1366
+ if (!attribute) {
1367
+ throw new Error('Parameter `attribute` is required when calling `getTopFilterForAttribute`.');
1368
+ }
1369
+ if (!index) {
1370
+ throw new Error('Parameter `index` is required when calling `getTopFilterForAttribute`.');
1371
+ }
1372
+ const requestPath = '/2/filters/{attribute}'.replace('{attribute}', encodeURIComponent(attribute));
1373
+ const headers = {};
1374
+ const queryParameters = {};
1375
+ if (index !== undefined) {
1376
+ queryParameters.index = index.toString();
1377
+ }
1378
+ if (search !== undefined) {
1379
+ queryParameters.search = search.toString();
1380
+ }
1381
+ if (startDate !== undefined) {
1382
+ queryParameters.startDate = startDate.toString();
1383
+ }
1384
+ if (endDate !== undefined) {
1385
+ queryParameters.endDate = endDate.toString();
1386
+ }
1387
+ if (limit !== undefined) {
1388
+ queryParameters.limit = limit.toString();
1389
+ }
1390
+ if (offset !== undefined) {
1391
+ queryParameters.offset = offset.toString();
1392
+ }
1393
+ if (tags !== undefined) {
1394
+ queryParameters.tags = tags.toString();
1395
+ }
1396
+ const request = {
1397
+ method: 'GET',
1398
+ path: requestPath,
1399
+ queryParameters,
1400
+ headers,
1401
+ };
1402
+ return transporter.request(request, requestOptions);
1403
+ },
1404
+ /**
1405
+ * Returns top filters for filter-enabled searches that don\'t return results. Limited to the 1,000 most recently used filters.
1406
+ *
1407
+ * Required API Key ACLs:
1408
+ * - analytics.
1409
+ *
1410
+ * @param getTopFiltersNoResults - The getTopFiltersNoResults object.
1411
+ * @param getTopFiltersNoResults.index - Index name to target.
1412
+ * @param getTopFiltersNoResults.search - User query.
1413
+ * @param getTopFiltersNoResults.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1414
+ * @param getTopFiltersNoResults.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1415
+ * @param getTopFiltersNoResults.limit - Number of records to return (page size).
1416
+ * @param getTopFiltersNoResults.offset - Position of the starting record. Used for paging. 0 is the first record.
1417
+ * @param getTopFiltersNoResults.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1418
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1419
+ */
1420
+ getTopFiltersNoResults({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1421
+ if (!index) {
1422
+ throw new Error('Parameter `index` is required when calling `getTopFiltersNoResults`.');
1423
+ }
1424
+ const requestPath = '/2/filters/noResults';
1425
+ const headers = {};
1426
+ const queryParameters = {};
1427
+ if (index !== undefined) {
1428
+ queryParameters.index = index.toString();
1429
+ }
1430
+ if (search !== undefined) {
1431
+ queryParameters.search = search.toString();
1432
+ }
1433
+ if (startDate !== undefined) {
1434
+ queryParameters.startDate = startDate.toString();
1435
+ }
1436
+ if (endDate !== undefined) {
1437
+ queryParameters.endDate = endDate.toString();
1438
+ }
1439
+ if (limit !== undefined) {
1440
+ queryParameters.limit = limit.toString();
1441
+ }
1442
+ if (offset !== undefined) {
1443
+ queryParameters.offset = offset.toString();
1444
+ }
1445
+ if (tags !== undefined) {
1446
+ queryParameters.tags = tags.toString();
1447
+ }
1448
+ const request = {
1449
+ method: 'GET',
1450
+ path: requestPath,
1451
+ queryParameters,
1452
+ headers,
1453
+ };
1454
+ return transporter.request(request, requestOptions);
1455
+ },
1456
+ /**
1457
+ * Return the most popular clicked results in the last 1,000 searches.
1458
+ *
1459
+ * Required API Key ACLs:
1460
+ * - analytics.
1461
+ *
1462
+ * @param getTopHits - The getTopHits object.
1463
+ * @param getTopHits.index - Index name to target.
1464
+ * @param getTopHits.search - User query.
1465
+ * @param getTopHits.clickAnalytics - Whether to include [click and conversion](https://www.algolia.com/doc/guides/sending-events/getting-started/) rates for a search.
1466
+ * @param getTopHits.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1467
+ * @param getTopHits.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1468
+ * @param getTopHits.limit - Number of records to return (page size).
1469
+ * @param getTopHits.offset - Position of the starting record. Used for paging. 0 is the first record.
1470
+ * @param getTopHits.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1471
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1472
+ */
1473
+ getTopHits({ index, search, clickAnalytics, startDate, endDate, limit, offset, tags, }, requestOptions) {
1474
+ if (!index) {
1475
+ throw new Error('Parameter `index` is required when calling `getTopHits`.');
1476
+ }
1477
+ const requestPath = '/2/hits';
1478
+ const headers = {};
1479
+ const queryParameters = {};
1480
+ if (index !== undefined) {
1481
+ queryParameters.index = index.toString();
1482
+ }
1483
+ if (search !== undefined) {
1484
+ queryParameters.search = search.toString();
1485
+ }
1486
+ if (clickAnalytics !== undefined) {
1487
+ queryParameters.clickAnalytics = clickAnalytics.toString();
1488
+ }
1489
+ if (startDate !== undefined) {
1490
+ queryParameters.startDate = startDate.toString();
1491
+ }
1492
+ if (endDate !== undefined) {
1493
+ queryParameters.endDate = endDate.toString();
1494
+ }
1495
+ if (limit !== undefined) {
1496
+ queryParameters.limit = limit.toString();
1497
+ }
1498
+ if (offset !== undefined) {
1499
+ queryParameters.offset = offset.toString();
1500
+ }
1501
+ if (tags !== undefined) {
1502
+ queryParameters.tags = tags.toString();
1503
+ }
1504
+ const request = {
1505
+ method: 'GET',
1506
+ path: requestPath,
1507
+ queryParameters,
1508
+ headers,
1509
+ };
1510
+ return transporter.request(request, requestOptions);
1511
+ },
1512
+ /**
1513
+ * Returns the most popular of the latest 1,000 searches. For each search, also returns the number of hits.
1514
+ *
1515
+ * Required API Key ACLs:
1516
+ * - analytics.
1517
+ *
1518
+ * @param getTopSearches - The getTopSearches object.
1519
+ * @param getTopSearches.index - Index name to target.
1520
+ * @param getTopSearches.clickAnalytics - Whether to include [click and conversion](https://www.algolia.com/doc/guides/sending-events/getting-started/) rates for a search.
1521
+ * @param getTopSearches.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1522
+ * @param getTopSearches.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1523
+ * @param getTopSearches.orderBy - Reorder the results.
1524
+ * @param getTopSearches.direction - Sorting direction of the results: ascending or descending.
1525
+ * @param getTopSearches.limit - Number of records to return (page size).
1526
+ * @param getTopSearches.offset - Position of the starting record. Used for paging. 0 is the first record.
1527
+ * @param getTopSearches.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1528
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1529
+ */
1530
+ getTopSearches({ index, clickAnalytics, startDate, endDate, orderBy, direction, limit, offset, tags, }, requestOptions) {
1531
+ if (!index) {
1532
+ throw new Error('Parameter `index` is required when calling `getTopSearches`.');
1533
+ }
1534
+ const requestPath = '/2/searches';
1535
+ const headers = {};
1536
+ const queryParameters = {};
1537
+ if (index !== undefined) {
1538
+ queryParameters.index = index.toString();
1539
+ }
1540
+ if (clickAnalytics !== undefined) {
1541
+ queryParameters.clickAnalytics = clickAnalytics.toString();
1542
+ }
1543
+ if (startDate !== undefined) {
1544
+ queryParameters.startDate = startDate.toString();
1545
+ }
1546
+ if (endDate !== undefined) {
1547
+ queryParameters.endDate = endDate.toString();
1548
+ }
1549
+ if (orderBy !== undefined) {
1550
+ queryParameters.orderBy = orderBy.toString();
1551
+ }
1552
+ if (direction !== undefined) {
1553
+ queryParameters.direction = direction.toString();
1554
+ }
1555
+ if (limit !== undefined) {
1556
+ queryParameters.limit = limit.toString();
1557
+ }
1558
+ if (offset !== undefined) {
1559
+ queryParameters.offset = offset.toString();
1560
+ }
1561
+ if (tags !== undefined) {
1562
+ queryParameters.tags = tags.toString();
1563
+ }
1564
+ const request = {
1565
+ method: 'GET',
1566
+ path: requestPath,
1567
+ queryParameters,
1568
+ headers,
1569
+ };
1570
+ return transporter.request(request, requestOptions);
1571
+ },
1572
+ /**
1573
+ * Return the count of unique users.
1574
+ *
1575
+ * Required API Key ACLs:
1576
+ * - analytics.
1577
+ *
1578
+ * @param getUsersCount - The getUsersCount object.
1579
+ * @param getUsersCount.index - Index name to target.
1580
+ * @param getUsersCount.startDate - Start date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1581
+ * @param getUsersCount.endDate - End date (a string in the format `YYYY-MM-DD`) of the period to analyze.
1582
+ * @param getUsersCount.tags - Filter analytics on the [`analyticsTags`](https://www.algolia.com/doc/api-reference/api-parameters/analyticsTags/) set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it must be URL-encoded.
1583
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1584
+ */
1585
+ getUsersCount({ index, startDate, endDate, tags }, requestOptions) {
1586
+ if (!index) {
1587
+ throw new Error('Parameter `index` is required when calling `getUsersCount`.');
1588
+ }
1589
+ const requestPath = '/2/users/count';
1590
+ const headers = {};
1591
+ const queryParameters = {};
1592
+ if (index !== undefined) {
1593
+ queryParameters.index = index.toString();
1594
+ }
1595
+ if (startDate !== undefined) {
1596
+ queryParameters.startDate = startDate.toString();
1597
+ }
1598
+ if (endDate !== undefined) {
1599
+ queryParameters.endDate = endDate.toString();
1600
+ }
1601
+ if (tags !== undefined) {
1602
+ queryParameters.tags = tags.toString();
1603
+ }
1604
+ const request = {
1605
+ method: 'GET',
1606
+ path: requestPath,
1607
+ queryParameters,
1608
+ headers,
1609
+ };
1610
+ return transporter.request(request, requestOptions);
1611
+ },
1612
+ };
1609
1613
  }
1610
1614
 
1611
- // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
1612
- function analyticsClient(appId, apiKey, region, options) {
1613
- if (!appId || typeof appId !== 'string') {
1614
- throw new Error('`appId` is missing.');
1615
- }
1616
- if (!apiKey || typeof apiKey !== 'string') {
1617
- throw new Error('`apiKey` is missing.');
1618
- }
1619
- if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
1620
- throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
1621
- }
1622
- return createAnalyticsClient({
1623
- appId,
1624
- apiKey,
1625
- region,
1626
- timeouts: {
1627
- connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
1628
- read: DEFAULT_READ_TIMEOUT_BROWSER,
1629
- write: DEFAULT_WRITE_TIMEOUT_BROWSER,
1630
- },
1631
- requester: createXhrRequester(),
1632
- algoliaAgents: [{ segment: 'Browser' }],
1633
- authMode: 'WithinQueryParameters',
1634
- responsesCache: createMemoryCache(),
1635
- requestsCache: createMemoryCache({ serializable: false }),
1636
- hostsCache: createFallbackableCache({
1637
- caches: [
1638
- createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
1639
- createMemoryCache(),
1640
- ],
1641
- }),
1642
- ...options,
1643
- });
1615
+ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
1616
+ function analyticsClient(appId, apiKey, region, options) {
1617
+ if (!appId || typeof appId !== 'string') {
1618
+ throw new Error('`appId` is missing.');
1619
+ }
1620
+ if (!apiKey || typeof apiKey !== 'string') {
1621
+ throw new Error('`apiKey` is missing.');
1622
+ }
1623
+ if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
1624
+ throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
1625
+ }
1626
+ return createAnalyticsClient({
1627
+ appId,
1628
+ apiKey,
1629
+ region,
1630
+ timeouts: {
1631
+ connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
1632
+ read: DEFAULT_READ_TIMEOUT_BROWSER,
1633
+ write: DEFAULT_WRITE_TIMEOUT_BROWSER,
1634
+ },
1635
+ requester: createXhrRequester(),
1636
+ algoliaAgents: [{ segment: 'Browser' }],
1637
+ authMode: 'WithinQueryParameters',
1638
+ responsesCache: createMemoryCache(),
1639
+ requestsCache: createMemoryCache({ serializable: false }),
1640
+ hostsCache: createFallbackableCache({
1641
+ caches: [
1642
+ createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
1643
+ createMemoryCache(),
1644
+ ],
1645
+ }),
1646
+ ...options,
1647
+ });
1644
1648
  }
1645
1649
 
1646
1650
  export { analyticsClient, apiClientVersion };