@algolia/client-analytics 5.0.0-alpha.8 → 5.0.0-alpha.80

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