@algolia/client-insights 5.2.5 → 5.3.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/dist/browser.d.ts CHANGED
@@ -1,5 +1,89 @@
1
1
  import * as _algolia_client_common from '@algolia/client-common';
2
- import { ClientOptions } from '@algolia/client-common';
2
+ import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
3
+
4
+ /**
5
+ * Properties for the `customDelete` method.
6
+ */
7
+ type CustomDeleteProps = {
8
+ /**
9
+ * Path of the endpoint, anything after \"/1\" must be specified.
10
+ */
11
+ path: string;
12
+ /**
13
+ * Query parameters to apply to the current query.
14
+ */
15
+ parameters?: Record<string, any>;
16
+ };
17
+ /**
18
+ * Properties for the `customGet` method.
19
+ */
20
+ type CustomGetProps = {
21
+ /**
22
+ * Path of the endpoint, anything after \"/1\" must be specified.
23
+ */
24
+ path: string;
25
+ /**
26
+ * Query parameters to apply to the current query.
27
+ */
28
+ parameters?: Record<string, any>;
29
+ };
30
+ /**
31
+ * Properties for the `customPost` method.
32
+ */
33
+ type CustomPostProps = {
34
+ /**
35
+ * Path of the endpoint, anything after \"/1\" must be specified.
36
+ */
37
+ path: string;
38
+ /**
39
+ * Query parameters to apply to the current query.
40
+ */
41
+ parameters?: Record<string, any>;
42
+ /**
43
+ * Parameters to send with the custom request.
44
+ */
45
+ body?: Record<string, unknown>;
46
+ };
47
+ /**
48
+ * Properties for the `customPut` method.
49
+ */
50
+ type CustomPutProps = {
51
+ /**
52
+ * Path of the endpoint, anything after \"/1\" must be specified.
53
+ */
54
+ path: string;
55
+ /**
56
+ * Query parameters to apply to the current query.
57
+ */
58
+ parameters?: Record<string, any>;
59
+ /**
60
+ * Parameters to send with the custom request.
61
+ */
62
+ body?: Record<string, unknown>;
63
+ };
64
+ /**
65
+ * Properties for the `deleteUserToken` method.
66
+ */
67
+ type DeleteUserTokenProps = {
68
+ /**
69
+ * User token for which to delete all associated events.
70
+ */
71
+ userToken: string;
72
+ };
73
+
74
+ /**
75
+ * The response of the Insights API.
76
+ */
77
+ type EventsResponse = {
78
+ /**
79
+ * Details about the response, such as error messages.
80
+ */
81
+ message?: string;
82
+ /**
83
+ * The HTTP status code of the response.
84
+ */
85
+ status?: number;
86
+ };
3
87
 
4
88
  type AddToCartEvent = 'addToCart';
5
89
 
@@ -325,13 +409,6 @@ type ConvertedObjectIDsAfterSearch = {
325
409
  timestamp?: number;
326
410
  };
327
411
 
328
- /**
329
- * Error.
330
- */
331
- type ErrorBase = Record<string, any> & {
332
- message?: string;
333
- };
334
-
335
412
  type PurchaseEvent = 'purchase';
336
413
 
