@algolia/client-analytics 5.2.5 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +1152 -809
- package/dist/builds/browser.js +61 -47
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +1 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +1 -1
- package/dist/builds/node.cjs +61 -47
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +61 -47
- package/dist/builds/node.js.map +1 -1
- package/dist/node.d.cts +1153 -810
- package/dist/node.d.ts +1153 -810
- package/dist/src/analyticsClient.cjs +61 -47
- package/dist/src/analyticsClient.cjs.map +1 -1
- package/dist/src/analyticsClient.js +61 -47
- package/dist/src/analyticsClient.js.map +1 -1
- package/package.json +4 -4
package/dist/builds/node.js
CHANGED
|
@@ -10,7 +10,7 @@ import { createHttpRequester } from "@algolia/requester-node-http";
|
|
|
10
10
|
|
|
11
11
|
// src/analyticsClient.ts
|
|
12
12
|
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
13
|
-
var apiClientVersion = "5.
|
|
13
|
+
var apiClientVersion = "5.3.1";
|
|
14
14
|
var REGIONS = ["de", "us"];
|
|
15
15
|
function getDefaultHosts(region) {
|
|
16
16
|
const url = !region ? "analytics.algolia.com" : "analytics.{region}.algolia.com".replace("{region}", region);
|
|
@@ -25,26 +25,25 @@ function createAnalyticsClient({
|
|
|
25
25
|
...options
|
|
26
26
|
}) {
|
|
27
27
|
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
28
|
-
const transporter = createTransporter({
|
|
29
|
-
hosts: getDefaultHosts(regionOption),
|
|
30
|
-
...options,
|
|
31
|
-
algoliaAgent: getAlgoliaAgent({
|
|
32
|
-
algoliaAgents,
|
|
33
|
-
client: "Analytics",
|
|
34
|
-
version: apiClientVersion
|
|
35
|
-
}),
|
|
36
|
-
baseHeaders: {
|
|
37
|
-
"content-type": "text/plain",
|
|
38
|
-
...auth.headers(),
|
|
39
|
-
...options.baseHeaders
|
|
40
|
-
},
|
|
41
|
-
baseQueryParameters: {
|
|
42
|
-
...auth.queryParameters(),
|
|
43
|
-
...options.baseQueryParameters
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
28
|
return {
|
|
47
|
-
transporter
|
|
29
|
+
transporter: createTransporter({
|
|
30
|
+
hosts: getDefaultHosts(regionOption),
|
|
31
|
+
...options,
|
|
32
|
+
algoliaAgent: getAlgoliaAgent({
|
|
33
|
+
algoliaAgents,
|
|
34
|
+
client: "Analytics",
|
|
35
|
+
version: apiClientVersion
|
|
36
|
+
}),
|
|
37
|
+
baseHeaders: {
|
|
38
|
+
"content-type": "text/plain",
|
|
39
|
+
...auth.headers(),
|
|
40
|
+
...options.baseHeaders
|
|
41
|
+
},
|
|
42
|
+
baseQueryParameters: {
|
|
43
|
+
...auth.queryParameters(),
|
|
44
|
+
...options.baseQueryParameters
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
48
47
|
/**
|
|
49
48
|
* The `appId` currently in use.
|
|
50
49
|
*/
|
|
@@ -53,13 +52,15 @@ function createAnalyticsClient({
|
|
|
53
52
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
54
53
|
*/
|
|
55
54
|
clearCache() {
|
|
56
|
-
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(
|
|
55
|
+
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
|
|
56
|
+
() => void 0
|
|
57
|
+
);
|
|
57
58
|
},
|
|
58
59
|
/**
|
|
59
60
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
60
61
|
*/
|
|
61
62
|
get _ua() {
|
|
62
|
-
return transporter.algoliaAgent.value;
|
|
63
|
+
return this.transporter.algoliaAgent.value;
|
|
63
64
|
},
|
|
64
65
|
/**
|
|
65
66
|
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
@@ -68,7 +69,20 @@ function createAnalyticsClient({
|
|
|
68
69
|
* @param version - The version of the agent.
|
|
69
70
|
*/
|
|
70
71
|
addAlgoliaAgent(segment, version) {
|
|
71
|
-
transporter.algoliaAgent.add({ segment, version });
|
|
72
|
+
this.transporter.algoliaAgent.add({ segment, version });
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Helper method to switch the API key used to authenticate the requests.
|
|
76
|
+
*
|
|
77
|
+
* @param params - Method params.
|
|
78
|
+
* @param params.apiKey - The new API Key to use.
|
|
79
|
+
*/
|
|
80
|
+
setClientApiKey({ apiKey }) {
|
|
81
|
+
if (!authMode || authMode === "WithinHeaders") {
|
|
82
|
+
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
|
|
83
|
+
} else {
|
|
84
|
+
this.transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
|
|
85
|
+
}
|
|
72
86
|
},
|
|
73
87
|
/**
|
|
74
88
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -91,7 +105,7 @@ function createAnalyticsClient({
|
|
|
91
105
|
queryParameters,
|
|
92
106
|
headers
|
|
93
107
|
};
|
|
94
|
-
return transporter.request(request, requestOptions);
|
|
108
|
+
return this.transporter.request(request, requestOptions);
|
|
95
109
|
},
|
|
96
110
|
/**
|
|
97
111
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -114,7 +128,7 @@ function createAnalyticsClient({
|
|
|
114
128
|
queryParameters,
|
|
115
129
|
headers
|
|
116
130
|
};
|
|
117
|
-
return transporter.request(request, requestOptions);
|
|
131
|
+
return this.transporter.request(request, requestOptions);
|
|
118
132
|
},
|
|
119
133
|
/**
|
|
120
134
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -139,7 +153,7 @@ function createAnalyticsClient({
|
|
|
139
153
|
headers,
|
|
140
154
|
data: body ? body : {}
|
|
141
155
|
};
|
|
142
|
-
return transporter.request(request, requestOptions);
|
|
156
|
+
return this.transporter.request(request, requestOptions);
|
|
143
157
|
},
|
|
144
158
|
/**
|
|
145
159
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -164,7 +178,7 @@ function createAnalyticsClient({
|
|
|
164
178
|
headers,
|
|
165
179
|
data: body ? body : {}
|
|
166
180
|
};
|
|
167
|
-
return transporter.request(request, requestOptions);
|
|
181
|
+
return this.transporter.request(request, requestOptions);
|
|
168
182
|
},
|
|
169
183
|
/**
|
|
170
184
|
* 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.
|
|
@@ -204,7 +218,7 @@ function createAnalyticsClient({
|
|
|
204
218
|
queryParameters,
|
|
205
219
|
headers
|
|
206
220
|
};
|
|
207
|
-
return transporter.request(request, requestOptions);
|
|
221
|
+
return this.transporter.request(request, requestOptions);
|
|
208
222
|
},
|
|
209
223
|
/**
|
|
210
224
|
* 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.
|
|
@@ -244,7 +258,7 @@ function createAnalyticsClient({
|
|
|
244
258
|
queryParameters,
|
|
245
259
|
headers
|
|
246
260
|
};
|
|
247
|
-
return transporter.request(request, requestOptions);
|
|
261
|
+
return this.transporter.request(request, requestOptions);
|
|
248
262
|
},
|
|
249
263
|
/**
|
|
250
264
|
* 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.
|
|
@@ -284,7 +298,7 @@ function createAnalyticsClient({
|
|
|
284
298
|
queryParameters,
|
|
285
299
|
headers
|
|
286
300
|
};
|
|
287
|
-
return transporter.request(request, requestOptions);
|
|
301
|
+
return this.transporter.request(request, requestOptions);
|
|
288
302
|
},
|
|
289
303
|
/**
|
|
290
304
|
* 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.
|
|
@@ -324,7 +338,7 @@ function createAnalyticsClient({
|
|
|
324
338
|
queryParameters,
|
|
325
339
|
headers
|
|
326
340
|
};
|
|
327
|
-
return transporter.request(request, requestOptions);
|
|
341
|
+
return this.transporter.request(request, requestOptions);
|
|
328
342
|
},
|
|
329
343
|
/**
|
|
330
344
|
* 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.
|
|
@@ -364,7 +378,7 @@ function createAnalyticsClient({
|
|
|
364
378
|
queryParameters,
|
|
365
379
|
headers
|
|
366
380
|
};
|
|
367
|
-
return transporter.request(request, requestOptions);
|
|
381
|
+
return this.transporter.request(request, requestOptions);
|
|
368
382
|
},
|
|
369
383
|
/**
|
|
370
384
|
* 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.
|
|
@@ -404,7 +418,7 @@ function createAnalyticsClient({
|
|
|
404
418
|
queryParameters,
|
|
405
419
|
headers
|
|
406
420
|
};
|
|
407
|
-
return transporter.request(request, requestOptions);
|
|
421
|
+
return this.transporter.request(request, requestOptions);
|
|
408
422
|
},
|
|
409
423
|
/**
|
|
410
424
|
* 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.
|
|
@@ -444,7 +458,7 @@ function createAnalyticsClient({
|
|
|
444
458
|
queryParameters,
|
|
445
459
|
headers
|
|
446
460
|
};
|
|
447
|
-
return transporter.request(request, requestOptions);
|
|
461
|
+
return this.transporter.request(request, requestOptions);
|
|
448
462
|
},
|
|
449
463
|
/**
|
|
450
464
|
* 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.
|
|
@@ -484,7 +498,7 @@ function createAnalyticsClient({
|
|
|
484
498
|
queryParameters,
|
|
485
499
|
headers
|
|
486
500
|
};
|
|
487
|
-
return transporter.request(request, requestOptions);
|
|
501
|
+
return this.transporter.request(request, requestOptions);
|
|
488
502
|
},
|
|
489
503
|
/**
|
|
490
504
|
* 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.
|
|
@@ -524,7 +538,7 @@ function createAnalyticsClient({
|
|
|
524
538
|
queryParameters,
|
|
525
539
|
headers
|
|
526
540
|
};
|
|
527
|
-
return transporter.request(request, requestOptions);
|
|
541
|
+
return this.transporter.request(request, requestOptions);
|
|
528
542
|
},
|
|
529
543
|
/**
|
|
530
544
|
* 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.
|
|
@@ -564,7 +578,7 @@ function createAnalyticsClient({
|
|
|
564
578
|
queryParameters,
|
|
565
579
|
headers
|
|
566
580
|
};
|
|
567
|
-
return transporter.request(request, requestOptions);
|
|
581
|
+
return this.transporter.request(request, requestOptions);
|
|
568
582
|
},
|
|
569
583
|
/**
|
|
570
584
|
* Retrieves the most popular searches that didn\'t lead to any clicks, from the 1,000 most frequent searches.
|
|
@@ -612,7 +626,7 @@ function createAnalyticsClient({
|
|
|
612
626
|
queryParameters,
|
|
613
627
|
headers
|
|
614
628
|
};
|
|
615
|
-
return transporter.request(request, requestOptions);
|
|
629
|
+
return this.transporter.request(request, requestOptions);
|
|
616
630
|
},
|
|
617
631
|
/**
|
|
618
632
|
* Retrieves the most popular searches that didn\'t return any results.
|
|
@@ -660,7 +674,7 @@ function createAnalyticsClient({
|
|
|
660
674
|
queryParameters,
|
|
661
675
|
headers
|
|
662
676
|
};
|
|
663
|
-
return transporter.request(request, requestOptions);
|
|
677
|
+
return this.transporter.request(request, requestOptions);
|
|
664
678
|
},
|
|
665
679
|
/**
|
|
666
680
|
* Retrieves the time when the Analytics data for the specified index was last updated. The Analytics data is updated every 5 minutes.
|
|
@@ -688,7 +702,7 @@ function createAnalyticsClient({
|
|
|
688
702
|
queryParameters,
|
|
689
703
|
headers
|
|
690
704
|
};
|
|
691
|
-
return transporter.request(request, requestOptions);
|
|
705
|
+
return this.transporter.request(request, requestOptions);
|
|
692
706
|
},
|
|
693
707
|
/**
|
|
694
708
|
* Retrieves the countries with the most searches to your index.
|
|
@@ -736,7 +750,7 @@ function createAnalyticsClient({
|
|
|
736
750
|
queryParameters,
|
|
737
751
|
headers
|
|
738
752
|
};
|
|
739
|
-
return transporter.request(request, requestOptions);
|
|
753
|
+
return this.transporter.request(request, requestOptions);
|
|
740
754
|
},
|
|
741
755
|
/**
|
|
742
756
|
* Retrieves the most frequently used filter attributes. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
@@ -788,7 +802,7 @@ function createAnalyticsClient({
|
|
|
788
802
|
queryParameters,
|
|
789
803
|
headers
|
|
790
804
|
};
|
|
791
|
-
return transporter.request(request, requestOptions);
|
|
805
|
+
return this.transporter.request(request, requestOptions);
|
|
792
806
|
},
|
|
793
807
|
/**
|
|
794
808
|
* Retrieves the most frequent filter (facet) values for a filter attribute. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
@@ -844,7 +858,7 @@ function createAnalyticsClient({
|
|
|
844
858
|
queryParameters,
|
|
845
859
|
headers
|
|
846
860
|
};
|
|
847
|
-
return transporter.request(request, requestOptions);
|
|
861
|
+
return this.transporter.request(request, requestOptions);
|
|
848
862
|
},
|
|
849
863
|
/**
|
|
850
864
|
* 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.
|
|
@@ -896,7 +910,7 @@ function createAnalyticsClient({
|
|
|
896
910
|
queryParameters,
|
|
897
911
|
headers
|
|
898
912
|
};
|
|
899
|
-
return transporter.request(request, requestOptions);
|
|
913
|
+
return this.transporter.request(request, requestOptions);
|
|
900
914
|
},
|
|
901
915
|
/**
|
|
902
916
|
* Retrieves the object IDs of the most frequent search results.
|
|
@@ -956,7 +970,7 @@ function createAnalyticsClient({
|
|
|
956
970
|
queryParameters,
|
|
957
971
|
headers
|
|
958
972
|
};
|
|
959
|
-
return transporter.request(request, requestOptions);
|
|
973
|
+
return this.transporter.request(request, requestOptions);
|
|
960
974
|
},
|
|
961
975
|
/**
|
|
962
976
|
* Returns the most popular search terms.
|
|
@@ -1031,7 +1045,7 @@ function createAnalyticsClient({
|
|
|
1031
1045
|
queryParameters,
|
|
1032
1046
|
headers
|
|
1033
1047
|
};
|
|
1034
|
-
return transporter.request(request, requestOptions);
|
|
1048
|
+
return this.transporter.request(request, requestOptions);
|
|
1035
1049
|
},
|
|
1036
1050
|
/**
|
|
1037
1051
|
* 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.
|
|
@@ -1071,7 +1085,7 @@ function createAnalyticsClient({
|
|
|
1071
1085
|
queryParameters,
|
|
1072
1086
|
headers
|
|
1073
1087
|
};
|
|
1074
|
-
return transporter.request(request, requestOptions);
|
|
1088
|
+
return this.transporter.request(request, requestOptions);
|
|
1075
1089
|
}
|
|
1076
1090
|
};
|
|
1077
1091
|
}
|