@algolia/client-insights 5.27.0 → 5.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,11 +41,11 @@ All of our clients comes with type definition, and are available for both browse
41
41
  ### With a package manager
42
42
 
43
43
  ```bash
44
- yarn add @algolia/client-insights@5.27.0
44
+ yarn add @algolia/client-insights@5.28.0
45
45
  # or
46
- npm install @algolia/client-insights@5.27.0
46
+ npm install @algolia/client-insights@5.28.0
47
47
  # or
48
- pnpm add @algolia/client-insights@5.27.0
48
+ pnpm add @algolia/client-insights@5.28.0
49
49
  ```
50
50
 
51
51
  ### Without a package manager
@@ -53,7 +53,7 @@ pnpm add @algolia/client-insights@5.27.0
53
53
  Add the following JavaScript snippet to the <head> of your website:
54
54
 
55
55
  ```html
56
- <script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.27.0/dist/builds/browser.umd.js"></script>
56
+ <script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.28.0/dist/builds/browser.umd.js"></script>
57
57
  ```
58
58
 
59
59
  ### Usage
package/dist/browser.d.ts CHANGED
@@ -8,11 +8,11 @@ type EventsResponse = {
8
8
  /**
9
9
  * Details about the response, such as error messages.
10
10
  */
11
- message?: string;
11
+ message?: string | undefined;
12
12
  /**
13
13
  * The HTTP status code of the response.
14
14
  */
15
- status?: number;
15
+ status?: number | undefined;
16
16
  };
17
17
 
18
18
  type AddToCartEvent = 'addToCart';
@@ -30,12 +30,12 @@ type Discount = number | string;
30
30
  type Price = number | string;
31
31
 
32
32
  type ObjectData = {
33
- price?: Price;
33
+ price?: Price | undefined;
34
34
  /**
35
35
  * Quantity of a product that has been purchased or added to the cart. The total purchase value is the sum of `quantity` multiplied with the `price` for each purchased item.
36
36
  */
37
- quantity?: number;
38
- discount?: Discount;
37
+ quantity?: number | undefined;
38
+ discount?: Discount | undefined;
39
39
  };
40
40
 
41
41
  /**
@@ -68,33 +68,33 @@ type AddedToCartObjectIDs = {
68
68
  /**
69
69
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
70
70
  */
71
- authenticatedUserToken?: string;
71
+ authenticatedUserToken?: string | undefined;
72
72
  /**
73
73
  * Three-letter [currency code](https://www.iso.org/iso-4217-currency-codes.html).
74
74
  */
75
- currency?: string;
75
+ currency?: string | undefined;
76
76
  /**
77
77
  * Extra information about the records involved in a purchase or add-to-cart event. If specified, it must have the same length as `objectIDs`.
78
78
  */
79
- objectData?: Array<ObjectData>;
79
+ objectData?: Array<ObjectData> | undefined;
80
80
  /**
81
81
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
82
82
  */
83
- timestamp?: number;
84
- value?: Value;
83
+ timestamp?: number | undefined;
84
+ value?: Value | undefined;
85
85
  };
86
86
 
87
87
  type ObjectDataAfterSearch = {
88
88
  /**
89
89
  * Unique identifier for a search query, used to track purchase events with multiple records that originate from different searches.
90
90
  */
91
- queryID?: string;
92
- price?: Price;
91
+ queryID?: string | undefined;
92
+ price?: Price | undefined;
93
93
  /**
94
94
  * Quantity of a product that has been purchased or added to the cart. The total purchase value is the sum of `quantity` multiplied with the `price` for each purchased item.
95
95
  */
96
- quantity?: number;
97
- discount?: Discount;
96
+ quantity?: number | undefined;
97
+ discount?: Discount | undefined;
98
98
  };
99
99
 
100
100
  /**
@@ -126,20 +126,20 @@ type AddedToCartObjectIDsAfterSearch = {
126
126
  /**
127
127
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
128
128
  */
129
- authenticatedUserToken?: string;
129
+ authenticatedUserToken?: string | undefined;
130
130
  /**
131
131
  * Three-letter [currency code](https://www.iso.org/iso-4217-currency-codes.html).
132
132
  */
133
- currency?: string;
133
+ currency?: string | undefined;
134
134
  /**
135
135
  * Extra information about the records involved in a purchase or add-to-cart events. If provided, it must be the same length as `objectIDs`.
136
136
  */
137
- objectData?: Array<ObjectDataAfterSearch>;
137
+ objectData?: Array<ObjectDataAfterSearch> | undefined;
138
138
  /**
139
139
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
140
140
  */
