@algolia/client-insights 5.0.0-alpha.99 → 5.0.0-beta.10

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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/dist/builds/browser.d.ts +19 -3
  3. package/dist/builds/browser.d.ts.map +1 -1
  4. package/dist/builds/node.d.ts +19 -3
  5. package/dist/builds/node.d.ts.map +1 -1
  6. package/dist/client-insights.cjs +27 -30
  7. package/dist/client-insights.esm.browser.js +23 -38
  8. package/dist/client-insights.esm.node.js +27 -30
  9. package/dist/client-insights.umd.js +2 -2
  10. package/dist/model/addedToCartObjectIDs.d.ts +6 -6
  11. package/dist/model/addedToCartObjectIDsAfterSearch.d.ts +6 -6
  12. package/dist/model/clickedFilters.d.ts +6 -6
  13. package/dist/model/clickedObjectIDs.d.ts +6 -6
  14. package/dist/model/clickedObjectIDsAfterSearch.d.ts +7 -7
  15. package/dist/model/clientMethodProps.d.ts +1 -1
  16. package/dist/model/convertedFilters.d.ts +6 -6
  17. package/dist/model/convertedObjectIDs.d.ts +6 -6
  18. package/dist/model/convertedObjectIDsAfterSearch.d.ts +6 -6
  19. package/dist/model/discount.d.ts +1 -1
  20. package/dist/model/insightsEvents.d.ts +1 -1
  21. package/dist/model/objectData.d.ts +1 -1
  22. package/dist/model/objectDataAfterSearch.d.ts +1 -1
  23. package/dist/model/price.d.ts +1 -1
  24. package/dist/model/purchasedObjectIDs.d.ts +6 -6
  25. package/dist/model/purchasedObjectIDsAfterSearch.d.ts +7 -7
  26. package/dist/model/purchasedObjectIDsAfterSearch.d.ts.map +1 -1
  27. package/dist/model/viewedFilters.d.ts +6 -6
  28. package/dist/model/viewedObjectIDs.d.ts +6 -6
  29. package/dist/src/insightsClient.d.ts +4 -14
  30. package/dist/src/insightsClient.d.ts.map +1 -1
  31. package/model/addedToCartObjectIDs.ts +6 -6
  32. package/model/addedToCartObjectIDsAfterSearch.ts +6 -6
  33. package/model/clickedFilters.ts +6 -6
  34. package/model/clickedObjectIDs.ts +6 -6
  35. package/model/clickedObjectIDsAfterSearch.ts +7 -7
  36. package/model/clientMethodProps.ts +1 -1
  37. package/model/convertedFilters.ts +6 -6
  38. package/model/convertedObjectIDs.ts +6 -6
  39. package/model/convertedObjectIDsAfterSearch.ts +6 -6
  40. package/model/discount.ts +1 -1
  41. package/model/insightsEvents.ts +1 -1
  42. package/model/objectData.ts +1 -1
  43. package/model/objectDataAfterSearch.ts +1 -1
  44. package/model/price.ts +1 -1
  45. package/model/purchasedObjectIDs.ts +6 -6
  46. package/model/purchasedObjectIDsAfterSearch.ts +7 -7
  47. package/model/viewedFilters.ts +6 -6
  48. package/model/viewedObjectIDs.ts +6 -6
  49. package/package.json +11 -8
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013-Present Algolia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,22 @@
1
1
  import type { ClientOptions } from '@algolia/client-common';
2
- import type { InsightsClient, Region } from '../src/insightsClient';
3
- export { apiClientVersion, InsightsClient, Region, } from '../src/insightsClient';
2
+ import type { Region } from '../src/insightsClient';
3
+ export { apiClientVersion, Region } from '../src/insightsClient';
4
4
  export * from '../model';
