@algolia/client-insights 5.0.0-alpha.98 → 5.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builds/browser.d.ts +19 -3
- package/dist/builds/browser.d.ts.map +1 -1
- package/dist/builds/node.d.ts +19 -3
- package/dist/builds/node.d.ts.map +1 -1
- package/dist/client-insights.cjs +27 -30
- package/dist/client-insights.esm.browser.js +14 -22
- package/dist/client-insights.esm.node.js +27 -30
- package/dist/client-insights.umd.js +2 -2
- package/dist/model/addedToCartObjectIDs.d.ts +6 -6
- package/dist/model/addedToCartObjectIDsAfterSearch.d.ts +6 -6
- package/dist/model/clickedFilters.d.ts +6 -6
- package/dist/model/clickedObjectIDs.d.ts +6 -6
- package/dist/model/clickedObjectIDsAfterSearch.d.ts +7 -7
- package/dist/model/clientMethodProps.d.ts +1 -1
- package/dist/model/convertedFilters.d.ts +6 -6
- package/dist/model/convertedObjectIDs.d.ts +6 -6
- package/dist/model/convertedObjectIDsAfterSearch.d.ts +6 -6
- package/dist/model/discount.d.ts +1 -1
- package/dist/model/insightsEvents.d.ts +1 -1
- package/dist/model/objectData.d.ts +1 -1
- package/dist/model/objectDataAfterSearch.d.ts +1 -1
- package/dist/model/price.d.ts +1 -1
- package/dist/model/purchasedObjectIDs.d.ts +6 -6
- package/dist/model/purchasedObjectIDsAfterSearch.d.ts +7 -7
- package/dist/model/purchasedObjectIDsAfterSearch.d.ts.map +1 -1
- package/dist/model/viewedFilters.d.ts +6 -6
- package/dist/model/viewedObjectIDs.d.ts +6 -6
- package/dist/src/insightsClient.d.ts +4 -14
- package/dist/src/insightsClient.d.ts.map +1 -1
- package/model/addedToCartObjectIDs.ts +6 -6
- package/model/addedToCartObjectIDsAfterSearch.ts +6 -6
- package/model/clickedFilters.ts +6 -6
- package/model/clickedObjectIDs.ts +6 -6
- package/model/clickedObjectIDsAfterSearch.ts +7 -7
- package/model/clientMethodProps.ts +1 -1
- package/model/convertedFilters.ts +6 -6
- package/model/convertedObjectIDs.ts +6 -6
- package/model/convertedObjectIDsAfterSearch.ts +6 -6
- package/model/discount.ts +1 -1
- package/model/insightsEvents.ts +1 -1
- package/model/objectData.ts +1 -1
- package/model/objectDataAfterSearch.ts +1 -1
- package/model/price.ts +1 -1
- package/model/purchasedObjectIDs.ts +6 -6
- package/model/purchasedObjectIDsAfterSearch.ts +7 -7
- package/model/viewedFilters.ts +6 -6
- package/model/viewedObjectIDs.ts +6 -6
- package/package.json +7 -7
package/dist/builds/browser.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import type { ClientOptions } from '@algolia/client-common';
|
|
2
|
-
import type {
|
|
3
|
-
export { apiClientVersion,
|
|
2
|
+
import type { Region } from '../src/insightsClient';
|
|
3
|
+
export { apiClientVersion, Region } from '../src/insightsClient';
|
|
4
4
|
export * from '../model';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The client type.
|
|
7
|
+
*/
|
|
8
|
+
export type InsightsClient = ReturnType<typeof insightsClient>;
|
|
9
|
+
export declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): {
|
|
10
|
+
transporter: import("@algolia/client-common").Transporter;
|
|
11
|
+
appId: string;
|
|
12
|
+
clearCache(): Promise<void>;
|
|
13
|
+
readonly _ua: string;
|
|
14
|
+
addAlgoliaAgent(segment: string, version?: string | undefined): void;
|
|
15
|
+
customDelete({ path, parameters }: import("../model").CustomDeleteProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<Record<string, any>>;
|
|
16
|
+
customGet({ path, parameters }: import("../model").CustomGetProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<Record<string, any>>;
|
|
17
|
+
customPost({ path, parameters, body }: import("../model").CustomPostProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<Record<string, any>>;
|
|
18
|
+
customPut({ path, parameters, body }: import("../model").CustomPutProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<Record<string, any>>;
|
|
19
|
+
deleteUserToken({ userToken }: import("../model").DeleteUserTokenProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<void>;
|
|
20
|
+
pushEvents(insightsEvents: import("../model").InsightsEvents, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("../model").EventsResponse>;
|
|
21
|
+
};
|
|
6
22
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAW5D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAW5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAOpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACjE,cAAc,UAAU,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAG/D,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa;;;;;;;;;;;;EAsCxB"}
|
package/dist/builds/node.d.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import type { ClientOptions } from '@algolia/client-common';
|
|
2
|
-
import type {
|
|
3
|
-
export { apiClientVersion,
|
|
2
|
+
import type { Region } from '../src/insightsClient';
|
|
3
|
+
export { apiClientVersion, Region } from '../src/insightsClient';
|
|
4
4
|
export * from '../model';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The client type.
|
|
7
|
+
*/
|
|
8
|
+
export type InsightsClient = ReturnType<typeof insightsClient>;
|
|
9
|
+
export declare function insightsClient(appId: string, apiKey: string, region?: Region, options?: ClientOptions): {
|
|
10
|
+
transporter: import("@algolia/client-common").Transporter;
|
|
11
|
+
appId: string;
|
|
12
|
+
clearCache(): Promise<void>;
|
|
13
|
+
_ua: string;
|
|
14
|
+
addAlgoliaAgent(segment: string, version?: string | undefined): void;
|
|
15
|
+
customDelete({ path, parameters }: import("../model").CustomDeleteProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<Record<string, any>>;
|
|
16
|
+
customGet({ path, parameters }: import("../model").CustomGetProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<Record<string, any>>;
|
|
17
|
+
customPost({ path, parameters, body }: import("../model").CustomPostProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<Record<string, any>>;
|
|
18
|
+
customPut({ path, parameters, body }: import("../model").CustomPutProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<Record<string, any>>;
|
|
19
|
+
deleteUserToken({ userToken }: import("../model").DeleteUserTokenProps, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<void>;
|
|
20
|
+
pushEvents(insightsEvents: import("../model").InsightsEvents, requestOptions?: import("@algolia/client-common").RequestOptions | undefined): Promise<import("../model").EventsResponse>;
|
|
21
|
+
};
|
|
6
22
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACjE,cAAc,UAAU,CAAC;AAEzB;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAG/D,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa;;;;;;;;;;;;EAkCxB"}
|
package/dist/client-insights.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var clientCommon = require('@algolia/client-common');
|
|
|
4
4
|
var requesterNodeHttp = require('@algolia/requester-node-http');
|
|
5
5
|
|
|
6
6
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
7
|
-
const apiClientVersion = '5.0.0-
|
|
7
|
+
const apiClientVersion = '5.0.0-beta.1';
|
|
8
8
|
const REGIONS = ['de', 'us'];
|
|
9
9
|
function getDefaultHosts(region) {
|
|
10
10
|
const url = !region
|
|
@@ -66,7 +66,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
66
66
|
/**
|
|
67
67
|
* This method allow you to send requests to the Algolia REST API.
|
|
68
68
|
*
|
|
69
|
-
* @summary Send requests to the Algolia REST API.
|
|
70
69
|
* @param customDelete - The customDelete object.
|
|
71
70
|
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
72
71
|
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
@@ -76,7 +75,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
76
75
|
if (!path) {
|
|
77
76
|
throw new Error('Parameter `path` is required when calling `customDelete`.');
|
|
78
77
|
}
|
|
79
|
-
const requestPath = '/
|
|
78
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
80
79
|
const headers = {};
|
|
81
80
|
const queryParameters = parameters ? parameters : {};
|
|
82
81
|
const request = {
|
|
@@ -90,7 +89,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
90
89
|
/**
|
|
91
90
|
* This method allow you to send requests to the Algolia REST API.
|
|
92
91
|
*
|
|
93
|
-
* @summary Send requests to the Algolia REST API.
|
|
94
92
|
* @param customGet - The customGet object.
|
|
95
93
|
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
96
94
|
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
@@ -100,7 +98,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
100
98
|
if (!path) {
|
|
101
99
|
throw new Error('Parameter `path` is required when calling `customGet`.');
|
|
102
100
|
}
|
|
103
|
-
const requestPath = '/
|
|
101
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
104
102
|
const headers = {};
|
|
105
103
|
const queryParameters = parameters ? parameters : {};
|
|
106
104
|
const request = {
|
|
@@ -114,7 +112,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
114
112
|
/**
|
|
115
113
|
* This method allow you to send requests to the Algolia REST API.
|
|
116
114
|
*
|
|
117
|
-
* @summary Send requests to the Algolia REST API.
|
|
118
115
|
* @param customPost - The customPost object.
|
|
119
116
|
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
120
117
|
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
@@ -125,7 +122,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
125
122
|
if (!path) {
|
|
126
123
|
throw new Error('Parameter `path` is required when calling `customPost`.');
|
|
127
124
|
}
|
|
128
|
-
const requestPath = '/
|
|
125
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
129
126
|
const headers = {};
|
|
130
127
|
const queryParameters = parameters ? parameters : {};
|
|
131
128
|
const request = {
|
|
@@ -140,7 +137,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
140
137
|
/**
|
|
141
138
|
* This method allow you to send requests to the Algolia REST API.
|
|
142
139
|
*
|
|
143
|
-
* @summary Send requests to the Algolia REST API.
|
|
144
140
|
* @param customPut - The customPut object.
|
|
145
141
|
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
146
142
|
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
@@ -151,7 +147,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
151
147
|
if (!path) {
|
|
152
148
|
throw new Error('Parameter `path` is required when calling `customPut`.');
|
|
153
149
|
}
|
|
154
|
-
const requestPath = '/
|
|
150
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
155
151
|
const headers = {};
|
|
156
152
|
const queryParameters = parameters ? parameters : {};
|
|
157
153
|
const request = {
|
|
@@ -164,11 +160,10 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
164
160
|
return transporter.request(request, requestOptions);
|
|
165
161
|
},
|
|
166
162
|
/**
|
|
167
|
-
*
|
|
163
|
+
* Deletes all events related to the specified user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](/specs/personalization#tag/profiles/operation/deleteUserProfile).
|
|
168
164
|
*
|
|
169
|
-
* @summary Delete user token.
|
|
170
165
|
* @param deleteUserToken - The deleteUserToken object.
|
|
171
|
-
* @param deleteUserToken.userToken -
|
|
166
|
+
* @param deleteUserToken.userToken - User token for which to delete all associated events.
|
|
172
167
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
173
168
|
*/
|
|
174
169
|
deleteUserToken({ userToken }, requestOptions) {
|
|
@@ -187,9 +182,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
187
182
|
return transporter.request(request, requestOptions);
|
|
188
183
|
},
|
|
189
184
|
/**
|
|
190
|
-
*
|
|
185
|
+
* Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.
|
|
191
186
|
*
|
|
192
|
-
* @summary Send events.
|
|
193
187
|
* @param insightsEvents - The insightsEvents object.
|
|
194
188
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
195
189
|
*/
|
|
@@ -216,6 +210,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
216
210
|
}
|
|
217
211
|
|
|
218
212
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
213
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
219
214
|
function insightsClient(appId, apiKey, region, options) {
|
|
220
215
|
if (!appId || typeof appId !== 'string') {
|
|
221
216
|
throw new Error('`appId` is missing.');
|
|
@@ -226,22 +221,24 @@ function insightsClient(appId, apiKey, region, options) {
|
|
|
226
221
|
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
|
|
227
222
|
throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
|
|
228
223
|
}
|
|
229
|
-
return
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
224
|
+
return {
|
|
225
|
+
...createInsightsClient({
|
|
226
|
+
appId,
|
|
227
|
+
apiKey,
|
|
228
|
+
region,
|
|
229
|
+
timeouts: {
|
|
230
|
+
connect: clientCommon.DEFAULT_CONNECT_TIMEOUT_NODE,
|
|
231
|
+
read: clientCommon.DEFAULT_READ_TIMEOUT_NODE,
|
|
232
|
+
write: clientCommon.DEFAULT_WRITE_TIMEOUT_NODE,
|
|
233
|
+
},
|
|
234
|
+
requester: requesterNodeHttp.createHttpRequester(),
|
|
235
|
+
algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
|
|
236
|
+
responsesCache: clientCommon.createNullCache(),
|
|
237
|
+
requestsCache: clientCommon.createNullCache(),
|
|
238
|
+
hostsCache: clientCommon.createMemoryCache(),
|
|
239
|
+
...options,
|
|
240
|
+
}),
|
|
241
|
+
};
|
|
245
242
|
}
|
|
246
243
|
|
|
247
244
|
exports.apiClientVersion = apiClientVersion;
|
|
@@ -207,7 +207,7 @@ function _toPrimitive(t, r) {
|
|
|
207
207
|
}
|
|
208
208
|
function _toPropertyKey(t) {
|
|
209
209
|
var i = _toPrimitive(t, "string");
|
|
210
|
-
return "symbol" == typeof i ? i :
|
|
210
|
+
return "symbol" == typeof i ? i : i + "";
|
|
211
211
|
}
|
|
212
212
|
function _defineProperty(obj, key, value) {
|
|
213
213
|
key = _toPropertyKey(key);
|
|
@@ -270,7 +270,7 @@ class DetailedApiError extends ApiError {
|
|
|
270
270
|
}
|
|
271
271
|
function serializeUrl(host, path, queryParameters) {
|
|
272
272
|
const queryParametersAsString = serializeQueryParameters(queryParameters);
|
|
273
|
-
let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.
|
|
273
|
+
let url = `${host.protocol}://${host.url}${host.port ? `:${host.port}` : ''}/${path.charAt(0) === '/' ? path.substring(1) : path}`;
|
|
274
274
|
if (queryParametersAsString.length) {
|
|
275
275
|
url += `?${queryParametersAsString}`;
|
|
276
276
|
}
|
|
@@ -278,7 +278,7 @@ function serializeUrl(host, path, queryParameters) {
|
|
|
278
278
|
}
|
|
279
279
|
function serializeQueryParameters(parameters) {
|
|
280
280
|
const isObjectOrArray = value => Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
|
|
281
|
-
return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key])}`).join('&');
|
|
281
|
+
return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key]).replaceAll('+', '%20')}`).join('&');
|
|
282
282
|
}
|
|
283
283
|
function serializeData(request, requestOptions) {
|
|
284
284
|
if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
|
|
@@ -449,16 +449,13 @@ function createTransporter({
|
|
|
449
449
|
if (host === undefined) {
|
|
450
450
|
throw new RetryError(stackTraceWithoutCredentials(stackTrace));
|
|
451
451
|
}
|
|
452
|
-
let responseTimeout = requestOptions.
|
|
453
|
-
if (responseTimeout === undefined) {
|
|
454
|
-
responseTimeout = isRead ? timeouts.read : timeouts.write;
|
|
455
|
-
}
|
|
452
|
+
let responseTimeout = isRead ? requestOptions.timeouts?.read || timeouts.read : requestOptions.timeouts?.write || timeouts.write;
|
|
456
453
|
const payload = {
|
|
457
454
|
data,
|
|
458
455
|
headers,
|
|
459
456
|
method: request.method,
|
|
460
457
|
url: serializeUrl(host, request.path, queryParameters),
|
|
461
|
-
connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
|
|
458
|
+
connectTimeout: getTimeout(timeoutsCount, requestOptions.timeouts?.connect || timeouts.connect),
|
|
462
459
|
responseTimeout: getTimeout(timeoutsCount, responseTimeout)
|
|
463
460
|
};
|
|
464
461
|
/**
|
|
@@ -686,7 +683,7 @@ function createXhrRequester() {
|
|
|
686
683
|
}
|
|
687
684
|
|
|
688
685
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
689
|
-
const apiClientVersion = '5.0.0-
|
|
686
|
+
const apiClientVersion = '5.0.0-beta.1';
|
|
690
687
|
const REGIONS = ['de', 'us'];
|
|
691
688
|
function getDefaultHosts(region) {
|
|
692
689
|
const url = !region
|
|
@@ -748,7 +745,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
748
745
|
/**
|
|
749
746
|
* This method allow you to send requests to the Algolia REST API.
|
|
750
747
|
*
|
|
751
|
-
* @summary Send requests to the Algolia REST API.
|
|
752
748
|
* @param customDelete - The customDelete object.
|
|
753
749
|
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
754
750
|
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
@@ -758,7 +754,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
758
754
|
if (!path) {
|
|
759
755
|
throw new Error('Parameter `path` is required when calling `customDelete`.');
|
|
760
756
|
}
|
|
761
|
-
const requestPath = '/
|
|
757
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
762
758
|
const headers = {};
|
|
763
759
|
const queryParameters = parameters ? parameters : {};
|
|
764
760
|
const request = {
|
|
@@ -772,7 +768,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
772
768
|
/**
|
|
773
769
|
* This method allow you to send requests to the Algolia REST API.
|
|
774
770
|
*
|
|
775
|
-
* @summary Send requests to the Algolia REST API.
|
|
776
771
|
* @param customGet - The customGet object.
|
|
777
772
|
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
778
773
|
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
@@ -782,7 +777,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
782
777
|
if (!path) {
|
|
783
778
|
throw new Error('Parameter `path` is required when calling `customGet`.');
|
|
784
779
|
}
|
|
785
|
-
const requestPath = '/
|
|
780
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
786
781
|
const headers = {};
|
|
787
782
|
const queryParameters = parameters ? parameters : {};
|
|
788
783
|
const request = {
|
|
@@ -796,7 +791,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
796
791
|
/**
|
|
797
792
|
* This method allow you to send requests to the Algolia REST API.
|
|
798
793
|
*
|
|
799
|
-
* @summary Send requests to the Algolia REST API.
|
|
800
794
|
* @param customPost - The customPost object.
|
|
801
795
|
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
802
796
|
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
@@ -807,7 +801,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
807
801
|
if (!path) {
|
|
808
802
|
throw new Error('Parameter `path` is required when calling `customPost`.');
|
|
809
803
|
}
|
|
810
|
-
const requestPath = '/
|
|
804
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
811
805
|
const headers = {};
|
|
812
806
|
const queryParameters = parameters ? parameters : {};
|
|
813
807
|
const request = {
|
|
@@ -822,7 +816,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
822
816
|
/**
|
|
823
817
|
* This method allow you to send requests to the Algolia REST API.
|
|
824
818
|
*
|
|
825
|
-
* @summary Send requests to the Algolia REST API.
|
|
826
819
|
* @param customPut - The customPut object.
|
|
827
820
|
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
828
821
|
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
@@ -833,7 +826,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
833
826
|
if (!path) {
|
|
834
827
|
throw new Error('Parameter `path` is required when calling `customPut`.');
|
|
835
828
|
}
|
|
836
|
-
const requestPath = '/
|
|
829
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
837
830
|
const headers = {};
|
|
838
831
|
const queryParameters = parameters ? parameters : {};
|
|
839
832
|
const request = {
|
|
@@ -846,11 +839,10 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
846
839
|
return transporter.request(request, requestOptions);
|
|
847
840
|
},
|
|
848
841
|
/**
|
|
849
|
-
*
|
|
842
|
+
* Deletes all events related to the specified user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](/specs/personalization#tag/profiles/operation/deleteUserProfile).
|
|
850
843
|
*
|
|
851
|
-
* @summary Delete user token.
|
|
852
844
|
* @param deleteUserToken - The deleteUserToken object.
|
|
853
|
-
* @param deleteUserToken.userToken -
|
|
845
|
+
* @param deleteUserToken.userToken - User token for which to delete all associated events.
|
|
854
846
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
855
847
|
*/
|
|
856
848
|
deleteUserToken({ userToken }, requestOptions) {
|
|
@@ -869,9 +861,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
869
861
|
return transporter.request(request, requestOptions);
|
|
870
862
|
},
|
|
871
863
|
/**
|
|
872
|
-
*
|
|
864
|
+
* 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.
|
|
873
865
|
*
|
|
874
|
-
* @summary Send events.
|
|
875
866
|
* @param insightsEvents - The insightsEvents object.
|
|
876
867
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
877
868
|
*/
|
|
@@ -898,6 +889,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
898
889
|
}
|
|
899
890
|
|
|
900
891
|
// 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.
|
|
892
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
901
893
|
function insightsClient(appId, apiKey, region, options) {
|
|
902
894
|
if (!appId || typeof appId !== 'string') {
|
|
903
895
|
throw new Error('`appId` is missing.');
|
|
@@ -2,7 +2,7 @@ import { createAuth, createTransporter, getAlgoliaAgent, DEFAULT_CONNECT_TIMEOUT
|
|
|
2
2
|
import { createHttpRequester } from '@algolia/requester-node-http';
|
|
3
3
|
|
|
4
4
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
5
|
-
const apiClientVersion = '5.0.0-
|
|
5
|
+
const apiClientVersion = '5.0.0-beta.1';
|
|
6
6
|
const REGIONS = ['de', 'us'];
|
|
7
7
|
function getDefaultHosts(region) {
|
|
8
8
|
const url = !region
|
|
@@ -64,7 +64,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
64
64
|
/**
|
|
65
65
|
* This method allow you to send requests to the Algolia REST API.
|
|
66
66
|
*
|
|
67
|
-
* @summary Send requests to the Algolia REST API.
|
|
68
67
|
* @param customDelete - The customDelete object.
|
|
69
68
|
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
70
69
|
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
@@ -74,7 +73,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
74
73
|
if (!path) {
|
|
75
74
|
throw new Error('Parameter `path` is required when calling `customDelete`.');
|
|
76
75
|
}
|
|
77
|
-
const requestPath = '/
|
|
76
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
78
77
|
const headers = {};
|
|
79
78
|
const queryParameters = parameters ? parameters : {};
|
|
80
79
|
const request = {
|
|
@@ -88,7 +87,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
88
87
|
/**
|
|
89
88
|
* This method allow you to send requests to the Algolia REST API.
|
|
90
89
|
*
|
|
91
|
-
* @summary Send requests to the Algolia REST API.
|
|
92
90
|
* @param customGet - The customGet object.
|
|
93
91
|
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
94
92
|
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
@@ -98,7 +96,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
98
96
|
if (!path) {
|
|
99
97
|
throw new Error('Parameter `path` is required when calling `customGet`.');
|
|
100
98
|
}
|
|
101
|
-
const requestPath = '/
|
|
99
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
102
100
|
const headers = {};
|
|
103
101
|
const queryParameters = parameters ? parameters : {};
|
|
104
102
|
const request = {
|
|
@@ -112,7 +110,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
112
110
|
/**
|
|
113
111
|
* This method allow you to send requests to the Algolia REST API.
|
|
114
112
|
*
|
|
115
|
-
* @summary Send requests to the Algolia REST API.
|
|
116
113
|
* @param customPost - The customPost object.
|
|
117
114
|
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
118
115
|
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
@@ -123,7 +120,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
123
120
|
if (!path) {
|
|
124
121
|
throw new Error('Parameter `path` is required when calling `customPost`.');
|
|
125
122
|
}
|
|
126
|
-
const requestPath = '/
|
|
123
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
127
124
|
const headers = {};
|
|
128
125
|
const queryParameters = parameters ? parameters : {};
|
|
129
126
|
const request = {
|
|
@@ -138,7 +135,6 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
138
135
|
/**
|
|
139
136
|
* This method allow you to send requests to the Algolia REST API.
|
|
140
137
|
*
|
|
141
|
-
* @summary Send requests to the Algolia REST API.
|
|
142
138
|
* @param customPut - The customPut object.
|
|
143
139
|
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
144
140
|
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
@@ -149,7 +145,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
149
145
|
if (!path) {
|
|
150
146
|
throw new Error('Parameter `path` is required when calling `customPut`.');
|
|
151
147
|
}
|
|
152
|
-
const requestPath = '/
|
|
148
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
153
149
|
const headers = {};
|
|
154
150
|
const queryParameters = parameters ? parameters : {};
|
|
155
151
|
const request = {
|
|
@@ -162,11 +158,10 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
162
158
|
return transporter.request(request, requestOptions);
|
|
163
159
|
},
|
|
164
160
|
/**
|
|
165
|
-
*
|
|
161
|
+
* Deletes all events related to the specified user token from events metrics and analytics. To delete a personalization user profile, see [Delete a user profile](/specs/personalization#tag/profiles/operation/deleteUserProfile).
|
|
166
162
|
*
|
|
167
|
-
* @summary Delete user token.
|
|
168
163
|
* @param deleteUserToken - The deleteUserToken object.
|
|
169
|
-
* @param deleteUserToken.userToken -
|
|
164
|
+
* @param deleteUserToken.userToken - User token for which to delete all associated events.
|
|
170
165
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
171
166
|
*/
|
|
172
167
|
deleteUserToken({ userToken }, requestOptions) {
|
|
@@ -185,9 +180,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
185
180
|
return transporter.request(request, requestOptions);
|
|
186
181
|
},
|
|
187
182
|
/**
|
|
188
|
-
*
|
|
183
|
+
* Sends a list of events to the Insights API. You can include up to 1,000 events in a single request, but the request body must be smaller than 2 MB.
|
|
189
184
|
*
|
|
190
|
-
* @summary Send events.
|
|
191
185
|
* @param insightsEvents - The insightsEvents object.
|
|
192
186
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
193
187
|
*/
|
|
@@ -214,6 +208,7 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
|
|
|
214
208
|
}
|
|
215
209
|
|
|
216
210
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
|
211
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
217
212
|
function insightsClient(appId, apiKey, region, options) {
|
|
218
213
|
if (!appId || typeof appId !== 'string') {
|
|
219
214
|
throw new Error('`appId` is missing.');
|
|
@@ -224,22 +219,24 @@ function insightsClient(appId, apiKey, region, options) {
|
|
|
224
219
|
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
|
|
225
220
|
throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
|
|
226
221
|
}
|
|
227
|
-
return
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
222
|
+
return {
|
|
223
|
+
...createInsightsClient({
|
|
224
|
+
appId,
|
|
225
|
+
apiKey,
|
|
226
|
+
region,
|
|
227
|
+
timeouts: {
|
|
228
|
+
connect: DEFAULT_CONNECT_TIMEOUT_NODE,
|
|
229
|
+
read: DEFAULT_READ_TIMEOUT_NODE,
|
|
230
|
+
write: DEFAULT_WRITE_TIMEOUT_NODE,
|
|
231
|
+
},
|
|
232
|
+
requester: createHttpRequester(),
|
|
233
|
+
algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
|
|
234
|
+
responsesCache: createNullCache(),
|
|
235
|
+
requestsCache: createNullCache(),
|
|
236
|
+
hostsCache: createMemoryCache(),
|
|
237
|
+
...options,
|
|
238
|
+
}),
|
|
239
|
+
};
|
|
243
240
|
}
|
|
244
241
|
|
|
245
242
|
export { apiClientVersion, insightsClient };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! client-insights.umd.js | 5.0.0-
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-insights"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function s(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function a(){return JSON.parse(s().getItem(r)||"{}")}function n(e){s().setItem(r,JSON.stringify(e))}return{get:(t,r,s={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){const t=e.timeToLive?1e3*e.timeToLive:null,r=a(),s=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(n(s),!t)return;n(Object.fromEntries(Object.entries(s).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),a()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||s.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const n=a();return n[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},s().setItem(r,JSON.stringify(n)),t})),delete:e=>Promise.resolve().then((()=>{const t=a();delete t[JSON.stringify(e)],s().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{s().removeItem(r)}))}}function r(e){const t=[...e.caches],s=t.shift();return void 0===s?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,a,n={miss:()=>Promise.resolve()})=>s.get(e,a,n).catch((()=>r({caches:t}).get(e,a,n))),set:(e,a)=>s.set(e,a).catch((()=>r({caches:t}).set(e,a))),delete:e=>s.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>s.clear().catch((()=>r({caches:t}).clear()))}}function s(e={serializable:!0}){let t={};return{get(r,s,a={miss:()=>Promise.resolve()}){const n=JSON.stringify(r);if(n in t)return Promise.resolve(e.serializable?JSON.parse(t[n]):t[n]);const o=s();return o.then((e=>a.miss(e))).then((()=>o))},set:(r,s)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(s):s,Promise.resolve(s)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const a=12e4;function n(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>a},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=a}}}function o(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function i(e,t,r){return(t=o(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class c extends Error{constructor(e,t){super(e),i(this,"name","AlgoliaError"),t&&(this.name=t)}}class u extends c{constructor(e,t,r){super(e,r),i(this,"stackTrace",void 0),this.stackTrace=t}}class l extends u{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, please create a ticket at https://support.algolia.com/ sharing steps we can use to reproduce the issue.",e,"RetryError")}}class h extends u{constructor(e,t,r,s="ApiError"){super(e,r,s),i(this,"status",void 0),this.status=t}}class m extends c{constructor(e,t){super(e,"DeserializationError"),i(this,"response",void 0),this.response=t}}class d extends h{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),i(this,"error",void 0),this.error=r}}function p(e,t,r){const s=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${encodeURIComponent(t(e[r])?JSON.stringify(e[r]):e[r])}`)).join("&")}(r);let a=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return s.length&&(a+=`?${s}`),a}function g(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function f({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:s,algoliaAgent:a,timeouts:o,requester:i,requestsCache:c,responsesCache:u}){async function f(c,u,f=!0){const y=[],v=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(c,u),P=function(e,t,r){const s={Accept:"application/json",...e,...t,...r},a={};return Object.keys(s).forEach((e=>{const t=s[e];a[e.toLowerCase()]=t})),a}(r,c.headers,u.headers),w="GET"===c.method?{...c.data,...u.data}:{},b={...s,...c.queryParameters,...w};if(a.value&&(b["x-algolia-agent"]=a.value),u&&u.queryParameters)for(const e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?b[e]=u.queryParameters[e].toString():b[e]=u.queryParameters[e];let T=0;const q=async(e,r)=>{const s=e.pop();if(void 0===s)throw new l(function(e){return e.map((e=>g(e)))}(y));let a=u.timeout;void 0===a&&(a=f?o.read:o.write);const w={data:v,headers:P,method:c.method,url:p(s,c.path,b),connectTimeout:r(T,o.connect),responseTimeout:r(T,a)},O=t=>{const r={request:w,response:t,host:s,triesLeft:e.length};return y.push(r),r},E=await i.send(w);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(E)){const a=O(E);return E.isTimedOut&&T++,console.log("Retryable failure",g(a)),await t.set(s,n(s,E.isTimedOut?"timed out":"down")),q(e,r)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(t){throw new m(t.message,e)}}(E);throw O(E),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new d(s.message,t,s.error,r):new h(s.message,t,r)}catch(e){}return new h(e,t,r)}(E,y)},O=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),E=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(n(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),o=[...s,...a];return{hosts:o.length>0?o:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(O);return q([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:t,requester:i,timeouts:o,algoliaAgent:a,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){const a=e.useReadTransporter||"GET"===e.method;if(!a)return f(e,t,a);const n=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return n();const o={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return u.get(o,(()=>c.get(o,(()=>c.set(o,n()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>u.set(o,e)})},requestsCache:c,responsesCache:u}}function y({algoliaAgents:e,client:t,version:r}){const s=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>s.add(e))),s}const v="5.0.0-alpha.98",P=["de","us"];e.apiClientVersion=v,e.insightsClient=function(e,a,n,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");if(n&&("string"!=typeof n||!P.includes(n)))throw new Error(`\`region\` must be one of the following: ${P.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,region:a,...n}){const o=function(e,t,r="WithinHeaders"){const s={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?s:{},queryParameters:()=>"WithinQueryParameters"===r?s:{}}}(e,t,r),i=f({hosts:(c=a,[{url:c?"insights.{region}.algolia.io".replace("{region}",c):"insights.algolia.io",accept:"readWrite",protocol:"https"}]),...n,algoliaAgent:y({algoliaAgents:s,client:"Insights",version:v}),baseHeaders:{"content-type":"text/plain",...o.headers(),...n.baseHeaders},baseQueryParameters:{...o.queryParameters(),...n.baseQueryParameters}});var c;return{transporter:i,appId:e,clearCache:()=>Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then((()=>{})),get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(e,t){i.algoliaAgent.add({segment:e,version:t})},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");const s={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");const s={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customPost({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");const a={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},customPut({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");const a={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},deleteUserToken({userToken:e},t){if(!e)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");const r={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},pushEvents(e,t){if(!e)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!e.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");const r={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:e};return i.request(r,t)}}}({appId:e,apiKey:a,region:n,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const s=(e,s)=>setTimeout((()=>{r.abort(),t({status:0,content:s,isTimedOut:!0})}),e),a=s(e.connectTimeout,"Connection timeout");let n;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===n&&(clearTimeout(a),n=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:s(),requestsCache:s({serializable:!1}),hostsCache:r({caches:[t({key:`${v}-${e}`}),s()]}),...o})}}));
|
|
1
|
+
/*! client-insights.umd.js | 5.0.0-beta.1 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-insights"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function s(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function a(){return JSON.parse(s().getItem(r)||"{}")}function n(e){s().setItem(r,JSON.stringify(e))}return{get:(t,r,s={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){const t=e.timeToLive?1e3*e.timeToLive:null,r=a(),s=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(n(s),!t)return;n(Object.fromEntries(Object.entries(s).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),a()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||s.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const n=a();return n[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},s().setItem(r,JSON.stringify(n)),t})),delete:e=>Promise.resolve().then((()=>{const t=a();delete t[JSON.stringify(e)],s().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{s().removeItem(r)}))}}function r(e){const t=[...e.caches],s=t.shift();return void 0===s?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,a,n={miss:()=>Promise.resolve()})=>s.get(e,a,n).catch((()=>r({caches:t}).get(e,a,n))),set:(e,a)=>s.set(e,a).catch((()=>r({caches:t}).set(e,a))),delete:e=>s.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>s.clear().catch((()=>r({caches:t}).clear()))}}function s(e={serializable:!0}){let t={};return{get(r,s,a={miss:()=>Promise.resolve()}){const n=JSON.stringify(r);if(n in t)return Promise.resolve(e.serializable?JSON.parse(t[n]):t[n]);const o=s();return o.then((e=>a.miss(e))).then((()=>o))},set:(r,s)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(s):s,Promise.resolve(s)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const a=12e4;function n(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>a},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=a}}}function o(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function i(e,t,r){return(t=o(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class c extends Error{constructor(e,t){super(e),i(this,"name","AlgoliaError"),t&&(this.name=t)}}class u extends c{constructor(e,t,r){super(e,r),i(this,"stackTrace",void 0),this.stackTrace=t}}class l extends u{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, please create a ticket at https://support.algolia.com/ sharing steps we can use to reproduce the issue.",e,"RetryError")}}class h extends u{constructor(e,t,r,s="ApiError"){super(e,r,s),i(this,"status",void 0),this.status=t}}class m extends c{constructor(e,t){super(e,"DeserializationError"),i(this,"response",void 0),this.response=t}}class d extends h{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),i(this,"error",void 0),this.error=r}}function p(e,t,r){const s=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${encodeURIComponent(t(e[r])?JSON.stringify(e[r]):e[r]).replaceAll("+","%20")}`)).join("&")}(r);let a=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${"/"===t.charAt(0)?t.substring(1):t}`;return s.length&&(a+=`?${s}`),a}function g(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function f({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:s,algoliaAgent:a,timeouts:o,requester:i,requestsCache:c,responsesCache:u}){async function f(c,u,f=!0){const y=[],v=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(c,u),P=function(e,t,r){const s={Accept:"application/json",...e,...t,...r},a={};return Object.keys(s).forEach((e=>{const t=s[e];a[e.toLowerCase()]=t})),a}(r,c.headers,u.headers),w="GET"===c.method?{...c.data,...u.data}:{},b={...s,...c.queryParameters,...w};if(a.value&&(b["x-algolia-agent"]=a.value),u&&u.queryParameters)for(const e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?b[e]=u.queryParameters[e].toString():b[e]=u.queryParameters[e];let T=0;const q=async(e,r)=>{const s=e.pop();if(void 0===s)throw new l(function(e){return e.map((e=>g(e)))}(y));let a=f?u.timeouts?.read||o.read:u.timeouts?.write||o.write;const w={data:v,headers:P,method:c.method,url:p(s,c.path,b),connectTimeout:r(T,u.timeouts?.connect||o.connect),responseTimeout:r(T,a)},O=t=>{const r={request:w,response:t,host:s,triesLeft:e.length};return y.push(r),r},E=await i.send(w);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&!~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(E)){const a=O(E);return E.isTimedOut&&T++,console.log("Retryable failure",g(a)),await t.set(s,n(s,E.isTimedOut?"timed out":"down")),q(e,r)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(t){throw new m(t.message,e)}}(E);throw O(E),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new d(s.message,t,s.error,r):new h(s.message,t,r)}catch(e){}return new h(e,t,r)}(E,y)},O=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),E=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(n(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),o=[...s,...a];return{hosts:o.length>0?o:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(O);return q([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:t,requester:i,timeouts:o,algoliaAgent:a,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){const a=e.useReadTransporter||"GET"===e.method;if(!a)return f(e,t,a);const n=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return n();const o={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return u.get(o,(()=>c.get(o,(()=>c.set(o,n()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>u.set(o,e)})},requestsCache:c,responsesCache:u}}function y({algoliaAgents:e,client:t,version:r}){const s=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>s.add(e))),s}const v="5.0.0-beta.1",P=["de","us"];e.apiClientVersion=v,e.insightsClient=function(e,a,n,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");if(n&&("string"!=typeof n||!P.includes(n)))throw new Error(`\`region\` must be one of the following: ${P.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,region:a,...n}){const o=function(e,t,r="WithinHeaders"){const s={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?s:{},queryParameters:()=>"WithinQueryParameters"===r?s:{}}}(e,t,r),i=f({hosts:(c=a,[{url:c?"insights.{region}.algolia.io".replace("{region}",c):"insights.algolia.io",accept:"readWrite",protocol:"https"}]),...n,algoliaAgent:y({algoliaAgents:s,client:"Insights",version:v}),baseHeaders:{"content-type":"text/plain",...o.headers(),...n.baseHeaders},baseQueryParameters:{...o.queryParameters(),...n.baseQueryParameters}});var c;return{transporter:i,appId:e,clearCache:()=>Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then((()=>{})),get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(e,t){i.algoliaAgent.add({segment:e,version:t})},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");const s={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");const s={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customPost({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");const a={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},customPut({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");const a={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},deleteUserToken({userToken:e},t){if(!e)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");const r={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},pushEvents(e,t){if(!e)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!e.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");const r={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:e};return i.request(r,t)}}}({appId:e,apiKey:a,region:n,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const s=(e,s)=>setTimeout((()=>{r.abort(),t({status:0,content:s,isTimedOut:!0})}),e),a=s(e.connectTimeout,"Connection timeout");let n;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===n&&(clearTimeout(a),n=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:s(),requestsCache:s({serializable:!1}),hostsCache:r({caches:[t({key:`${v}-${e}`}),s()]}),...o})}}));
|
|
@@ -7,25 +7,25 @@ import type { Value } from './value';
|
|
|
7
7
|
*/
|
|
8
8
|
export type AddedToCartObjectIDs = {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Event name, up to 64 ASCII characters. Consider naming events consistently—for example, by adopting Segment\'s [object-action](https://segment.com/academy/collecting-data/naming-conventions-for-clean-data/#the-object-action-framework) framework.
|
|
11
11
|
*/
|
|
12
12
|
eventName: string;
|
|
13
13
|
eventType: ConversionEvent;
|
|
14
14
|
eventSubtype: AddToCartEvent;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Index name (case-sensitive) to which the event\'s items belong.
|
|
17
17
|
*/
|
|
18
18
|
index: string;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Object IDs of the records that are part of the event.
|
|
21
21
|
*/
|
|
22
22
|
objectIDs: string[];
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Anonymous or pseudonymous user identifier. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
|
|
25
25
|
*/
|
|
26
26
|
userToken: string;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Identifier for authenticated users. When the user signs in, you can get an identifier from your system and send it as `authenticatedUserToken`. This lets you keep using the `userToken` from before the user signed in, while providing a reliable way to identify users across sessions. Don\'t use personally identifiable information in user tokens. For more information, see [User token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
|
|
29
29
|
*/
|
|
30
30
|
authenticatedUserToken?: string;
|
|
31
31
|
/**
|
|
@@ -37,7 +37,7 @@ export type AddedToCartObjectIDs = {
|
|
|
37
37
|
*/
|
|
38
38
|
objectData?: ObjectData[];
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Timestamp of the event, measured in milliseconds since the Unix epoch. By default, the Insights API uses the time it receives an event as its timestamp.
|
|
41
41
|
*/
|
|
42
42
|
timestamp?: number;
|
|
43
43
|
value?: Value;
|