141
- timestamp?: number;
142
- value?: Value;
141
+ timestamp?: number | undefined;
142
+ value?: Value | undefined;
143
143
  };
144
144
 
145
145
  type ClickEvent = 'click';
@@ -168,11 +168,11 @@ type ClickedFilters = {
168
168
  /**
169
169
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
170
170
  */
171
- authenticatedUserToken?: string;
171
+ authenticatedUserToken?: string | undefined;
172
172
  /**
173
173
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
174
174
  */
175
- timestamp?: number;
175
+ timestamp?: number | undefined;
176
176
  };
177
177
 
178
178
  /**
@@ -199,11 +199,11 @@ type ClickedObjectIDs = {
199
199
  /**
200
200
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
201
201
  */
202
- authenticatedUserToken?: string;
202
+ authenticatedUserToken?: string | undefined;
203
203
  /**
204
204
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
205
205
  */
206
- timestamp?: number;
206
+ timestamp?: number | undefined;
207
207
  };
208
208
 
209
209
  /**
@@ -238,11 +238,11 @@ type ClickedObjectIDsAfterSearch = {
238
238
  /**
239
239
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
240
240
  */
241
- authenticatedUserToken?: string;
241
+ authenticatedUserToken?: string | undefined;
242
242
  /**
243
243
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
244
244
  */
245
- timestamp?: number;
245
+ timestamp?: number | undefined;
246
246
  };
247
247
 
248
248
  type ConvertedFilters = {
@@ -266,11 +266,11 @@ type ConvertedFilters = {
266
266
  /**
267
267
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
268
268
  */
269
- authenticatedUserToken?: string;
269
+ authenticatedUserToken?: string | undefined;
270
270
  /**
271
271
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
272
272
  */
273
- timestamp?: number;
273
+ timestamp?: number | undefined;
274
274
  };
275
275
 
276
276
  /**
@@ -297,11 +297,11 @@ type ConvertedObjectIDs = {
297
297
  /**
298
298
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
299
299
  */
300
- authenticatedUserToken?: string;
300
+ authenticatedUserToken?: string | undefined;
301
301
  /**
302
302
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
303
303
  */
304
- timestamp?: number;
304
+ timestamp?: number | undefined;
305
305
  };
306
306
 
307
307
  /**
@@ -332,11 +332,11 @@ type ConvertedObjectIDsAfterSearch = {
332
332
  /**
333
333
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
334
334
  */
335
- authenticatedUserToken?: string;
335
+ authenticatedUserToken?: string | undefined;
336
336
  /**
337
337
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
338
338
  */
339
- timestamp?: number;
339
+ timestamp?: number | undefined;
340
340
  };
341
341
 
342
342
  type PurchaseEvent = 'purchase';
@@ -366,20 +366,20 @@ type PurchasedObjectIDs = {
366
366
  /**
367
367
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
368
368
  */
369
- authenticatedUserToken?: string;
369
+ authenticatedUserToken?: string | undefined;
370
370
  /**
371
371
  * Three-letter [currency code](https://www.iso.org/iso-4217-currency-codes.html).
372
372
  */
373
- currency?: string;
373
+ currency?: string | undefined;
374
374
  /**
375
375
  * Extra information about the records involved in a purchase or add-to-cart event. If specified, it must have the same length as `objectIDs`.
376
376
  */
377
- objectData?: Array<ObjectData>;
377
+ objectData?: Array<ObjectData> | undefined;
378
378
  /**
379
379
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
380
380
  */
381
- timestamp?: number;
382
- value?: Value;
381
+ timestamp?: number | undefined;
382
+ value?: Value | undefined;
383
383
  };
384
384
 
385
385
  /**
@@ -407,11 +407,11 @@ type PurchasedObjectIDsAfterSearch = {
407
407
  /**
408
408
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
409
409
  */
410
- authenticatedUserToken?: string;
410
+ authenticatedUserToken?: string | undefined;
411
411
  /**
412
412
  * Three-letter [currency code](https://www.iso.org/iso-4217-currency-codes.html).
413
413
  */
414
- currency?: string;
414
+ currency?: string | undefined;
415
415
  /**
416
416
  * Extra information about the records involved in a purchase or add-to-cart events. If provided, it must be the same length as `objectIDs`.
417
417
  */
@@ -419,8 +419,8 @@ type PurchasedObjectIDsAfterSearch = {
419
419
  /**
420
420
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
421
421
  */
422
- timestamp?: number;
423
- value?: Value;
422
+ timestamp?: number | undefined;
423
+ value?: Value | undefined;
424
424
  };
425
425
 
