@algolia/client-analytics 5.0.0-alpha.11 → 5.0.0-alpha.110
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 +39 -5
- package/dist/builds/browser.d.ts.map +1 -1
- package/dist/builds/node.d.ts +39 -5
- package/dist/builds/node.d.ts.map +1 -1
- package/dist/{client-analytics.cjs.js → client-analytics.cjs} +1083 -924
- package/dist/client-analytics.esm.browser.js +1293 -1160
- package/dist/client-analytics.esm.node.js +1083 -922
- package/dist/client-analytics.umd.js +2 -2
- package/dist/model/clickPositionsInner.d.ts +14 -0
- package/dist/model/clickPositionsInner.d.ts.map +1 -0
- package/dist/model/clientMethodProps.d.ts +578 -507
- package/dist/model/clientMethodProps.d.ts.map +1 -1
- package/dist/model/currenciesValue.d.ts +14 -0
- package/dist/model/currenciesValue.d.ts.map +1 -0
- package/dist/model/dailyAddToCartRates.d.ts +19 -0
- package/dist/model/dailyAddToCartRates.d.ts.map +1 -0
- package/dist/model/dailyAverageClicks.d.ts +15 -0
- package/dist/model/dailyAverageClicks.d.ts.map +1 -0
- package/dist/model/dailyClickThroughRates.d.ts +19 -0
- package/dist/model/dailyClickThroughRates.d.ts.map +1 -0
- package/dist/model/dailyConversionRates.d.ts +19 -0
- package/dist/model/dailyConversionRates.d.ts.map +1 -0
- package/dist/model/dailyNoClickRates.d.ts +19 -0
- package/dist/model/dailyNoClickRates.d.ts.map +1 -0
- package/dist/model/dailyNoResultsRates.d.ts +19 -0
- package/dist/model/dailyNoResultsRates.d.ts.map +1 -0
- package/dist/model/dailyPurchaseRates.d.ts +19 -0
- package/dist/model/dailyPurchaseRates.d.ts.map +1 -0
- package/dist/model/dailyRevenue.d.ts +12 -0
- package/dist/model/dailyRevenue.d.ts.map +1 -0
- package/dist/model/dailySearches.d.ts +11 -0
- package/dist/model/dailySearches.d.ts.map +1 -0
- package/dist/model/dailySearchesNoClicks.d.ts +15 -0
- package/dist/model/dailySearchesNoClicks.d.ts.map +1 -0
- package/dist/model/dailySearchesNoResults.d.ts +15 -0
- package/dist/model/dailySearchesNoResults.d.ts.map +1 -0
- package/dist/model/dailyUsers.d.ts +11 -0
- package/dist/model/dailyUsers.d.ts.map +1 -0
- package/dist/model/direction.d.ts +1 -1
- package/dist/model/direction.d.ts.map +1 -1
- package/dist/model/errorBase.d.ts +6 -6
- package/dist/model/errorBase.d.ts.map +1 -1
- package/dist/model/getAddToCartRateResponse.d.ts +20 -0
- package/dist/model/getAddToCartRateResponse.d.ts.map +1 -0
- package/dist/model/getAverageClickPositionResponse.d.ts +15 -15
- package/dist/model/getAverageClickPositionResponse.d.ts.map +1 -1
- package/dist/model/getClickPositionsResponse.d.ts +7 -7
- package/dist/model/getClickPositionsResponse.d.ts.map +1 -1
- package/dist/model/getClickThroughRateResponse.d.ts +19 -19
- package/dist/model/getClickThroughRateResponse.d.ts.map +1 -1
- package/dist/model/getConversionRateResponse.d.ts +20 -0
- package/dist/model/getConversionRateResponse.d.ts.map +1 -0
- package/dist/model/getNoClickRateResponse.d.ts +19 -19
- package/dist/model/getNoClickRateResponse.d.ts.map +1 -1
- package/dist/model/getNoResultsRateResponse.d.ts +19 -19
- package/dist/model/getNoResultsRateResponse.d.ts.map +1 -1
- package/dist/model/getPurchaseRateResponse.d.ts +20 -0
- package/dist/model/getPurchaseRateResponse.d.ts.map +1 -0
- package/dist/model/getRevenue.d.ts +13 -0
- package/dist/model/getRevenue.d.ts.map +1 -0
- package/dist/model/getSearchesCountResponse.d.ts +11 -11
- package/dist/model/getSearchesCountResponse.d.ts.map +1 -1
- package/dist/model/getSearchesNoClicksResponse.d.ts +7 -7
- package/dist/model/getSearchesNoClicksResponse.d.ts.map +1 -1
- package/dist/model/getSearchesNoResultsResponse.d.ts +7 -7
- package/dist/model/getSearchesNoResultsResponse.d.ts.map +1 -1
- package/dist/model/getStatusResponse.d.ts +6 -6
- package/dist/model/getStatusResponse.d.ts.map +1 -1
- package/dist/model/getTopCountriesResponse.d.ts +7 -7
- package/dist/model/getTopCountriesResponse.d.ts.map +1 -1
- package/dist/model/getTopFilterAttribute.d.ts +10 -10
- package/dist/model/getTopFilterAttribute.d.ts.map +1 -1
- package/dist/model/getTopFilterAttributesResponse.d.ts +7 -7
- package/dist/model/getTopFilterAttributesResponse.d.ts.map +1 -1
- package/dist/model/getTopFilterForAttribute.d.ts +16 -18
- package/dist/model/getTopFilterForAttribute.d.ts.map +1 -1
- package/dist/model/getTopFilterForAttributeResponse.d.ts +7 -7
- package/dist/model/getTopFilterForAttributeResponse.d.ts.map +1 -1
- package/dist/model/getTopFiltersNoResultsResponse.d.ts +7 -7
- package/dist/model/getTopFiltersNoResultsResponse.d.ts.map +1 -1
- package/dist/model/getTopFiltersNoResultsValue.d.ts +12 -14
- package/dist/model/getTopFiltersNoResultsValue.d.ts.map +1 -1
- package/dist/model/getTopFiltersNoResultsValues.d.ts +11 -11
- package/dist/model/getTopFiltersNoResultsValues.d.ts.map +1 -1
- package/dist/model/getTopHitsResponse.d.ts +4 -3
- package/dist/model/getTopHitsResponse.d.ts.map +1 -1
- package/dist/model/getTopSearchesResponse.d.ts +4 -3
- package/dist/model/getTopSearchesResponse.d.ts.map +1 -1
- package/dist/model/getUsersCountResponse.d.ts +11 -11
- package/dist/model/getUsersCountResponse.d.ts.map +1 -1
- package/dist/model/index.d.ts +56 -44
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/operator.d.ts +5 -0
- package/dist/model/operator.d.ts.map +1 -0
- package/dist/model/orderBy.d.ts +4 -1
- package/dist/model/orderBy.d.ts.map +1 -1
- package/dist/model/topCountry.d.ts +10 -10
- package/dist/model/topCountry.d.ts.map +1 -1
- package/dist/model/topHit.d.ts +10 -10
- package/dist/model/topHit.d.ts.map +1 -1
- package/dist/model/topHitWithAnalytics.d.ts +30 -30
- package/dist/model/topHitWithAnalytics.d.ts.map +1 -1
- package/dist/model/topHitWithRevenueAnalytics.d.ts +52 -0
- package/dist/model/topHitWithRevenueAnalytics.d.ts.map +1 -0
- package/dist/model/topHitsResponse.d.ts +7 -7
- package/dist/model/topHitsResponse.d.ts.map +1 -1
- package/dist/model/topHitsResponseWithAnalytics.d.ts +7 -7
- package/dist/model/topHitsResponseWithAnalytics.d.ts.map +1 -1
- package/dist/model/topHitsResponseWithRevenueAnalytics.d.ts +8 -0
- package/dist/model/topHitsResponseWithRevenueAnalytics.d.ts.map +1 -0
- package/dist/model/topSearch.d.ts +14 -14
- package/dist/model/topSearch.d.ts.map +1 -1
- package/dist/model/topSearchWithAnalytics.d.ts +43 -38
- package/dist/model/topSearchWithAnalytics.d.ts.map +1 -1
- package/dist/model/topSearchWithRevenueAnalytics.d.ts +65 -0
- package/dist/model/topSearchWithRevenueAnalytics.d.ts.map +1 -0
- package/dist/model/topSearchesResponse.d.ts +7 -7
- package/dist/model/topSearchesResponse.d.ts.map +1 -1
- package/dist/model/topSearchesResponseWithAnalytics.d.ts +7 -7
- package/dist/model/topSearchesResponseWithAnalytics.d.ts.map +1 -1
- package/dist/model/topSearchesResponseWithRevenueAnalytics.d.ts +8 -0
- package/dist/model/topSearchesResponseWithRevenueAnalytics.d.ts.map +1 -0
- package/dist/src/analyticsClient.d.ts +391 -318
- package/dist/src/analyticsClient.d.ts.map +1 -1
- package/index.js +1 -1
- package/model/clickPositionsInner.ts +16 -0
- package/model/clientMethodProps.ts +211 -137
- package/model/currenciesValue.ts +16 -0
- package/model/dailyAddToCartRates.ts +23 -0
- package/model/dailyAverageClicks.ts +18 -0
- package/model/dailyClickThroughRates.ts +23 -0
- package/model/dailyConversionRates.ts +23 -0
- package/model/dailyNoClickRates.ts +23 -0
- package/model/dailyNoResultsRates.ts +23 -0
- package/model/dailyPurchaseRates.ts +23 -0
- package/model/dailyRevenue.ts +15 -0
- package/model/dailySearches.ts +13 -0
- package/model/dailySearchesNoClicks.ts +18 -0
- package/model/dailySearchesNoResults.ts +18 -0
- package/model/dailyUsers.ts +13 -0
- package/model/direction.ts +1 -1
- package/model/errorBase.ts +1 -1
- package/model/getAddToCartRateResponse.ts +25 -0
- package/model/getAverageClickPositionResponse.ts +7 -7
- package/model/getClickPositionsResponse.ts +4 -4
- package/model/getClickThroughRateResponse.ts +8 -8
- package/model/getConversionRateResponse.ts +25 -0
- package/model/getNoClickRateResponse.ts +7 -7
- package/model/getNoResultsRateResponse.ts +7 -7
- package/model/getPurchaseRateResponse.ts +25 -0
- package/model/getRevenue.ts +16 -0
- package/model/getSearchesCountResponse.ts +5 -5
- package/model/getSearchesNoClicksResponse.ts +4 -4
- package/model/getSearchesNoResultsResponse.ts +4 -4
- package/model/getStatusResponse.ts +3 -3
- package/model/getTopCountriesResponse.ts +2 -2
- package/model/getTopFilterAttribute.ts +3 -3
- package/model/getTopFilterAttributesResponse.ts +2 -2
- package/model/getTopFilterForAttribute.ts +7 -8
- package/model/getTopFilterForAttributeResponse.ts +2 -2
- package/model/getTopFiltersNoResultsResponse.ts +3 -3
- package/model/getTopFiltersNoResultsValue.ts +6 -7
- package/model/getTopFiltersNoResultsValues.ts +3 -3
- package/model/getTopHitsResponse.ts +6 -2
- package/model/getTopSearchesResponse.ts +4 -2
- package/model/getUsersCountResponse.ts +5 -5
- package/model/index.ts +24 -12
- package/model/operator.ts +6 -0
- package/model/orderBy.ts +4 -1
- package/model/topCountry.ts +3 -3
- package/model/topHit.ts +3 -3
- package/model/topHitWithAnalytics.ts +11 -11
- package/model/topHitWithRevenueAnalytics.ts +65 -0
- package/model/topHitsResponse.ts +2 -2
- package/model/topHitsResponseWithAnalytics.ts +2 -2
- package/model/topHitsResponseWithRevenueAnalytics.ts +10 -0
- package/model/topSearch.ts +4 -4
- package/model/topSearchWithAnalytics.ts +20 -13
- package/model/topSearchWithRevenueAnalytics.ts +81 -0
- package/model/topSearchesResponse.ts +2 -2
- package/model/topSearchesResponseWithAnalytics.ts +2 -2
- package/model/topSearchesResponseWithRevenueAnalytics.ts +10 -0
- package/package.json +10 -9
- package/dist/model/averageClickEvent.d.ts +0 -15
- package/dist/model/averageClickEvent.d.ts.map +0 -1
- package/dist/model/clickPosition.d.ts +0 -11
- package/dist/model/clickPosition.d.ts.map +0 -1
- package/dist/model/clickThroughRateEvent.d.ts +0 -19
- package/dist/model/clickThroughRateEvent.d.ts.map +0 -1
- package/dist/model/conversionRateEvent.d.ts +0 -19
- package/dist/model/conversionRateEvent.d.ts.map +0 -1
- package/dist/model/getConversationRateResponse.d.ts +0 -20
- package/dist/model/getConversationRateResponse.d.ts.map +0 -1
- package/dist/model/noClickRateEvent.d.ts +0 -19
- package/dist/model/noClickRateEvent.d.ts.map +0 -1
- package/dist/model/noResultsRateEvent.d.ts +0 -19
- package/dist/model/noResultsRateEvent.d.ts.map +0 -1
- package/dist/model/searchEvent.d.ts +0 -11
- package/dist/model/searchEvent.d.ts.map +0 -1
- package/dist/model/searchNoClickEvent.d.ts +0 -15
- package/dist/model/searchNoClickEvent.d.ts.map +0 -1
- package/dist/model/searchNoResultEvent.d.ts +0 -15
- package/dist/model/searchNoResultEvent.d.ts.map +0 -1
- package/dist/model/userWithDate.d.ts +0 -11
- package/dist/model/userWithDate.d.ts.map +0 -1
- package/model/averageClickEvent.ts +0 -18
- package/model/clickPosition.ts +0 -13
- package/model/clickThroughRateEvent.ts +0 -23
- package/model/conversionRateEvent.ts +0 -23
- package/model/getConversationRateResponse.ts +0 -25
- package/model/noClickRateEvent.ts +0 -23
- package/model/noResultsRateEvent.ts +0 -23
- package/model/searchEvent.ts +0 -13
- package/model/searchNoClickEvent.ts +0 -18
- package/model/searchNoResultEvent.ts +0 -18
- package/model/userWithDate.ts +0 -13
|
@@ -7,53 +7,69 @@ function createAuth(appId, apiKey, authMode = 'WithinHeaders') {
|
|
|
7
7
|
headers() {
|
|
8
8
|
return authMode === 'WithinHeaders' ? credentials : {};
|
|
9
9
|
},
|
|
10
|
-
|
|
11
10
|
queryParameters() {
|
|
12
11
|
return authMode === 'WithinQueryParameters' ? credentials : {};
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
};
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
function createBrowserLocalStorageCache(options) {
|
|
19
|
-
let storage;
|
|
20
|
-
|
|
17
|
+
let storage;
|
|
18
|
+
// We've changed the namespace to avoid conflicts with v4, as this version is a huge breaking change
|
|
21
19
|
const namespaceKey = `algolia-client-js-${options.key}`;
|
|
22
|
-
|
|
23
20
|
function getStorage() {
|
|
24
21
|
if (storage === undefined) {
|
|
25
22
|
storage = options.localStorage || window.localStorage;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
24
|
return storage;
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
function getNamespace() {
|
|
32
27
|
return JSON.parse(getStorage().getItem(namespaceKey) || '{}');
|
|
33
28
|
}
|
|
34
|
-
|
|
29
|
+
function setNamespace(namespace) {
|
|
30
|
+
getStorage().setItem(namespaceKey, JSON.stringify(namespace));
|
|
31
|
+
}
|
|
32
|
+
function removeOutdatedCacheItems() {
|
|
33
|
+
const timeToLive = options.timeToLive ? options.timeToLive * 1000 : null;
|
|
34
|
+
const namespace = getNamespace();
|
|
35
|
+
const filteredNamespaceWithoutOldFormattedCacheItems = Object.fromEntries(Object.entries(namespace).filter(([, cacheItem]) => {
|
|
36
|
+
return cacheItem.timestamp !== undefined;
|
|
37
|
+
}));
|
|
38
|
+
setNamespace(filteredNamespaceWithoutOldFormattedCacheItems);
|
|
39
|
+
if (!timeToLive) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const filteredNamespaceWithoutExpiredItems = Object.fromEntries(Object.entries(filteredNamespaceWithoutOldFormattedCacheItems).filter(([, cacheItem]) => {
|
|
43
|
+
const currentTimestamp = new Date().getTime();
|
|
44
|
+
const isExpired = cacheItem.timestamp + timeToLive < currentTimestamp;
|
|
45
|
+
return !isExpired;
|
|
46
|
+
}));
|
|
47
|
+
setNamespace(filteredNamespaceWithoutExpiredItems);
|
|
48
|
+
}
|
|
35
49
|
return {
|
|
36
50
|
get(key, defaultValue, events = {
|
|
37
51
|
miss: () => Promise.resolve()
|
|
38
52
|
}) {
|
|
39
53
|
return Promise.resolve().then(() => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
removeOutdatedCacheItems();
|
|
55
|
+
return getNamespace()[JSON.stringify(key)];
|
|
56
|
+
}).then(value => {
|
|
57
|
+
return Promise.all([value ? value.value : defaultValue(), value !== undefined]);
|
|
43
58
|
}).then(([value, exists]) => {
|
|
44
59
|
return Promise.all([value, exists || events.miss(value)]);
|
|
45
60
|
}).then(([value]) => value);
|
|
46
61
|
},
|
|
47
|
-
|
|
48
62
|
set(key, value) {
|
|
49
63
|
return Promise.resolve().then(() => {
|
|
50
64
|
const namespace = getNamespace();
|
|
51
|
-
namespace[JSON.stringify(key)] =
|
|
65
|
+
namespace[JSON.stringify(key)] = {
|
|
66
|
+
timestamp: new Date().getTime(),
|
|
67
|
+
value
|
|
68
|
+
};
|
|
52
69
|
getStorage().setItem(namespaceKey, JSON.stringify(namespace));
|
|
53
70
|
return value;
|
|
54
71
|
});
|
|
55
72
|
},
|
|
56
|
-
|
|
57
73
|
delete(key) {
|
|
58
74
|
return Promise.resolve().then(() => {
|
|
59
75
|
const namespace = getNamespace();
|
|
@@ -61,13 +77,11 @@ function createBrowserLocalStorageCache(options) {
|
|
|
61
77
|
getStorage().setItem(namespaceKey, JSON.stringify(namespace));
|
|
62
78
|
});
|
|
63
79
|
},
|
|
64
|
-
|
|
65
80
|
clear() {
|
|
66
81
|
return Promise.resolve().then(() => {
|
|
67
82
|
getStorage().removeItem(namespaceKey);
|
|
68
83
|
});
|
|
69
84
|
}
|
|
70
|
-
|
|
71
85
|
};
|
|
72
86
|
}
|
|
73
87
|
|
|
@@ -79,30 +93,24 @@ function createNullCache() {
|
|
|
79
93
|
const value = defaultValue();
|
|
80
94
|
return value.then(result => Promise.all([result, events.miss(result)])).then(([result]) => result);
|
|
81
95
|
},
|
|
82
|
-
|
|
83
96
|
set(_key, value) {
|
|
84
97
|
return Promise.resolve(value);
|
|
85
98
|
},
|
|
86
|
-
|
|
87
99
|
delete(_key) {
|
|
88
100
|
return Promise.resolve();
|
|
89
101
|
},
|
|
90
|
-
|
|
91
102
|
clear() {
|
|
92
103
|
return Promise.resolve();
|
|
93
104
|
}
|
|
94
|
-
|
|
95
105
|
};
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
function createFallbackableCache(options) {
|
|
99
109
|
const caches = [...options.caches];
|
|
100
110
|
const current = caches.shift();
|
|
101
|
-
|
|
102
111
|
if (current === undefined) {
|
|
103
112
|
return createNullCache();
|
|
104
113
|
}
|
|
105
|
-
|
|
106
114
|
return {
|
|
107
115
|
get(key, defaultValue, events = {
|
|
108
116
|
miss: () => Promise.resolve()
|
|
@@ -113,7 +121,6 @@ function createFallbackableCache(options) {
|
|
|
113
121
|
}).get(key, defaultValue, events);
|
|
114
122
|
});
|
|
115
123
|
},
|
|
116
|
-
|
|
117
124
|
set(key, value) {
|
|
118
125
|
return current.set(key, value).catch(() => {
|
|
119
126
|
return createFallbackableCache({
|
|
@@ -121,7 +128,6 @@ function createFallbackableCache(options) {
|
|
|
121
128
|
}).set(key, value);
|
|
122
129
|
});
|
|
123
130
|
},
|
|
124
|
-
|
|
125
131
|
delete(key) {
|
|
126
132
|
return current.delete(key).catch(() => {
|
|
127
133
|
return createFallbackableCache({
|
|
@@ -129,7 +135,6 @@ function createFallbackableCache(options) {
|
|
|
129
135
|
}).delete(key);
|
|
130
136
|
});
|
|
131
137
|
},
|
|
132
|
-
|
|
133
138
|
clear() {
|
|
134
139
|
return current.clear().catch(() => {
|
|
135
140
|
return createFallbackableCache({
|
|
@@ -137,7 +142,6 @@ function createFallbackableCache(options) {
|
|
|
137
142
|
}).clear();
|
|
138
143
|
});
|
|
139
144
|
}
|
|
140
|
-
|
|
141
145
|
};
|
|
142
146
|
}
|
|
143
147
|
|
|
@@ -150,30 +154,24 @@ function createMemoryCache(options = {
|
|
|
150
154
|
miss: () => Promise.resolve()
|
|
151
155
|
}) {
|
|
152
156
|
const keyAsString = JSON.stringify(key);
|
|
153
|
-
|
|
154
157
|
if (keyAsString in cache) {
|
|
155
158
|
return Promise.resolve(options.serializable ? JSON.parse(cache[keyAsString]) : cache[keyAsString]);
|
|
156
159
|
}
|
|
157
|
-
|
|
158
160
|
const promise = defaultValue();
|
|
159
161
|
return promise.then(value => events.miss(value)).then(() => promise);
|
|
160
162
|
},
|
|
161
|
-
|
|
162
163
|
set(key, value) {
|
|
163
164
|
cache[JSON.stringify(key)] = options.serializable ? JSON.stringify(value) : value;
|
|
164
165
|
return Promise.resolve(value);
|
|
165
166
|
},
|
|
166
|
-
|
|
167
167
|
delete(key) {
|
|
168
168
|
delete cache[JSON.stringify(key)];
|
|
169
169
|
return Promise.resolve();
|
|
170
170
|
},
|
|
171
|
-
|
|
172
171
|
clear() {
|
|
173
172
|
cache = {};
|
|
174
173
|
return Promise.resolve();
|
|
175
174
|
}
|
|
176
|
-
|
|
177
175
|
};
|
|
178
176
|
}
|
|
179
177
|
|
|
@@ -182,16 +180,14 @@ function createMemoryCache(options = {
|
|
|
182
180
|
const EXPIRATION_DELAY = 2 * 60 * 1000;
|
|
183
181
|
function createStatefulHost(host, status = 'up') {
|
|
184
182
|
const lastUpdate = Date.now();
|
|
185
|
-
|
|
186
183
|
function isUp() {
|
|
187
184
|
return status === 'up' || Date.now() - lastUpdate > EXPIRATION_DELAY;
|
|
188
185
|
}
|
|
189
|
-
|
|
190
186
|
function isTimedOut() {
|
|
191
187
|
return status === 'timed out' && Date.now() - lastUpdate <= EXPIRATION_DELAY;
|
|
192
188
|
}
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
return {
|
|
190
|
+
...host,
|
|
195
191
|
status,
|
|
196
192
|
lastUpdate,
|
|
197
193
|
isUp,
|
|
@@ -199,7 +195,22 @@ function createStatefulHost(host, status = 'up') {
|
|
|
199
195
|
};
|
|
200
196
|
}
|
|
201
197
|
|
|
198
|
+
function _toPrimitive(t, r) {
|
|
199
|
+
if ("object" != typeof t || !t) return t;
|
|
200
|
+
var e = t[Symbol.toPrimitive];
|
|
201
|
+
if (void 0 !== e) {
|
|
202
|
+
var i = e.call(t, r || "default");
|
|
203
|
+
if ("object" != typeof i) return i;
|
|
204
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
205
|
+
}
|
|
206
|
+
return ("string" === r ? String : Number)(t);
|
|
207
|
+
}
|
|
208
|
+
function _toPropertyKey(t) {
|
|
209
|
+
var i = _toPrimitive(t, "string");
|
|
210
|
+
return "symbol" == typeof i ? i : i + "";
|
|
211
|
+
}
|
|
202
212
|
function _defineProperty(obj, key, value) {
|
|
213
|
+
key = _toPropertyKey(key);
|
|
203
214
|
if (key in obj) {
|
|
204
215
|
Object.defineProperty(obj, key, {
|
|
205
216
|
value: value,
|
|
@@ -210,79 +221,71 @@ function _defineProperty(obj, key, value) {
|
|
|
210
221
|
} else {
|
|
211
222
|
obj[key] = value;
|
|
212
223
|
}
|
|
213
|
-
|
|
214
224
|
return obj;
|
|
215
225
|
}
|
|
216
226
|
|
|
217
227
|
class AlgoliaError extends Error {
|
|
218
228
|
constructor(message, name) {
|
|
219
229
|
super(message);
|
|
220
|
-
|
|
221
230
|
_defineProperty(this, "name", 'AlgoliaError');
|
|
222
|
-
|
|
223
231
|
if (name) {
|
|
224
232
|
this.name = name;
|
|
225
233
|
}
|
|
226
234
|
}
|
|
227
|
-
|
|
228
235
|
}
|
|
229
236
|
class ErrorWithStackTrace extends AlgoliaError {
|
|
230
237
|
constructor(message, stackTrace, name) {
|
|
231
|
-
super(message, name);
|
|
232
|
-
|
|
238
|
+
super(message, name);
|
|
239
|
+
// the array and object should be frozen to reflect the stackTrace at the time of the error
|
|
233
240
|
_defineProperty(this, "stackTrace", void 0);
|
|
234
|
-
|
|
235
241
|
this.stackTrace = stackTrace;
|
|
236
242
|
}
|
|
237
|
-
|
|
238
243
|
}
|
|
239
244
|
class RetryError extends ErrorWithStackTrace {
|
|
240
245
|
constructor(stackTrace) {
|
|
241
|
-
super('Unreachable hosts - your application id may be incorrect. If the error persists,
|
|
246
|
+
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.', stackTrace, 'RetryError');
|
|
242
247
|
}
|
|
243
|
-
|
|
244
248
|
}
|
|
245
249
|
class ApiError extends ErrorWithStackTrace {
|
|
246
|
-
constructor(message, status, stackTrace) {
|
|
247
|
-
super(message, stackTrace,
|
|
248
|
-
|
|
250
|
+
constructor(message, status, stackTrace, name = 'ApiError') {
|
|
251
|
+
super(message, stackTrace, name);
|
|
249
252
|
_defineProperty(this, "status", void 0);
|
|
250
|
-
|
|
251
253
|
this.status = status;
|
|
252
254
|
}
|
|
253
|
-
|
|
254
255
|
}
|
|
255
256
|
class DeserializationError extends AlgoliaError {
|
|
256
257
|
constructor(message, response) {
|
|
257
258
|
super(message, 'DeserializationError');
|
|
258
|
-
|
|
259
259
|
_defineProperty(this, "response", void 0);
|
|
260
|
-
|
|
261
260
|
this.response = response;
|
|
262
261
|
}
|
|
263
|
-
|
|
262
|
+
}
|
|
263
|
+
// DetailedApiError is only used by the ingestion client to return more informative error, other clients will use ApiClient.
|
|
264
|
+
class DetailedApiError extends ApiError {
|
|
265
|
+
constructor(message, status, error, stackTrace) {
|
|
266
|
+
super(message, status, stackTrace, 'DetailedApiError');
|
|
267
|
+
_defineProperty(this, "error", void 0);
|
|
268
|
+
this.error = error;
|
|
269
|
+
}
|
|
264
270
|
}
|
|
265
271
|
function serializeUrl(host, path, queryParameters) {
|
|
266
272
|
const queryParametersAsString = serializeQueryParameters(queryParameters);
|
|
267
|
-
let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.
|
|
268
|
-
|
|
273
|
+
let url = `${host.protocol}://${host.url}${host.port ? `:${host.port}` : ''}/${path.charAt(0) === '/' ? path.substring(1) : path}`;
|
|
269
274
|
if (queryParametersAsString.length) {
|
|
270
275
|
url += `?${queryParametersAsString}`;
|
|
271
276
|
}
|
|
272
|
-
|
|
273
277
|
return url;
|
|
274
278
|
}
|
|
275
279
|
function serializeQueryParameters(parameters) {
|
|
276
280
|
const isObjectOrArray = value => Object.prototype.toString.call(value) === '[object Object]' || Object.prototype.toString.call(value) === '[object Array]';
|
|
277
|
-
|
|
278
|
-
return Object.keys(parameters).map(key => `${key}=${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('&');
|
|
279
282
|
}
|
|
280
283
|
function serializeData(request, requestOptions) {
|
|
281
284
|
if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
|
|
282
285
|
return undefined;
|
|
283
286
|
}
|
|
284
|
-
|
|
285
|
-
|
|
287
|
+
const data = Array.isArray(request.data) ? request.data : {
|
|
288
|
+
...request.data,
|
|
286
289
|
...requestOptions.data
|
|
287
290
|
};
|
|
288
291
|
return JSON.stringify(data);
|
|
@@ -312,14 +315,16 @@ function deserializeFailure({
|
|
|
312
315
|
content,
|
|
313
316
|
status
|
|
314
317
|
}, stackFrame) {
|
|
315
|
-
let message = content;
|
|
316
|
-
|
|
317
318
|
try {
|
|
318
|
-
|
|
319
|
-
|
|
319
|
+
const parsed = JSON.parse(content);
|
|
320
|
+
if ('error' in parsed) {
|
|
321
|
+
return new DetailedApiError(parsed.message, status, parsed.error, stackFrame);
|
|
322
|
+
}
|
|
323
|
+
return new ApiError(parsed.message, status, stackFrame);
|
|
324
|
+
} catch (e) {
|
|
325
|
+
// ..
|
|
320
326
|
}
|
|
321
|
-
|
|
322
|
-
return new ApiError(message, status, stackFrame);
|
|
327
|
+
return new ApiError(content, status, stackFrame);
|
|
323
328
|
}
|
|
324
329
|
|
|
325
330
|
function isNetworkError({
|
|
@@ -350,9 +355,12 @@ function stackFrameWithoutCredentials(stackFrame) {
|
|
|
350
355
|
const modifiedHeaders = stackFrame.request.headers['x-algolia-api-key'] ? {
|
|
351
356
|
'x-algolia-api-key': '*****'
|
|
352
357
|
} : {};
|
|
353
|
-
return {
|
|
354
|
-
|
|
355
|
-
|
|
358
|
+
return {
|
|
359
|
+
...stackFrame,
|
|
360
|
+
request: {
|
|
361
|
+
...stackFrame.request,
|
|
362
|
+
headers: {
|
|
363
|
+
...stackFrame.request.headers,
|
|
356
364
|
...modifiedHeaders
|
|
357
365
|
}
|
|
358
366
|
}
|
|
@@ -377,53 +385,49 @@ function createTransporter({
|
|
|
377
385
|
});
|
|
378
386
|
}));
|
|
379
387
|
const hostsUp = statefulHosts.filter(host => host.isUp());
|
|
380
|
-
const hostsTimedOut = statefulHosts.filter(host => host.isTimedOut());
|
|
381
|
-
|
|
388
|
+
const hostsTimedOut = statefulHosts.filter(host => host.isTimedOut());
|
|
389
|
+
// Note, we put the hosts that previously timed out on the end of the list.
|
|
382
390
|
const hostsAvailable = [...hostsUp, ...hostsTimedOut];
|
|
383
391
|
const compatibleHostsAvailable = hostsAvailable.length > 0 ? hostsAvailable : compatibleHosts;
|
|
384
392
|
return {
|
|
385
393
|
hosts: compatibleHostsAvailable,
|
|
386
|
-
|
|
387
394
|
getTimeout(timeoutsCount, baseTimeout) {
|
|
388
|
-
/**
|
|
389
|
-
* Imagine that you have 4 hosts, if timeouts will increase
|
|
390
|
-
* on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
|
|
391
|
-
*
|
|
392
|
-
* Note that, the very next request, we start from the previous timeout.
|
|
393
|
-
*
|
|
394
|
-
* 5 (timed out) > 6 (timed out) > 7 ...
|
|
395
|
-
*
|
|
396
|
-
* This strategy may need to be reviewed, but is the strategy on the our
|
|
397
|
-
* current v3 version.
|
|
395
|
+
/**
|
|
396
|
+
* Imagine that you have 4 hosts, if timeouts will increase
|
|
397
|
+
* on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
|
|
398
|
+
*
|
|
399
|
+
* Note that, the very next request, we start from the previous timeout.
|
|
400
|
+
*
|
|
401
|
+
* 5 (timed out) > 6 (timed out) > 7 ...
|
|
402
|
+
*
|
|
403
|
+
* This strategy may need to be reviewed, but is the strategy on the our
|
|
404
|
+
* current v3 version.
|
|
398
405
|
*/
|
|
399
406
|
const timeoutMultiplier = hostsTimedOut.length === 0 && timeoutsCount === 0 ? 1 : hostsTimedOut.length + 3 + timeoutsCount;
|
|
400
407
|
return timeoutMultiplier * baseTimeout;
|
|
401
408
|
}
|
|
402
|
-
|
|
403
409
|
};
|
|
404
410
|
}
|
|
405
|
-
|
|
406
411
|
async function retryableRequest(request, requestOptions, isRead = true) {
|
|
407
412
|
const stackTrace = [];
|
|
408
|
-
/**
|
|
409
|
-
* First we prepare the payload that do not depend from hosts.
|
|
413
|
+
/**
|
|
414
|
+
* First we prepare the payload that do not depend from hosts.
|
|
410
415
|
*/
|
|
411
|
-
|
|
412
416
|
const data = serializeData(request, requestOptions);
|
|
413
|
-
const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
|
|
414
|
-
|
|
415
|
-
const dataQueryParameters = request.method === 'GET' ? {
|
|
417
|
+
const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
|
|
418
|
+
// On `GET`, the data is proxied to query parameters.
|
|
419
|
+
const dataQueryParameters = request.method === 'GET' ? {
|
|
420
|
+
...request.data,
|
|
416
421
|
...requestOptions.data
|
|
417
422
|
} : {};
|
|
418
|
-
const queryParameters = {
|
|
423
|
+
const queryParameters = {
|
|
424
|
+
...baseQueryParameters,
|
|
419
425
|
...request.queryParameters,
|
|
420
426
|
...dataQueryParameters
|
|
421
427
|
};
|
|
422
|
-
|
|
423
428
|
if (algoliaAgent.value) {
|
|
424
429
|
queryParameters['x-algolia-agent'] = algoliaAgent.value;
|
|
425
430
|
}
|
|
426
|
-
|
|
427
431
|
if (requestOptions && requestOptions.queryParameters) {
|
|
428
432
|
for (const key of Object.keys(requestOptions.queryParameters)) {
|
|
429
433
|
// We want to keep `undefined` and `null` values,
|
|
@@ -436,25 +440,19 @@ function createTransporter({
|
|
|
436
440
|
}
|
|
437
441
|
}
|
|
438
442
|
}
|
|
439
|
-
|
|
440
443
|
let timeoutsCount = 0;
|
|
441
|
-
|
|
442
444
|
const retry = async (retryableHosts, getTimeout) => {
|
|
443
|
-
/**
|
|
444
|
-
* We iterate on each host, until there is no host left.
|
|
445
|
+
/**
|
|
446
|
+
* We iterate on each host, until there is no host left.
|
|
445
447
|
*/
|
|
446
448
|
const host = retryableHosts.pop();
|
|
447
|
-
|
|
448
449
|
if (host === undefined) {
|
|
449
450
|
throw new RetryError(stackTraceWithoutCredentials(stackTrace));
|
|
450
451
|
}
|
|
451
|
-
|
|
452
452
|
let responseTimeout = requestOptions.timeout;
|
|
453
|
-
|
|
454
453
|
if (responseTimeout === undefined) {
|
|
455
454
|
responseTimeout = isRead ? timeouts.read : timeouts.write;
|
|
456
455
|
}
|
|
457
|
-
|
|
458
456
|
const payload = {
|
|
459
457
|
data,
|
|
460
458
|
headers,
|
|
@@ -463,12 +461,11 @@ function createTransporter({
|
|
|
463
461
|
connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
|
|
464
462
|
responseTimeout: getTimeout(timeoutsCount, responseTimeout)
|
|
465
463
|
};
|
|
466
|
-
/**
|
|
467
|
-
* The stackFrame is pushed to the stackTrace so we
|
|
468
|
-
* can have information about onRetry and onFailure
|
|
469
|
-
* decisions.
|
|
464
|
+
/**
|
|
465
|
+
* The stackFrame is pushed to the stackTrace so we
|
|
466
|
+
* can have information about onRetry and onFailure
|
|
467
|
+
* decisions.
|
|
470
468
|
*/
|
|
471
|
-
|
|
472
469
|
const pushToStackTrace = response => {
|
|
473
470
|
const stackFrame = {
|
|
474
471
|
request: payload,
|
|
@@ -479,102 +476,85 @@ function createTransporter({
|
|
|
479
476
|
stackTrace.push(stackFrame);
|
|
480
477
|
return stackFrame;
|
|
481
478
|
};
|
|
482
|
-
|
|
483
479
|
const response = await requester.send(payload);
|
|
484
|
-
|
|
485
480
|
if (isRetryable(response)) {
|
|
486
|
-
const stackFrame = pushToStackTrace(response);
|
|
487
|
-
|
|
481
|
+
const stackFrame = pushToStackTrace(response);
|
|
482
|
+
// If response is a timeout, we increase the number of timeouts so we can increase the timeout later.
|
|
488
483
|
if (response.isTimedOut) {
|
|
489
484
|
timeoutsCount++;
|
|
490
485
|
}
|
|
491
|
-
/**
|
|
492
|
-
* Failures are individually sent to the logger, allowing
|
|
493
|
-
* the end user to debug / store stack frames even
|
|
494
|
-
* when a retry error does not happen.
|
|
486
|
+
/**
|
|
487
|
+
* Failures are individually sent to the logger, allowing
|
|
488
|
+
* the end user to debug / store stack frames even
|
|
489
|
+
* when a retry error does not happen.
|
|
495
490
|
*/
|
|
496
491
|
// eslint-disable-next-line no-console -- this will be fixed by exposing a `logger` to the transporter
|
|
497
|
-
|
|
498
|
-
|
|
499
492
|
console.log('Retryable failure', stackFrameWithoutCredentials(stackFrame));
|
|
500
|
-
/**
|
|
501
|
-
* We also store the state of the host in failure cases. If the host, is
|
|
502
|
-
* down it will remain down for the next 2 minutes. In a timeout situation,
|
|
503
|
-
* this host will be added end of the list of hosts on the next request.
|
|
493
|
+
/**
|
|
494
|
+
* We also store the state of the host in failure cases. If the host, is
|
|
495
|
+
* down it will remain down for the next 2 minutes. In a timeout situation,
|
|
496
|
+
* this host will be added end of the list of hosts on the next request.
|
|
504
497
|
*/
|
|
505
|
-
|
|
506
498
|
await hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down'));
|
|
507
499
|
return retry(retryableHosts, getTimeout);
|
|
508
500
|
}
|
|
509
|
-
|
|
510
501
|
if (isSuccess(response)) {
|
|
511
502
|
return deserializeSuccess(response);
|
|
512
503
|
}
|
|
513
|
-
|
|
514
504
|
pushToStackTrace(response);
|
|
515
505
|
throw deserializeFailure(response, stackTrace);
|
|
516
506
|
};
|
|
517
|
-
/**
|
|
518
|
-
* Finally, for each retryable host perform request until we got a non
|
|
519
|
-
* retryable response. Some notes here:
|
|
520
|
-
*
|
|
521
|
-
* 1. The reverse here is applied so we can apply a `pop` later on => more performant.
|
|
522
|
-
* 2. We also get from the retryable options a timeout multiplier that is tailored
|
|
523
|
-
* for the current context.
|
|
507
|
+
/**
|
|
508
|
+
* Finally, for each retryable host perform request until we got a non
|
|
509
|
+
* retryable response. Some notes here:
|
|
510
|
+
*
|
|
511
|
+
* 1. The reverse here is applied so we can apply a `pop` later on => more performant.
|
|
512
|
+
* 2. We also get from the retryable options a timeout multiplier that is tailored
|
|
513
|
+
* for the current context.
|
|
524
514
|
*/
|
|
525
|
-
|
|
526
|
-
|
|
527
515
|
const compatibleHosts = hosts.filter(host => host.accept === 'readWrite' || (isRead ? host.accept === 'read' : host.accept === 'write'));
|
|
528
516
|
const options = await createRetryableOptions(compatibleHosts);
|
|
529
517
|
return retry([...options.hosts].reverse(), options.getTimeout);
|
|
530
518
|
}
|
|
531
|
-
|
|
532
519
|
function createRequest(request, requestOptions = {}) {
|
|
533
|
-
/**
|
|
534
|
-
* A read request is either a `GET` request, or a request that we make
|
|
535
|
-
* via the `read` transporter (e.g. `search`).
|
|
520
|
+
/**
|
|
521
|
+
* A read request is either a `GET` request, or a request that we make
|
|
522
|
+
* via the `read` transporter (e.g. `search`).
|
|
536
523
|
*/
|
|
537
524
|
const isRead = request.useReadTransporter || request.method === 'GET';
|
|
538
|
-
|
|
539
525
|
if (!isRead) {
|
|
540
|
-
/**
|
|
541
|
-
* On write requests, no cache mechanisms are applied, and we
|
|
542
|
-
* proxy the request immediately to the requester.
|
|
526
|
+
/**
|
|
527
|
+
* On write requests, no cache mechanisms are applied, and we
|
|
528
|
+
* proxy the request immediately to the requester.
|
|
543
529
|
*/
|
|
544
530
|
return retryableRequest(request, requestOptions, isRead);
|
|
545
531
|
}
|
|
546
|
-
|
|
547
532
|
const createRetryableRequest = () => {
|
|
548
|
-
/**
|
|
549
|
-
* Then, we prepare a function factory that contains the construction of
|
|
550
|
-
* the retryable request. At this point, we may *not* perform the actual
|
|
551
|
-
* request. But we want to have the function factory ready.
|
|
533
|
+
/**
|
|
534
|
+
* Then, we prepare a function factory that contains the construction of
|
|
535
|
+
* the retryable request. At this point, we may *not* perform the actual
|
|
536
|
+
* request. But we want to have the function factory ready.
|
|
552
537
|
*/
|
|
553
538
|
return retryableRequest(request, requestOptions);
|
|
554
539
|
};
|
|
555
|
-
/**
|
|
556
|
-
* Once we have the function factory ready, we need to determine of the
|
|
557
|
-
* request is "cacheable" - should be cached. Note that, once again,
|
|
558
|
-
* the user can force this option.
|
|
540
|
+
/**
|
|
541
|
+
* Once we have the function factory ready, we need to determine of the
|
|
542
|
+
* request is "cacheable" - should be cached. Note that, once again,
|
|
543
|
+
* the user can force this option.
|
|
559
544
|
*/
|
|
560
|
-
|
|
561
|
-
|
|
562
545
|
const cacheable = requestOptions.cacheable || request.cacheable;
|
|
563
|
-
/**
|
|
564
|
-
* If is not "cacheable", we immediately trigger the retryable request, no
|
|
565
|
-
* need to check cache implementations.
|
|
546
|
+
/**
|
|
547
|
+
* If is not "cacheable", we immediately trigger the retryable request, no
|
|
548
|
+
* need to check cache implementations.
|
|
566
549
|
*/
|
|
567
|
-
|
|
568
550
|
if (cacheable !== true) {
|
|
569
551
|
return createRetryableRequest();
|
|
570
552
|
}
|
|
571
|
-
/**
|
|
572
|
-
* If the request is "cacheable", we need to first compute the key to ask
|
|
573
|
-
* the cache implementations if this request is on progress or if the
|
|
574
|
-
* response already exists on the cache.
|
|
553
|
+
/**
|
|
554
|
+
* If the request is "cacheable", we need to first compute the key to ask
|
|
555
|
+
* the cache implementations if this request is on progress or if the
|
|
556
|
+
* response already exists on the cache.
|
|
575
557
|
*/
|
|
576
|
-
|
|
577
|
-
|
|
578
558
|
const key = {
|
|
579
559
|
request,
|
|
580
560
|
requestOptions,
|
|
@@ -583,33 +563,31 @@ function createTransporter({
|
|
|
583
563
|
headers: baseHeaders
|
|
584
564
|
}
|
|
585
565
|
};
|
|
586
|
-
/**
|
|
587
|
-
* With the computed key, we first ask the responses cache
|
|
588
|
-
* implementation if this request was been resolved before.
|
|
566
|
+
/**
|
|
567
|
+
* With the computed key, we first ask the responses cache
|
|
568
|
+
* implementation if this request was been resolved before.
|
|
589
569
|
*/
|
|
590
|
-
|
|
591
570
|
return responsesCache.get(key, () => {
|
|
592
|
-
/**
|
|
593
|
-
* If the request has never resolved before, we actually ask if there
|
|
594
|
-
* is a current request with the same key on progress.
|
|
571
|
+
/**
|
|
572
|
+
* If the request has never resolved before, we actually ask if there
|
|
573
|
+
* is a current request with the same key on progress.
|
|
595
574
|
*/
|
|
596
575
|
return requestsCache.get(key, () =>
|
|
597
|
-
/**
|
|
598
|
-
* Finally, if there is no request in progress with the same key,
|
|
599
|
-
* this `createRetryableRequest()` will actually trigger the
|
|
600
|
-
* retryable request.
|
|
576
|
+
/**
|
|
577
|
+
* Finally, if there is no request in progress with the same key,
|
|
578
|
+
* this `createRetryableRequest()` will actually trigger the
|
|
579
|
+
* retryable request.
|
|
601
580
|
*/
|
|
602
581
|
requestsCache.set(key, createRetryableRequest()).then(response => Promise.all([requestsCache.delete(key), response]), err => Promise.all([requestsCache.delete(key), Promise.reject(err)])).then(([_, response]) => response));
|
|
603
582
|
}, {
|
|
604
|
-
/**
|
|
605
|
-
* Of course, once we get this response back from the server, we
|
|
606
|
-
* tell response cache to actually store the received response
|
|
607
|
-
* to be used later.
|
|
583
|
+
/**
|
|
584
|
+
* Of course, once we get this response back from the server, we
|
|
585
|
+
* tell response cache to actually store the received response
|
|
586
|
+
* to be used later.
|
|
608
587
|
*/
|
|
609
588
|
miss: response => responsesCache.set(key, response)
|
|
610
589
|
});
|
|
611
590
|
}
|
|
612
|
-
|
|
613
591
|
return {
|
|
614
592
|
hostsCache,
|
|
615
593
|
requester,
|
|
@@ -627,17 +605,13 @@ function createTransporter({
|
|
|
627
605
|
function createAlgoliaAgent(version) {
|
|
628
606
|
const algoliaAgent = {
|
|
629
607
|
value: `Algolia for JavaScript (${version})`,
|
|
630
|
-
|
|
631
608
|
add(options) {
|
|
632
609
|
const addedAlgoliaAgent = `; ${options.segment}${options.version !== undefined ? ` (${options.version})` : ''}`;
|
|
633
|
-
|
|
634
610
|
if (algoliaAgent.value.indexOf(addedAlgoliaAgent) === -1) {
|
|
635
611
|
algoliaAgent.value = `${algoliaAgent.value}${addedAlgoliaAgent}`;
|
|
636
612
|
}
|
|
637
|
-
|
|
638
613
|
return algoliaAgent;
|
|
639
614
|
}
|
|
640
|
-
|
|
641
615
|
};
|
|
642
616
|
return algoliaAgent;
|
|
643
617
|
}
|
|
@@ -659,988 +633,1147 @@ const DEFAULT_CONNECT_TIMEOUT_BROWSER = 1000;
|
|
|
659
633
|
const DEFAULT_READ_TIMEOUT_BROWSER = 2000;
|
|
660
634
|
const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
|
|
661
635
|
|
|
662
|
-
function createXhrRequester() {
|
|
663
|
-
function send(request) {
|
|
664
|
-
return new Promise((resolve) => {
|
|
665
|
-
const baseRequester = new XMLHttpRequest();
|
|
666
|
-
baseRequester.open(request.method, request.url, true);
|
|
667
|
-
Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
|
|
668
|
-
const createTimeout = (timeout, content) => {
|
|
669
|
-
return setTimeout(() => {
|
|
670
|
-
baseRequester.abort();
|
|
671
|
-
resolve({
|
|
672
|
-
status: 0,
|
|
673
|
-
content,
|
|
674
|
-
isTimedOut: true,
|
|
675
|
-
});
|
|
676
|
-
}, timeout);
|
|
677
|
-
};
|
|
678
|
-
const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
|
|
679
|
-
let responseTimeout;
|
|
680
|
-
baseRequester.onreadystatechange = () => {
|
|
681
|
-
if (baseRequester.readyState > baseRequester.OPENED &&
|
|
682
|
-
responseTimeout === undefined) {
|
|
683
|
-
clearTimeout(connectTimeout);
|
|
684
|
-
responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
|
|
685
|
-
}
|
|
686
|
-
};
|
|
687
|
-
baseRequester.onerror = () => {
|
|
688
|
-
// istanbul ignore next
|
|
689
|
-
if (baseRequester.status === 0) {
|
|
690
|
-
clearTimeout(connectTimeout);
|
|
691
|
-
clearTimeout(responseTimeout);
|
|
692
|
-
resolve({
|
|
693
|
-
content: baseRequester.responseText || 'Network request failed',
|
|
694
|
-
status: baseRequester.status,
|
|
695
|
-
isTimedOut: false,
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
baseRequester.onload = () => {
|
|
700
|
-
clearTimeout(connectTimeout);
|
|
701
|
-
clearTimeout(responseTimeout);
|
|
702
|
-
resolve({
|
|
703
|
-
content: baseRequester.responseText,
|
|
704
|
-
status: baseRequester.status,
|
|
705
|
-
isTimedOut: false,
|
|
706
|
-
});
|
|
707
|
-
};
|
|
708
|
-
baseRequester.send(request.data);
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
return { send };
|
|
636
|
+
function createXhrRequester() {
|
|
637
|
+
function send(request) {
|
|
638
|
+
return new Promise((resolve) => {
|
|
639
|
+
const baseRequester = new XMLHttpRequest();
|
|
640
|
+
baseRequester.open(request.method, request.url, true);
|
|
641
|
+
Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
|
|
642
|
+
const createTimeout = (timeout, content) => {
|
|
643
|
+
return setTimeout(() => {
|
|
644
|
+
baseRequester.abort();
|
|
645
|
+
resolve({
|
|
646
|
+
status: 0,
|
|
647
|
+
content,
|
|
648
|
+
isTimedOut: true,
|
|
649
|
+
});
|
|
650
|
+
}, timeout);
|
|
651
|
+
};
|
|
652
|
+
const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
|
|
653
|
+
let responseTimeout;
|
|
654
|
+
baseRequester.onreadystatechange = () => {
|
|
655
|
+
if (baseRequester.readyState > baseRequester.OPENED &&
|
|
656
|
+
responseTimeout === undefined) {
|
|
657
|
+
clearTimeout(connectTimeout);
|
|
658
|
+
responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
baseRequester.onerror = () => {
|
|
662
|
+
// istanbul ignore next
|
|
663
|
+
if (baseRequester.status === 0) {
|
|
664
|
+
clearTimeout(connectTimeout);
|
|
665
|
+
clearTimeout(responseTimeout);
|
|
666
|
+
resolve({
|
|
667
|
+
content: baseRequester.responseText || 'Network request failed',
|
|
668
|
+
status: baseRequester.status,
|
|
669
|
+
isTimedOut: false,
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
baseRequester.onload = () => {
|
|
674
|
+
clearTimeout(connectTimeout);
|
|
675
|
+
clearTimeout(responseTimeout);
|
|
676
|
+
resolve({
|
|
677
|
+
content: baseRequester.responseText,
|
|
678
|
+
status: baseRequester.status,
|
|
679
|
+
isTimedOut: false,
|
|
680
|
+
});
|
|
681
|
+
};
|
|
682
|
+
baseRequester.send(request.data);
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
return { send };
|
|
712
686
|
}
|
|
713
687
|
|
|
714
|
-
//
|
|
715
|
-
const apiClientVersion = '5.0.0-alpha.
|
|
716
|
-
const REGIONS = ['de', 'us'];
|
|
717
|
-
function getDefaultHosts(region) {
|
|
718
|
-
const url = !region
|
|
719
|
-
? 'analytics.algolia.com'
|
|
720
|
-
: 'analytics.{region}.algolia.com'.replace('{region}', region);
|
|
721
|
-
return [{ url, accept: 'readWrite', protocol: 'https' }];
|
|
722
|
-
}
|
|
723
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
724
|
-
function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
|
|
725
|
-
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
726
|
-
const transporter = createTransporter({
|
|
727
|
-
hosts: getDefaultHosts(regionOption),
|
|
728
|
-
...options,
|
|
729
|
-
algoliaAgent: getAlgoliaAgent({
|
|
730
|
-
algoliaAgents,
|
|
731
|
-
client: 'Analytics',
|
|
732
|
-
version: apiClientVersion,
|
|
733
|
-
}),
|
|
734
|
-
baseHeaders: {
|
|
735
|
-
'content-type': 'text/plain',
|
|
736
|
-
...auth.headers(),
|
|
737
|
-
...options.baseHeaders,
|
|
738
|
-
},
|
|
739
|
-
baseQueryParameters: {
|
|
740
|
-
...auth.queryParameters(),
|
|
741
|
-
...options.baseQueryParameters,
|
|
742
|
-
},
|
|
743
|
-
});
|
|
744
|
-
return {
|
|
745
|
-
transporter,
|
|
746
|
-
/**
|
|
747
|
-
* The `appId` currently in use.
|
|
748
|
-
*/
|
|
749
|
-
appId: appIdOption,
|
|
750
|
-
/**
|
|
751
|
-
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
752
|
-
*/
|
|
753
|
-
clearCache() {
|
|
754
|
-
return Promise.all([
|
|
755
|
-
transporter.requestsCache.clear(),
|
|
756
|
-
transporter.responsesCache.clear(),
|
|
757
|
-
]).then(() => undefined);
|
|
758
|
-
},
|
|
759
|
-
/**
|
|
760
|
-
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
761
|
-
*/
|
|
762
|
-
get _ua() {
|
|
763
|
-
return transporter.algoliaAgent.value;
|
|
764
|
-
},
|
|
765
|
-
/**
|
|
766
|
-
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
767
|
-
*
|
|
768
|
-
* @param segment - The algolia agent (user-agent) segment to add.
|
|
769
|
-
* @param version - The version of the agent.
|
|
770
|
-
*/
|
|
771
|
-
addAlgoliaAgent(segment, version) {
|
|
772
|
-
transporter.algoliaAgent.add({ segment, version });
|
|
773
|
-
},
|
|
774
|
-
/**
|
|
775
|
-
* This method allow you to send requests to the Algolia REST API.
|
|
776
|
-
*
|
|
777
|
-
* @
|
|
778
|
-
* @param
|
|
779
|
-
* @param
|
|
780
|
-
* @param
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
787
|
-
const
|
|
788
|
-
const
|
|
789
|
-
const
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
* @
|
|
802
|
-
* @param
|
|
803
|
-
* @param
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
}
|
|
811
|
-
const
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
* @
|
|
826
|
-
* @param
|
|
827
|
-
* @param
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if (
|
|
885
|
-
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
queryParameters
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
};
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
};
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
if (index
|
|
1378
|
-
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
}
|
|
1383
|
-
if (
|
|
1384
|
-
queryParameters.
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
*
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
if (
|
|
1423
|
-
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
if (
|
|
1429
|
-
queryParameters.
|
|
1430
|
-
}
|
|
1431
|
-
if (
|
|
1432
|
-
queryParameters.
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
if (
|
|
1478
|
-
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
if (
|
|
1484
|
-
queryParameters.
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
if (
|
|
1531
|
-
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
if (
|
|
1537
|
-
queryParameters.
|
|
1538
|
-
}
|
|
1539
|
-
if (
|
|
1540
|
-
queryParameters.
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1559
|
-
* @
|
|
1560
|
-
* @param
|
|
1561
|
-
* @param
|
|
1562
|
-
* @param
|
|
1563
|
-
* @param
|
|
1564
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1565
|
-
*/
|
|
1566
|
-
|
|
1567
|
-
if (!
|
|
1568
|
-
throw new Error('Parameter `
|
|
1569
|
-
}
|
|
1570
|
-
const requestPath = '/
|
|
1571
|
-
const headers = {};
|
|
1572
|
-
const queryParameters =
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
688
|
+
// 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-alpha.110';
|
|
690
|
+
const REGIONS = ['de', 'us'];
|
|
691
|
+
function getDefaultHosts(region) {
|
|
692
|
+
const url = !region
|
|
693
|
+
? 'analytics.algolia.com'
|
|
694
|
+
: 'analytics.{region}.algolia.com'.replace('{region}', region);
|
|
695
|
+
return [{ url, accept: 'readWrite', protocol: 'https' }];
|
|
696
|
+
}
|
|
697
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
698
|
+
function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
|
|
699
|
+
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
700
|
+
const transporter = createTransporter({
|
|
701
|
+
hosts: getDefaultHosts(regionOption),
|
|
702
|
+
...options,
|
|
703
|
+
algoliaAgent: getAlgoliaAgent({
|
|
704
|
+
algoliaAgents,
|
|
705
|
+
client: 'Analytics',
|
|
706
|
+
version: apiClientVersion,
|
|
707
|
+
}),
|
|
708
|
+
baseHeaders: {
|
|
709
|
+
'content-type': 'text/plain',
|
|
710
|
+
...auth.headers(),
|
|
711
|
+
...options.baseHeaders,
|
|
712
|
+
},
|
|
713
|
+
baseQueryParameters: {
|
|
714
|
+
...auth.queryParameters(),
|
|
715
|
+
...options.baseQueryParameters,
|
|
716
|
+
},
|
|
717
|
+
});
|
|
718
|
+
return {
|
|
719
|
+
transporter,
|
|
720
|
+
/**
|
|
721
|
+
* The `appId` currently in use.
|
|
722
|
+
*/
|
|
723
|
+
appId: appIdOption,
|
|
724
|
+
/**
|
|
725
|
+
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
726
|
+
*/
|
|
727
|
+
clearCache() {
|
|
728
|
+
return Promise.all([
|
|
729
|
+
transporter.requestsCache.clear(),
|
|
730
|
+
transporter.responsesCache.clear(),
|
|
731
|
+
]).then(() => undefined);
|
|
732
|
+
},
|
|
733
|
+
/**
|
|
734
|
+
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
735
|
+
*/
|
|
736
|
+
get _ua() {
|
|
737
|
+
return transporter.algoliaAgent.value;
|
|
738
|
+
},
|
|
739
|
+
/**
|
|
740
|
+
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
741
|
+
*
|
|
742
|
+
* @param segment - The algolia agent (user-agent) segment to add.
|
|
743
|
+
* @param version - The version of the agent.
|
|
744
|
+
*/
|
|
745
|
+
addAlgoliaAgent(segment, version) {
|
|
746
|
+
transporter.algoliaAgent.add({ segment, version });
|
|
747
|
+
},
|
|
748
|
+
/**
|
|
749
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
750
|
+
*
|
|
751
|
+
* @param customDelete - The customDelete object.
|
|
752
|
+
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
753
|
+
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
754
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
755
|
+
*/
|
|
756
|
+
customDelete({ path, parameters }, requestOptions) {
|
|
757
|
+
if (!path) {
|
|
758
|
+
throw new Error('Parameter `path` is required when calling `customDelete`.');
|
|
759
|
+
}
|
|
760
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
761
|
+
const headers = {};
|
|
762
|
+
const queryParameters = parameters ? parameters : {};
|
|
763
|
+
const request = {
|
|
764
|
+
method: 'DELETE',
|
|
765
|
+
path: requestPath,
|
|
766
|
+
queryParameters,
|
|
767
|
+
headers,
|
|
768
|
+
};
|
|
769
|
+
return transporter.request(request, requestOptions);
|
|
770
|
+
},
|
|
771
|
+
/**
|
|
772
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
773
|
+
*
|
|
774
|
+
* @param customGet - The customGet object.
|
|
775
|
+
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
776
|
+
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
777
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
778
|
+
*/
|
|
779
|
+
customGet({ path, parameters }, requestOptions) {
|
|
780
|
+
if (!path) {
|
|
781
|
+
throw new Error('Parameter `path` is required when calling `customGet`.');
|
|
782
|
+
}
|
|
783
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
784
|
+
const headers = {};
|
|
785
|
+
const queryParameters = parameters ? parameters : {};
|
|
786
|
+
const request = {
|
|
787
|
+
method: 'GET',
|
|
788
|
+
path: requestPath,
|
|
789
|
+
queryParameters,
|
|
790
|
+
headers,
|
|
791
|
+
};
|
|
792
|
+
return transporter.request(request, requestOptions);
|
|
793
|
+
},
|
|
794
|
+
/**
|
|
795
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
796
|
+
*
|
|
797
|
+
* @param customPost - The customPost object.
|
|
798
|
+
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
799
|
+
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
800
|
+
* @param customPost.body - Parameters to send with the custom request.
|
|
801
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
802
|
+
*/
|
|
803
|
+
customPost({ path, parameters, body }, requestOptions) {
|
|
804
|
+
if (!path) {
|
|
805
|
+
throw new Error('Parameter `path` is required when calling `customPost`.');
|
|
806
|
+
}
|
|
807
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
808
|
+
const headers = {};
|
|
809
|
+
const queryParameters = parameters ? parameters : {};
|
|
810
|
+
const request = {
|
|
811
|
+
method: 'POST',
|
|
812
|
+
path: requestPath,
|
|
813
|
+
queryParameters,
|
|
814
|
+
headers,
|
|
815
|
+
data: body ? body : {},
|
|
816
|
+
};
|
|
817
|
+
return transporter.request(request, requestOptions);
|
|
818
|
+
},
|
|
819
|
+
/**
|
|
820
|
+
* This method allow you to send requests to the Algolia REST API.
|
|
821
|
+
*
|
|
822
|
+
* @param customPut - The customPut object.
|
|
823
|
+
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
824
|
+
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
825
|
+
* @param customPut.body - Parameters to send with the custom request.
|
|
826
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
827
|
+
*/
|
|
828
|
+
customPut({ path, parameters, body }, requestOptions) {
|
|
829
|
+
if (!path) {
|
|
830
|
+
throw new Error('Parameter `path` is required when calling `customPut`.');
|
|
831
|
+
}
|
|
832
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
833
|
+
const headers = {};
|
|
834
|
+
const queryParameters = parameters ? parameters : {};
|
|
835
|
+
const request = {
|
|
836
|
+
method: 'PUT',
|
|
837
|
+
path: requestPath,
|
|
838
|
+
queryParameters,
|
|
839
|
+
headers,
|
|
840
|
+
data: body ? body : {},
|
|
841
|
+
};
|
|
842
|
+
return transporter.request(request, requestOptions);
|
|
843
|
+
},
|
|
844
|
+
/**
|
|
845
|
+
* Retrieves the add-to-cart rate for all of your searches with at least one add-to-cart event, including a daily breakdown. By default, the analyzed period includes the last eight days including the current day.
|
|
846
|
+
*
|
|
847
|
+
* Required API Key ACLs:
|
|
848
|
+
* - analytics.
|
|
849
|
+
*
|
|
850
|
+
* @param getAddToCartRate - The getAddToCartRate object.
|
|
851
|
+
* @param getAddToCartRate.index - Index name.
|
|
852
|
+
* @param getAddToCartRate.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
853
|
+
* @param getAddToCartRate.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
854
|
+
* @param getAddToCartRate.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
855
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
856
|
+
*/
|
|
857
|
+
getAddToCartRate({ index, startDate, endDate, tags }, requestOptions) {
|
|
858
|
+
if (!index) {
|
|
859
|
+
throw new Error('Parameter `index` is required when calling `getAddToCartRate`.');
|
|
860
|
+
}
|
|
861
|
+
const requestPath = '/2/conversions/addToCartRate';
|
|
862
|
+
const headers = {};
|
|
863
|
+
const queryParameters = {};
|
|
864
|
+
if (index !== undefined) {
|
|
865
|
+
queryParameters.index = index.toString();
|
|
866
|
+
}
|
|
867
|
+
if (startDate !== undefined) {
|
|
868
|
+
queryParameters.startDate = startDate.toString();
|
|
869
|
+
}
|
|
870
|
+
if (endDate !== undefined) {
|
|
871
|
+
queryParameters.endDate = endDate.toString();
|
|
872
|
+
}
|
|
873
|
+
if (tags !== undefined) {
|
|
874
|
+
queryParameters.tags = tags.toString();
|
|
875
|
+
}
|
|
876
|
+
const request = {
|
|
877
|
+
method: 'GET',
|
|
878
|
+
path: requestPath,
|
|
879
|
+
queryParameters,
|
|
880
|
+
headers,
|
|
881
|
+
};
|
|
882
|
+
return transporter.request(request, requestOptions);
|
|
883
|
+
},
|
|
884
|
+
/**
|
|
885
|
+
* Retrieves the average click position of your search results, including a daily breakdown. The average click position is the average of all clicked search results\' positions. For example, if users only ever click on the first result for any search, the average click position is 1. By default, the analyzed period includes the last eight days including the current day.
|
|
886
|
+
*
|
|
887
|
+
* Required API Key ACLs:
|
|
888
|
+
* - analytics.
|
|
889
|
+
*
|
|
890
|
+
* @param getAverageClickPosition - The getAverageClickPosition object.
|
|
891
|
+
* @param getAverageClickPosition.index - Index name.
|
|
892
|
+
* @param getAverageClickPosition.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
893
|
+
* @param getAverageClickPosition.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
894
|
+
* @param getAverageClickPosition.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
895
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
896
|
+
*/
|
|
897
|
+
getAverageClickPosition({ index, startDate, endDate, tags }, requestOptions) {
|
|
898
|
+
if (!index) {
|
|
899
|
+
throw new Error('Parameter `index` is required when calling `getAverageClickPosition`.');
|
|
900
|
+
}
|
|
901
|
+
const requestPath = '/2/clicks/averageClickPosition';
|
|
902
|
+
const headers = {};
|
|
903
|
+
const queryParameters = {};
|
|
904
|
+
if (index !== undefined) {
|
|
905
|
+
queryParameters.index = index.toString();
|
|
906
|
+
}
|
|
907
|
+
if (startDate !== undefined) {
|
|
908
|
+
queryParameters.startDate = startDate.toString();
|
|
909
|
+
}
|
|
910
|
+
if (endDate !== undefined) {
|
|
911
|
+
queryParameters.endDate = endDate.toString();
|
|
912
|
+
}
|
|
913
|
+
if (tags !== undefined) {
|
|
914
|
+
queryParameters.tags = tags.toString();
|
|
915
|
+
}
|
|
916
|
+
const request = {
|
|
917
|
+
method: 'GET',
|
|
918
|
+
path: requestPath,
|
|
919
|
+
queryParameters,
|
|
920
|
+
headers,
|
|
921
|
+
};
|
|
922
|
+
return transporter.request(request, requestOptions);
|
|
923
|
+
},
|
|
924
|
+
/**
|
|
925
|
+
* Retrieves the positions in the search results and their associated number of clicks. This lets you check how many clicks the first, second, or tenth search results receive.
|
|
926
|
+
*
|
|
927
|
+
* Required API Key ACLs:
|
|
928
|
+
* - analytics.
|
|
929
|
+
*
|
|
930
|
+
* @param getClickPositions - The getClickPositions object.
|
|
931
|
+
* @param getClickPositions.index - Index name.
|
|
932
|
+
* @param getClickPositions.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
933
|
+
* @param getClickPositions.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
934
|
+
* @param getClickPositions.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
935
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
936
|
+
*/
|
|
937
|
+
getClickPositions({ index, startDate, endDate, tags }, requestOptions) {
|
|
938
|
+
if (!index) {
|
|
939
|
+
throw new Error('Parameter `index` is required when calling `getClickPositions`.');
|
|
940
|
+
}
|
|
941
|
+
const requestPath = '/2/clicks/positions';
|
|
942
|
+
const headers = {};
|
|
943
|
+
const queryParameters = {};
|
|
944
|
+
if (index !== undefined) {
|
|
945
|
+
queryParameters.index = index.toString();
|
|
946
|
+
}
|
|
947
|
+
if (startDate !== undefined) {
|
|
948
|
+
queryParameters.startDate = startDate.toString();
|
|
949
|
+
}
|
|
950
|
+
if (endDate !== undefined) {
|
|
951
|
+
queryParameters.endDate = endDate.toString();
|
|
952
|
+
}
|
|
953
|
+
if (tags !== undefined) {
|
|
954
|
+
queryParameters.tags = tags.toString();
|
|
955
|
+
}
|
|
956
|
+
const request = {
|
|
957
|
+
method: 'GET',
|
|
958
|
+
path: requestPath,
|
|
959
|
+
queryParameters,
|
|
960
|
+
headers,
|
|
961
|
+
};
|
|
962
|
+
return transporter.request(request, requestOptions);
|
|
963
|
+
},
|
|
964
|
+
/**
|
|
965
|
+
* Retrieves the click-through rate for all of your searches with at least one click event, including a daily breakdown By default, the analyzed period includes the last eight days including the current day.
|
|
966
|
+
*
|
|
967
|
+
* Required API Key ACLs:
|
|
968
|
+
* - analytics.
|
|
969
|
+
*
|
|
970
|
+
* @param getClickThroughRate - The getClickThroughRate object.
|
|
971
|
+
* @param getClickThroughRate.index - Index name.
|
|
972
|
+
* @param getClickThroughRate.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
973
|
+
* @param getClickThroughRate.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
974
|
+
* @param getClickThroughRate.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
975
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
976
|
+
*/
|
|
977
|
+
getClickThroughRate({ index, startDate, endDate, tags }, requestOptions) {
|
|
978
|
+
if (!index) {
|
|
979
|
+
throw new Error('Parameter `index` is required when calling `getClickThroughRate`.');
|
|
980
|
+
}
|
|
981
|
+
const requestPath = '/2/clicks/clickThroughRate';
|
|
982
|
+
const headers = {};
|
|
983
|
+
const queryParameters = {};
|
|
984
|
+
if (index !== undefined) {
|
|
985
|
+
queryParameters.index = index.toString();
|
|
986
|
+
}
|
|
987
|
+
if (startDate !== undefined) {
|
|
988
|
+
queryParameters.startDate = startDate.toString();
|
|
989
|
+
}
|
|
990
|
+
if (endDate !== undefined) {
|
|
991
|
+
queryParameters.endDate = endDate.toString();
|
|
992
|
+
}
|
|
993
|
+
if (tags !== undefined) {
|
|
994
|
+
queryParameters.tags = tags.toString();
|
|
995
|
+
}
|
|
996
|
+
const request = {
|
|
997
|
+
method: 'GET',
|
|
998
|
+
path: requestPath,
|
|
999
|
+
queryParameters,
|
|
1000
|
+
headers,
|
|
1001
|
+
};
|
|
1002
|
+
return transporter.request(request, requestOptions);
|
|
1003
|
+
},
|
|
1004
|
+
/**
|
|
1005
|
+
* Retrieves the conversion rate for all of your searches with at least one conversion event, including a daily breakdown. By default, the analyzed period includes the last eight days including the current day.
|
|
1006
|
+
*
|
|
1007
|
+
* Required API Key ACLs:
|
|
1008
|
+
* - analytics.
|
|
1009
|
+
*
|
|
1010
|
+
* @param getConversionRate - The getConversionRate object.
|
|
1011
|
+
* @param getConversionRate.index - Index name.
|
|
1012
|
+
* @param getConversionRate.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1013
|
+
* @param getConversionRate.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1014
|
+
* @param getConversionRate.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1015
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1016
|
+
*/
|
|
1017
|
+
getConversionRate({ index, startDate, endDate, tags }, requestOptions) {
|
|
1018
|
+
if (!index) {
|
|
1019
|
+
throw new Error('Parameter `index` is required when calling `getConversionRate`.');
|
|
1020
|
+
}
|
|
1021
|
+
const requestPath = '/2/conversions/conversionRate';
|
|
1022
|
+
const headers = {};
|
|
1023
|
+
const queryParameters = {};
|
|
1024
|
+
if (index !== undefined) {
|
|
1025
|
+
queryParameters.index = index.toString();
|
|
1026
|
+
}
|
|
1027
|
+
if (startDate !== undefined) {
|
|
1028
|
+
queryParameters.startDate = startDate.toString();
|
|
1029
|
+
}
|
|
1030
|
+
if (endDate !== undefined) {
|
|
1031
|
+
queryParameters.endDate = endDate.toString();
|
|
1032
|
+
}
|
|
1033
|
+
if (tags !== undefined) {
|
|
1034
|
+
queryParameters.tags = tags.toString();
|
|
1035
|
+
}
|
|
1036
|
+
const request = {
|
|
1037
|
+
method: 'GET',
|
|
1038
|
+
path: requestPath,
|
|
1039
|
+
queryParameters,
|
|
1040
|
+
headers,
|
|
1041
|
+
};
|
|
1042
|
+
return transporter.request(request, requestOptions);
|
|
1043
|
+
},
|
|
1044
|
+
/**
|
|
1045
|
+
* Retrieves the fraction of searches that didn\'t lead to any click within a time range, including a daily breakdown. By default, the analyzed period includes the last eight days including the current day.
|
|
1046
|
+
*
|
|
1047
|
+
* Required API Key ACLs:
|
|
1048
|
+
* - analytics.
|
|
1049
|
+
*
|
|
1050
|
+
* @param getNoClickRate - The getNoClickRate object.
|
|
1051
|
+
* @param getNoClickRate.index - Index name.
|
|
1052
|
+
* @param getNoClickRate.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1053
|
+
* @param getNoClickRate.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1054
|
+
* @param getNoClickRate.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1055
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1056
|
+
*/
|
|
1057
|
+
getNoClickRate({ index, startDate, endDate, tags }, requestOptions) {
|
|
1058
|
+
if (!index) {
|
|
1059
|
+
throw new Error('Parameter `index` is required when calling `getNoClickRate`.');
|
|
1060
|
+
}
|
|
1061
|
+
const requestPath = '/2/searches/noClickRate';
|
|
1062
|
+
const headers = {};
|
|
1063
|
+
const queryParameters = {};
|
|
1064
|
+
if (index !== undefined) {
|
|
1065
|
+
queryParameters.index = index.toString();
|
|
1066
|
+
}
|
|
1067
|
+
if (startDate !== undefined) {
|
|
1068
|
+
queryParameters.startDate = startDate.toString();
|
|
1069
|
+
}
|
|
1070
|
+
if (endDate !== undefined) {
|
|
1071
|
+
queryParameters.endDate = endDate.toString();
|
|
1072
|
+
}
|
|
1073
|
+
if (tags !== undefined) {
|
|
1074
|
+
queryParameters.tags = tags.toString();
|
|
1075
|
+
}
|
|
1076
|
+
const request = {
|
|
1077
|
+
method: 'GET',
|
|
1078
|
+
path: requestPath,
|
|
1079
|
+
queryParameters,
|
|
1080
|
+
headers,
|
|
1081
|
+
};
|
|
1082
|
+
return transporter.request(request, requestOptions);
|
|
1083
|
+
},
|
|
1084
|
+
/**
|
|
1085
|
+
* Retrieves the fraction of searches that didn\'t return any results within a time range, including a daily breakdown. By default, the analyzed period includes the last eight days including the current day.
|
|
1086
|
+
*
|
|
1087
|
+
* Required API Key ACLs:
|
|
1088
|
+
* - analytics.
|
|
1089
|
+
*
|
|
1090
|
+
* @param getNoResultsRate - The getNoResultsRate object.
|
|
1091
|
+
* @param getNoResultsRate.index - Index name.
|
|
1092
|
+
* @param getNoResultsRate.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1093
|
+
* @param getNoResultsRate.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1094
|
+
* @param getNoResultsRate.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1095
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1096
|
+
*/
|
|
1097
|
+
getNoResultsRate({ index, startDate, endDate, tags }, requestOptions) {
|
|
1098
|
+
if (!index) {
|
|
1099
|
+
throw new Error('Parameter `index` is required when calling `getNoResultsRate`.');
|
|
1100
|
+
}
|
|
1101
|
+
const requestPath = '/2/searches/noResultRate';
|
|
1102
|
+
const headers = {};
|
|
1103
|
+
const queryParameters = {};
|
|
1104
|
+
if (index !== undefined) {
|
|
1105
|
+
queryParameters.index = index.toString();
|
|
1106
|
+
}
|
|
1107
|
+
if (startDate !== undefined) {
|
|
1108
|
+
queryParameters.startDate = startDate.toString();
|
|
1109
|
+
}
|
|
1110
|
+
if (endDate !== undefined) {
|
|
1111
|
+
queryParameters.endDate = endDate.toString();
|
|
1112
|
+
}
|
|
1113
|
+
if (tags !== undefined) {
|
|
1114
|
+
queryParameters.tags = tags.toString();
|
|
1115
|
+
}
|
|
1116
|
+
const request = {
|
|
1117
|
+
method: 'GET',
|
|
1118
|
+
path: requestPath,
|
|
1119
|
+
queryParameters,
|
|
1120
|
+
headers,
|
|
1121
|
+
};
|
|
1122
|
+
return transporter.request(request, requestOptions);
|
|
1123
|
+
},
|
|
1124
|
+
/**
|
|
1125
|
+
* Retrieves the purchase rate for all of your searches with at least one purchase event, including a daily breakdown. By default, the analyzed period includes the last eight days including the current day.
|
|
1126
|
+
*
|
|
1127
|
+
* Required API Key ACLs:
|
|
1128
|
+
* - analytics.
|
|
1129
|
+
*
|
|
1130
|
+
* @param getPurchaseRate - The getPurchaseRate object.
|
|
1131
|
+
* @param getPurchaseRate.index - Index name.
|
|
1132
|
+
* @param getPurchaseRate.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1133
|
+
* @param getPurchaseRate.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1134
|
+
* @param getPurchaseRate.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1135
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1136
|
+
*/
|
|
1137
|
+
getPurchaseRate({ index, startDate, endDate, tags }, requestOptions) {
|
|
1138
|
+
if (!index) {
|
|
1139
|
+
throw new Error('Parameter `index` is required when calling `getPurchaseRate`.');
|
|
1140
|
+
}
|
|
1141
|
+
const requestPath = '/2/conversions/purchaseRate';
|
|
1142
|
+
const headers = {};
|
|
1143
|
+
const queryParameters = {};
|
|
1144
|
+
if (index !== undefined) {
|
|
1145
|
+
queryParameters.index = index.toString();
|
|
1146
|
+
}
|
|
1147
|
+
if (startDate !== undefined) {
|
|
1148
|
+
queryParameters.startDate = startDate.toString();
|
|
1149
|
+
}
|
|
1150
|
+
if (endDate !== undefined) {
|
|
1151
|
+
queryParameters.endDate = endDate.toString();
|
|
1152
|
+
}
|
|
1153
|
+
if (tags !== undefined) {
|
|
1154
|
+
queryParameters.tags = tags.toString();
|
|
1155
|
+
}
|
|
1156
|
+
const request = {
|
|
1157
|
+
method: 'GET',
|
|
1158
|
+
path: requestPath,
|
|
1159
|
+
queryParameters,
|
|
1160
|
+
headers,
|
|
1161
|
+
};
|
|
1162
|
+
return transporter.request(request, requestOptions);
|
|
1163
|
+
},
|
|
1164
|
+
/**
|
|
1165
|
+
* Retrieves revenue-related metrics, such as the total revenue or the average order value. To retrieve revenue-related metrics, sent purchase events. By default, the analyzed period includes the last eight days including the current day.
|
|
1166
|
+
*
|
|
1167
|
+
* Required API Key ACLs:
|
|
1168
|
+
* - analytics.
|
|
1169
|
+
*
|
|
1170
|
+
* @param getRevenue - The getRevenue object.
|
|
1171
|
+
* @param getRevenue.index - Index name.
|
|
1172
|
+
* @param getRevenue.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1173
|
+
* @param getRevenue.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1174
|
+
* @param getRevenue.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1175
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1176
|
+
*/
|
|
1177
|
+
getRevenue({ index, startDate, endDate, tags }, requestOptions) {
|
|
1178
|
+
if (!index) {
|
|
1179
|
+
throw new Error('Parameter `index` is required when calling `getRevenue`.');
|
|
1180
|
+
}
|
|
1181
|
+
const requestPath = '/2/conversions/revenue';
|
|
1182
|
+
const headers = {};
|
|
1183
|
+
const queryParameters = {};
|
|
1184
|
+
if (index !== undefined) {
|
|
1185
|
+
queryParameters.index = index.toString();
|
|
1186
|
+
}
|
|
1187
|
+
if (startDate !== undefined) {
|
|
1188
|
+
queryParameters.startDate = startDate.toString();
|
|
1189
|
+
}
|
|
1190
|
+
if (endDate !== undefined) {
|
|
1191
|
+
queryParameters.endDate = endDate.toString();
|
|
1192
|
+
}
|
|
1193
|
+
if (tags !== undefined) {
|
|
1194
|
+
queryParameters.tags = tags.toString();
|
|
1195
|
+
}
|
|
1196
|
+
const request = {
|
|
1197
|
+
method: 'GET',
|
|
1198
|
+
path: requestPath,
|
|
1199
|
+
queryParameters,
|
|
1200
|
+
headers,
|
|
1201
|
+
};
|
|
1202
|
+
return transporter.request(request, requestOptions);
|
|
1203
|
+
},
|
|
1204
|
+
/**
|
|
1205
|
+
* Retrieves the number of searches within a time range, including a daily breakdown. By default, the analyzed period includes the last eight days including the current day.
|
|
1206
|
+
*
|
|
1207
|
+
* Required API Key ACLs:
|
|
1208
|
+
* - analytics.
|
|
1209
|
+
*
|
|
1210
|
+
* @param getSearchesCount - The getSearchesCount object.
|
|
1211
|
+
* @param getSearchesCount.index - Index name.
|
|
1212
|
+
* @param getSearchesCount.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1213
|
+
* @param getSearchesCount.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1214
|
+
* @param getSearchesCount.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1215
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1216
|
+
*/
|
|
1217
|
+
getSearchesCount({ index, startDate, endDate, tags }, requestOptions) {
|
|
1218
|
+
if (!index) {
|
|
1219
|
+
throw new Error('Parameter `index` is required when calling `getSearchesCount`.');
|
|
1220
|
+
}
|
|
1221
|
+
const requestPath = '/2/searches/count';
|
|
1222
|
+
const headers = {};
|
|
1223
|
+
const queryParameters = {};
|
|
1224
|
+
if (index !== undefined) {
|
|
1225
|
+
queryParameters.index = index.toString();
|
|
1226
|
+
}
|
|
1227
|
+
if (startDate !== undefined) {
|
|
1228
|
+
queryParameters.startDate = startDate.toString();
|
|
1229
|
+
}
|
|
1230
|
+
if (endDate !== undefined) {
|
|
1231
|
+
queryParameters.endDate = endDate.toString();
|
|
1232
|
+
}
|
|
1233
|
+
if (tags !== undefined) {
|
|
1234
|
+
queryParameters.tags = tags.toString();
|
|
1235
|
+
}
|
|
1236
|
+
const request = {
|
|
1237
|
+
method: 'GET',
|
|
1238
|
+
path: requestPath,
|
|
1239
|
+
queryParameters,
|
|
1240
|
+
headers,
|
|
1241
|
+
};
|
|
1242
|
+
return transporter.request(request, requestOptions);
|
|
1243
|
+
},
|
|
1244
|
+
/**
|
|
1245
|
+
* Retrieves the most popular searches that didn\'t lead to any clicks, from the 1,000 most frequent searches.
|
|
1246
|
+
*
|
|
1247
|
+
* Required API Key ACLs:
|
|
1248
|
+
* - analytics.
|
|
1249
|
+
*
|
|
1250
|
+
* @param getSearchesNoClicks - The getSearchesNoClicks object.
|
|
1251
|
+
* @param getSearchesNoClicks.index - Index name.
|
|
1252
|
+
* @param getSearchesNoClicks.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1253
|
+
* @param getSearchesNoClicks.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1254
|
+
* @param getSearchesNoClicks.limit - Number of items to return.
|
|
1255
|
+
* @param getSearchesNoClicks.offset - Position of the first item to return.
|
|
1256
|
+
* @param getSearchesNoClicks.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1257
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1258
|
+
*/
|
|
1259
|
+
getSearchesNoClicks({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
|
|
1260
|
+
if (!index) {
|
|
1261
|
+
throw new Error('Parameter `index` is required when calling `getSearchesNoClicks`.');
|
|
1262
|
+
}
|
|
1263
|
+
const requestPath = '/2/searches/noClicks';
|
|
1264
|
+
const headers = {};
|
|
1265
|
+
const queryParameters = {};
|
|
1266
|
+
if (index !== undefined) {
|
|
1267
|
+
queryParameters.index = index.toString();
|
|
1268
|
+
}
|
|
1269
|
+
if (startDate !== undefined) {
|
|
1270
|
+
queryParameters.startDate = startDate.toString();
|
|
1271
|
+
}
|
|
1272
|
+
if (endDate !== undefined) {
|
|
1273
|
+
queryParameters.endDate = endDate.toString();
|
|
1274
|
+
}
|
|
1275
|
+
if (limit !== undefined) {
|
|
1276
|
+
queryParameters.limit = limit.toString();
|
|
1277
|
+
}
|
|
1278
|
+
if (offset !== undefined) {
|
|
1279
|
+
queryParameters.offset = offset.toString();
|
|
1280
|
+
}
|
|
1281
|
+
if (tags !== undefined) {
|
|
1282
|
+
queryParameters.tags = tags.toString();
|
|
1283
|
+
}
|
|
1284
|
+
const request = {
|
|
1285
|
+
method: 'GET',
|
|
1286
|
+
path: requestPath,
|
|
1287
|
+
queryParameters,
|
|
1288
|
+
headers,
|
|
1289
|
+
};
|
|
1290
|
+
return transporter.request(request, requestOptions);
|
|
1291
|
+
},
|
|
1292
|
+
/**
|
|
1293
|
+
* Retrieves the most popular searches that didn\'t return any results.
|
|
1294
|
+
*
|
|
1295
|
+
* Required API Key ACLs:
|
|
1296
|
+
* - analytics.
|
|
1297
|
+
*
|
|
1298
|
+
* @param getSearchesNoResults - The getSearchesNoResults object.
|
|
1299
|
+
* @param getSearchesNoResults.index - Index name.
|
|
1300
|
+
* @param getSearchesNoResults.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1301
|
+
* @param getSearchesNoResults.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1302
|
+
* @param getSearchesNoResults.limit - Number of items to return.
|
|
1303
|
+
* @param getSearchesNoResults.offset - Position of the first item to return.
|
|
1304
|
+
* @param getSearchesNoResults.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1305
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1306
|
+
*/
|
|
1307
|
+
getSearchesNoResults({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
|
|
1308
|
+
if (!index) {
|
|
1309
|
+
throw new Error('Parameter `index` is required when calling `getSearchesNoResults`.');
|
|
1310
|
+
}
|
|
1311
|
+
const requestPath = '/2/searches/noResults';
|
|
1312
|
+
const headers = {};
|
|
1313
|
+
const queryParameters = {};
|
|
1314
|
+
if (index !== undefined) {
|
|
1315
|
+
queryParameters.index = index.toString();
|
|
1316
|
+
}
|
|
1317
|
+
if (startDate !== undefined) {
|
|
1318
|
+
queryParameters.startDate = startDate.toString();
|
|
1319
|
+
}
|
|
1320
|
+
if (endDate !== undefined) {
|
|
1321
|
+
queryParameters.endDate = endDate.toString();
|
|
1322
|
+
}
|
|
1323
|
+
if (limit !== undefined) {
|
|
1324
|
+
queryParameters.limit = limit.toString();
|
|
1325
|
+
}
|
|
1326
|
+
if (offset !== undefined) {
|
|
1327
|
+
queryParameters.offset = offset.toString();
|
|
1328
|
+
}
|
|
1329
|
+
if (tags !== undefined) {
|
|
1330
|
+
queryParameters.tags = tags.toString();
|
|
1331
|
+
}
|
|
1332
|
+
const request = {
|
|
1333
|
+
method: 'GET',
|
|
1334
|
+
path: requestPath,
|
|
1335
|
+
queryParameters,
|
|
1336
|
+
headers,
|
|
1337
|
+
};
|
|
1338
|
+
return transporter.request(request, requestOptions);
|
|
1339
|
+
},
|
|
1340
|
+
/**
|
|
1341
|
+
* Retrieves the time when the Analytics data for the specified index was last updated. The Analytics data is updated every 5 minutes.
|
|
1342
|
+
*
|
|
1343
|
+
* Required API Key ACLs:
|
|
1344
|
+
* - analytics.
|
|
1345
|
+
*
|
|
1346
|
+
* @param getStatus - The getStatus object.
|
|
1347
|
+
* @param getStatus.index - Index name.
|
|
1348
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1349
|
+
*/
|
|
1350
|
+
getStatus({ index }, requestOptions) {
|
|
1351
|
+
if (!index) {
|
|
1352
|
+
throw new Error('Parameter `index` is required when calling `getStatus`.');
|
|
1353
|
+
}
|
|
1354
|
+
const requestPath = '/2/status';
|
|
1355
|
+
const headers = {};
|
|
1356
|
+
const queryParameters = {};
|
|
1357
|
+
if (index !== undefined) {
|
|
1358
|
+
queryParameters.index = index.toString();
|
|
1359
|
+
}
|
|
1360
|
+
const request = {
|
|
1361
|
+
method: 'GET',
|
|
1362
|
+
path: requestPath,
|
|
1363
|
+
queryParameters,
|
|
1364
|
+
headers,
|
|
1365
|
+
};
|
|
1366
|
+
return transporter.request(request, requestOptions);
|
|
1367
|
+
},
|
|
1368
|
+
/**
|
|
1369
|
+
* Retrieves the countries with the most searches to your index.
|
|
1370
|
+
*
|
|
1371
|
+
* Required API Key ACLs:
|
|
1372
|
+
* - analytics.
|
|
1373
|
+
*
|
|
1374
|
+
* @param getTopCountries - The getTopCountries object.
|
|
1375
|
+
* @param getTopCountries.index - Index name.
|
|
1376
|
+
* @param getTopCountries.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1377
|
+
* @param getTopCountries.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1378
|
+
* @param getTopCountries.limit - Number of items to return.
|
|
1379
|
+
* @param getTopCountries.offset - Position of the first item to return.
|
|
1380
|
+
* @param getTopCountries.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1381
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1382
|
+
*/
|
|
1383
|
+
getTopCountries({ index, startDate, endDate, limit, offset, tags }, requestOptions) {
|
|
1384
|
+
if (!index) {
|
|
1385
|
+
throw new Error('Parameter `index` is required when calling `getTopCountries`.');
|
|
1386
|
+
}
|
|
1387
|
+
const requestPath = '/2/countries';
|
|
1388
|
+
const headers = {};
|
|
1389
|
+
const queryParameters = {};
|
|
1390
|
+
if (index !== undefined) {
|
|
1391
|
+
queryParameters.index = index.toString();
|
|
1392
|
+
}
|
|
1393
|
+
if (startDate !== undefined) {
|
|
1394
|
+
queryParameters.startDate = startDate.toString();
|
|
1395
|
+
}
|
|
1396
|
+
if (endDate !== undefined) {
|
|
1397
|
+
queryParameters.endDate = endDate.toString();
|
|
1398
|
+
}
|
|
1399
|
+
if (limit !== undefined) {
|
|
1400
|
+
queryParameters.limit = limit.toString();
|
|
1401
|
+
}
|
|
1402
|
+
if (offset !== undefined) {
|
|
1403
|
+
queryParameters.offset = offset.toString();
|
|
1404
|
+
}
|
|
1405
|
+
if (tags !== undefined) {
|
|
1406
|
+
queryParameters.tags = tags.toString();
|
|
1407
|
+
}
|
|
1408
|
+
const request = {
|
|
1409
|
+
method: 'GET',
|
|
1410
|
+
path: requestPath,
|
|
1411
|
+
queryParameters,
|
|
1412
|
+
headers,
|
|
1413
|
+
};
|
|
1414
|
+
return transporter.request(request, requestOptions);
|
|
1415
|
+
},
|
|
1416
|
+
/**
|
|
1417
|
+
* Retrieves the most frequently used filter attributes. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
1418
|
+
*
|
|
1419
|
+
* Required API Key ACLs:
|
|
1420
|
+
* - analytics.
|
|
1421
|
+
*
|
|
1422
|
+
* @param getTopFilterAttributes - The getTopFilterAttributes object.
|
|
1423
|
+
* @param getTopFilterAttributes.index - Index name.
|
|
1424
|
+
* @param getTopFilterAttributes.search - Search query.
|
|
1425
|
+
* @param getTopFilterAttributes.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1426
|
+
* @param getTopFilterAttributes.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1427
|
+
* @param getTopFilterAttributes.limit - Number of items to return.
|
|
1428
|
+
* @param getTopFilterAttributes.offset - Position of the first item to return.
|
|
1429
|
+
* @param getTopFilterAttributes.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1430
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1431
|
+
*/
|
|
1432
|
+
getTopFilterAttributes({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
|
|
1433
|
+
if (!index) {
|
|
1434
|
+
throw new Error('Parameter `index` is required when calling `getTopFilterAttributes`.');
|
|
1435
|
+
}
|
|
1436
|
+
const requestPath = '/2/filters';
|
|
1437
|
+
const headers = {};
|
|
1438
|
+
const queryParameters = {};
|
|
1439
|
+
if (index !== undefined) {
|
|
1440
|
+
queryParameters.index = index.toString();
|
|
1441
|
+
}
|
|
1442
|
+
if (search !== undefined) {
|
|
1443
|
+
queryParameters.search = search.toString();
|
|
1444
|
+
}
|
|
1445
|
+
if (startDate !== undefined) {
|
|
1446
|
+
queryParameters.startDate = startDate.toString();
|
|
1447
|
+
}
|
|
1448
|
+
if (endDate !== undefined) {
|
|
1449
|
+
queryParameters.endDate = endDate.toString();
|
|
1450
|
+
}
|
|
1451
|
+
if (limit !== undefined) {
|
|
1452
|
+
queryParameters.limit = limit.toString();
|
|
1453
|
+
}
|
|
1454
|
+
if (offset !== undefined) {
|
|
1455
|
+
queryParameters.offset = offset.toString();
|
|
1456
|
+
}
|
|
1457
|
+
if (tags !== undefined) {
|
|
1458
|
+
queryParameters.tags = tags.toString();
|
|
1459
|
+
}
|
|
1460
|
+
const request = {
|
|
1461
|
+
method: 'GET',
|
|
1462
|
+
path: requestPath,
|
|
1463
|
+
queryParameters,
|
|
1464
|
+
headers,
|
|
1465
|
+
};
|
|
1466
|
+
return transporter.request(request, requestOptions);
|
|
1467
|
+
},
|
|
1468
|
+
/**
|
|
1469
|
+
* Retrieves the most frequent filter (facet) values for a filter attribute. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
1470
|
+
*
|
|
1471
|
+
* Required API Key ACLs:
|
|
1472
|
+
* - analytics.
|
|
1473
|
+
*
|
|
1474
|
+
* @param getTopFilterForAttribute - The getTopFilterForAttribute object.
|
|
1475
|
+
* @param getTopFilterForAttribute.attribute - Attribute name.
|
|
1476
|
+
* @param getTopFilterForAttribute.index - Index name.
|
|
1477
|
+
* @param getTopFilterForAttribute.search - Search query.
|
|
1478
|
+
* @param getTopFilterForAttribute.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1479
|
+
* @param getTopFilterForAttribute.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1480
|
+
* @param getTopFilterForAttribute.limit - Number of items to return.
|
|
1481
|
+
* @param getTopFilterForAttribute.offset - Position of the first item to return.
|
|
1482
|
+
* @param getTopFilterForAttribute.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1483
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1484
|
+
*/
|
|
1485
|
+
getTopFilterForAttribute({ attribute, index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
|
|
1486
|
+
if (!attribute) {
|
|
1487
|
+
throw new Error('Parameter `attribute` is required when calling `getTopFilterForAttribute`.');
|
|
1488
|
+
}
|
|
1489
|
+
if (!index) {
|
|
1490
|
+
throw new Error('Parameter `index` is required when calling `getTopFilterForAttribute`.');
|
|
1491
|
+
}
|
|
1492
|
+
const requestPath = '/2/filters/{attribute}'.replace('{attribute}', encodeURIComponent(attribute));
|
|
1493
|
+
const headers = {};
|
|
1494
|
+
const queryParameters = {};
|
|
1495
|
+
if (index !== undefined) {
|
|
1496
|
+
queryParameters.index = index.toString();
|
|
1497
|
+
}
|
|
1498
|
+
if (search !== undefined) {
|
|
1499
|
+
queryParameters.search = search.toString();
|
|
1500
|
+
}
|
|
1501
|
+
if (startDate !== undefined) {
|
|
1502
|
+
queryParameters.startDate = startDate.toString();
|
|
1503
|
+
}
|
|
1504
|
+
if (endDate !== undefined) {
|
|
1505
|
+
queryParameters.endDate = endDate.toString();
|
|
1506
|
+
}
|
|
1507
|
+
if (limit !== undefined) {
|
|
1508
|
+
queryParameters.limit = limit.toString();
|
|
1509
|
+
}
|
|
1510
|
+
if (offset !== undefined) {
|
|
1511
|
+
queryParameters.offset = offset.toString();
|
|
1512
|
+
}
|
|
1513
|
+
if (tags !== undefined) {
|
|
1514
|
+
queryParameters.tags = tags.toString();
|
|
1515
|
+
}
|
|
1516
|
+
const request = {
|
|
1517
|
+
method: 'GET',
|
|
1518
|
+
path: requestPath,
|
|
1519
|
+
queryParameters,
|
|
1520
|
+
headers,
|
|
1521
|
+
};
|
|
1522
|
+
return transporter.request(request, requestOptions);
|
|
1523
|
+
},
|
|
1524
|
+
/**
|
|
1525
|
+
* Retrieves the most frequently used filters for a search that didn\'t return any results. To get the most frequent searches without results, use the [Retrieve searches without results](#tag/search/operation/getSearchesNoResults) operation.
|
|
1526
|
+
*
|
|
1527
|
+
* Required API Key ACLs:
|
|
1528
|
+
* - analytics.
|
|
1529
|
+
*
|
|
1530
|
+
* @param getTopFiltersNoResults - The getTopFiltersNoResults object.
|
|
1531
|
+
* @param getTopFiltersNoResults.index - Index name.
|
|
1532
|
+
* @param getTopFiltersNoResults.search - Search query.
|
|
1533
|
+
* @param getTopFiltersNoResults.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1534
|
+
* @param getTopFiltersNoResults.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1535
|
+
* @param getTopFiltersNoResults.limit - Number of items to return.
|
|
1536
|
+
* @param getTopFiltersNoResults.offset - Position of the first item to return.
|
|
1537
|
+
* @param getTopFiltersNoResults.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1538
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1539
|
+
*/
|
|
1540
|
+
getTopFiltersNoResults({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
|
|
1541
|
+
if (!index) {
|
|
1542
|
+
throw new Error('Parameter `index` is required when calling `getTopFiltersNoResults`.');
|
|
1543
|
+
}
|
|
1544
|
+
const requestPath = '/2/filters/noResults';
|
|
1545
|
+
const headers = {};
|
|
1546
|
+
const queryParameters = {};
|
|
1547
|
+
if (index !== undefined) {
|
|
1548
|
+
queryParameters.index = index.toString();
|
|
1549
|
+
}
|
|
1550
|
+
if (search !== undefined) {
|
|
1551
|
+
queryParameters.search = search.toString();
|
|
1552
|
+
}
|
|
1553
|
+
if (startDate !== undefined) {
|
|
1554
|
+
queryParameters.startDate = startDate.toString();
|
|
1555
|
+
}
|
|
1556
|
+
if (endDate !== undefined) {
|
|
1557
|
+
queryParameters.endDate = endDate.toString();
|
|
1558
|
+
}
|
|
1559
|
+
if (limit !== undefined) {
|
|
1560
|
+
queryParameters.limit = limit.toString();
|
|
1561
|
+
}
|
|
1562
|
+
if (offset !== undefined) {
|
|
1563
|
+
queryParameters.offset = offset.toString();
|
|
1564
|
+
}
|
|
1565
|
+
if (tags !== undefined) {
|
|
1566
|
+
queryParameters.tags = tags.toString();
|
|
1567
|
+
}
|
|
1568
|
+
const request = {
|
|
1569
|
+
method: 'GET',
|
|
1570
|
+
path: requestPath,
|
|
1571
|
+
queryParameters,
|
|
1572
|
+
headers,
|
|
1573
|
+
};
|
|
1574
|
+
return transporter.request(request, requestOptions);
|
|
1575
|
+
},
|
|
1576
|
+
/**
|
|
1577
|
+
* Retrieves the object IDs of the most frequent search results.
|
|
1578
|
+
*
|
|
1579
|
+
* Required API Key ACLs:
|
|
1580
|
+
* - analytics.
|
|
1581
|
+
*
|
|
1582
|
+
* @param getTopHits - The getTopHits object.
|
|
1583
|
+
* @param getTopHits.index - Index name.
|
|
1584
|
+
* @param getTopHits.search - Search query.
|
|
1585
|
+
* @param getTopHits.clickAnalytics - Whether to include metrics related to click and conversion events in the response.
|
|
1586
|
+
* @param getTopHits.revenueAnalytics - Whether to include revenue-related metrics in the response. If true, metrics related to click and conversion events are also included in the response.
|
|
1587
|
+
* @param getTopHits.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1588
|
+
* @param getTopHits.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1589
|
+
* @param getTopHits.limit - Number of items to return.
|
|
1590
|
+
* @param getTopHits.offset - Position of the first item to return.
|
|
1591
|
+
* @param getTopHits.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1592
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1593
|
+
*/
|
|
1594
|
+
getTopHits({ index, search, clickAnalytics, revenueAnalytics, startDate, endDate, limit, offset, tags, }, requestOptions) {
|
|
1595
|
+
if (!index) {
|
|
1596
|
+
throw new Error('Parameter `index` is required when calling `getTopHits`.');
|
|
1597
|
+
}
|
|
1598
|
+
const requestPath = '/2/hits';
|
|
1599
|
+
const headers = {};
|
|
1600
|
+
const queryParameters = {};
|
|
1601
|
+
if (index !== undefined) {
|
|
1602
|
+
queryParameters.index = index.toString();
|
|
1603
|
+
}
|
|
1604
|
+
if (search !== undefined) {
|
|
1605
|
+
queryParameters.search = search.toString();
|
|
1606
|
+
}
|
|
1607
|
+
if (clickAnalytics !== undefined) {
|
|
1608
|
+
queryParameters.clickAnalytics = clickAnalytics.toString();
|
|
1609
|
+
}
|
|
1610
|
+
if (revenueAnalytics !== undefined) {
|
|
1611
|
+
queryParameters.revenueAnalytics = revenueAnalytics.toString();
|
|
1612
|
+
}
|
|
1613
|
+
if (startDate !== undefined) {
|
|
1614
|
+
queryParameters.startDate = startDate.toString();
|
|
1615
|
+
}
|
|
1616
|
+
if (endDate !== undefined) {
|
|
1617
|
+
queryParameters.endDate = endDate.toString();
|
|
1618
|
+
}
|
|
1619
|
+
if (limit !== undefined) {
|
|
1620
|
+
queryParameters.limit = limit.toString();
|
|
1621
|
+
}
|
|
1622
|
+
if (offset !== undefined) {
|
|
1623
|
+
queryParameters.offset = offset.toString();
|
|
1624
|
+
}
|
|
1625
|
+
if (tags !== undefined) {
|
|
1626
|
+
queryParameters.tags = tags.toString();
|
|
1627
|
+
}
|
|
1628
|
+
const request = {
|
|
1629
|
+
method: 'GET',
|
|
1630
|
+
path: requestPath,
|
|
1631
|
+
queryParameters,
|
|
1632
|
+
headers,
|
|
1633
|
+
};
|
|
1634
|
+
return transporter.request(request, requestOptions);
|
|
1635
|
+
},
|
|
1636
|
+
/**
|
|
1637
|
+
* Returns the most popular search terms.
|
|
1638
|
+
*
|
|
1639
|
+
* Required API Key ACLs:
|
|
1640
|
+
* - analytics.
|
|
1641
|
+
*
|
|
1642
|
+
* @param getTopSearches - The getTopSearches object.
|
|
1643
|
+
* @param getTopSearches.index - Index name.
|
|
1644
|
+
* @param getTopSearches.clickAnalytics - Whether to include metrics related to click and conversion events in the response.
|
|
1645
|
+
* @param getTopSearches.revenueAnalytics - Whether to include revenue-related metrics in the response. If true, metrics related to click and conversion events are also included in the response.
|
|
1646
|
+
* @param getTopSearches.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1647
|
+
* @param getTopSearches.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1648
|
+
* @param getTopSearches.orderBy - Attribute by which to order the response items. If the `clickAnalytics` parameter is false, only `searchCount` is available.
|
|
1649
|
+
* @param getTopSearches.direction - Sorting direction of the results: ascending or descending.
|
|
1650
|
+
* @param getTopSearches.limit - Number of items to return.
|
|
1651
|
+
* @param getTopSearches.offset - Position of the first item to return.
|
|
1652
|
+
* @param getTopSearches.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1653
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1654
|
+
*/
|
|
1655
|
+
getTopSearches({ index, clickAnalytics, revenueAnalytics, startDate, endDate, orderBy, direction, limit, offset, tags, }, requestOptions) {
|
|
1656
|
+
if (!index) {
|
|
1657
|
+
throw new Error('Parameter `index` is required when calling `getTopSearches`.');
|
|
1658
|
+
}
|
|
1659
|
+
const requestPath = '/2/searches';
|
|
1660
|
+
const headers = {};
|
|
1661
|
+
const queryParameters = {};
|
|
1662
|
+
if (index !== undefined) {
|
|
1663
|
+
queryParameters.index = index.toString();
|
|
1664
|
+
}
|
|
1665
|
+
if (clickAnalytics !== undefined) {
|
|
1666
|
+
queryParameters.clickAnalytics = clickAnalytics.toString();
|
|
1667
|
+
}
|
|
1668
|
+
if (revenueAnalytics !== undefined) {
|
|
1669
|
+
queryParameters.revenueAnalytics = revenueAnalytics.toString();
|
|
1670
|
+
}
|
|
1671
|
+
if (startDate !== undefined) {
|
|
1672
|
+
queryParameters.startDate = startDate.toString();
|
|
1673
|
+
}
|
|
1674
|
+
if (endDate !== undefined) {
|
|
1675
|
+
queryParameters.endDate = endDate.toString();
|
|
1676
|
+
}
|
|
1677
|
+
if (orderBy !== undefined) {
|
|
1678
|
+
queryParameters.orderBy = orderBy.toString();
|
|
1679
|
+
}
|
|
1680
|
+
if (direction !== undefined) {
|
|
1681
|
+
queryParameters.direction = direction.toString();
|
|
1682
|
+
}
|
|
1683
|
+
if (limit !== undefined) {
|
|
1684
|
+
queryParameters.limit = limit.toString();
|
|
1685
|
+
}
|
|
1686
|
+
if (offset !== undefined) {
|
|
1687
|
+
queryParameters.offset = offset.toString();
|
|
1688
|
+
}
|
|
1689
|
+
if (tags !== undefined) {
|
|
1690
|
+
queryParameters.tags = tags.toString();
|
|
1691
|
+
}
|
|
1692
|
+
const request = {
|
|
1693
|
+
method: 'GET',
|
|
1694
|
+
path: requestPath,
|
|
1695
|
+
queryParameters,
|
|
1696
|
+
headers,
|
|
1697
|
+
};
|
|
1698
|
+
return transporter.request(request, requestOptions);
|
|
1699
|
+
},
|
|
1700
|
+
/**
|
|
1701
|
+
* Retrieves the number of unique users within a time range, including a daily breakdown. Since this endpoint returns the number of unique users, the sum of the daily values might be different from the total number. By default, Algolia distinguishes search users by their IP address, _unless_ you include a pseudonymous user identifier in your search requests with the `userToken` API parameter or `x-algolia-usertoken` request header. By default, the analyzed period includes the last eight days including the current day.
|
|
1702
|
+
*
|
|
1703
|
+
* Required API Key ACLs:
|
|
1704
|
+
* - analytics.
|
|
1705
|
+
*
|
|
1706
|
+
* @param getUsersCount - The getUsersCount object.
|
|
1707
|
+
* @param getUsersCount.index - Index name.
|
|
1708
|
+
* @param getUsersCount.startDate - Start date (`YYYY-MM-DD`) of the period to analyze.
|
|
1709
|
+
* @param getUsersCount.endDate - End date (`YYYY-MM-DD`) of the period to analyze.
|
|
1710
|
+
* @param getUsersCount.tags - Tags by which to segment the analytics. You can combine multiple tags with `OR` and `AND`. Tags must be URL-encoded. For more information, see [Segment your analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/).
|
|
1711
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1712
|
+
*/
|
|
1713
|
+
getUsersCount({ index, startDate, endDate, tags }, requestOptions) {
|
|
1714
|
+
if (!index) {
|
|
1715
|
+
throw new Error('Parameter `index` is required when calling `getUsersCount`.');
|
|
1716
|
+
}
|
|
1717
|
+
const requestPath = '/2/users/count';
|
|
1718
|
+
const headers = {};
|
|
1719
|
+
const queryParameters = {};
|
|
1720
|
+
if (index !== undefined) {
|
|
1721
|
+
queryParameters.index = index.toString();
|
|
1722
|
+
}
|
|
1723
|
+
if (startDate !== undefined) {
|
|
1724
|
+
queryParameters.startDate = startDate.toString();
|
|
1725
|
+
}
|
|
1726
|
+
if (endDate !== undefined) {
|
|
1727
|
+
queryParameters.endDate = endDate.toString();
|
|
1728
|
+
}
|
|
1729
|
+
if (tags !== undefined) {
|
|
1730
|
+
queryParameters.tags = tags.toString();
|
|
1731
|
+
}
|
|
1732
|
+
const request = {
|
|
1733
|
+
method: 'GET',
|
|
1734
|
+
path: requestPath,
|
|
1735
|
+
queryParameters,
|
|
1736
|
+
headers,
|
|
1737
|
+
};
|
|
1738
|
+
return transporter.request(request, requestOptions);
|
|
1739
|
+
},
|
|
1740
|
+
};
|
|
1609
1741
|
}
|
|
1610
1742
|
|
|
1611
|
-
//
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1743
|
+
// 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.
|
|
1744
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
1745
|
+
function analyticsClient(appId, apiKey, region, options) {
|
|
1746
|
+
if (!appId || typeof appId !== 'string') {
|
|
1747
|
+
throw new Error('`appId` is missing.');
|
|
1748
|
+
}
|
|
1749
|
+
if (!apiKey || typeof apiKey !== 'string') {
|
|
1750
|
+
throw new Error('`apiKey` is missing.');
|
|
1751
|
+
}
|
|
1752
|
+
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
|
|
1753
|
+
throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
|
|
1754
|
+
}
|
|
1755
|
+
return createAnalyticsClient({
|
|
1756
|
+
appId,
|
|
1757
|
+
apiKey,
|
|
1758
|
+
region,
|
|
1759
|
+
timeouts: {
|
|
1760
|
+
connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
|
|
1761
|
+
read: DEFAULT_READ_TIMEOUT_BROWSER,
|
|
1762
|
+
write: DEFAULT_WRITE_TIMEOUT_BROWSER,
|
|
1763
|
+
},
|
|
1764
|
+
requester: createXhrRequester(),
|
|
1765
|
+
algoliaAgents: [{ segment: 'Browser' }],
|
|
1766
|
+
authMode: 'WithinQueryParameters',
|
|
1767
|
+
responsesCache: createMemoryCache(),
|
|
1768
|
+
requestsCache: createMemoryCache({ serializable: false }),
|
|
1769
|
+
hostsCache: createFallbackableCache({
|
|
1770
|
+
caches: [
|
|
1771
|
+
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
|
|
1772
|
+
createMemoryCache(),
|
|
1773
|
+
],
|
|
1774
|
+
}),
|
|
1775
|
+
...options,
|
|
1776
|
+
});
|
|
1644
1777
|
}
|
|
1645
1778
|
|
|
1646
1779
|
export { analyticsClient, apiClientVersion };
|