@algolia/client-insights 5.28.0 → 5.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/browser.d.ts +9 -9
- package/dist/builds/browser.js +5 -5
- 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 +5 -5
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +5 -5
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +5 -5
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +5 -5
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +9 -9
- package/dist/node.d.cts +9 -9
- package/dist/node.d.ts +9 -9
- package/dist/src/insightsClient.cjs +5 -5
- package/dist/src/insightsClient.cjs.map +1 -1
- package/dist/src/insightsClient.js +5 -5
- package/dist/src/insightsClient.js.map +1 -1
- package/dist/worker.d.ts +9 -9
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -41,11 +41,11 @@ All of our clients comes with type definition, and are available for both browse
|
|
|
41
41
|
### With a package manager
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
yarn add @algolia/client-insights@5.
|
|
44
|
+
yarn add @algolia/client-insights@5.30.0
|
|
45
45
|
# or
|
|
46
|
-
npm install @algolia/client-insights@5.
|
|
46
|
+
npm install @algolia/client-insights@5.30.0
|
|
47
47
|
# or
|
|
48
|
-
pnpm add @algolia/client-insights@5.
|
|
48
|
+
pnpm add @algolia/client-insights@5.30.0
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
### Without a package manager
|
|
@@ -53,7 +53,7 @@ pnpm add @algolia/client-insights@5.28.0
|
|
|
53
53
|
Add the following JavaScript snippet to the <head> of your website:
|
|
54
54
|
|
|
55
55
|
```html
|
|
56
|
-
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.
|
|
56
|
+
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-insights@5.30.0/dist/builds/browser.umd.js"></script>
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
### Usage
|
package/dist/browser.d.ts
CHANGED
|
@@ -501,7 +501,7 @@ type InsightsEvents = {
|
|
|
501
501
|
*/
|
|
502
502
|
type CustomDeleteProps = {
|
|
503
503
|
/**
|
|
504
|
-
* Path of the endpoint,
|
|
504
|
+
* Path of the endpoint, for example `1/newFeature`.
|
|
505
505
|
*/
|
|
506
506
|
path: string;
|
|
507
507
|
/**
|
|
@@ -516,7 +516,7 @@ type CustomDeleteProps = {
|
|
|
516
516
|
*/
|
|
517
517
|
type CustomGetProps = {
|
|
518
518
|
/**
|
|
519
|
-
* Path of the endpoint,
|
|
519
|
+
* Path of the endpoint, for example `1/newFeature`.
|
|
520
520
|
*/
|
|
521
521
|
path: string;
|
|
522
522
|
/**
|
|
@@ -531,7 +531,7 @@ type CustomGetProps = {
|
|
|
531
531
|
*/
|
|
532
532
|
type CustomPostProps = {
|
|
533
533
|
/**
|
|
534
|
-
* Path of the endpoint,
|
|
534
|
+
* Path of the endpoint, for example `1/newFeature`.
|
|
535
535
|
*/
|
|
536
536
|
path: string;
|
|
537
537
|
/**
|
|
@@ -550,7 +550,7 @@ type CustomPostProps = {
|
|
|
550
550
|
*/
|
|
551
551
|
type CustomPutProps = {
|
|
552
552
|
/**
|
|
553
|
-
* Path of the endpoint,
|
|
553
|
+
* Path of the endpoint, for example `1/newFeature`.
|
|
554
554
|
*/
|
|
555
555
|
path: string;
|
|
556
556
|
/**
|
|
@@ -574,7 +574,7 @@ type DeleteUserTokenProps = {
|
|
|
574
574
|
userToken: string;
|
|
575
575
|
};
|
|
576
576
|
|
|
577
|
-
declare const apiClientVersion = "5.
|
|
577
|
+
declare const apiClientVersion = "5.30.0";
|
|
578
578
|
declare const REGIONS: readonly ["de", "us"];
|
|
579
579
|
type Region = (typeof REGIONS)[number];
|
|
580
580
|
type RegionOptions = {
|
|
@@ -617,7 +617,7 @@ declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
617
617
|
/**
|
|
618
618
|
* This method lets you send requests to the Algolia REST API.
|
|
619
619
|
* @param customDelete - The customDelete object.
|
|
620
|
-
* @param customDelete.path - Path of the endpoint,
|
|
620
|
+
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
|
|
621
621
|
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
622
622
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
623
623
|
*/
|
|
@@ -625,7 +625,7 @@ declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
625
625
|
/**
|
|
626
626
|
* This method lets you send requests to the Algolia REST API.
|
|
627
627
|
* @param customGet - The customGet object.
|
|
628
|
-
* @param customGet.path - Path of the endpoint,
|
|
628
|
+
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
|
|
629
629
|
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
630
630
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
631
631
|
*/
|
|
@@ -633,7 +633,7 @@ declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
633
633
|
/**
|
|
634
634
|
* This method lets you send requests to the Algolia REST API.
|
|
635
635
|
* @param customPost - The customPost object.
|
|
636
|
-
* @param customPost.path - Path of the endpoint,
|
|
636
|
+
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
|
|
637
637
|
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
638
638
|
* @param customPost.body - Parameters to send with the custom request.
|
|
639
639
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -642,7 +642,7 @@ declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
642
642
|
/**
|
|
643
643
|
* This method lets you send requests to the Algolia REST API.
|
|
644
644
|
* @param customPut - The customPut object.
|
|
645
|
-
* @param customPut.path - Path of the endpoint,
|
|
645
|
+
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
|
|
646
646
|
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
647
647
|
* @param customPut.body - Parameters to send with the custom request.
|
|
648
648
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
package/dist/builds/browser.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
|
|
10
10
|
// src/insightsClient.ts
|
|
11
11
|
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
12
|
-
var apiClientVersion = "5.
|
|
12
|
+
var apiClientVersion = "5.30.0";
|
|
13
13
|
var REGIONS = ["de", "us"];
|
|
14
14
|
function getDefaultHosts(region) {
|
|
15
15
|
const url = !region ? "insights.algolia.io" : "insights.{region}.algolia.io".replace("{region}", region);
|
|
@@ -89,7 +89,7 @@ function createInsightsClient({
|
|
|
89
89
|
/**
|
|
90
90
|
* This method lets you send requests to the Algolia REST API.
|
|
91
91
|
* @param customDelete - The customDelete object.
|
|
92
|
-
* @param customDelete.path - Path of the endpoint,
|
|
92
|
+
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
|
|
93
93
|
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
94
94
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
95
95
|
*/
|
|
@@ -111,7 +111,7 @@ function createInsightsClient({
|
|
|
111
111
|
/**
|
|
112
112
|
* This method lets you send requests to the Algolia REST API.
|
|
113
113
|
* @param customGet - The customGet object.
|
|
114
|
-
* @param customGet.path - Path of the endpoint,
|
|
114
|
+
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
|
|
115
115
|
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
116
116
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
117
117
|
*/
|
|
@@ -133,7 +133,7 @@ function createInsightsClient({
|
|
|
133
133
|
/**
|
|
134
134
|
* This method lets you send requests to the Algolia REST API.
|
|
135
135
|
* @param customPost - The customPost object.
|
|
136
|
-
* @param customPost.path - Path of the endpoint,
|
|
136
|
+
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
|
|
137
137
|
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
138
138
|
* @param customPost.body - Parameters to send with the custom request.
|
|
139
139
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -157,7 +157,7 @@ function createInsightsClient({
|
|
|
157
157
|
/**
|
|
158
158
|
* This method lets you send requests to the Algolia REST API.
|
|
159
159
|
* @param customPut - The customPut object.
|
|
160
|
-
* @param customPut.path - Path of the endpoint,
|
|
160
|
+
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
|
|
161
161
|
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
162
162
|
* @param customPut.body - Parameters to send with the custom request.
|
|
163
163
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../builds/browser.ts","../../src/insightsClient.ts"],"sourcesContent":["// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.\n\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\n\nimport type { ClientOptions } from '@algolia/client-common';\n\nimport { apiClientVersion, createInsightsClient } from '../src/insightsClient';\n\nimport type { Region } from '../src/insightsClient';\nimport { REGIONS } from '../src/insightsClient';\n\nexport type { Region, RegionOptions } from '../src/insightsClient';\n\nexport { apiClientVersion } from '../src/insightsClient';\n\nexport * from '../model';\n\nexport function insightsClient(\n appId: string,\n apiKey: string,\n region?: Region | undefined,\n options?: ClientOptions | undefined,\n): InsightsClient {\n if (!appId || typeof appId !== 'string') {\n throw new Error('`appId` is missing.');\n }\n\n if (!apiKey || typeof apiKey !== 'string') {\n throw new Error('`apiKey` is missing.');\n }\n\n if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {\n throw new Error(`\\`region\\` must be one of the following: ${REGIONS.join(', ')}`);\n }\n\n return createInsightsClient({\n appId,\n apiKey,\n region,\n timeouts: {\n connect: 1000,\n read: 2000,\n write: 30000,\n },\n logger: createNullLogger(),\n requester: createXhrRequester(),\n algoliaAgents: [{ segment: 'Browser' }],\n authMode: 'WithinQueryParameters',\n responsesCache: createMemoryCache(),\n requestsCache: createMemoryCache({ serializable: false }),\n hostsCache: createFallbackableCache({\n caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()],\n }),\n ...options,\n });\n}\n\nexport type InsightsClient = ReturnType<typeof createInsightsClient>;\n","// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.\n\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\nimport { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\n\nimport type { EventsResponse } from '../model/eventsResponse';\nimport type { InsightsEvents } from '../model/insightsEvents';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserTokenProps,\n} from '../model/clientMethodProps';\n\nexport const apiClientVersion = '5.28.0';\n\nexport const REGIONS = ['de', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\nexport type RegionOptions = { region?: Region | undefined };\n\nfunction getDefaultHosts(region?: Region | undefined): Host[] {\n const url = !region ? 'insights.algolia.io' : 'insights.{region}.algolia.io'.replace('{region}', region);\n\n return [{ url, accept: 'readWrite', protocol: 'https' }];\n}\n\nexport function createInsightsClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & RegionOptions) {\n const auth = createAuth(appIdOption, apiKeyOption, authMode);\n const transporter = createTransporter({\n hosts: getDefaultHosts(regionOption),\n ...options,\n algoliaAgent: getAlgoliaAgent({\n algoliaAgents,\n client: 'Insights',\n version: apiClientVersion,\n }),\n baseHeaders: {\n 'content-type': 'text/plain',\n ...auth.headers(),\n ...options.baseHeaders,\n },\n baseQueryParameters: {\n ...auth.queryParameters(),\n ...options.baseQueryParameters,\n },\n });\n\n return {\n transporter,\n\n /**\n * The `appId` currently in use.\n */\n appId: appIdOption,\n\n /**\n * The `apiKey` currently in use.\n */\n apiKey: apiKeyOption,\n\n /**\n * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.\n */\n clearCache(): Promise<void> {\n return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => undefined);\n },\n\n /**\n * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.\n */\n get _ua(): string {\n return transporter.algoliaAgent.value;\n },\n\n /**\n * Adds a `segment` to the `x-algolia-agent` sent with every requests.\n *\n * @param segment - The algolia agent (user-agent) segment to add.\n * @param version - The version of the agent.\n */\n addAlgoliaAgent(segment: string, version?: string | undefined): void {\n transporter.algoliaAgent.add({ segment, version });\n },\n\n /**\n * Helper method to switch the API key used to authenticate the requests.\n *\n * @param params - Method params.\n * @param params.apiKey - The new API Key to use.\n */\n setClientApiKey({ apiKey }: { apiKey: string }): void {\n if (!authMode || authMode === 'WithinHeaders') {\n transporter.baseHeaders['x-algolia-api-key'] = apiKey;\n } else {\n transporter.baseQueryParameters['x-algolia-api-key'] = apiKey;\n }\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customDelete - The customDelete object.\n * @param customDelete.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customDelete.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customDelete(\n { path, parameters }: CustomDeleteProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customDelete`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customGet - The customGet object.\n * @param customGet.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customGet.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customGet`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customPost - The customPost object.\n * @param customPost.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPost.parameters - Query parameters to apply to the current query.\n * @param customPost.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPost(\n { path, parameters, body }: CustomPostProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPost`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customPut - The customPut object.\n * @param customPut.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPut.parameters - Query parameters to apply to the current query.\n * @param customPut.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPut(\n { path, parameters, body }: CustomPutProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPut`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'PUT',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Deletes all events related to the specified user token from events metrics and analytics. The deletion is asynchronous, and processed within 48 hours. To delete a personalization user profile, see `Delete a user profile` in the Personalization API.\n *\n * Required API Key ACLs:\n * - deleteObject\n * @param deleteUserToken - The deleteUserToken object.\n * @param deleteUserToken.userToken - User token for which to delete all associated events.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n deleteUserToken({ userToken }: DeleteUserTokenProps, requestOptions?: RequestOptions): Promise<void> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `deleteUserToken`.');\n }\n\n const requestPath = '/1/usertokens/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.\n *\n * Required API Key ACLs:\n * - search\n * @param insightsEvents - The insightsEvents object.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n pushEvents(insightsEvents: InsightsEvents, requestOptions?: RequestOptions): Promise<EventsResponse> {\n if (!insightsEvents) {\n throw new Error('Parameter `insightsEvents` is required when calling `pushEvents`.');\n }\n\n if (!insightsEvents.events) {\n throw new Error('Parameter `insightsEvents.events` is required when calling `pushEvents`.');\n }\n\n const requestPath = '/1/events';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: insightsEvents,\n };\n\n return transporter.request(request, requestOptions);\n },\n };\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AAEnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACCP,SAAS,YAAY,mBAAmB,uBAAuB;AAaxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAIlC,SAAS,gBAAgB,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;AAA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A,MACR,SAAS;AAAA,MACT,MAAM;AAAA,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 { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\n\nimport type { ClientOptions } from '@algolia/client-common';\n\nimport { apiClientVersion, createInsightsClient } from '../src/insightsClient';\n\nimport type { Region } from '../src/insightsClient';\nimport { REGIONS } from '../src/insightsClient';\n\nexport type { Region, RegionOptions } from '../src/insightsClient';\n\nexport { apiClientVersion } from '../src/insightsClient';\n\nexport * from '../model';\n\nexport function insightsClient(\n appId: string,\n apiKey: string,\n region?: Region | undefined,\n options?: ClientOptions | undefined,\n): InsightsClient {\n if (!appId || typeof appId !== 'string') {\n throw new Error('`appId` is missing.');\n }\n\n if (!apiKey || typeof apiKey !== 'string') {\n throw new Error('`apiKey` is missing.');\n }\n\n if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {\n throw new Error(`\\`region\\` must be one of the following: ${REGIONS.join(', ')}`);\n }\n\n return createInsightsClient({\n appId,\n apiKey,\n region,\n timeouts: {\n connect: 1000,\n read: 2000,\n write: 30000,\n },\n logger: createNullLogger(),\n requester: createXhrRequester(),\n algoliaAgents: [{ segment: 'Browser' }],\n authMode: 'WithinQueryParameters',\n responsesCache: createMemoryCache(),\n requestsCache: createMemoryCache({ serializable: false }),\n hostsCache: createFallbackableCache({\n caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()],\n }),\n ...options,\n });\n}\n\nexport type InsightsClient = ReturnType<typeof createInsightsClient>;\n","// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.\n\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\nimport { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\n\nimport type { EventsResponse } from '../model/eventsResponse';\nimport type { InsightsEvents } from '../model/insightsEvents';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserTokenProps,\n} from '../model/clientMethodProps';\n\nexport const apiClientVersion = '5.30.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, requ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AY,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,2 +1,2 @@
|
|
|
1
|
-
function H(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,o)=>setTimeout(()=>{t.abort(),s({status:0,content:o,isTimedOut:!0})},a),l=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(l),p=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(l),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(l),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function W(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(s)||"{}")}function l(a){t().setItem(s,JSON.stringify(a))}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,h])=>h.timestamp!==void 0));if(l(i),!a)return;let m=Object.fromEntries(Object.entries(i).filter(([,h])=>{let y=new Date().getTime();return!(h.timestamp+a<y)}));l(m)}return{get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(m=>Promise.all([m?m.value:o(),m!==void 0])).then(([m,h])=>Promise.all([m,h||i.miss(m)])).then(([m])=>m)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},t().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],t().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{t().removeItem(s)})}}}function V(){return{get(r,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function x(r){let e=[...r.caches],s=e.shift();return s===void 0?V():{get(t,n,l={miss:()=>Promise.resolve()}){return s.get(t,n,l).catch(()=>x({caches:e}).get(t,n,l))},set(t,n){return s.set(t,n).catch(()=>x({caches:e}).set(t,n))},delete(t){return s.delete(t).catch(()=>x({caches:e}).delete(t))},clear(){return s.clear().catch(()=>x({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return{get(s,t,n={miss:()=>Promise.resolve()}){let l=JSON.stringify(s);if(l in e)return Promise.resolve(r.serializable?JSON.parse(e[l]):e[l]);let p=t();return p.then(a=>n.miss(a)).then(()=>p)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function z({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function M(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var $=2*60*1e3;function j(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>$}function n(){return e==="timed out"&&Date.now()-s<=$}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var Q=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}};var G=class extends Q{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},Z=class extends G{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},b=class extends G{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},ee=class extends Q{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends b{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s}};function te(r,e,s){let t=se(s),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function se(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function oe(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ne(r,e,s){let t={Accept:"application/json",...r,...e,...s},n={};return Object.keys(t).forEach(l=>{let p=t[l];n[l.toLowerCase()]=p}),n}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},s){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,s):new b(t.message,e,s)}catch{}return new b(r,e,s)}function ce({isTimedOut:r,status:e}){return!r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>F(e))}function F(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function B({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:l,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function m(c){let u=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve(j(d))))),g=u.filter(d=>d.isUp()),P=u.filter(d=>d.isTimedOut()),w=[...g,...P];return{hosts:w.length>0?w:c,getTimeout(d,v){return(P.length===0&&d===0?1:P.length+3+d)*v}}}async function h(c,u,g=!0){let P=[],w=oe(c,u),E=ne(s,c.headers,u.headers),d=c.method==="GET"?{...c.data,...u.data}:{},v={...n,...c.queryParameters,...d};if(l.value&&(v["x-algolia-agent"]=l.value),u&&u.queryParameters)for(let f of Object.keys(u.queryParameters))!u.queryParameters[f]||Object.prototype.toString.call(u.queryParameters[f])==="[object Object]"?v[f]=u.queryParameters[f]:v[f]=u.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(P));let C={...p,...u.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,C.connect),responseTimeout:S(O,g?C.read:C.write)},U=I=>{let L={request:_,response:I,host:R,triesLeft:f.length};return P.push(L),L},T=await a.send(_);if(ue(T)){let I=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",F(I)),await e.set(R,j(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,P)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await m(K);return D([...k.hosts].reverse(),k.getTimeout)}function y(c,u={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return h(c,u,g);let P=()=>h(c,u);if((u.cacheable||c.cacheable)!==!0)return P();let E={request:c,requestOptions:u,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,P()).then(d=>Promise.all([o.delete(E),d]),d=>Promise.all([o.delete(E),Promise.reject(d)])).then(([d,v])=>v)),{miss:d=>i.set(E,d)})}return{hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:l,baseHeaders:s,baseQueryParameters:n,hosts:r,request:y,requestsCache:o,responsesCache:i}}var A="5.28.0",N=["de","us"];function de(r){return[{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:s,algoliaAgents:t,region:n,...l}){let p=J(r,e,s),a=B({hosts:de(n),...l,algoliaAgent:z({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...l.baseHeaders},baseQueryParameters:{...p.queryParameters(),...l.baseQueryParameters}});return{transporter:a,appId:r,apiKey:e,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},customDelete({path:o,parameters:i},m){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(u,m)},customGet({path:o,parameters:i},m){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(u,m)},customPost({path:o,parameters:i,body:m},h){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:m},h){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,h)},deleteUserToken({userToken:o},i){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(o,i){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return a.request(c,i)}}}function er(r,e,s,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:M(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:x({caches:[W({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,er as insightsClient};
|
|
1
|
+
function H(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,o)=>setTimeout(()=>{t.abort(),s({status:0,content:o,isTimedOut:!0})},a),l=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(l),p=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(l),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(l),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function W(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(s)||"{}")}function l(a){t().setItem(s,JSON.stringify(a))}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,o=n(),i=Object.fromEntries(Object.entries(o).filter(([,h])=>h.timestamp!==void 0));if(l(i),!a)return;let m=Object.fromEntries(Object.entries(i).filter(([,h])=>{let y=new Date().getTime();return!(h.timestamp+a<y)}));l(m)}return{get(a,o,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(m=>Promise.all([m?m.value:o(),m!==void 0])).then(([m,h])=>Promise.all([m,h||i.miss(m)])).then(([m])=>m)},set(a,o){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},t().setItem(s,JSON.stringify(i)),o})},delete(a){return Promise.resolve().then(()=>{let o=n();delete o[JSON.stringify(a)],t().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{t().removeItem(s)})}}}function V(){return{get(r,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function x(r){let e=[...r.caches],s=e.shift();return s===void 0?V():{get(t,n,l={miss:()=>Promise.resolve()}){return s.get(t,n,l).catch(()=>x({caches:e}).get(t,n,l))},set(t,n){return s.set(t,n).catch(()=>x({caches:e}).set(t,n))},delete(t){return s.delete(t).catch(()=>x({caches:e}).delete(t))},clear(){return s.clear().catch(()=>x({caches:e}).clear())}}}function q(r={serializable:!0}){let e={};return{get(s,t,n={miss:()=>Promise.resolve()}){let l=JSON.stringify(s);if(l in e)return Promise.resolve(r.serializable?JSON.parse(e[l]):e[l]);let p=t();return p.then(a=>n.miss(a)).then(()=>p)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function z({algoliaAgents:r,client:e,version:s}){let t=Y(s).add({segment:e,version:s});return r.forEach(n=>t.add(n)),t}function M(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var $=2*60*1e3;function j(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>$}function n(){return e==="timed out"&&Date.now()-s<=$}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:n}}var Q=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}};var G=class extends Q{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},Z=class extends G{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},b=class extends G{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},ee=class extends Q{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends b{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s}};function te(r,e,s){let t=se(s),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}function se(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function oe(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ne(r,e,s){let t={Accept:"application/json",...r,...e,...s},n={};return Object.keys(t).forEach(l=>{let p=t[l];n[l.toLowerCase()]=p}),n}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},s){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,s):new b(t.message,e,s)}catch{}return new b(r,e,s)}function ce({isTimedOut:r,status:e}){return!r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>F(e))}function F(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function B({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:n,algoliaAgent:l,timeouts:p,requester:a,requestsCache:o,responsesCache:i}){async function m(c){let u=await Promise.all(c.map(d=>e.get(d,()=>Promise.resolve(j(d))))),g=u.filter(d=>d.isUp()),P=u.filter(d=>d.isTimedOut()),w=[...g,...P];return{hosts:w.length>0?w:c,getTimeout(d,v){return(P.length===0&&d===0?1:P.length+3+d)*v}}}async function h(c,u,g=!0){let P=[],w=oe(c,u),E=ne(s,c.headers,u.headers),d=c.method==="GET"?{...c.data,...u.data}:{},v={...n,...c.queryParameters,...d};if(l.value&&(v["x-algolia-agent"]=l.value),u&&u.queryParameters)for(let f of Object.keys(u.queryParameters))!u.queryParameters[f]||Object.prototype.toString.call(u.queryParameters[f])==="[object Object]"?v[f]=u.queryParameters[f]:v[f]=u.queryParameters[f].toString();let O=0,D=async(f,S)=>{let R=f.pop();if(R===void 0)throw new Z(me(P));let C={...p,...u.timeouts},_={data:w,headers:E,method:c.method,url:te(R,c.path,v),connectTimeout:S(O,C.connect),responseTimeout:S(O,g?C.read:C.write)},U=I=>{let L={request:_,response:I,host:R,triesLeft:f.length};return P.push(L),L},T=await a.send(_);if(ue(T)){let I=U(T);return T.isTimedOut&&O++,t.info("Retryable failure",F(I)),await e.set(R,j(R,T.isTimedOut?"timed out":"down")),D(f,S)}if(le(T))return ae(T);throw U(T),ie(T,P)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await m(K);return D([...k.hosts].reverse(),k.getTimeout)}function y(c,u={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return h(c,u,g);let P=()=>h(c,u);if((u.cacheable||c.cacheable)!==!0)return P();let E={request:c,requestOptions:u,transporter:{queryParameters:n,headers:s}};return i.get(E,()=>o.get(E,()=>o.set(E,P()).then(d=>Promise.all([o.delete(E),d]),d=>Promise.all([o.delete(E),Promise.reject(d)])).then(([d,v])=>v)),{miss:d=>i.set(E,d)})}return{hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:l,baseHeaders:s,baseQueryParameters:n,hosts:r,request:y,requestsCache:o,responsesCache:i}}var A="5.30.0",N=["de","us"];function de(r){return[{url:r?"insights.{region}.algolia.io".replace("{region}",r):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:s,algoliaAgents:t,region:n,...l}){let p=J(r,e,s),a=B({hosts:de(n),...l,algoliaAgent:z({algoliaAgents:t,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...l.baseHeaders},baseQueryParameters:{...p.queryParameters(),...l.baseQueryParameters}});return{transporter:a,appId:r,apiKey:e,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,i){a.algoliaAgent.add({segment:o,version:i})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},customDelete({path:o,parameters:i},m){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(u,m)},customGet({path:o,parameters:i},m){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{}};return a.request(u,m)},customPost({path:o,parameters:i,body:m},h){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,h)},customPut({path:o,parameters:i,body:m},h){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:i||{},headers:{},data:m||{}};return a.request(g,h)},deleteUserToken({userToken:o},i){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let c={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,i)},pushEvents(o,i){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let c={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return a.request(c,i)}}}function er(r,e,s,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:s,timeouts:{connect:1e3,read:2e3,write:3e4},logger:M(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:q(),requestsCache:q({serializable:!1}),hostsCache:x({caches:[W({key:`${A}-${r}`}),q()]}),...t})}export{A as apiClientVersion,er as insightsClient};
|
|
2
2
|
//# sourceMappingURL=browser.min.js.map
|