337
414
  /**
@@ -482,20 +559,6 @@ type ViewedObjectIDs = {
482
559
 
483
560
  type EventsItems = AddedToCartObjectIDs | AddedToCartObjectIDsAfterSearch | ClickedFilters | ClickedObjectIDs | ClickedObjectIDsAfterSearch | ConvertedFilters | ConvertedObjectIDs | ConvertedObjectIDsAfterSearch | PurchasedObjectIDs | PurchasedObjectIDsAfterSearch | ViewedFilters | ViewedObjectIDs;
484
561
 
485
- /**
486
- * The response of the Insights API.
487
- */
488
- type EventsResponse = {
489
- /**
490
- * Details about the response, such as error messages.
491
- */
492
- message?: string;
493
- /**
494
- * The HTTP status code of the response.
495
- */
496
- status?: number;
497
- };
498
-
499
562
  type InsightsEvents = {
500
563
  /**
501
564
  * Click and conversion events. **All** events must be valid, otherwise the API returns an error.
@@ -503,96 +566,105 @@ type InsightsEvents = {
503
566
  events: EventsItems[];
504
567
  };
505
568
 
506
- /**
507
- * Properties for the `customDelete` method.
508
- */
509
- type CustomDeleteProps = {
510
- /**
511
- * Path of the endpoint, anything after \"/1\" must be specified.
512
- */
513
- path: string;
514
- /**
515
- * Query parameters to apply to the current query.
516
- */
517
- parameters?: Record<string, any>;
518
- };
519
- /**
520
- * Properties for the `customGet` method.
521
- */
522
- type CustomGetProps = {
523
- /**
524
- * Path of the endpoint, anything after \"/1\" must be specified.
525
- */
526
- path: string;
527
- /**
528
- * Query parameters to apply to the current query.
529
- */
530
- parameters?: Record<string, any>;
531
- };
532
- /**
533
- * Properties for the `customPost` method.
534
- */
535
- type CustomPostProps = {
536
- /**
537
- * Path of the endpoint, anything after \"/1\" must be specified.
538
- */
539
- path: string;
569
+ declare const apiClientVersion = "5.3.0";
570
+ declare const REGIONS: readonly ["de", "us"];
571
+ type Region = (typeof REGIONS)[number];
572
+ declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
573
+ region?: Region;
574
+ }): {
575
+ transporter: _algolia_client_common.Transporter;
540
576
  /**
541
- * Query parameters to apply to the current query.
577
+ * The `appId` currently in use.
542
578
  */
543
- parameters?: Record<string, any>;
579
+ appId: string;
544
580
  /**
545
- * Parameters to send with the custom request.
581
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
546
582
  */
547
- body?: Record<string, unknown>;
548
- };
549
- /**
550
- * Properties for the `customPut` method.
551
- */
552
- type CustomPutProps = {
583
+ clearCache(): Promise<void>;
553
584
  /**
554
- * Path of the endpoint, anything after \"/1\" must be specified.
585
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
555
586
  */
556
- path: string;
587
+ readonly _ua: string;
557
588
  /**
558
- * Query parameters to apply to the current query.
589
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
590
+ *
591
+ * @param segment - The algolia agent (user-agent) segment to add.
592
+ * @param version - The version of the agent.
559
593
  */
560
- parameters?: Record<string, any>;
594
+ addAlgoliaAgent(segment: string, version?: string): void;
561
595
  /**
562
- * Parameters to send with the custom request.
563
- */
564
- body?: Record<string, unknown>;
596
+ * Helper method to switch the API key used to authenticate the requests.
597
+ *
598
+ * @param params - Method params.
599
+ * @param params.apiKey - The new API Key to use.
600
+ */
601
+ setClientApiKey({ apiKey }: {
602
+ apiKey: string;
603
+ }): void;
604
+ /**
605
+ * This method allow you to send requests to the Algolia REST API.
606
+ *
607
+ * @param customDelete - The customDelete object.
608
+ * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
609
+ * @param customDelete.parameters - Query parameters to apply to the current query.
610
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
611
+ */
612
+ customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
613
+ /**
614
+ * This method allow you to send requests to the Algolia REST API.
615
+ *
616
+ * @param customGet - The customGet object.
617
+ * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
618
+ * @param customGet.parameters - Query parameters to apply to the current query.
619
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
620
+ */
621
+ customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
622
+ /**
623
+ * This method allow you to send requests to the Algolia REST API.
624
+ *
625
+ * @param customPost - The customPost object.
626
+ * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
627
+ * @param customPost.parameters - Query parameters to apply to the current query.
628
+ * @param customPost.body - Parameters to send with the custom request.
629
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
630
+ */
631
+ customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
632
+ /**
633
+ * This method allow you to send requests to the Algolia REST API.
634
+ *
635
+ * @param customPut - The customPut object.
636
+ * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
637
+ * @param customPut.parameters - Query parameters to apply to the current query.
638
+ * @param customPut.body - Parameters to send with the custom request.
639
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
640
+ */
641
+ customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
642
+ /**
643
+ * 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.
644
+ *
645
+ * @param deleteUserToken - The deleteUserToken object.
646
+ * @param deleteUserToken.userToken - User token for which to delete all associated events.
647
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
648
+ */
649
+ deleteUserToken({ userToken }: DeleteUserTokenProps, requestOptions?: RequestOptions): Promise<void>;
650
+ /**
651
+ * 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.
652
+ *
653
+ * @param insightsEvents - The insightsEvents object.
654
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
655
+ */
656
+ pushEvents(insightsEvents: InsightsEvents, requestOptions?: RequestOptions): Promise<EventsResponse>;
565
657
  };
658
+
566
659
  /**
567
- * Properties for the `deleteUserToken` method.
660
+ * Error.
568
661
  */
