@algolia/client-insights 5.48.0 → 5.48.2
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 +4 -4
- package/dist/browser.d.ts +13 -13
- package/dist/builds/browser.js +1 -1
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +1 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +1 -1
- package/dist/builds/fetch.js +1 -1
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +1 -1
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +1 -1
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +1 -1
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +13 -13
- package/dist/node.d.cts +13 -13
- package/dist/node.d.ts +13 -13
- package/dist/src/insightsClient.cjs +1 -1
- package/dist/src/insightsClient.cjs.map +1 -1
- package/dist/src/insightsClient.js +1 -1
- package/dist/src/insightsClient.js.map +1 -1
- package/dist/worker.d.ts +13 -13
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -40,11 +40,11 @@ All of our clients comes with type definition, and are available for both browse
|
|
|
40
40
|
### With a package manager
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
yarn add @algolia/client-insights@5.48.
|
|
43
|
+
yarn add @algolia/client-insights@5.48.2
|
|
44
44
|
# or
|
|
45
|
-
npm install @algolia/client-insights@5.48.
|
|
45
|
+
npm install @algolia/client-insights@5.48.2
|
|
46
46
|
# or
|
|
47
|
-
pnpm add @algolia/client-insights@5.48.
|
|
47
|
+
pnpm add @algolia/client-insights@5.48.2
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
### Without a package manager
|
|
@@ -52,7 +52,7 @@ pnpm add @algolia/client-insights@5.48.0
|
|
|
52
52
|
Add the following JavaScript snippet to the <head> of your website:
|
|
53
53
|
|
|
54
54
|
```html
|
|
55
|
-
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.48.
|
|
55
|
+
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.48.2/dist/builds/browser.umd.js"></script>
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
### Usage
|
package/dist/browser.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ type AddedToCartObjectIDs = {
|
|
|
78
78
|
*/
|
|
79
79
|
objectData?: Array<ObjectData> | undefined;
|
|
80
80
|
/**
|
|
81
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
81
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
82
82
|
*/
|
|
83
83
|
timestamp?: number | undefined;
|
|
84
84
|
value?: Value | undefined;
|
|
@@ -136,7 +136,7 @@ type AddedToCartObjectIDsAfterSearch = {
|
|
|
136
136
|
*/
|
|
137
137
|
objectData?: Array<ObjectDataAfterSearch> | undefined;
|
|
138
138
|
/**
|
|
139
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
139
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
140
140
|
*/
|
|
141
141
|
timestamp?: number | undefined;
|
|
142
142
|
value?: Value | undefined;
|
|
@@ -170,7 +170,7 @@ type ClickedFilters = {
|
|
|
170
170
|
*/
|
|
171
171
|
authenticatedUserToken?: string | undefined;
|
|
172
172
|
/**
|
|
173
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
173
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
174
174
|
*/
|
|
175
175
|
timestamp?: number | undefined;
|
|
176
176
|
};
|
|
@@ -201,7 +201,7 @@ type ClickedObjectIDs = {
|
|
|
201
201
|
*/
|
|
202
202
|
authenticatedUserToken?: string | undefined;
|
|
203
203
|
/**
|
|
204
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
204
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
205
205
|
*/
|
|
206
206
|
timestamp?: number | undefined;
|
|
207
207
|
};
|
|
@@ -240,7 +240,7 @@ type ClickedObjectIDsAfterSearch = {
|
|
|
240
240
|
*/
|
|
241
241
|
authenticatedUserToken?: string | undefined;
|
|
242
242
|
/**
|
|
243
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
243
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
244
244
|
*/
|
|
245
245
|
timestamp?: number | undefined;
|
|
246
246
|
};
|
|
@@ -268,7 +268,7 @@ type ConvertedFilters = {
|
|
|
268
268
|
*/
|
|
269
269
|
authenticatedUserToken?: string | undefined;
|
|
270
270
|
/**
|
|
271
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
271
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
272
272
|
*/
|
|
273
273
|
timestamp?: number | undefined;
|
|
274
274
|
};
|
|
@@ -299,7 +299,7 @@ type ConvertedObjectIDs = {
|
|
|
299
299
|
*/
|
|
300
300
|
authenticatedUserToken?: string | undefined;
|
|
301
301
|
/**
|
|
302
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
302
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
303
303
|
*/
|
|
304
304
|
timestamp?: number | undefined;
|
|
305
305
|
};
|
|
@@ -334,7 +334,7 @@ type ConvertedObjectIDsAfterSearch = {
|
|
|
334
334
|
*/
|
|
335
335
|
authenticatedUserToken?: string | undefined;
|
|
336
336
|
/**
|
|
337
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
337
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
338
338
|
*/
|
|
339
339
|
timestamp?: number | undefined;
|
|
340
340
|
};
|
|
@@ -376,7 +376,7 @@ type PurchasedObjectIDs = {
|
|
|
376
376
|
*/
|
|
377
377
|
objectData?: Array<ObjectData> | undefined;
|
|
378
378
|
/**
|
|
379
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
379
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
380
380
|
*/
|
|
381
381
|
timestamp?: number | undefined;
|
|
382
382
|
value?: Value | undefined;
|
|
@@ -417,7 +417,7 @@ type PurchasedObjectIDsAfterSearch = {
|
|
|
417
417
|
*/
|
|
418
418
|
objectData: Array<ObjectDataAfterSearch>;
|
|
419
419
|
/**
|
|
420
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
420
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
421
421
|
*/
|
|
422
422
|
timestamp?: number | undefined;
|
|
423
423
|
value?: Value | undefined;
|
|
@@ -451,7 +451,7 @@ type ViewedFilters = {
|
|
|
451
451
|
*/
|
|
452
452
|
authenticatedUserToken?: string | undefined;
|
|
453
453
|
/**
|
|
454
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
454
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
455
455
|
*/
|
|
456
456
|
timestamp?: number | undefined;
|
|
457
457
|
};
|
|
@@ -482,7 +482,7 @@ type ViewedObjectIDs = {
|
|
|
482
482
|
*/
|
|
483
483
|
authenticatedUserToken?: string | undefined;
|
|
484
484
|
/**
|
|
485
|
-
* Timestamp of the event, measured in milliseconds since the Unix epoch.
|
|
485
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. Must be no older than 30 days. If not provided, we use the time at which the request was received.
|
|
486
486
|
*/
|
|
487
487
|
timestamp?: number | undefined;
|
|
488
488
|
};
|
|
@@ -574,7 +574,7 @@ type DeleteUserTokenProps = {
|
|
|
574
574
|
userToken: string;
|
|
575
575
|
};
|
|
576
576
|
|
|
577
|
-
declare const apiClientVersion = "5.48.
|
|
577
|
+
declare const apiClientVersion = "5.48.2";
|
|
578
578
|
declare const REGIONS: readonly ["de", "us"];
|
|
579
579
|
type Region = (typeof REGIONS)[number];
|
|
580
580
|
type RegionOptions = {
|
package/dist/builds/browser.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createXhrRequester } from "@algolia/requester-browser-xhr";
|
|
|
9
9
|
|
|
10
10
|
// src/insightsClient.ts
|
|
11
11
|
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
12
|
-
var apiClientVersion = "5.48.
|
|
12
|
+
var apiClientVersion = "5.48.2";
|
|
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 {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\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.48.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, for example `1/newFeature`.\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, for example `1/newFeature`.\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, for example `1/newFeature`.\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, for example `1/newFeature`.\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 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;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;;;ACEnC,SAAS,YAAY,mBAAmB,uBAAuB;AAaxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAIlC,SAAS,gBAAgB,QAAqC;AAC5D,QAAM,MAAM,CAAC,SAAS,wBAAwB,+BAA+B,QAAQ,YAAY,MAAM;AAEvG,SAAO,CAAC,EAAE,KAAK,QAAQ,aAAa,UAAU,QAAQ,CAAC;AACzD;AAEO,SAAS,qBAAqB;AAAA,EACnC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,GAAG;AACL,GAAwC;AACtC,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;AAAA,MAChB,GAAG,KAAK,QAAQ;AAAA,MAChB,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,qBAAqB;AAAA,MACnB,GAAG,KAAK,gBAAgB;AAAA,MACxB,GAAG,QAAQ;AAAA,IACb;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO;AAAA;AAAA;AAAA;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AA,MACN,OAAO;AAAA,IACT;AAAA,IACA,QAAQ,iBAAiB;AAAA,IACzB,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 {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\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.48.2';\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, for example `1/newFeature`.\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, for example `1/newFeature`.\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, for example `1/newFeature`.\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, for example `1/newFeature`.\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 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;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,+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,2 +1,2 @@
|
|
|
1
|
-
function j(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 u(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(u(i),!a)return;let l=Object.fromEntries(Object.entries(i).filter(([,h])=>{let P=new Date().getTime();return!(h.timestamp+a<P)}));u(l)}return{get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(l=>Promise.all([l?l.value:o(),l!==void 0])).then(([l,h])=>Promise.all([l,h||i.miss(l)])).then(([l])=>l)},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,u={miss:()=>Promise.resolve()}){return s.get(t,n,u).catch(()=>x({caches:e}).get(t,n,u))},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 u=JSON.stringify(s);if(u in e)return Promise.resolve(r.serializable?JSON.parse(e[u]):e[u]);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 W(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 J({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function z(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=120*1e3;function $(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>H}function n(){return e==="timed out"&&Date.now()-s<=H}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var M=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}};var Q=class extends M{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},Z=class extends Q{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",r,"RetryError")}},I=class extends Q{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},ee=class extends M{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends I{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(u=>{let p=t[u];n[u.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 I(t.message,e,s)}catch{}return new I(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=>G(e))}function G(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 F({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:u,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function l(c){let m=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve($(d))))),g=m.filter(d=>d.isUp()),y=m.filter(d=>d.isTimedOut()),w=[...g,...y];return{hosts:w.length>0?w:c,getTimeout(d,v){return(y.length===0&&d===0?1:y.length+3+d)*v}}}async function h(c,m,g){let y=[],w=oe(c,m),E=ne(s,c.headers,m.headers),d=c.method==="GET"?{...c.data,...m.data}:{},v={...n,...c.queryParameters,...d};if(u.value&&(v["x-algolia-agent"]=u.value),m&&m.queryParameters)for(let f of Object.keys(m.queryParameters))!m.queryParameters[f]||Object.prototype.toString.call(m.queryParameters[f])==="[object Object]"?v[f]=m.queryParameters[f]:v[f]=m.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(y));let b={...p,...m.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,b.connect),responseTimeout:S(O,g?b.read:b.write)},U=C=>{let L={request:_,response:C,host:R,triesLeft:f.length};return y.push(L),L},T=await a.send(_);if(ue(T)){let C=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",G(C)),await e.set(R,$(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,y)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await l(K);return D([...k.hosts].reverse(),k.getTimeout)}function P(c,m={}){let g=()=>h(c,m,y),y=c.useReadTransporter||c.method==="GET";if((m.cacheable||c.cacheable)!==!0)return g();let E={request:c,requestOptions:m,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,g()).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:u,baseHeaders:s,baseQueryParameters:n,hosts:r,request:P,requestsCache:o,responsesCache:i}}function B(){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),u=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(u),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var A="5.48.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,...u}){let p=W(r,e,s),a=F({hosts:de(n),...u,algoliaAgent:J({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.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},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let m={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customGet({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let m={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customPost({path:o,parameters:i,body:l},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:l||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:l},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:l||{}};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:z(),requester:B(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:x({caches:[j({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,er as insightsClient};
|
|
1
|
+
function j(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 u(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(u(i),!a)return;let l=Object.fromEntries(Object.entries(i).filter(([,h])=>{let P=new Date().getTime();return!(h.timestamp+a<P)}));u(l)}return{get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(l=>Promise.all([l?l.value:o(),l!==void 0])).then(([l,h])=>Promise.all([l,h||i.miss(l)])).then(([l])=>l)},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,u={miss:()=>Promise.resolve()}){return s.get(t,n,u).catch(()=>x({caches:e}).get(t,n,u))},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 u=JSON.stringify(s);if(u in e)return Promise.resolve(r.serializable?JSON.parse(e[u]):e[u]);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 W(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 J({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function z(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=120*1e3;function $(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>H}function n(){return e==="timed out"&&Date.now()-s<=H}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var M=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}};var Q=class extends M{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},Z=class extends Q{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",r,"RetryError")}},I=class extends Q{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},ee=class extends M{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends I{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(u=>{let p=t[u];n[u.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 I(t.message,e,s)}catch{}return new I(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=>G(e))}function G(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 F({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:u,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function l(c){let m=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve($(d))))),g=m.filter(d=>d.isUp()),y=m.filter(d=>d.isTimedOut()),w=[...g,...y];return{hosts:w.length>0?w:c,getTimeout(d,v){return(y.length===0&&d===0?1:y.length+3+d)*v}}}async function h(c,m,g){let y=[],w=oe(c,m),E=ne(s,c.headers,m.headers),d=c.method==="GET"?{...c.data,...m.data}:{},v={...n,...c.queryParameters,...d};if(u.value&&(v["x-algolia-agent"]=u.value),m&&m.queryParameters)for(let f of Object.keys(m.queryParameters))!m.queryParameters[f]||Object.prototype.toString.call(m.queryParameters[f])==="[object Object]"?v[f]=m.queryParameters[f]:v[f]=m.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(y));let b={...p,...m.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,b.connect),responseTimeout:S(O,g?b.read:b.write)},U=C=>{let L={request:_,response:C,host:R,triesLeft:f.length};return y.push(L),L},T=await a.send(_);if(ue(T)){let C=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",G(C)),await e.set(R,$(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,y)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await l(K);return D([...k.hosts].reverse(),k.getTimeout)}function P(c,m={}){let g=()=>h(c,m,y),y=c.useReadTransporter||c.method==="GET";if((m.cacheable||c.cacheable)!==!0)return g();let E={request:c,requestOptions:m,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,g()).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:u,baseHeaders:s,baseQueryParameters:n,hosts:r,request:P,requestsCache:o,responsesCache:i}}function B(){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),u=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(u),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var A="5.48.2",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,...u}){let p=W(r,e,s),a=F({hosts:de(n),...u,algoliaAgent:J({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.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},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let m={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customGet({path:o,parameters:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let m={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(m,l)},customPost({path:o,parameters:i,body:l},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:l||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:l},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:l||{}};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:z(),requester:B(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:x({caches:[j({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,er as insightsClient};
|
|
2
2
|
//# sourceMappingURL=browser.min.js.map
|