426
426
  type ViewEvent = 'view';
@@ -449,11 +449,11 @@ type ViewedFilters = {
449
449
  /**
450
450
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
451
451
  */
452
- authenticatedUserToken?: string;
452
+ authenticatedUserToken?: string | undefined;
453
453
  /**
454
454
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
455
455
  */
456
- timestamp?: number;
456
+ timestamp?: number | undefined;
457
457
  };
458
458
 
459
459
  /**
@@ -480,11 +480,11 @@ type ViewedObjectIDs = {
480
480
  /**
481
481
  * Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
482
482
  */
483
- authenticatedUserToken?: string;
483
+ authenticatedUserToken?: string | undefined;
484
484
  /**
485
485
  * Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
486
486
  */
487
- timestamp?: number;
487
+ timestamp?: number | undefined;
488
488
  };
489
489
 
490
490
  type EventsItems = ClickedObjectIDsAfterSearch | AddedToCartObjectIDsAfterSearch | PurchasedObjectIDsAfterSearch | ConvertedObjectIDsAfterSearch | ClickedObjectIDs | PurchasedObjectIDs | AddedToCartObjectIDs | ConvertedObjectIDs | ClickedFilters | ConvertedFilters | ViewedObjectIDs | ViewedFilters;
@@ -509,7 +509,7 @@ type CustomDeleteProps = {
509
509
  */
510
510
  parameters?: {
511
511
  [key: string]: any;
512
- };
512
+ } | undefined;
513
513
  };
514
514
  /**
515
515
  * Properties for the `customGet` method.
@@ -524,7 +524,7 @@ type CustomGetProps = {
524
524
  */
525
525
  parameters?: {
526
526
  [key: string]: any;
527
- };
527
+ } | undefined;
528
528
  };
529
529
  /**
530
530
  * Properties for the `customPost` method.
@@ -539,11 +539,11 @@ type CustomPostProps = {
539
539
  */
540
540
  parameters?: {
541
541
  [key: string]: any;
542
- };
542
+ } | undefined;
543
543
  /**
544
544
  * Parameters to send with the custom request.
545
545
  */
546
- body?: Record<string, unknown>;
546
+ body?: Record<string, unknown> | undefined;
547
547
  };
548
548
  /**
549
549
  * Properties for the `customPut` method.
@@ -558,11 +558,11 @@ type CustomPutProps = {
558
558
  */
559
559
  parameters?: {
560
560
  [key: string]: any;
561
- };
561
+ } | undefined;
562
562
  /**
563
563
  * Parameters to send with the custom request.
564
564
  */
565
- body?: Record<string, unknown>;
565
+ body?: Record<string, unknown> | undefined;
566
566
  };
567
567
  /**
568
568
  * Properties for the `deleteUserToken` method.
@@ -574,11 +574,11 @@ type DeleteUserTokenProps = {
574
574
  userToken: string;
575
575
  };
576
576
 
577
- declare const apiClientVersion = "5.27.0";
577
+ declare const apiClientVersion = "5.28.0";
578
578
  declare const REGIONS: readonly ["de", "us"];
579
579
  type Region = (typeof REGIONS)[number];
580
580
  type RegionOptions = {
581
- region?: Region;
581
+ region?: Region | undefined;
582
582
  };
583
583
  declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
584
584
  transporter: _algolia_client_common.Transporter;
@@ -604,7 +604,7 @@ declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption
604
604
  * @param segment - The algolia agent (user-agent) segment to add.
605
605
  * @param version - The version of the agent.
606
606
  */
607
- addAlgoliaAgent(segment: string, version?: string): void;
607
+ addAlgoliaAgent(segment: string, version?: string | undefined): void;
608
608
  /**
609
609
  * Helper method to switch the API key used to authenticate the requests.
610
610
  *
@@ -673,10 +673,10 @@ declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption
673
673
  * Error.
674
674
  */
675
675
  type ErrorBase = Record<string, any> & {
676
- message?: string;
676
+ message?: string | undefined;
677
677
  };
678
678
 
679
- declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): InsightsClient;
679
+ declare function insightsClient(appId: string, apiKey: string, region?: Region | undefined, options?: ClientOptions | undefined): InsightsClient;
680
680
  type InsightsClient = ReturnType<typeof createInsightsClient>;
681
681
 