569
- type DeleteUserTokenProps = {
570
- /**
571
- * User token for which to delete all associated events.
572
- */
573
- userToken: string;
662
+ type ErrorBase = Record<string, any> & {
663
+ message?: string;
574
664
  };
575
665
 
576
- declare const apiClientVersion = "5.2.5";
577
- declare const REGIONS: readonly ["de", "us"];
578
- type Region = (typeof REGIONS)[number];
666
+ type InsightsClient = ReturnType<typeof createInsightsClient>;
579
667
 
580
- /**
581
- * The client type.
582
- */
583
- type InsightsClient = ReturnType<typeof insightsClient>;
584
- declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): {
585
- transporter: _algolia_client_common.Transporter;
586
- appId: string;
587
- clearCache(): Promise<void>;
588
- readonly _ua: string;
589
- addAlgoliaAgent(segment: string, version?: string): void;
590
- customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
591
- customGet({ path, parameters }: CustomGetProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
592
- customPost({ path, parameters, body }: CustomPostProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
593
- customPut({ path, parameters, body }: CustomPutProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
594
- deleteUserToken({ userToken }: DeleteUserTokenProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<void>;
595
- pushEvents(insightsEvents: InsightsEvents, requestOptions?: _algolia_client_common.RequestOptions): Promise<EventsResponse>;
596
- };
668
+ declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): InsightsClient;
597
669
 
598
670
  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 Value, type ViewEvent, type ViewedFilters, type ViewedObjectIDs, apiClientVersion, insightsClient };
@@ -11,7 +11,7 @@ import { createXhrRequester } from "@algolia/requester-browser-xhr";
11
11
 
12
12
  // src/insightsClient.ts
13
13
  import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
14
- var apiClientVersion = "5.2.5";
14
+ var apiClientVersion = "5.3.0";
15
15
  var REGIONS = ["de", "us"];
16
16
  function getDefaultHosts(region) {
17
17
  const url = !region ? "insights.algolia.io" : "insights.{region}.algolia.io".replace("{region}", region);
@@ -26,26 +26,25 @@ function createInsightsClient({
26
26
  ...options
27
27
  }) {
28
28
  const auth = createAuth(appIdOption, apiKeyOption, authMode);
29
- const transporter = createTransporter({
30
- hosts: getDefaultHosts(regionOption),
31
- ...options,
32
- algoliaAgent: getAlgoliaAgent({
33
- algoliaAgents,
34
- client: "Insights",
35
- version: apiClientVersion
36
- }),
37
- baseHeaders: {
38
- "content-type": "text/plain",
39
- ...auth.headers(),
40
- ...options.baseHeaders
41
- },
42
- baseQueryParameters: {
43
- ...auth.queryParameters(),
44
- ...options.baseQueryParameters
45
- }
46
- });
47
29
  return {
48
- transporter,
30
+ transporter: createTransporter({
31
+ hosts: getDefaultHosts(regionOption),
32
+ ...options,
33
+ algoliaAgent: getAlgoliaAgent({
34
+ algoliaAgents,
35
+ client: "Insights",
36
+ version: apiClientVersion
37
+ }),
38
+ baseHeaders: {
39
+ "content-type": "text/plain",
40
+ ...auth.headers(),
41
+ ...options.baseHeaders
42
+ },
43
+ baseQueryParameters: {
44
+ ...auth.queryParameters(),
45
+ ...options.baseQueryParameters
46
+ }
47
+ }),
49
48
  /**
50
49
  * The `appId` currently in use.
51
50
  */
@@ -54,13 +53,15 @@ function createInsightsClient({
54
53
  * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
55
54
  */
56
55
  clearCache() {
57
- return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
56
+ return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
57
+ () => void 0
58
+ );
58
59
  },
59
60
  /**
60
61
  * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
61
62
  */
62
63
  get _ua() {
63
- return transporter.algoliaAgent.value;
64
+ return this.transporter.algoliaAgent.value;
64
65
  },
65
66
  /**
66
67
  * Adds a `segment` to the `x-algolia-agent` sent with every requests.
@@ -69,7 +70,16 @@ function createInsightsClient({
69
70
  * @param version - The version of the agent.
70
71
  */
71
72
  addAlgoliaAgent(segment, version) {
72
- transporter.algoliaAgent.add({ segment, version });
73
+ this.transporter.algoliaAgent.add({ segment, version });
74
+ },
75
+ /**
76
+ * Helper method to switch the API key used to authenticate the requests.
77
+ *
78
+ * @param params - Method params.
79
+ * @param params.apiKey - The new API Key to use.
80
+ */
81
+ setClientApiKey({ apiKey }) {
82
+ this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
73
83
  },
74
84
  /**
75
85
  * This method allow you to send requests to the Algolia REST API.
@@ -92,7 +102,7 @@ function createInsightsClient({
92
102
  queryParameters,
93
103
  headers
94
104
  };
95
- return transporter.request(request, requestOptions);
105
+ return this.transporter.request(request, requestOptions);
96
106
  },
97
107
  /**
98
108
  * This method allow you to send requests to the Algolia REST API.
@@ -115,7 +125,7 @@ function createInsightsClient({
115
125
  queryParameters,
116
126
  headers
117
127
  };
118
- return transporter.request(request, requestOptions);
128
+ return this.transporter.request(request, requestOptions);
119
129
  },
120
130
  /**
121
131
  * This method allow you to send requests to the Algolia REST API.
@@ -140,7 +150,7 @@ function createInsightsClient({
140
150
  headers,
141
151
  data: body ? body : {}
142
152
  };
143
- return transporter.request(request, requestOptions);
153
+ return this.transporter.request(request, requestOptions);
144
154
  },
145
155
  /**
146
156
  * This method allow you to send requests to the Algolia REST API.
@@ -165,7 +175,7 @@ function createInsightsClient({
165
175
  headers,
166
176
  data: body ? body : {}
167
177
  };
168
- return transporter.request(request, requestOptions);
178
+ return this.transporter.request(request, requestOptions);
169
179
  },
170
180
  /**
171
181
  * 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.
@@ -187,7 +197,7 @@ function createInsightsClient({
187
197
  queryParameters,
188
198
  headers
189
199
  };
190
- return transporter.request(request, requestOptions);
200
+ return this.transporter.request(request, requestOptions);
191
201
  },
192
202
  /**
193
203
  * 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.
@@ -212,7 +222,7 @@ function createInsightsClient({
212
222
  headers,
213
223
  data: insightsEvents
214
224
  };
215
- return transporter.request(request, requestOptions);
225
+ return this.transporter.request(request, requestOptions);
216
226
  }
217
227
  };
218
228
  }
@@ -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 type { ClientOptions } from '@algolia/client-common';\nimport {\n createMemoryCache,\n createFallbackableCache,\n createBrowserLocalStorageCache,\n DEFAULT_CONNECT_TIMEOUT_BROWSER,\n DEFAULT_READ_TIMEOUT_BROWSER,\n DEFAULT_WRITE_TIMEOUT_BROWSER,\n} from '@algolia/client-common';\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport type { Region } from '../src/insightsClient';\nimport { createInsightsClient, apiClientVersion, REGIONS } from '../src/insightsClient';\n\nexport { apiClientVersion, Region } from '../src/insightsClient';\nexport * from '../model';\n\n/**\n * The client type.\n */\nexport type InsightsClient = ReturnType<typeof insightsClient>;\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions) {\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: DEFAULT_CONNECT_TIMEOUT_BROWSER,\n read: DEFAULT_READ_TIMEOUT_BROWSER,\n write: DEFAULT_WRITE_TIMEOUT_BROWSER,\n },\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","// 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 { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserTokenProps,\n} from '../model/clientMethodProps';\nimport type { EventsResponse } from '../model/eventsResponse';\nimport type { InsightsEvents } from '../model/insightsEvents';\n\nexport const apiClientVersion = '5.2.5';\n\nexport const REGIONS = ['de', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\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\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createInsightsClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & { region?: Region }) {\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 * 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 * This method allow you to send requests to the Algolia REST API.\n *\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 allow you to send requests to the Algolia REST API.\n *\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 allow you to send requests to the Algolia REST API.\n *\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 allow you to send requests to the Algolia REST API.\n *\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 * @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 * @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":";AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;;;ACTnC,SAAS,YAAY,mBAAmB,uBAAuB;AAoBxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAGlC,SAAS,gBAAgB,QAAyB;AAChD,QAAM,MAAM,CAAC,SAAS,wBAAwB,+BAA+B,QAAQ,YAAY,MAAM;AAEvG,SAAO,CAAC,EAAE,KAAK,QAAQ,aAAa,UAAU,QAAQ,CAAC;AACzD;AAGO,SAAS,qBAAqB;AAAA,EACnC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,GAAG;AACL,GAA8C;AAC5C,QAAM,OAAO,WAAW,aAAa,cAAc,QAAQ;AAC3D,QAAM,cAAc,kBAAkB;AAAA,IACpC,OAAO,gBAAgB,YAAY;AAAA,IACnC,GAAG;AAAA,IACH,cAAc,gBAAgB;AAAA,MAC5B;AAAA,MACA,QAAQ;AAAA,MACR,SAAS;AAAA,IACX,CAAC;AAAA,IACD,aAAa;AAAA,MACX,gBAAgB;AA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,OAAO;AAAA,IACT;AAAA,IACA,WAAW,mBAAmB;AAAA,IAC9B,eAAe,CAAC,EAAE,SAAS,UAAU,CAAC;AAAA,IACtC,UAAU;AAAA,IACV,gBAAgB,kBAAkB;AAAA,IAClC,eAAe,kBAAkB,EAAE,cAAc,MAAM,CAAC;AAAA,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 type { ClientOptions } from '@algolia/client-common';\nimport {\n createMemoryCache,\n createFallbackableCache,\n createBrowserLocalStorageCache,\n DEFAULT_CONNECT_TIMEOUT_BROWSER,\n DEFAULT_READ_TIMEOUT_BROWSER,\n DEFAULT_WRITE_TIMEOUT_BROWSER,\n} from '@algolia/client-common';\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport type { Region } from '../src/insightsClient';\nimport { createInsightsClient, apiClientVersion, REGIONS } from '../src/insightsClient';\n\nexport type InsightsClient = ReturnType<typeof createInsightsClient>;\n\nexport { apiClientVersion, Region } from '../src/insightsClient';\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: DEFAULT_CONNECT_TIMEOUT_BROWSER,\n read: DEFAULT_READ_TIMEOUT_BROWSER,\n write: DEFAULT_WRITE_TIMEOUT_BROWSER,\n },\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","// 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 { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserTokenProps,\n} from '../model/clientMethodProps';\nimport type { EventsResponse } from '../model/eventsResponse';\nimport type { InsightsEvents } from '../model/insightsEvents';\n\nexport const apiClientVersion = '5.3.0';\n\nexport const REGIONS = ['de', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\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\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createInsightsClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & { region?: Region }) {\n const auth = createAuth(appIdOption, apiKeyOption, authMode);\n\n return {\n 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 /**\n * The `appId` currently in use.\n */\n appId: appIdOption,\n\n /**\n * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.\n */\n clearCache(): Promise<void> {\n return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(\n () => undefined,\n );\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 this.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 this.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 this.transporter.baseHeaders['x-algolia-api-key'] = apiKey;\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\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 this.transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\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 this.transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\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 this.transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\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 this.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 * @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 this.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 * @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 this.transporter.request(request, requestOptions);\n },\n };\n}\n"],"mappings":";AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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AAC;AACH;","names":[]}
@@ -1,2 +1,2 @@
1
- function j(t,e,o="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return o==="WithinHeaders"?r:{}},queryParameters(){return o==="WithinQueryParameters"?r:{}}}}function H(t){let e,o=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function s(){return JSON.parse(r().getItem(o)||"{}")}function m(a){r().setItem(o,JSON.stringify(a))}function d(){let a=t.timeToLive?t.timeToLive*1e3:null,n=s(),c=Object.fromEntries(Object.entries(n).filter(([,p])=>p.timestamp!==void 0));if(m(c),!a)return;let u=Object.fromEntries(Object.entries(c).filter(([,p])=>{let l=new Date().getTime();return!(p.timestamp+a<l)}));m(u)}return{get(a,n,c={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(d(),s()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:n(),u!==void 0])).then(([u,p])=>Promise.all([u,p||c.miss(u)])).then(([u])=>u)},set(a,n){return Promise.resolve().then(()=>{let c=s();return c[JSON.stringify(a)]={timestamp:new Date().getTime(),value:n},r().setItem(o,JSON.stringify(c)),n})},delete(a){return Promise.resolve().then(()=>{let n=s();delete n[JSON.stringify(a)],r().setItem(o,JSON.stringify(n))})},clear(){return Promise.resolve().then(()=>{r().removeItem(o)})}}}function Y(){return{get(t,e,o={miss:()=>Promise.resolve()}){return e().then(s=>Promise.all([s,o.miss(s)])).then(([s])=>s)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function v(t){let e=[...t.caches],o=e.shift();return o===void 0?Y():{get(r,s,m={miss:()=>Promise.resolve()}){return o.get(r,s,m).catch(()=>v({caches:e}).get(r,s,m))},set(r,s){return o.set(r,s).catch(()=>v({caches:e}).set(r,s))},delete(r){return o.delete(r).catch(()=>v({caches:e}).delete(r))},clear(){return o.clear().catch(()=>v({caches:e}).clear())}}}function x(t={serializable:!0}){let e={};return{get(o,r,s={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let d=r();return d.then(a=>s.miss(a)).then(()=>d)},set(o,r){return e[JSON.stringify(o)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var L=2*60*1e3;function W(t,e="up"){let o=Date.now();function r(){return e==="up"||Date.now()-o>L}function s(){return e==="timed out"&&Date.now()-o<=L}return{...t,status:e,lastUpdate:o,isUp:r,isTimedOut:s}}var J=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},$=class extends J{stackTrace;constructor(t,e,o){super(t,o),this.stackTrace=e}},Z=class extends ${constructor(t){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.",t,"RetryError")}},b=class extends ${status;constructor(t,e,o,r="ApiError"){super(t,o,r),this.status=e}},ee=class extends J{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},te=class extends b{error;constructor(t,e,o,r){super(t,e,r,"DetailedApiError"),this.error=o}};function re(t,e,o){let r=oe(o),s=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(s+=`?${r}`),s}function oe(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function se(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let o=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(o)}function ne(t,e,o){let r={Accept:"application/json",...t,...e,...o},s={};return Object.keys(r).forEach(m=>{let d=r[m];s[m.toLowerCase()]=d}),s}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},o){try{let r=JSON.parse(t);return"error"in r?new te(r.message,e,r.error,o):new b(r.message,e,o)}catch{}return new b(t,e,o)}function ce({isTimedOut:t,status:e}){return!t&&~~e===0}function ue({isTimedOut:t,status:e}){return t||ce({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return~~(t/100)===2}function me(t){return t.map(e=>M(e))}function M(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function z({hosts:t,hostsCache:e,baseHeaders:o,baseQueryParameters:r,algoliaAgent:s,timeouts:m,requester:d,requestsCache:a,responsesCache:n}){async function c(l){let i=await Promise.all(l.map(h=>e.get(h,()=>Promise.resolve(W(h))))),P=i.filter(h=>h.isUp()),f=i.filter(h=>h.isTimedOut()),R=[...P,...f];return{hosts:R.length>0?R:l,getTimeout(h,y){return(f.length===0&&h===0?1:f.length+3+h)*y}}}async function u(l,i,P=!0){let f=[],R=se(l,i),E=ne(o,l.headers,i.headers),h=l.method==="GET"?{...l.data,...i.data}:{},y={...r,...l.queryParameters,...h};if(s.value&&(y["x-algolia-agent"]=s.value),i&&i.queryParameters)for(let g of Object.keys(i.queryParameters))!i.queryParameters[g]||Object.prototype.toString.call(i.queryParameters[g])==="[object Object]"?y[g]=i.queryParameters[g]:y[g]=i.queryParameters[g].toString();let O=0,D=async(g,q)=>{let w=g.pop();if(w===void 0)throw new Z(me(f));let S={...m,...i.timeouts},U={data:R,headers:E,method:l.method,url:re(w,l.path,y),connectTimeout:q(O,S.connect),responseTimeout:q(O,P?S.read:S.write)},_=C=>{let k={request:U,response:C,host:w,triesLeft:g.length};return f.push(k),k},T=await d.send(U);if(ue(T)){let C=_(T);return T.isTimedOut&&O++,console.log("Retryable failure",M(C)),await e.set(w,W(w,T.isTimedOut?"timed out":"down")),D(g,q)}if(le(T))return ae(T);throw _(T),ie(T,f)},K=t.filter(g=>g.accept==="readWrite"||(P?g.accept==="read":g.accept==="write")),I=await c(K);return D([...I.hosts].reverse(),I.getTimeout)}function p(l,i={}){let P=l.useReadTransporter||l.method==="GET";if(!P)return u(l,i,P);let f=()=>u(l,i);if((i.cacheable||l.cacheable)!==!0)return f();let E={request:l,requestOptions:i,transporter:{queryParameters:r,headers:o}};return n.get(E,()=>a.get(E,()=>a.set(E,f()).then(h=>Promise.all([a.delete(E),h]),h=>Promise.all([a.delete(E),Promise.reject(h)])).then(([h,y])=>y)),{miss:h=>n.set(E,h)})}return{hostsCache:e,requester:d,timeouts:m,algoliaAgent:s,baseHeaders:o,baseQueryParameters:r,hosts:t,request:p,requestsCache:a,responsesCache:n}}function he(t){let e={value:`Algolia for JavaScript (${t})`,add(o){let r=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function F({algoliaAgents:t,client:e,version:o}){let r=he(o).add({segment:e,version:o});return t.forEach(s=>r.add(s)),r}var G=1e3,Q=2e3,B=3e4;function X(){function t(e){return new Promise(o=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let s=(a,n)=>setTimeout(()=>{r.abort(),o({status:0,content:n,isTimedOut:!0})},a),m=s(e.connectTimeout,"Connection timeout"),d;r.onreadystatechange=()=>{r.readyState>r.OPENED&&d===void 0&&(clearTimeout(m),d=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(d),o({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(m),clearTimeout(d),o({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}var A="5.2.5",N=["de","us"];function de(t){return[{url:t?"insights.{region}.algolia.io".replace("{region}",t):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function V({appId:t,apiKey:e,authMode:o,algoliaAgents:r,region:s,...m}){let d=j(t,e,o),a=z({hosts:de(s),...m,algoliaAgent:F({algoliaAgents:r,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...d.headers(),...m.baseHeaders},baseQueryParameters:{...d.queryParameters(),...m.baseQueryParameters}});return{transporter:a,appId:t,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(n,c){a.algoliaAgent.add({segment:n,version:c})},customDelete({path:n,parameters:c},u){if(!n)throw new Error("Parameter `path` is required when calling `customDelete`.");let P={method:"DELETE",path:"/{path}".replace("{path}",n),queryParameters:c||{},headers:{}};return a.request(P,u)},customGet({path:n,parameters:c},u){if(!n)throw new Error("Parameter `path` is required when calling `customGet`.");let P={method:"GET",path:"/{path}".replace("{path}",n),queryParameters:c||{},headers:{}};return a.request(P,u)},customPost({path:n,parameters:c,body:u},p){if(!n)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",n),queryParameters:c||{},headers:{},data:u||{}};return a.request(f,p)},customPut({path:n,parameters:c,body:u},p){if(!n)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",n),queryParameters:c||{},headers:{},data:u||{}};return a.request(f,p)},deleteUserToken({userToken:n},c){if(!n)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let i={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(n)),queryParameters:{},headers:{}};return a.request(i,c)},pushEvents(n,c){if(!n)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!n.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let i={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:n};return a.request(i,c)}}}function rt(t,e,o,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(o&&(typeof o!="string"||!N.includes(o)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return V({appId:t,apiKey:e,region:o,timeouts:{connect:G,read:Q,write:B},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:v({caches:[H({key:`${A}-${t}`}),x()]}),...r})}export{A as apiClientVersion,rt as insightsClient};
1
+ function H(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function j(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function n(){return JSON.parse(r().getItem(s)||"{}")}function u(o){r().setItem(s,JSON.stringify(o))}function p(){let o=t.timeToLive?t.timeToLive*1e3:null,a=n(),l=Object.fromEntries(Object.entries(a).filter(([,f])=>f.timestamp!==void 0));if(u(l),!o)return;let m=Object.fromEntries(Object.entries(l).filter(([,f])=>{let i=new Date().getTime();return!(f.timestamp+o<i)}));u(m)}return{get(o,a,l={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(o)])).then(m=>Promise.all([m?m.value:a(),m!==void 0])).then(([m,f])=>Promise.all([m,f||l.miss(m)])).then(([m])=>m)},set(o,a){return Promise.resolve().then(()=>{let l=n();return l[JSON.stringify(o)]={timestamp:new Date().getTime(),value:a},r().setItem(s,JSON.stringify(l)),a})},delete(o){return Promise.resolve().then(()=>{let a=n();delete a[JSON.stringify(o)],r().setItem(s,JSON.stringify(a))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function Y(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function v(t){let e=[...t.caches],s=e.shift();return s===void 0?Y():{get(r,n,u={miss:()=>Promise.resolve()}){return s.get(r,n,u).catch(()=>v({caches:e}).get(r,n,u))},set(r,n){return s.set(r,n).catch(()=>v({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>v({caches:e}).delete(r))},clear(){return s.clear().catch(()=>v({caches:e}).clear())}}}function x(t={serializable:!0}){let e={};return{get(s,r,n={miss:()=>Promise.resolve()}){let u=JSON.stringify(s);if(u in e)return Promise.resolve(t.serializable?JSON.parse(e[u]):e[u]);let p=r();return p.then(o=>n.miss(o)).then(()=>p)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var L=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>L}function n(){return e==="timed out"&&Date.now()-s<=L}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var J=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},$=class extends J{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},Z=class extends ${constructor(t){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.",t,"RetryError")}},b=class extends ${status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},ee=class extends J{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},te=class extends b{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function re(t,e,s){let r=se(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function se(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function oe(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ne(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(u=>{let p=r[u];n[u.toLowerCase()]=p}),n}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new te(r.message,e,r.error,s):new b(r.message,e,s)}catch{}return new b(t,e,s)}function ce({isTimedOut:t,status:e}){return!t&&~~e===0}function ue({isTimedOut:t,status:e}){return t||ce({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return~~(t/100)===2}function me(t){return t.map(e=>M(e))}function M(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function z({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:u,requester:p,requestsCache:o,responsesCache:a}){async function l(i){let c=await Promise.all(i.map(h=>e.get(h,()=>Promise.resolve(W(h))))),g=c.filter(h=>h.isUp()),P=c.filter(h=>h.isTimedOut()),R=[...g,...P];return{hosts:R.length>0?R:i,getTimeout(h,E){return(P.length===0&&h===0?1:P.length+3+h)*E}}}async function m(i,c,g=!0){let P=[],R=oe(i,c),y=ne(s,i.headers,c.headers),h=i.method==="GET"?{...i.data,...c.data}:{},E={...r,...i.queryParameters,...h};if(n.value&&(E["x-algolia-agent"]=n.value),c&&c.queryParameters)for(let d of Object.keys(c.queryParameters))!c.queryParameters[d]||Object.prototype.toString.call(c.queryParameters[d])==="[object Object]"?E[d]=c.queryParameters[d]:E[d]=c.queryParameters[d].toString();let O=0,D=async(d,q)=>{let w=d.pop();if(w===void 0)throw new Z(me(P));let S={...u,...c.timeouts},U={data:R,headers:y,method:i.method,url:re(w,i.path,E),connectTimeout:q(O,S.connect),responseTimeout:q(O,g?S.read:S.write)},_=C=>{let k={request:U,response:C,host:w,triesLeft:d.length};return P.push(k),k},T=await p.send(U);if(ue(T)){let C=_(T);return T.isTimedOut&&O++,console.log("Retryable failure",M(C)),await e.set(w,W(w,T.isTimedOut?"timed out":"down")),D(d,q)}if(le(T))return ae(T);throw _(T),ie(T,P)},V=t.filter(d=>d.accept==="readWrite"||(g?d.accept==="read":d.accept==="write")),I=await l(V);return D([...I.hosts].reverse(),I.getTimeout)}function f(i,c={}){let g=i.useReadTransporter||i.method==="GET";if(!g)return m(i,c,g);let P=()=>m(i,c);if((c.cacheable||i.cacheable)!==!0)return P();let y={request:i,requestOptions:c,transporter:{queryParameters:r,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,P()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,E])=>E)),{miss:h=>a.set(y,h)})}return{hostsCache:e,requester:p,timeouts:u,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:f,requestsCache:o,responsesCache:a}}function he(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function F({algoliaAgents:t,client:e,version:s}){let r=he(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var G=1e3,Q=2e3,B=3e4;function X(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>r.setRequestHeader(o,e.headers[o]));let n=(o,a)=>setTimeout(()=>{r.abort(),s({status:0,content:a,isTimedOut:!0})},o),u=n(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(u),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}var A="5.3.0",N=["de","us"];function pe(t){return[{url:t?"insights.{region}.algolia.io".replace("{region}",t):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function K({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:n,...u}){let p=H(t,e,s);return{transporter:z({hosts:pe(n),...u,algoliaAgent:F({algoliaAgents:r,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.baseQueryParameters}}),appId:t,clearCache(){return Promise.all([this.transporter.requestsCache.clear(),this.transporter.responsesCache.clear()]).then(()=>{})},get _ua(){return this.transporter.algoliaAgent.value},addAlgoliaAgent(o,a){this.transporter.algoliaAgent.add({segment:o,version:a})},setClientApiKey({apiKey:o}){this.transporter.baseHeaders["x-algolia-api-key"]=o},customDelete({path:o,parameters:a},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let c={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customGet({path:o,parameters:a},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let c={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customPost({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},customPut({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},deleteUserToken({userToken:o},a){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let i={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(i,a)},pushEvents(o,a){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 i={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return this.transporter.request(i,a)}}}function rt(t,e,s,r){if(!t||typeof t!="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 K({appId:t,apiKey:e,region:s,timeouts:{connect:G,read:Q,write:B},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:v({caches:[j({key:`${A}-${t}`}),x()]}),...r})}export{A as apiClientVersion,rt as insightsClient};
2
2
  //# sourceMappingURL=browser.min.js.map