@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/browser.js
CHANGED
|
@@ -11,7 +11,7 @@ import { createXhrRequester } from "@algolia/requester-browser-xhr";
|
|
|
11
11
|
|
|
12
12
|
// src/analyticsClient.ts
|
|
13
13
|
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
14
|
-
var apiClientVersion = "5.
|
|
14
|
+
var apiClientVersion = "5.3.1";
|
|
15
15
|
var REGIONS = ["de", "us"];
|
|
16
16
|
function getDefaultHosts(region) {
|
|
17
17
|
const url = !region ? "analytics.algolia.com" : "analytics.{region}.algolia.com".replace("{region}", region);
|
|
@@ -26,26 +26,25 @@ function createAnalyticsClient({
|
|
|
26
26
|
...options
|
|
27
27
|
}) {
|
|
28
28
|
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
29
|
-
const 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
|
-
});
|
|
47
29
|
return {
|
|
48
|
-
transporter
|
|
30
|
+
transporter: createTransporter({
|
|
31
|
+
hosts: getDefaultHosts(regionOption),
|
|
32
|
+
...options,
|
|
33
|
+
algoliaAgent: getAlgoliaAgent({
|
|
34
|
+
algoliaAgents,
|
|
35
|
+
client: "Analytics",
|
|
36
|
+
version: apiClientVersion
|
|
37
|
+
}),
|
|
38
|
+
baseHeaders: {
|
|
39
|
+
"content-type": "text/plain",
|
|
40
|
+
...auth.headers(),
|
|
41
|
+
...options.baseHeaders
|
|
42
|
+
},
|
|
43
|
+
baseQueryParameters: {
|
|
44
|
+
...auth.queryParameters(),
|
|
45
|
+
...options.baseQueryParameters
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
49
48
|
/**
|
|
50
49
|
* The `appId` currently in use.
|
|
51
50
|
*/
|
|
@@ -54,13 +53,15 @@ function createAnalyticsClient({
|
|
|
54
53
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
55
54
|
*/
|
|
56
55
|
clearCache() {
|
|
57
|
-
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(
|
|
56
|
+
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
|
|
57
|
+
() => void 0
|
|
58
|
+
);
|
|
58
59
|
},
|
|
59
60
|
/**
|
|
60
61
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
61
62
|
*/
|
|
62
63
|
get _ua() {
|
|
63
|
-
return transporter.algoliaAgent.value;
|
|
64
|
+
return this.transporter.algoliaAgent.value;
|
|
64
65
|
},
|
|
65
66
|
/**
|
|
66
67
|
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
@@ -69,7 +70,20 @@ function createAnalyticsClient({
|
|
|
69
70
|
* @param version - The version of the agent.
|
|
70
71
|
*/
|
|
71
72
|
addAlgoliaAgent(segment, version) {
|
|
72
|
-
transporter.algoliaAgent.add({ segment, version });
|
|
73
|
+
this.transporter.algoliaAgent.add({ segment, version });
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* Helper method to switch the API key used to authenticate the requests.
|
|
77
|
+
*
|
|
78
|
+
* @param params - Method params.
|
|
79
|
+
* @param params.apiKey - The new API Key to use.
|
|
80
|
+
*/
|
|
81
|
+
setClientApiKey({ apiKey }) {
|
|
82
|
+
if (!authMode || authMode === "WithinHeaders") {
|
|
83
|
+
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
|
|
84
|
+
} else {
|
|
85
|
+
this.transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
|
|
86
|
+
}
|
|
73
87
|
},
|
|
74
88
|
/**
|
|
75
89
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -92,7 +106,7 @@ function createAnalyticsClient({
|
|
|
92
106
|
queryParameters,
|
|
93
107
|
headers
|
|
94
108
|
};
|
|
95
|
-
return transporter.request(request, requestOptions);
|
|
109
|
+
return this.transporter.request(request, requestOptions);
|
|
96
110
|
},
|
|
97
111
|
/**
|
|
98
112
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -115,7 +129,7 @@ function createAnalyticsClient({
|
|
|
115
129
|
queryParameters,
|
|
116
130
|
headers
|
|
117
131
|
};
|
|
118
|
-
return transporter.request(request, requestOptions);
|
|
132
|
+
return this.transporter.request(request, requestOptions);
|
|
119
133
|
},
|
|
120
134
|
/**
|
|
121
135
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -140,7 +154,7 @@ function createAnalyticsClient({
|
|
|
140
154
|
headers,
|
|
141
155
|
data: body ? body : {}
|
|
142
156
|
};
|
|
143
|
-
return transporter.request(request, requestOptions);
|
|
157
|
+
return this.transporter.request(request, requestOptions);
|
|
144
158
|
},
|
|
145
159
|
/**
|
|
146
160
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -165,7 +179,7 @@ function createAnalyticsClient({
|
|
|
165
179
|
headers,
|
|
166
180
|
data: body ? body : {}
|
|
167
181
|
};
|
|
168
|
-
return transporter.request(request, requestOptions);
|
|
182
|
+
return this.transporter.request(request, requestOptions);
|
|
169
183
|
},
|
|
170
184
|
/**
|
|
171
185
|
* 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.
|
|
@@ -205,7 +219,7 @@ function createAnalyticsClient({
|
|
|
205
219
|
queryParameters,
|
|
206
220
|
headers
|
|
207
221
|
};
|
|
208
|
-
return transporter.request(request, requestOptions);
|
|
222
|
+
return this.transporter.request(request, requestOptions);
|
|
209
223
|
},
|
|
210
224
|
/**
|
|
211
225
|
* 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.
|
|
@@ -245,7 +259,7 @@ function createAnalyticsClient({
|
|
|
245
259
|
queryParameters,
|
|
246
260
|
headers
|
|
247
261
|
};
|
|
248
|
-
return transporter.request(request, requestOptions);
|
|
262
|
+
return this.transporter.request(request, requestOptions);
|
|
249
263
|
},
|
|
250
264
|
/**
|
|
251
265
|
* 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.
|
|
@@ -285,7 +299,7 @@ function createAnalyticsClient({
|
|
|
285
299
|
queryParameters,
|
|
286
300
|
headers
|
|
287
301
|
};
|
|
288
|
-
return transporter.request(request, requestOptions);
|
|
302
|
+
return this.transporter.request(request, requestOptions);
|
|
289
303
|
},
|
|
290
304
|
/**
|
|
291
305
|
* 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.
|
|
@@ -325,7 +339,7 @@ function createAnalyticsClient({
|
|
|
325
339
|
queryParameters,
|
|
326
340
|
headers
|
|
327
341
|
};
|
|
328
|
-
return transporter.request(request, requestOptions);
|
|
342
|
+
return this.transporter.request(request, requestOptions);
|
|
329
343
|
},
|
|
330
344
|
/**
|
|
331
345
|
* 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.
|
|
@@ -365,7 +379,7 @@ function createAnalyticsClient({
|
|
|
365
379
|
queryParameters,
|
|
366
380
|
headers
|
|
367
381
|
};
|
|
368
|
-
return transporter.request(request, requestOptions);
|
|
382
|
+
return this.transporter.request(request, requestOptions);
|
|
369
383
|
},
|
|
370
384
|
/**
|
|
371
385
|
* 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.
|
|
@@ -405,7 +419,7 @@ function createAnalyticsClient({
|
|
|
405
419
|
queryParameters,
|
|
406
420
|
headers
|
|
407
421
|
};
|
|
408
|
-
return transporter.request(request, requestOptions);
|
|
422
|
+
return this.transporter.request(request, requestOptions);
|
|
409
423
|
},
|
|
410
424
|
/**
|
|
411
425
|
* 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.
|
|
@@ -445,7 +459,7 @@ function createAnalyticsClient({
|
|
|
445
459
|
queryParameters,
|
|
446
460
|
headers
|
|
447
461
|
};
|
|
448
|
-
return transporter.request(request, requestOptions);
|
|
462
|
+
return this.transporter.request(request, requestOptions);
|
|
449
463
|
},
|
|
450
464
|
/**
|
|
451
465
|
* 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.
|
|
@@ -485,7 +499,7 @@ function createAnalyticsClient({
|
|
|
485
499
|
queryParameters,
|
|
486
500
|
headers
|
|
487
501
|
};
|
|
488
|
-
return transporter.request(request, requestOptions);
|
|
502
|
+
return this.transporter.request(request, requestOptions);
|
|
489
503
|
},
|
|
490
504
|
/**
|
|
491
505
|
* 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.
|
|
@@ -525,7 +539,7 @@ function createAnalyticsClient({
|
|
|
525
539
|
queryParameters,
|
|
526
540
|
headers
|
|
527
541
|
};
|
|
528
|
-
return transporter.request(request, requestOptions);
|
|
542
|
+
return this.transporter.request(request, requestOptions);
|
|
529
543
|
},
|
|
530
544
|
/**
|
|
531
545
|
* 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.
|
|
@@ -565,7 +579,7 @@ function createAnalyticsClient({
|
|
|
565
579
|
queryParameters,
|
|
566
580
|
headers
|
|
567
581
|
};
|
|
568
|
-
return transporter.request(request, requestOptions);
|
|
582
|
+
return this.transporter.request(request, requestOptions);
|
|
569
583
|
},
|
|
570
584
|
/**
|
|
571
585
|
* Retrieves the most popular searches that didn\'t lead to any clicks, from the 1,000 most frequent searches.
|
|
@@ -613,7 +627,7 @@ function createAnalyticsClient({
|
|
|
613
627
|
queryParameters,
|
|
614
628
|
headers
|
|
615
629
|
};
|
|
616
|
-
return transporter.request(request, requestOptions);
|
|
630
|
+
return this.transporter.request(request, requestOptions);
|
|
617
631
|
},
|
|
618
632
|
/**
|
|
619
633
|
* Retrieves the most popular searches that didn\'t return any results.
|
|
@@ -661,7 +675,7 @@ function createAnalyticsClient({
|
|
|
661
675
|
queryParameters,
|
|
662
676
|
headers
|
|
663
677
|
};
|
|
664
|
-
return transporter.request(request, requestOptions);
|
|
678
|
+
return this.transporter.request(request, requestOptions);
|
|
665
679
|
},
|
|
666
680
|
/**
|
|
667
681
|
* Retrieves the time when the Analytics data for the specified index was last updated. The Analytics data is updated every 5 minutes.
|
|
@@ -689,7 +703,7 @@ function createAnalyticsClient({
|
|
|
689
703
|
queryParameters,
|
|
690
704
|
headers
|
|
691
705
|
};
|
|
692
|
-
return transporter.request(request, requestOptions);
|
|
706
|
+
return this.transporter.request(request, requestOptions);
|
|
693
707
|
},
|
|
694
708
|
/**
|
|
695
709
|
* Retrieves the countries with the most searches to your index.
|
|
@@ -737,7 +751,7 @@ function createAnalyticsClient({
|
|
|
737
751
|
queryParameters,
|
|
738
752
|
headers
|
|
739
753
|
};
|
|
740
|
-
return transporter.request(request, requestOptions);
|
|
754
|
+
return this.transporter.request(request, requestOptions);
|
|
741
755
|
},
|
|
742
756
|
/**
|
|
743
757
|
* Retrieves the most frequently used filter attributes. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
@@ -789,7 +803,7 @@ function createAnalyticsClient({
|
|
|
789
803
|
queryParameters,
|
|
790
804
|
headers
|
|
791
805
|
};
|
|
792
|
-
return transporter.request(request, requestOptions);
|
|
806
|
+
return this.transporter.request(request, requestOptions);
|
|
793
807
|
},
|
|
794
808
|
/**
|
|
795
809
|
* Retrieves the most frequent filter (facet) values for a filter attribute. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
@@ -845,7 +859,7 @@ function createAnalyticsClient({
|
|
|
845
859
|
queryParameters,
|
|
846
860
|
headers
|
|
847
861
|
};
|
|
848
|
-
return transporter.request(request, requestOptions);
|
|
862
|
+
return this.transporter.request(request, requestOptions);
|
|
849
863
|
},
|
|
850
864
|
/**
|
|
851
865
|
* 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.
|
|
@@ -897,7 +911,7 @@ function createAnalyticsClient({
|
|
|
897
911
|
queryParameters,
|
|
898
912
|
headers
|
|
899
913
|
};
|
|
900
|
-
return transporter.request(request, requestOptions);
|
|
914
|
+
return this.transporter.request(request, requestOptions);
|
|
901
915
|
},
|
|
902
916
|
/**
|
|
903
917
|
* Retrieves the object IDs of the most frequent search results.
|
|
@@ -957,7 +971,7 @@ function createAnalyticsClient({
|
|
|
957
971
|
queryParameters,
|
|
958
972
|
headers
|
|
959
973
|
};
|
|
960
|
-
return transporter.request(request, requestOptions);
|
|
974
|
+
return this.transporter.request(request, requestOptions);
|
|
961
975
|
},
|
|
962
976
|
/**
|
|
963
977
|
* Returns the most popular search terms.
|
|
@@ -1032,7 +1046,7 @@ function createAnalyticsClient({
|
|
|
1032
1046
|
queryParameters,
|
|
1033
1047
|
headers
|
|
1034
1048
|
};
|
|
1035
|
-
return transporter.request(request, requestOptions);
|
|
1049
|
+
return this.transporter.request(request, requestOptions);
|
|
1036
1050
|
},
|
|
1037
1051
|
/**
|
|
1038
1052
|
* 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.
|
|
@@ -1072,7 +1086,7 @@ function createAnalyticsClient({
|
|
|
1072
1086
|
queryParameters,
|
|
1073
1087
|
headers
|
|
1074
1088
|
};
|
|
1075
|
-
return transporter.request(request, requestOptions);
|
|
1089
|
+
return this.transporter.request(request, requestOptions);
|
|
1076
1090
|
}
|
|
1077
1091
|
};
|
|
1078
1092
|
}
|