682
682
  export { type AddToCartEvent, type AddedToCartObjectIDs, type AddedToCartObjectIDsAfterSearch, type ClickEvent, type ClickedFilters, type ClickedObjectIDs, type ClickedObjectIDsAfterSearch, type ConversionEvent, type ConvertedFilters, type ConvertedObjectIDs, type ConvertedObjectIDsAfterSearch, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserTokenProps, type Discount, type ErrorBase, type EventsItems, type EventsResponse, type InsightsClient, type InsightsEvents, type ObjectData, type ObjectDataAfterSearch, type Price, type PurchaseEvent, type PurchasedObjectIDs, type PurchasedObjectIDsAfterSearch, type Region, type RegionOptions, type Value, type ViewEvent, type ViewedFilters, type ViewedObjectIDs, apiClientVersion, insightsClient };
@@ -9,7 +9,7 @@ import {
9
9
 
10
10
  // src/insightsClient.ts
11
11
  import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
12
- var apiClientVersion = "5.27.0";
12
+ var apiClientVersion = "5.28.0";
13
13
  var REGIONS = ["de", "us"];
14
14
  function getDefaultHosts(region) {
15
15
  const url = !region ? "insights.algolia.io" : "insights.{region}.algolia.io".replace("{region}", region);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../builds/browser.ts","../../src/insightsClient.ts"],"sourcesContent":["// 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.\n\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\n\nimport type { ClientOptions } from '@algolia/client-common';\n\nimport { apiClientVersion, createInsightsClient } from '../src/insightsClient';\n\nimport type { Region } from '../src/insightsClient';\nimport { REGIONS } from '../src/insightsClient';\n\nexport type { Region, RegionOptions } from '../src/insightsClient';\n\nexport { apiClientVersion } from '../src/insightsClient';\n\nexport * from '../model';\n\nexport function insightsClient(\n appId: string,\n apiKey: string,\n region?: Region,\n options?: ClientOptions,\n): InsightsClient {\n if (!appId || typeof appId !== 'string') {\n throw new Error('`appId` is missing.');\n }\n\n if (!apiKey || typeof apiKey !== 'string') {\n throw new Error('`apiKey` is missing.');\n }\n\n if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {\n throw new Error(`\\`region\\` must be one of the following: ${REGIONS.join(', ')}`);\n }\n\n return createInsightsClient({\n appId,\n apiKey,\n region,\n timeouts: {\n connect: 1000,\n read: 2000,\n write: 30000,\n },\n logger: createNullLogger(),\n requester: createXhrRequester(),\n algoliaAgents: [{ segment: 'Browser' }],\n authMode: 'WithinQueryParameters',\n responsesCache: createMemoryCache(),\n requestsCache: createMemoryCache({ serializable: false }),\n hostsCache: createFallbackableCache({\n caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()],\n }),\n ...options,\n });\n}\n\nexport type InsightsClient = ReturnType<typeof createInsightsClient>;\n","// 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.\n\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\nimport { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\n\nimport type { EventsResponse } from '../model/eventsResponse';\nimport type { InsightsEvents } from '../model/insightsEvents';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserTokenProps,\n} from '../model/clientMethodProps';\n\nexport const apiClientVersion = '5.27.0';\n\nexport const REGIONS = ['de', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\nexport type RegionOptions = { region?: Region };\n\nfunction getDefaultHosts(region?: Region): Host[] {\n const url = !region ? 'insights.algolia.io' : 'insights.{region}.algolia.io'.replace('{region}', region);\n\n return [{ url, accept: 'readWrite', protocol: 'https' }];\n}\n\nexport function createInsightsClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & RegionOptions) {\n const auth = createAuth(appIdOption, apiKeyOption, authMode);\n const transporter = createTransporter({\n hosts: getDefaultHosts(regionOption),\n ...options,\n algoliaAgent: getAlgoliaAgent({\n algoliaAgents,\n client: 'Insights',\n version: apiClientVersion,\n }),\n baseHeaders: {\n 'content-type': 'text/plain',\n ...auth.headers(),\n ...options.baseHeaders,\n },\n baseQueryParameters: {\n ...auth.queryParameters(),\n ...options.baseQueryParameters,\n },\n });\n\n return {\n transporter,\n\n /**\n * The `appId` currently in use.\n */\n appId: appIdOption,\n\n /**\n * The `apiKey` currently in use.\n */\n apiKey: apiKeyOption,\n\n /**\n * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.\n */\n clearCache(): Promise<void> {\n return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => undefined);\n },\n\n /**\n * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.\n */\n get _ua(): string {\n return transporter.algoliaAgent.value;\n },\n\n /**\n * Adds a `segment` to the `x-algolia-agent` sent with every requests.\n *\n * @param segment - The algolia agent (user-agent) segment to add.\n * @param version - The version of the agent.\n */\n addAlgoliaAgent(segment: string, version?: string): void {\n transporter.algoliaAgent.add({ segment, version });\n },\n\n /**\n * Helper method to switch the API key used to authenticate the requests.\n *\n * @param params - Method params.\n * @param params.apiKey - The new API Key to use.\n */\n setClientApiKey({ apiKey }: { apiKey: string }): void {\n if (!authMode || authMode === 'WithinHeaders') {\n transporter.baseHeaders['x-algolia-api-key'] = apiKey;\n } else {\n transporter.baseQueryParameters['x-algolia-api-key'] = apiKey;\n }\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customDelete - The customDelete object.\n * @param customDelete.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customDelete.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customDelete(\n { path, parameters }: CustomDeleteProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customDelete`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customGet - The customGet object.\n * @param customGet.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customGet.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customGet`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customPost - The customPost object.\n * @param customPost.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPost.parameters - Query parameters to apply to the current query.\n * @param customPost.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPost(\n { path, parameters, body }: CustomPostProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPost`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customPut - The customPut object.\n * @param customPut.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPut.parameters - Query parameters to apply to the current query.\n * @param customPut.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPut(\n { path, parameters, body }: CustomPutProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPut`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'PUT',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Deletes all events related to the specified user token from events metrics and analytics. The deletion is asynchronous, and processed within 48 hours. To delete a personalization user profile, see `Delete a user profile` in the Personalization API.\n *\n * Required API Key ACLs:\n * - deleteObject\n * @param deleteUserToken - The deleteUserToken object.\n * @param deleteUserToken.userToken - User token for which to delete all associated events.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n deleteUserToken({ userToken }: DeleteUserTokenProps, requestOptions?: RequestOptions): Promise<void> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `deleteUserToken`.');\n }\n\n const requestPath = '/1/usertokens/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * 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.\n *\n * Required API Key ACLs:\n * - search\n * @param insightsEvents - The insightsEvents object.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n pushEvents(insightsEvents: InsightsEvents, requestOptions?: RequestOptions): Promise<EventsResponse> {\n if (!insightsEvents) {\n throw new Error('Parameter `insightsEvents` is required when calling `pushEvents`.');\n }\n\n if (!insightsEvents.events) {\n throw new Error('Parameter `insightsEvents.events` is required when calling `pushEvents`.');\n }\n\n const requestPath = '/1/events';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: insightsEvents,\n };\n\n return trans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IACxD,YAAY,wBAAwB;AAAA,MAClC,QAAQ,CAAC,+BAA+B,EAAE,KAAK,GAAG,gBAAgB,IAAI,KAAK,GAAG,CAAC,GAAG,kBAAkB,CAAC;AAAA,IACvG,CAAC;AAAA,IACD,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../builds/browser.ts","../../src/insightsClient.ts"],"sourcesContent":["// 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.\n\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\n\nimport type { ClientOptions } from '@algolia/client-common';\n\nimport { apiClientVersion, createInsightsClient } from '../src/insightsClient';\n\nimport type { Region } from '../src/insightsClient';\nimport { REGIONS } from '../src/insightsClient';\n\nexport type { Region, RegionOptions } from '../src/insightsClient';\n\nexport { apiClientVersion } from '../src/insightsClient';\n\nexport * from '../model';\n\nexport function insightsClient(\n appId: string,\n apiKey: string,\n region?: Region | undefined,\n options?: ClientOptions | undefined,\n): InsightsClient {\n if (!appId || typeof appId !== 'string') {\n throw new Error('`appId` is missing.');\n }\n\n if (!apiKey || typeof apiKey !== 'string') {\n throw new Error('`apiKey` is missing.');\n }\n\n if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {\n throw new Error(`\\`region\\` must be one of the following: ${REGIONS.join(', ')}`);\n }\n\n return createInsightsClient({\n appId,\n apiKey,\n region,\n timeouts: {\n connect: 1000,\n read: 2000,\n write: 30000,\n },\n logger: createNullLogger(),\n requester: createXhrRequester(),\n algoliaAgents: [{ segment: 'Browser' }],\n authMode: 'WithinQueryParameters',\n responsesCache: createMemoryCache(),\n requestsCache: createMemoryCache({ serializable: false }),\n hostsCache: createFallbackableCache({\n caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()],\n }),\n ...options,\n });\n}\n\nexport type InsightsClient = ReturnType<typeof createInsightsClient>;\n","// 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.\n\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\nimport { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\n\nimport type { EventsResponse } from '../model/eventsResponse';\nimport type { InsightsEvents } from '../model/insightsEvents';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserTokenProps,\n} from '../model/clientMethodProps';\n\nexport const apiClientVersion = '5.28.0';\n\nexport const REGIONS = ['de', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\nexport type RegionOptions = { region?: Region | undefined };\n\nfunction getDefaultHosts(region?: Region | undefined): Host[] {\n const url = !region ? 'insights.algolia.io' : 'insights.{region}.algolia.io'.replace('{region}', region);\n\n return [{ url, accept: 'readWrite', protocol: 'https' }];\n}\n\nexport function createInsightsClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & RegionOptions) {\n const auth = createAuth(appIdOption, apiKeyOption, authMode);\n const transporter = createTransporter({\n hosts: getDefaultHosts(regionOption),\n ...options,\n algoliaAgent: getAlgoliaAgent({\n algoliaAgents,\n client: 'Insights',\n version: apiClientVersion,\n }),\n baseHeaders: {\n 'content-type': 'text/plain',\n ...auth.headers(),\n ...options.baseHeaders,\n },\n baseQueryParameters: {\n ...auth.queryParameters(),\n ...options.baseQueryParameters,\n },\n });\n\n return {\n transporter,\n\n /**\n * The `appId` currently in use.\n */\n appId: appIdOption,\n\n /**\n * The `apiKey` currently in use.\n */\n apiKey: apiKeyOption,\n\n /**\n * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.\n */\n clearCache(): Promise<void> {\n return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => undefined);\n },\n\n /**\n * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.\n */\n get _ua(): string {\n return transporter.algoliaAgent.value;\n },\n\n /**\n * Adds a `segment` to the `x-algolia-agent` sent with every requests.\n *\n * @param segment - The algolia agent (user-agent) segment to add.\n * @param version - The version of the agent.\n */\n addAlgoliaAgent(segment: string, version?: string | undefined): void {\n transporter.algoliaAgent.add({ segment, version });\n },\n\n /**\n * Helper method to switch the API key used to authenticate the requests.\n *\n * @param params - Method params.\n * @param params.apiKey - The new API Key to use.\n */\n setClientApiKey({ apiKey }: { apiKey: string }): void {\n if (!authMode || authMode === 'WithinHeaders') {\n transporter.baseHeaders['x-algolia-api-key'] = apiKey;\n } else {\n transporter.baseQueryParameters['x-algolia-api-key'] = apiKey;\n }\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customDelete - The customDelete object.\n * @param customDelete.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customDelete.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customDelete(\n { path, parameters }: CustomDeleteProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customDelete`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customGet - The customGet object.\n * @param customGet.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customGet.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customGet`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customPost - The customPost object.\n * @param customPost.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPost.parameters - Query parameters to apply to the current query.\n * @param customPost.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPost(\n { path, parameters, body }: CustomPostProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPost`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customPut - The customPut object.\n * @param customPut.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPut.parameters - Query parameters to apply to the current query.\n * @param customPut.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPut(\n { path, parameters, body }: CustomPutProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPut`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'PUT',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Deletes all events related to the specified user token from events metrics and analytics. The deletion is asynchronous, and processed within 48 hours. To delete a personalization user profile, see `Delete a user profile` in the Personalization API.\n *\n * Required API Key ACLs:\n * - deleteObject\n * @param deleteUserToken - The deleteUserToken object.\n * @param deleteUserToken.userToken - User token for which to delete all associated events.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n deleteUserToken({ userToken }: DeleteUserTokenProps, requestOptions?: RequestOptions): Promise<void> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `deleteUserToken`.');\n }\n\n const requestPath = '/1/usertokens/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * 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.\n *\n * Required API Key ACLs:\n * - search\n * @param insightsEvents - The insightsEvents object.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n pushEvents(insightsEvents: InsightsEvents, requestOptions?: RequestOptions): Promise<EventsResponse> {\n if (!insightsEvents) {\n throw new Error('Parameter `insightsEvents` is required when calling `pushEvents`.');\n }\n\n if (!insightsEvents.events) {\n throw new Error('Parameter `insightsEvents.events` is required when calling `pushEvents`.');\n }\n\n const requestPath = '/1/events';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: insightsEvents,\n };\n\n return transporter.request(request, requestOptions);\n },\n };\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AAEnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACCP,SAAS,YAAY,mBAAmB,uBAAuB;AAaxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAIlC,SAAS,gBAAgB,Q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=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,o)=>setTimeout(()=>{t.abort(),s({status:0,content:o,isTimedOut:!0})},a),l=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(l),p=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(l),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(l),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function W(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(s)||"{}")}function l(a){t().setItem(s,JSON.stringify(a))}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,h])=>h.timestamp!==void 0));if(l(i),!a)return;let m=Object.fromEntries(Object.entries(i).filter(([,h])=>{let y=new Date().getTime();return!(h.timestamp+a<y)}));l(m)}return{get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(m=>Promise.all([m?m.value:o(),m!==void 0])).then(([m,h])=>Promise.all([m,h||i.miss(m)])).then(([m])=>m)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},t().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],t().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{t().removeItem(s)})}}}function V(){return{get(r,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function x(r){let e=[...r.caches],s=e.shift();return s===void 0?V():{get(t,n,l={miss:()=>Promise.resolve()}){return s.get(t,n,l).catch(()=>x({caches:e}).get(t,n,l))},set(t,n){return s.set(t,n).catch(()=>x({caches:e}).set(t,n))},delete(t){return s.delete(t).catch(()=>x({caches:e}).delete(t))},clear(){return s.clear().catch(()=>x({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return{get(s,t,n={miss:()=>Promise.resolve()}){let l=JSON.stringify(s);if(l in e)return Promise.resolve(r.serializable?JSON.parse(e[l]):e[l]);let p=t();return p.then(a=>n.miss(a)).then(()=>p)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function z({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function M(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var $=2*60*1e3;function j(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>$}function n(){return e==="timed out"&&Date.now()-s<=$}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var Q=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}};var G=class extends Q{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},Z=class extends G{constructor(r){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.",r,"RetryError")}},b=class extends G{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},ee=class extends Q{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends b{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s}};function te(r,e,s){let t=se(s),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function se(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function oe(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ne(r,e,s){let t={Accept:"application/json",...r,...e,...s},n={};return Object.keys(t).forEach(l=>{let p=t[l];n[l.toLowerCase()]=p}),n}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},s){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,s):new b(t.message,e,s)}catch{}return new b(r,e,s)}function ce({isTimedOut:r,status:e}){return!r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>F(e))}function F(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function B({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:l,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function m(c){let u=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve(j(d))))),g=u.filter(d=>d.isUp()),P=u.filter(d=>d.isTimedOut()),w=[...g,...P];return{hosts:w.length>0?w:c,getTimeout(d,v){return(P.length===0&&d===0?1:P.length+3+d)*v}}}async function h(c,u,g=!0){let P=[],w=oe(c,u),E=ne(s,c.headers,u.headers),d=c.method==="GET"?{...c.data,...u.data}:{},v={...n,...c.queryParameters,...d};if(l.value&&(v["x-algolia-agent"]=l.value),u&&u.queryParameters)for(let f of Object.keys(u.queryParameters))!u.queryParameters[f]||Object.prototype.toString.call(u.queryParameters[f])==="[object Object]"?v[f]=u.queryParameters[f]:v[f]=u.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(P));let C={...p,...u.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,C.connect),responseTimeout:S(O,g?C.read:C.write)},U=I=>{let L={request:_,response:I,host:R,triesLeft:f.length};return P.push(L),L},T=await a.send(_);if(ue(T)){let I=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",F(I)),await e.set(R,j(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,P)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await m(K);return D([...k.hosts].reverse(),k.getTimeout)}function y(c,u={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return h(c,u,g);let P=()=>h(c,u);if((u.cacheable||c.cacheable)!==!0)return P();let E={request:c,requestOptions:u,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,P()).then(d=>Promise.all([o.delete(E),d]),d=>Promise.all([o.delete(E),Promise.reject(d)])).then(([d,v])=>v)),{miss:d=>i.set(E,d)})}return{hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:l,baseHeaders:s,baseQueryParameters:n,hosts:r,request:y,requestsCache:o,responsesCache:i}}var A="5.27.0",N=["de","us"];function de(r){return[{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:s,algoliaAgents:t,region:n,...l}){let p=J(r,e,s),a=B({hosts:de(n),...l,algoliaAgent:z({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...l.baseHeaders},baseQueryParameters:{...p.queryParameters(),...l.baseQueryParameters}});return{transporter:a,appId:r,apiKey:e,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},customDelete({path:o,parameters:i},m){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(u,m)},customGet({path:o,parameters:i},m){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(u,m)},customPost({path:o,parameters:i,body:m},h){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:m},h){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,h)},deleteUserToken({userToken:o},i){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(o,i){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return a.request(c,i)}}}function er(r,e,s,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:M(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:x({caches:[W({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,er as insightsClient};
1
+ function H(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,o)=>setTimeout(()=>{t.abort(),s({status:0,content:o,isTimedOut:!0})},a),l=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(l),p=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(l),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(l),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function W(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(s)||"{}")}function l(a){t().setItem(s,JSON.stringify(a))}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,h])=>h.timestamp!==void 0));if(l(i),!a)return;let m=Object.fromEntries(Object.entries(i).filter(([,h])=>{let y=new Date().getTime();return!(h.timestamp+a<y)}));l(m)}return{get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(m=>Promise.all([m?m.value:o(),m!==void 0])).then(([m,h])=>Promise.all([m,h||i.miss(m)])).then(([m])=>m)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},t().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],t().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{t().removeItem(s)})}}}function V(){return{get(r,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function x(r){let e=[...r.caches],s=e.shift();return s===void 0?V():{get(t,n,l={miss:()=>Promise.resolve()}){return s.get(t,n,l).catch(()=>x({caches:e}).get(t,n,l))},set(t,n){return s.set(t,n).catch(()=>x({caches:e}).set(t,n))},delete(t){return s.delete(t).catch(()=>x({caches:e}).delete(t))},clear(){return s.clear().catch(()=>x({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return{get(s,t,n={miss:()=>Promise.resolve()}){let l=JSON.stringify(s);if(l in e)return Promise.resolve(r.serializable?JSON.parse(e[l]):e[l]);let p=t();return p.then(a=>n.miss(a)).then(()=>p)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function z({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function M(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var $=2*60*1e3;function j(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>$}function n(){return e==="timed out"&&Date.now()-s<=$}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var Q=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}};var G=class extends Q{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},Z=class extends G{constructor(r){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.",r,"RetryError")}},b=class extends G{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},ee=class extends Q{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends b{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s}};function te(r,e,s){let t=se(s),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function se(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function oe(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ne(r,e,s){let t={Accept:"application/json",...r,...e,...s},n={};return Object.keys(t).forEach(l=>{let p=t[l];n[l.toLowerCase()]=p}),n}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},s){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,s):new b(t.message,e,s)}catch{}return new b(r,e,s)}function ce({isTimedOut:r,status:e}){return!r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>F(e))}function F(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function B({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:l,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function m(c){let u=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve(j(d))))),g=u.filter(d=>d.isUp()),P=u.filter(d=>d.isTimedOut()),w=[...g,...P];return{hosts:w.length>0?w:c,getTimeout(d,v){return(P.length===0&&d===0?1:P.length+3+d)*v}}}async function h(c,u,g=!0){let P=[],w=oe(c,u),E=ne(s,c.headers,u.headers),d=c.method==="GET"?{...c.data,...u.data}:{},v={...n,...c.queryParameters,...d};if(l.value&&(v["x-algolia-agent"]=l.value),u&&u.queryParameters)for(let f of Object.keys(u.queryParameters))!u.queryParameters[f]||Object.prototype.toString.call(u.queryParameters[f])==="[object Object]"?v[f]=u.queryParameters[f]:v[f]=u.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(P));let C={...p,...u.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,C.connect),responseTimeout:S(O,g?C.read:C.write)},U=I=>{let L={request:_,response:I,host:R,triesLeft:f.length};return P.push(L),L},T=await a.send(_);if(ue(T)){let I=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",F(I)),await e.set(R,j(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,P)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await m(K);return D([...k.hosts].reverse(),k.getTimeout)}function y(c,u={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return h(c,u,g);let P=()=>h(c,u);if((u.cacheable||c.cacheable)!==!0)return P();let E={request:c,requestOptions:u,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,P()).then(d=>Promise.all([o.delete(E),d]),d=>Promise.all([o.delete(E),Promise.reject(d)])).then(([d,v])=>v)),{miss:d=>i.set(E,d)})}return{hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:l,baseHeaders:s,baseQueryParameters:n,hosts:r,request:y,requestsCache:o,responsesCache:i}}var A="5.28.0",N=["de","us"];function de(r){return[{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:s,algoliaAgents:t,region:n,...l}){let p=J(r,e,s),a=B({hosts:de(n),...l,algoliaAgent:z({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...l.baseHeaders},baseQueryParameters:{...p.queryParameters(),...l.baseQueryParameters}});return{transporter:a,appId:r,apiKey:e,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},customDelete({path:o,parameters:i},m){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(u,m)},customGet({path:o,parameters:i},m){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(u,m)},customPost({path:o,parameters:i,body:m},h){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:m},h){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,h)},deleteUserToken({userToken:o},i){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(o,i){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return a.request(c,i)}}}function er(r,e,s,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:M(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:x({caches:[W({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,er as insightsClient};
2
2
  //# sourceMappingURL=browser.min.js.map