5
- export declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): InsightsClient;
5
+ /**
6
+ * The client type.
7
+ */
8
+ export type InsightsClient = ReturnType<typeof insightsClient>;
9
+ export declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): {
10
+ transporter: import("@algolia/client-common").Transporter;
11
+ appId: string;
12
+ clearCache(): Promise<void>;
13
+ readonly _ua: string;
14
+ addAlgoliaAgent(segment: string, version?: string): void;
15
+ customDelete({ path, parameters }: import("../model").CustomDeleteProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<Record<string, any>>;
16
+ customGet({ path, parameters }: import("../model").CustomGetProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<Record<string, any>>;
17
+ customPost({ path, parameters, body }: import("../model").CustomPostProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<Record<string, any>>;
18
+ customPut({ path, parameters, body }: import("../model").CustomPutProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<Record<string, any>>;
19
+ deleteUserToken({ userToken }: import("../model").DeleteUserTokenProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<void>;
20
+ pushEvents(insightsEvents: import("../model").InsightsEvents, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<import("../model").EventsResponse>;
21
+ };
6
22
  //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAW5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAOpE,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,MAAM,GACP,MAAM,uBAAuB,CAAC;AAC/B,cAAc,UAAU,CAAC;AAEzB,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa,GACtB,cAAc,CAqChB"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAW5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAOpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACjE,cAAc,UAAU,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAG/D,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa;;;;;;;;;;;;EAsCxB"}
@@ -1,6 +1,22 @@
1
1
  import type { ClientOptions } from '@algolia/client-common';
2
- import type { InsightsClient, Region } from '../src/insightsClient';
3
- export { apiClientVersion, InsightsClient, Region, } from '../src/insightsClient';
2
+ import type { Region } from '../src/insightsClient';
3
+ export { apiClientVersion, Region } from '../src/insightsClient';
4
4
  export * from '../model';
5
- export declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): InsightsClient;
5
+ /**
6
+ * The client type.
7
+ */
8
+ export type InsightsClient = ReturnType<typeof insightsClient>;
9
+ export declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): {
10
+ transporter: import("@algolia/client-common").Transporter;
11
+ appId: string;
12
+ clearCache(): Promise<void>;
13
+ _ua: string;
14
+ addAlgoliaAgent(segment: string, version?: string): void;
15
+ customDelete({ path, parameters }: import("../model").CustomDeleteProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<Record<string, any>>;
16
+ customGet({ path, parameters }: import("../model").CustomGetProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<Record<string, any>>;
17
+ customPost({ path, parameters, body }: import("../model").CustomPostProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<Record<string, any>>;
18
+ customPut({ path, parameters, body }: import("../model").CustomPutProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<Record<string, any>>;
19
+ deleteUserToken({ userToken }: import("../model").DeleteUserTokenProps, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<void>;
20
+ pushEvents(insightsEvents: import("../model").InsightsEvents, requestOptions?: import("@algolia/client-common").RequestOptions): Promise<import("../model").EventsResponse>;
21
+ };
6
22
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpE,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,MAAM,GACP,MAAM,uBAAuB,CAAC;AAC/B,cAAc,UAAU,CAAC;AAEzB,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa,GACtB,cAAc,CA+BhB"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACjE,cAAc,UAAU,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAG/D,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa;;;;;;;;;;;;EAkCxB"}
@@ -4,7 +4,7 @@ var clientCommon = require('@algolia/client-common');
4
4
  var requesterNodeHttp = require('@algolia/requester-node-http');
5
5
 
6
6
  // 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.
7
- const apiClientVersion = '5.0.0-alpha.99';
7
+ const apiClientVersion = '5.0.0-beta.10';
8
8
  const REGIONS = ['de', 'us'];
9
9
  function getDefaultHosts(region) {
10
10
  const url = !region
@@ -66,7 +66,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
66
66
  /**
67
67
  * This method allow you to send requests to the Algolia REST API.
68
68
  *
69
- * @summary Send requests to the Algolia REST API.
70
69
  * @param customDelete - The customDelete object.
71
70
  * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
72
71
  * @param customDelete.parameters - Query parameters to apply to the current query.
@@ -76,7 +75,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
76
75
  if (!path) {
77
76
  throw new Error('Parameter `path` is required when calling `customDelete`.');
78
77
  }
79
- const requestPath = '/1{path}'.replace('{path}', path);
78
+ const requestPath = '/{path}'.replace('{path}', path);
80
79
  const headers = {};
81
80
  const queryParameters = parameters ? parameters : {};
82
81
  const request = {
@@ -90,7 +89,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
90
89
  /**
91
90
  * This method allow you to send requests to the Algolia REST API.
92
91
  *
93
- * @summary Send requests to the Algolia REST API.
94
92
  * @param customGet - The customGet object.
95
93
  * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
96
94
  * @param customGet.parameters - Query parameters to apply to the current query.
@@ -100,7 +98,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
100
98
  if (!path) {
101
99
  throw new Error('Parameter `path` is required when calling `customGet`.');
102
100
  }
103
- const requestPath = '/1{path}'.replace('{path}', path);
101
+ const requestPath = '/{path}'.replace('{path}', path);
104
102
  const headers = {};
105
103
  const queryParameters = parameters ? parameters : {};
106
104
  const request = {
@@ -114,7 +112,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
114
112
  /**
115
113
  * This method allow you to send requests to the Algolia REST API.
116
114
  *
117
- * @summary Send requests to the Algolia REST API.
118
115
  * @param customPost - The customPost object.
119
116
  * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
120
117
  * @param customPost.parameters - Query parameters to apply to the current query.
@@ -125,7 +122,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
125
122
  if (!path) {
126
123
  throw new Error('Parameter `path` is required when calling `customPost`.');
127
124
  }
128
- const requestPath = '/1{path}'.replace('{path}', path);
125
+ const requestPath = '/{path}'.replace('{path}', path);
129
126
  const headers = {};
130
127
  const queryParameters = parameters ? parameters : {};
131
128
  const request = {
@@ -140,7 +137,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
140
137
  /**
141
138
  * This method allow you to send requests to the Algolia REST API.
142
139
  *
143
- * @summary Send requests to the Algolia REST API.
144
140
  * @param customPut - The customPut object.
145
141
  * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
146
142
  * @param customPut.parameters - Query parameters to apply to the current query.
@@ -151,7 +147,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
151
147
  if (!path) {
152
148
  throw new Error('Parameter `path` is required when calling `customPut`.');
153
149
  }
154
- const requestPath = '/1{path}'.replace('{path}', path);
150
+ const requestPath = '/{path}'.replace('{path}', path);
155
151
  const headers = {};
156
152
  const queryParameters = parameters ? parameters : {};
157
153
  const request = {
@@ -164,11 +160,10 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
164
160
  return transporter.request(request, requestOptions);
165
161
  },
166
162
  /**
167
- * Delete all events related to a certain user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](https://www.algolia.com/doc/rest-api/personalization/#delete-a-user-profile).
163
+ * Deletes all events related to the specified user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](/specs/personalization#tag/profiles/operation/deleteUserProfile).
168
164
  *
169
- * @summary Delete user token.
170
165
  * @param deleteUserToken - The deleteUserToken object.
171
- * @param deleteUserToken.userToken - The user token for which to delete all associated events.
166
+ * @param deleteUserToken.userToken - User token for which to delete all associated events.
172
167
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
173
168
  */
174
169
  deleteUserToken({ userToken }, requestOptions) {
@@ -187,9 +182,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
187
182
  return transporter.request(request, requestOptions);
188
183
  },
189
184
  /**
190
- * Send a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2&nbsp;MB.
185
+ * Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2&nbsp;MB.
191
186
  *
192
- * @summary Send events.
193
187
  * @param insightsEvents - The insightsEvents object.
194
188
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
195
189
  */
@@ -216,6 +210,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
216
210
  }
217
211
 
218
212
  // 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.
213
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
219
214
  function insightsClient(appId, apiKey, region, options) {
220
215
  if (!appId || typeof appId !== 'string') {
221
216
  throw new Error('`appId` is missing.');
@@ -226,22 +221,24 @@ function insightsClient(appId, apiKey, region, options) {
226
221
  if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
227
222
  throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
228
223
  }
229
- return createInsightsClient({
230
- appId,
231
- apiKey,
232
- region,
233
- timeouts: {
234
- connect: clientCommon.DEFAULT_CONNECT_TIMEOUT_NODE,
235
- read: clientCommon.DEFAULT_READ_TIMEOUT_NODE,
236
- write: clientCommon.DEFAULT_WRITE_TIMEOUT_NODE,
237
- },
238
- requester: requesterNodeHttp.createHttpRequester(),
239
- algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
240
- responsesCache: clientCommon.createNullCache(),
241
- requestsCache: clientCommon.createNullCache(),
242
- hostsCache: clientCommon.createMemoryCache(),
243
- ...options,
244
- });
224
+ return {
225
+ ...createInsightsClient({
226
+ appId,
227
+ apiKey,
228
+ region,
229
+ timeouts: {
230
+ connect: clientCommon.DEFAULT_CONNECT_TIMEOUT_NODE,
231
+ read: clientCommon.DEFAULT_READ_TIMEOUT_NODE,
232
+ write: clientCommon.DEFAULT_WRITE_TIMEOUT_NODE,
233
+ },
234
+ requester: requesterNodeHttp.createHttpRequester(),
235
+ algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
236
+ responsesCache: clientCommon.createNullCache(),
237
+ requestsCache: clientCommon.createNullCache(),
238
+ hostsCache: clientCommon.createMemoryCache(),
239
+ ...options,
240
+ }),
241
+ };
245
242
  }
246
243
 
247
244
  exports.apiClientVersion = apiClientVersion;
@@ -195,6 +195,14 @@ function createStatefulHost(host, status = 'up') {
195
195
  };
196
196
  }
197
197
 
198
+ function _defineProperty(e, r, t) {
199
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
200
+ value: t,
201
+ enumerable: !0,
202
+ configurable: !0,
203
+ writable: !0
204
+ }) : e[r] = t, e;
205
+ }
198
206
  function _toPrimitive(t, r) {
199
207
  if ("object" != typeof t || !t) return t;
200
208
  var e = t[Symbol.toPrimitive];
@@ -207,21 +215,7 @@ function _toPrimitive(t, r) {
207
215
  }
208
216
  function _toPropertyKey(t) {
209
217
  var i = _toPrimitive(t, "string");
210
- return "symbol" == typeof i ? i : String(i);
211
- }
212
- function _defineProperty(obj, key, value) {
213
- key = _toPropertyKey(key);
214
- if (key in obj) {
215
- Object.defineProperty(obj, key, {
216
- value: value,
217
- enumerable: true,
218
- configurable: true,
219
- writable: true
220
- });
221
- } else {
222
- obj[key] = value;
223
- }
224
- return obj;
218
+ return "symbol" == typeof i ? i : i + "";
225
219
  }
226
220
 
227
221
  class AlgoliaError extends Error {
@@ -243,7 +237,7 @@ class ErrorWithStackTrace extends AlgoliaError {
243
237
  }
244
238
  class RetryError extends ErrorWithStackTrace {
245
239
  constructor(stackTrace) {
246
- super('Unreachable hosts - your application id may be incorrect. If the error persists, please create a ticket at https://support.algolia.com/ sharing steps we can use to reproduce the issue.', stackTrace, 'RetryError');
240
+ super('Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.', stackTrace, 'RetryError');
247
241
  }
248
242
  }
249
243
  class ApiError extends ErrorWithStackTrace {
@@ -270,15 +264,14 @@ class DetailedApiError extends ApiError {
270
264
  }
271
265
  function serializeUrl(host, path, queryParameters) {
272
266
  const queryParametersAsString = serializeQueryParameters(queryParameters);
273
- let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.substr(1) : path}`;
267
+ let url = `${host.protocol}://${host.url}${host.port ? `:${host.port}` : ''}/${path.charAt(0) === '/' ? path.substring(1) : path}`;
274
268
  if (queryParametersAsString.length) {
275
269
  url += `?${queryParametersAsString}`;
276
270
  }
277
271
  return url;
278
272
  }
279
273
  function serializeQueryParameters(parameters) {
280
- const isObjectOrArray = value => Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
281
- return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key])}`).join('&');
274
+ return Object.keys(parameters).filter(key => parameters[key] !== undefined).sort().map(key => `${key}=${encodeURIComponent(Object.prototype.toString.call(parameters[key]) === '[object Array]' ? parameters[key].join(',') : parameters[key]).replaceAll('+', '%20')}`).join('&');
282
275
  }
283
276
  function serializeData(request, requestOptions) {
284
277
  if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
@@ -449,16 +442,13 @@ function createTransporter({
449
442
  if (host === undefined) {
450
443
  throw new RetryError(stackTraceWithoutCredentials(stackTrace));
451
444
  }
452
- let responseTimeout = requestOptions.timeout;
453
- if (responseTimeout === undefined) {
454
- responseTimeout = isRead ? timeouts.read : timeouts.write;
455
- }
445
+ let responseTimeout = isRead ? requestOptions.timeouts?.read || timeouts.read : requestOptions.timeouts?.write || timeouts.write;
456
446
  const payload = {
457
447
  data,
458
448
  headers,
459
449
  method: request.method,
460
450
  url: serializeUrl(host, request.path, queryParameters),
461
- connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
451
+ connectTimeout: getTimeout(timeoutsCount, requestOptions.timeouts?.connect || timeouts.connect),
462
452
  responseTimeout: getTimeout(timeoutsCount, responseTimeout)
463
453
  };
464
454
  /**
@@ -686,7 +676,7 @@ function createXhrRequester() {
686
676
  }
687
677
 
688
678
  // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
689
- const apiClientVersion = '5.0.0-alpha.99';
679
+ const apiClientVersion = '5.0.0-beta.10';
690
680
  const REGIONS = ['de', 'us'];
691
681
  function getDefaultHosts(region) {
692
682
  const url = !region
@@ -748,7 +738,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
748
738
  /**
749
739
  * This method allow you to send requests to the Algolia REST API.
750
740
  *
751
- * @summary Send requests to the Algolia REST API.
752
741
  * @param customDelete - The customDelete object.
753
742
  * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
754
743
  * @param customDelete.parameters - Query parameters to apply to the current query.
@@ -758,7 +747,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
758
747
  if (!path) {
759
748
  throw new Error('Parameter `path` is required when calling `customDelete`.');
760
749
  }
761
- const requestPath = '/1{path}'.replace('{path}', path);
750
+ const requestPath = '/{path}'.replace('{path}', path);
762
751
  const headers = {};
763
752
  const queryParameters = parameters ? parameters : {};
764
753
  const request = {
@@ -772,7 +761,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
772
761
  /**
773
762
  * This method allow you to send requests to the Algolia REST API.
774
763
  *
775
- * @summary Send requests to the Algolia REST API.
776
764
  * @param customGet - The customGet object.
777
765
  * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
778
766
  * @param customGet.parameters - Query parameters to apply to the current query.
@@ -782,7 +770,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
782
770
  if (!path) {
783
771
  throw new Error('Parameter `path` is required when calling `customGet`.');
784
772
  }
785
- const requestPath = '/1{path}'.replace('{path}', path);
773
+ const requestPath = '/{path}'.replace('{path}', path);
786
774
  const headers = {};
787
775
  const queryParameters = parameters ? parameters : {};
788
776
  const request = {
@@ -796,7 +784,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
796
784
  /**
797
785
  * This method allow you to send requests to the Algolia REST API.
798
786
  *
799
- * @summary Send requests to the Algolia REST API.
800
787
  * @param customPost - The customPost object.
801
788
  * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
802
789
  * @param customPost.parameters - Query parameters to apply to the current query.
@@ -807,7 +794,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
807
794
  if (!path) {
808
795
  throw new Error('Parameter `path` is required when calling `customPost`.');
809
796
  }
810
- const requestPath = '/1{path}'.replace('{path}', path);
797
+ const requestPath = '/{path}'.replace('{path}', path);
811
798
  const headers = {};
812
799
  const queryParameters = parameters ? parameters : {};
813
800
  const request = {
@@ -822,7 +809,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
822
809
  /**
823
810
  * This method allow you to send requests to the Algolia REST API.
824
811
  *
825
- * @summary Send requests to the Algolia REST API.
826
812
  * @param customPut - The customPut object.
827
813
  * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
828
814
  * @param customPut.parameters - Query parameters to apply to the current query.
@@ -833,7 +819,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
833
819
  if (!path) {
834
820
  throw new Error('Parameter `path` is required when calling `customPut`.');
835
821
  }
836
- const requestPath = '/1{path}'.replace('{path}', path);
822
+ const requestPath = '/{path}'.replace('{path}', path);
837
823
  const headers = {};
838
824
  const queryParameters = parameters ? parameters : {};
839
825
  const request = {
@@ -846,11 +832,10 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
846
832
  return transporter.request(request, requestOptions);
847
833
  },
848
834
  /**
849
- * Delete all events related to a certain user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](https://www.algolia.com/doc/rest-api/personalization/#delete-a-user-profile).
835
+ * Deletes all events related to the specified user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](/specs/personalization#tag/profiles/operation/deleteUserProfile).
850
836
  *
851
- * @summary Delete user token.
852
837
  * @param deleteUserToken - The deleteUserToken object.
853
- * @param deleteUserToken.userToken - The user token for which to delete all associated events.
838
+ * @param deleteUserToken.userToken - User token for which to delete all associated events.
854
839
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
855
840
  */
856
841
  deleteUserToken({ userToken }, requestOptions) {
@@ -869,9 +854,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
869
854
  return transporter.request(request, requestOptions);
870
855
  },
871
856
  /**
872
- * Send a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2&nbsp;MB.
857
+ * Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2&nbsp;MB.
873
858
  *
874
- * @summary Send events.
875
859
  * @param insightsEvents - The insightsEvents object.
876
860
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
877
861
  */
@@ -898,6 +882,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
898
882
  }
899
883
 
900
884
  // 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.
885
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
901
886
  function insightsClient(appId, apiKey, region, options) {
902
887
  if (!appId || typeof appId !== 'string') {
903
888
  throw new Error('`appId` is missing.');
@@ -2,7 +2,7 @@ import { createAuth, createTransporter, getAlgoliaAgent, DEFAULT_CONNECT_TIMEOUT
2
2
  import { createHttpRequester } from '@algolia/requester-node-http';
3
3
 
4
4
  // 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.
5
- const apiClientVersion = '5.0.0-alpha.99';
5
+ const apiClientVersion = '5.0.0-beta.10';
6
6
  const REGIONS = ['de', 'us'];
7
7
  function getDefaultHosts(region) {
8
8
  const url = !region
@@ -64,7 +64,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
64
64
  /**
65
65
  * This method allow you to send requests to the Algolia REST API.
66
66
  *
67
- * @summary Send requests to the Algolia REST API.
68
67
  * @param customDelete - The customDelete object.
69
68
  * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
70
69
  * @param customDelete.parameters - Query parameters to apply to the current query.
@@ -74,7 +73,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
74
73
  if (!path) {
75
74
  throw new Error('Parameter `path` is required when calling `customDelete`.');
76
75
  }
77
- const requestPath = '/1{path}'.replace('{path}', path);
76
+ const requestPath = '/{path}'.replace('{path}', path);
78
77
  const headers = {};
79
78
  const queryParameters = parameters ? parameters : {};
80
79
  const request = {
@@ -88,7 +87,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
88
87
  /**
89
88
  * This method allow you to send requests to the Algolia REST API.
90
89
  *
91
- * @summary Send requests to the Algolia REST API.
92
90
  * @param customGet - The customGet object.
93
91
  * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
94
92
  * @param customGet.parameters - Query parameters to apply to the current query.
@@ -98,7 +96,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
98
96
  if (!path) {
99
97
  throw new Error('Parameter `path` is required when calling `customGet`.');
100
98
  }
101
- const requestPath = '/1{path}'.replace('{path}', path);
99
+ const requestPath = '/{path}'.replace('{path}', path);
102
100
  const headers = {};
103
101
  const queryParameters = parameters ? parameters : {};
104
102
  const request = {
@@ -112,7 +110,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
112
110
  /**
113
111
  * This method allow you to send requests to the Algolia REST API.
114
112
  *
115
- * @summary Send requests to the Algolia REST API.
116
113
  * @param customPost - The customPost object.
117
114
  * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
118
115
  * @param customPost.parameters - Query parameters to apply to the current query.
@@ -123,7 +120,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
123
120
  if (!path) {
124
121
  throw new Error('Parameter `path` is required when calling `customPost`.');
125
122
  }
126
- const requestPath = '/1{path}'.replace('{path}', path);
123
+ const requestPath = '/{path}'.replace('{path}', path);
127
124
  const headers = {};
128
125
  const queryParameters = parameters ? parameters : {};
129
126
  const request = {
@@ -138,7 +135,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
138
135
  /**
139
136
  * This method allow you to send requests to the Algolia REST API.
140
137
  *
141
- * @summary Send requests to the Algolia REST API.
142
138
  * @param customPut - The customPut object.
143
139
  * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
144
140
  * @param customPut.parameters - Query parameters to apply to the current query.
@@ -149,7 +145,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
149
145
  if (!path) {
150
146
  throw new Error('Parameter `path` is required when calling `customPut`.');
151
147
  }
152
- const requestPath = '/1{path}'.replace('{path}', path);
148
+ const requestPath = '/{path}'.replace('{path}', path);
153
149
  const headers = {};
154
150
  const queryParameters = parameters ? parameters : {};
155
151
  const request = {
@@ -162,11 +158,10 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
162
158
  return transporter.request(request, requestOptions);
163
159
  },
164
160
  /**
165
- * Delete all events related to a certain user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](https://www.algolia.com/doc/rest-api/personalization/#delete-a-user-profile).
161
+ * Deletes all events related to the specified user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](/specs/personalization#tag/profiles/operation/deleteUserProfile).
166
162
  *
167
- * @summary Delete user token.
168
163
  * @param deleteUserToken - The deleteUserToken object.
169
- * @param deleteUserToken.userToken - The user token for which to delete all associated events.
164
+ * @param deleteUserToken.userToken - User token for which to delete all associated events.
170
165
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
171
166
  */
172
167
  deleteUserToken({ userToken }, requestOptions) {
@@ -185,9 +180,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
185
180
  return transporter.request(request, requestOptions);
186
181
  },
187
182
  /**
188
- * Send a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2&nbsp;MB.
183
+ * Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2&nbsp;MB.
189
184
  *
190
- * @summary Send events.
191
185
  * @param insightsEvents - The insightsEvents object.
192
186
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
193
187
  */
@@ -214,6 +208,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
214
208
  }
215
209
 
216
210
  // 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.
211
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
217
212
  function insightsClient(appId, apiKey, region, options) {
218
213
  if (!appId || typeof appId !== 'string') {
219
214
  throw new Error('`appId` is missing.');
@@ -224,22 +219,24 @@ function insightsClient(appId, apiKey, region, options) {
224
219
  if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
225
220
  throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
226
221
  }
227
- return createInsightsClient({
228
- appId,
229
- apiKey,
230
- region,
231
- timeouts: {
232
- connect: DEFAULT_CONNECT_TIMEOUT_NODE,
233
- read: DEFAULT_READ_TIMEOUT_NODE,
234
- write: DEFAULT_WRITE_TIMEOUT_NODE,
235
- },
236
- requester: createHttpRequester(),
237
- algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
238
- responsesCache: createNullCache(),
239
- requestsCache: createNullCache(),
240
- hostsCache: createMemoryCache(),
241
- ...options,
242
- });
222
+ return {
223
+ ...createInsightsClient({
224
+ appId,
225
+ apiKey,
226
+ region,
227
+ timeouts: {
228
+ connect: DEFAULT_CONNECT_TIMEOUT_NODE,
229
+ read: DEFAULT_READ_TIMEOUT_NODE,
230
+ write: DEFAULT_WRITE_TIMEOUT_NODE,
231
+ },
232
+ requester: createHttpRequester(),
233
+ algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
234
+ responsesCache: createNullCache(),
235
+ requestsCache: createNullCache(),
236
+ hostsCache: createMemoryCache(),
237
+ ...options,
238
+ }),
239
+ };
243
240
  }
244
241
 
245
242
  export { apiClientVersion, insightsClient };
@@ -1,2 +1,2 @@
1
- /*! client-insights.umd.js | 5.0.0-alpha.99 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
2
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-insights"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function s(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function a(){return JSON.parse(s().getItem(r)||"{}")}function n(e){s().setItem(r,JSON.stringify(e))}return{get:(t,r,s={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){const t=e.timeToLive?1e3*e.timeToLive:null,r=a(),s=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(n(s),!t)return;n(Object.fromEntries(Object.entries(s).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),a()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||s.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const n=a();return n[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},s().setItem(r,JSON.stringify(n)),t})),delete:e=>Promise.resolve().then((()=>{const t=a();delete t[JSON.stringify(e)],s().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{s().removeItem(r)}))}}function r(e){const t=[...e.caches],s=t.shift();return void 0===s?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,a,n={miss:()=>Promise.resolve()})=>s.get(e,a,n).catch((()=>r({caches:t}).get(e,a,n))),set:(e,a)=>s.set(e,a).catch((()=>r({caches:t}).set(e,a))),delete:e=>s.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>s.clear().catch((()=>r({caches:t}).clear()))}}function s(e={serializable:!0}){let t={};return{get(r,s,a={miss:()=>Promise.resolve()}){const n=JSON.stringify(r);if(n in t)return Promise.resolve(e.serializable?JSON.parse(t[n]):t[n]);const o=s();return o.then((e=>a.miss(e))).then((()=>o))},set:(r,s)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(s):s,Promise.resolve(s)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const a=12e4;function n(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>a},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=a}}}function o(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function i(e,t,r){return(t=o(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class c extends Error{constructor(e,t){super(e),i(this,"name","AlgoliaError"),t&&(this.name=t)}}class u extends c{constructor(e,t,r){super(e,r),i(this,"stackTrace",void 0),this.stackTrace=t}}class l extends u{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, please create a ticket at https://support.algolia.com/ sharing steps we can use to reproduce the issue.",e,"RetryError")}}class h extends u{constructor(e,t,r,s="ApiError"){super(e,r,s),i(this,"status",void 0),this.status=t}}class m extends c{constructor(e,t){super(e,"DeserializationError"),i(this,"response",void 0),this.response=t}}class d extends h{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),i(this,"error",void 0),this.error=r}}function p(e,t,r){const s=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${encodeURIComponent(t(e[r])?JSON.stringify(e[r]):e[r])}`)).join("&")}(r);let a=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return s.length&&(a+=`?${s}`),a}function g(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function f({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:s,algoliaAgent:a,timeouts:o,requester:i,requestsCache:c,responsesCache:u}){async function f(c,u,f=!0){const y=[],v=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(c,u),P=function(e,t,r){const s={Accept:"application/json",...e,...t,...r},a={};return Object.keys(s).forEach((e=>{const t=s[e];a[e.toLowerCase()]=t})),a}(r,c.headers,u.headers),w="GET"===c.method?{...c.data,...u.data}:{},b={...s,...c.queryParameters,...w};if(a.value&&(b["x-algolia-agent"]=a.value),u&&u.queryParameters)for(const e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?b[e]=u.queryParameters[e].toString():b[e]=u.queryParameters[e];let T=0;const q=async(e,r)=>{const s=e.pop();if(void 0===s)throw new l(function(e){return e.map((e=>g(e)))}(y));let a=u.timeout;void 0===a&&(a=f?o.read:o.write);const w={data:v,headers:P,method:c.method,url:p(s,c.path,b),connectTimeout:r(T,o.connect),responseTimeout:r(T,a)},O=t=>{const r={request:w,response:t,host:s,triesLeft:e.length};return y.push(r),r},E=await i.send(w);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(E)){const a=O(E);return E.isTimedOut&&T++,console.log("Retryable failure",g(a)),await t.set(s,n(s,E.isTimedOut?"timed out":"down")),q(e,r)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(t){throw new m(t.message,e)}}(E);throw O(E),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new d(s.message,t,s.error,r):new h(s.message,t,r)}catch(e){}return new h(e,t,r)}(E,y)},O=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),E=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(n(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),o=[...s,...a];return{hosts:o.length>0?o:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(O);return q([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:t,requester:i,timeouts:o,algoliaAgent:a,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){const a=e.useReadTransporter||"GET"===e.method;if(!a)return f(e,t,a);const n=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return n();const o={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return u.get(o,(()=>c.get(o,(()=>c.set(o,n()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>u.set(o,e)})},requestsCache:c,responsesCache:u}}function y({algoliaAgents:e,client:t,version:r}){const s=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>s.add(e))),s}const v="5.0.0-alpha.99",P=["de","us"];e.apiClientVersion=v,e.insightsClient=function(e,a,n,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");if(n&&("string"!=typeof n||!P.includes(n)))throw new Error(`\`region\` must be one of the following: ${P.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,region:a,...n}){const o=function(e,t,r="WithinHeaders"){const s={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?s:{},queryParameters:()=>"WithinQueryParameters"===r?s:{}}}(e,t,r),i=f({hosts:(c=a,[{url:c?"insights.{region}.algolia.io".replace("{region}",c):"insights.algolia.io",accept:"readWrite",protocol:"https"}]),...n,algoliaAgent:y({algoliaAgents:s,client:"Insights",version:v}),baseHeaders:{"content-type":"text/plain",...o.headers(),...n.baseHeaders},baseQueryParameters:{...o.queryParameters(),...n.baseQueryParameters}});var c;return{transporter:i,appId:e,clearCache:()=>Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then((()=>{})),get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(e,t){i.algoliaAgent.add({segment:e,version:t})},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");const s={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");const s={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customPost({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");const a={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},customPut({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");const a={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},deleteUserToken({userToken:e},t){if(!e)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");const r={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},pushEvents(e,t){if(!e)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!e.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");const r={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:e};return i.request(r,t)}}}({appId:e,apiKey:a,region:n,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const s=(e,s)=>setTimeout((()=>{r.abort(),t({status:0,content:s,isTimedOut:!0})}),e),a=s(e.connectTimeout,"Connection timeout");let n;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===n&&(clearTimeout(a),n=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:s(),requestsCache:s({serializable:!1}),hostsCache:r({caches:[t({key:`${v}-${e}`}),s()]}),...o})}}));
1
+ /*! client-insights.umd.js | 5.0.0-beta.10 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
2
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-insights"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function s(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function a(){return JSON.parse(s().getItem(r)||"{}")}function o(e){s().setItem(r,JSON.stringify(e))}return{get:(t,r,s={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){const t=e.timeToLive?1e3*e.timeToLive:null,r=a(),s=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(o(s),!t)return;o(Object.fromEntries(Object.entries(s).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),a()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||s.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const o=a();return o[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},s().setItem(r,JSON.stringify(o)),t})),delete:e=>Promise.resolve().then((()=>{const t=a();delete t[JSON.stringify(e)],s().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{s().removeItem(r)}))}}function r(e){const t=[...e.caches],s=t.shift();return void 0===s?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,a,o={miss:()=>Promise.resolve()})=>s.get(e,a,o).catch((()=>r({caches:t}).get(e,a,o))),set:(e,a)=>s.set(e,a).catch((()=>r({caches:t}).set(e,a))),delete:e=>s.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>s.clear().catch((()=>r({caches:t}).clear()))}}function s(e={serializable:!0}){let t={};return{get(r,s,a={miss:()=>Promise.resolve()}){const o=JSON.stringify(r);if(o in t)return Promise.resolve(e.serializable?JSON.parse(t[o]):t[o]);const n=s();return n.then((e=>a.miss(e))).then((()=>n))},set:(r,s)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(s):s,Promise.resolve(s)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const a=12e4;function o(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>a},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=a}}}function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class i extends Error{constructor(e,t){super(e),n(this,"name","AlgoliaError"),t&&(this.name=t)}}class u extends i{constructor(e,t,r){super(e,r),n(this,"stackTrace",void 0),this.stackTrace=t}}class c extends u{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",e,"RetryError")}}class l extends u{constructor(e,t,r,s="ApiError"){super(e,r,s),n(this,"status",void 0),this.status=t}}class h extends i{constructor(e,t){super(e,"DeserializationError"),n(this,"response",void 0),this.response=t}}class m extends l{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),n(this,"error",void 0),this.error=r}}function d(e,t,r){const s=(a=r,Object.keys(a).filter((e=>void 0!==a[e])).sort().map((e=>`${e}=${encodeURIComponent("[object Array]"===Object.prototype.toString.call(a[e])?a[e].join(","):a[e]).replaceAll("+","%20")}`)).join("&"));var a;let o=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${"/"===t.charAt(0)?t.substring(1):t}`;return s.length&&(o+=`?${s}`),o}function p(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function g({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:s,algoliaAgent:a,timeouts:n,requester:i,requestsCache:u,responsesCache:g}){async function f(u,g,f=!0){const y=[],v=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(u,g),P=function(e,t,r){const s={Accept:"application/json",...e,...t,...r},a={};return Object.keys(s).forEach((e=>{const t=s[e];a[e.toLowerCase()]=t})),a}(r,u.headers,g.headers),w="GET"===u.method?{...u.data,...g.data}:{},T={...s,...u.queryParameters,...w};if(a.value&&(T["x-algolia-agent"]=a.value),g&&g.queryParameters)for(const e of Object.keys(g.queryParameters))g.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(g.queryParameters[e])?T[e]=g.queryParameters[e].toString():T[e]=g.queryParameters[e];let b=0;const q=async(e,r)=>{const s=e.pop();if(void 0===s)throw new c(function(e){return e.map((e=>p(e)))}(y));let a=f?g.timeouts?.read||n.read:g.timeouts?.write||n.write;const w={data:v,headers:P,method:u.method,url:d(s,u.path,T),connectTimeout:r(b,g.timeouts?.connect||n.connect),responseTimeout:r(b,a)},O=t=>{const r={request:w,response:t,host:s,triesLeft:e.length};return y.push(r),r},E=await i.send(w);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&!~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(E)){const a=O(E);return E.isTimedOut&&b++,console.log("Retryable failure",p(a)),await t.set(s,o(s,E.isTimedOut?"timed out":"down")),q(e,r)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(t){throw new h(t.message,e)}}(E);throw O(E),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new m(s.message,t,s.error,r):new l(s.message,t,r)}catch(e){}return new l(e,t,r)}(E,y)},O=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),E=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(o(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),n=[...s,...a];return{hosts:n.length>0?n:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(O);return q([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:t,requester:i,timeouts:n,algoliaAgent:a,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){const a=e.useReadTransporter||"GET"===e.method;if(!a)return f(e,t,a);const o=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return o();const n={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return g.get(n,(()=>u.get(n,(()=>u.set(n,o()).then((e=>Promise.all([u.delete(n),e])),(e=>Promise.all([u.delete(n),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>g.set(n,e)})},requestsCache:u,responsesCache:g}}function f({algoliaAgents:e,client:t,version:r}){const s=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>s.add(e))),s}const y="5.0.0-beta.10",v=["de","us"];e.apiClientVersion=y,e.insightsClient=function(e,a,o,n){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");if(o&&("string"!=typeof o||!v.includes(o)))throw new Error(`\`region\` must be one of the following: ${v.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,region:a,...o}){const n=function(e,t,r="WithinHeaders"){const s={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?s:{},queryParameters:()=>"WithinQueryParameters"===r?s:{}}}(e,t,r),i=g({hosts:(u=a,[{url:u?"insights.{region}.algolia.io".replace("{region}",u):"insights.algolia.io",accept:"readWrite",protocol:"https"}]),...o,algoliaAgent:f({algoliaAgents:s,client:"Insights",version:y}),baseHeaders:{"content-type":"text/plain",...n.headers(),...o.baseHeaders},baseQueryParameters:{...n.queryParameters(),...o.baseQueryParameters}});var u;return{transporter:i,appId:e,clearCache:()=>Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then((()=>{})),get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(e,t){i.algoliaAgent.add({segment:e,version:t})},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");const s={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");const s={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customPost({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");const a={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},customPut({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");const a={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},deleteUserToken({userToken:e},t){if(!e)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");const r={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},pushEvents(e,t){if(!e)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!e.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");const r={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:e};return i.request(r,t)}}}({appId:e,apiKey:a,region:o,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const s=(e,s)=>setTimeout((()=>{r.abort(),t({status:0,content:s,isTimedOut:!0})}),e),a=s(e.connectTimeout,"Connection timeout");let o;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===o&&(clearTimeout(a),o=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(o),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(o),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:s(),requestsCache:s({serializable:!1}),hostsCache:r({caches:[t({key:`${y}-${e}`}),s()]}),...n})}}));