@algolia/client-analytics 5.2.5 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +1152 -809
- package/dist/builds/browser.js +57 -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 +57 -47
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +57 -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 +57 -47
- package/dist/src/analyticsClient.cjs.map +1 -1
- package/dist/src/analyticsClient.js +57 -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.0";
|
|
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,16 @@ 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
|
+
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
|
|
73
83
|
},
|
|
74
84
|
/**
|
|
75
85
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -92,7 +102,7 @@ function createAnalyticsClient({
|
|
|
92
102
|
queryParameters,
|
|
93
103
|
headers
|
|
94
104
|
};
|
|
95
|
-
return transporter.request(request, requestOptions);
|
|
105
|
+
return this.transporter.request(request, requestOptions);
|
|
96
106
|
},
|
|
97
107
|
/**
|
|
98
108
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -115,7 +125,7 @@ function createAnalyticsClient({
|
|
|
115
125
|
queryParameters,
|
|
116
126
|
headers
|
|
117
127
|
};
|
|
118
|
-
return transporter.request(request, requestOptions);
|
|
128
|
+
return this.transporter.request(request, requestOptions);
|
|
119
129
|
},
|
|
120
130
|
/**
|
|
121
131
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -140,7 +150,7 @@ function createAnalyticsClient({
|
|
|
140
150
|
headers,
|
|
141
151
|
data: body ? body : {}
|
|
142
152
|
};
|
|
143
|
-
return transporter.request(request, requestOptions);
|
|
153
|
+
return this.transporter.request(request, requestOptions);
|
|
144
154
|
},
|
|
145
155
|
/**
|
|
146
156
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -165,7 +175,7 @@ function createAnalyticsClient({
|
|
|
165
175
|
headers,
|
|
166
176
|
data: body ? body : {}
|
|
167
177
|
};
|
|
168
|
-
return transporter.request(request, requestOptions);
|
|
178
|
+
return this.transporter.request(request, requestOptions);
|
|
169
179
|
},
|
|
170
180
|
/**
|
|
171
181
|
* 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 +215,7 @@ function createAnalyticsClient({
|
|
|
205
215
|
queryParameters,
|
|
206
216
|
headers
|
|
207
217
|
};
|
|
208
|
-
return transporter.request(request, requestOptions);
|
|
218
|
+
return this.transporter.request(request, requestOptions);
|
|
209
219
|
},
|
|
210
220
|
/**
|
|
211
221
|
* 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 +255,7 @@ function createAnalyticsClient({
|
|
|
245
255
|
queryParameters,
|
|
246
256
|
headers
|
|
247
257
|
};
|
|
248
|
-
return transporter.request(request, requestOptions);
|
|
258
|
+
return this.transporter.request(request, requestOptions);
|
|
249
259
|
},
|
|
250
260
|
/**
|
|
251
261
|
* 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 +295,7 @@ function createAnalyticsClient({
|
|
|
285
295
|
queryParameters,
|
|
286
296
|
headers
|
|
287
297
|
};
|
|
288
|
-
return transporter.request(request, requestOptions);
|
|
298
|
+
return this.transporter.request(request, requestOptions);
|
|
289
299
|
},
|
|
290
300
|
/**
|
|
291
301
|
* 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 +335,7 @@ function createAnalyticsClient({
|
|
|
325
335
|
queryParameters,
|
|
326
336
|
headers
|
|
327
337
|
};
|
|
328
|
-
return transporter.request(request, requestOptions);
|
|
338
|
+
return this.transporter.request(request, requestOptions);
|
|
329
339
|
},
|
|
330
340
|
/**
|
|
331
341
|
* 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 +375,7 @@ function createAnalyticsClient({
|
|
|
365
375
|
queryParameters,
|
|
366
376
|
headers
|
|
367
377
|
};
|
|
368
|
-
return transporter.request(request, requestOptions);
|
|
378
|
+
return this.transporter.request(request, requestOptions);
|
|
369
379
|
},
|
|
370
380
|
/**
|
|
371
381
|
* 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 +415,7 @@ function createAnalyticsClient({
|
|
|
405
415
|
queryParameters,
|
|
406
416
|
headers
|
|
407
417
|
};
|
|
408
|
-
return transporter.request(request, requestOptions);
|
|
418
|
+
return this.transporter.request(request, requestOptions);
|
|
409
419
|
},
|
|
410
420
|
/**
|
|
411
421
|
* 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 +455,7 @@ function createAnalyticsClient({
|
|
|
445
455
|
queryParameters,
|
|
446
456
|
headers
|
|
447
457
|
};
|
|
448
|
-
return transporter.request(request, requestOptions);
|
|
458
|
+
return this.transporter.request(request, requestOptions);
|
|
449
459
|
},
|
|
450
460
|
/**
|
|
451
461
|
* 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 +495,7 @@ function createAnalyticsClient({
|
|
|
485
495
|
queryParameters,
|
|
486
496
|
headers
|
|
487
497
|
};
|
|
488
|
-
return transporter.request(request, requestOptions);
|
|
498
|
+
return this.transporter.request(request, requestOptions);
|
|
489
499
|
},
|
|
490
500
|
/**
|
|
491
501
|
* 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 +535,7 @@ function createAnalyticsClient({
|
|
|
525
535
|
queryParameters,
|
|
526
536
|
headers
|
|
527
537
|
};
|
|
528
|
-
return transporter.request(request, requestOptions);
|
|
538
|
+
return this.transporter.request(request, requestOptions);
|
|
529
539
|
},
|
|
530
540
|
/**
|
|
531
541
|
* 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 +575,7 @@ function createAnalyticsClient({
|
|
|
565
575
|
queryParameters,
|
|
566
576
|
headers
|
|
567
577
|
};
|
|
568
|
-
return transporter.request(request, requestOptions);
|
|
578
|
+
return this.transporter.request(request, requestOptions);
|
|
569
579
|
},
|
|
570
580
|
/**
|
|
571
581
|
* Retrieves the most popular searches that didn\'t lead to any clicks, from the 1,000 most frequent searches.
|
|
@@ -613,7 +623,7 @@ function createAnalyticsClient({
|
|
|
613
623
|
queryParameters,
|
|
614
624
|
headers
|
|
615
625
|
};
|
|
616
|
-
return transporter.request(request, requestOptions);
|
|
626
|
+
return this.transporter.request(request, requestOptions);
|
|
617
627
|
},
|
|
618
628
|
/**
|
|
619
629
|
* Retrieves the most popular searches that didn\'t return any results.
|
|
@@ -661,7 +671,7 @@ function createAnalyticsClient({
|
|
|
661
671
|
queryParameters,
|
|
662
672
|
headers
|
|
663
673
|
};
|
|
664
|
-
return transporter.request(request, requestOptions);
|
|
674
|
+
return this.transporter.request(request, requestOptions);
|
|
665
675
|
},
|
|
666
676
|
/**
|
|
667
677
|
* Retrieves the time when the Analytics data for the specified index was last updated. The Analytics data is updated every 5 minutes.
|
|
@@ -689,7 +699,7 @@ function createAnalyticsClient({
|
|
|
689
699
|
queryParameters,
|
|
690
700
|
headers
|
|
691
701
|
};
|
|
692
|
-
return transporter.request(request, requestOptions);
|
|
702
|
+
return this.transporter.request(request, requestOptions);
|
|
693
703
|
},
|
|
694
704
|
/**
|
|
695
705
|
* Retrieves the countries with the most searches to your index.
|
|
@@ -737,7 +747,7 @@ function createAnalyticsClient({
|
|
|
737
747
|
queryParameters,
|
|
738
748
|
headers
|
|
739
749
|
};
|
|
740
|
-
return transporter.request(request, requestOptions);
|
|
750
|
+
return this.transporter.request(request, requestOptions);
|
|
741
751
|
},
|
|
742
752
|
/**
|
|
743
753
|
* Retrieves the most frequently used filter attributes. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
@@ -789,7 +799,7 @@ function createAnalyticsClient({
|
|
|
789
799
|
queryParameters,
|
|
790
800
|
headers
|
|
791
801
|
};
|
|
792
|
-
return transporter.request(request, requestOptions);
|
|
802
|
+
return this.transporter.request(request, requestOptions);
|
|
793
803
|
},
|
|
794
804
|
/**
|
|
795
805
|
* 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 +855,7 @@ function createAnalyticsClient({
|
|
|
845
855
|
queryParameters,
|
|
846
856
|
headers
|
|
847
857
|
};
|
|
848
|
-
return transporter.request(request, requestOptions);
|
|
858
|
+
return this.transporter.request(request, requestOptions);
|
|
849
859
|
},
|
|
850
860
|
/**
|
|
851
861
|
* 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 +907,7 @@ function createAnalyticsClient({
|
|
|
897
907
|
queryParameters,
|
|
898
908
|
headers
|
|
899
909
|
};
|
|
900
|
-
return transporter.request(request, requestOptions);
|
|
910
|
+
return this.transporter.request(request, requestOptions);
|
|
901
911
|
},
|
|
902
912
|
/**
|
|
903
913
|
* Retrieves the object IDs of the most frequent search results.
|
|
@@ -957,7 +967,7 @@ function createAnalyticsClient({
|
|
|
957
967
|
queryParameters,
|
|
958
968
|
headers
|
|
959
969
|
};
|
|
960
|
-
return transporter.request(request, requestOptions);
|
|
970
|
+
return this.transporter.request(request, requestOptions);
|
|
961
971
|
},
|
|
962
972
|
/**
|
|
963
973
|
* Returns the most popular search terms.
|
|
@@ -1032,7 +1042,7 @@ function createAnalyticsClient({
|
|
|
1032
1042
|
queryParameters,
|
|
1033
1043
|
headers
|
|
1034
1044
|
};
|
|
1035
|
-
return transporter.request(request, requestOptions);
|
|
1045
|
+
return this.transporter.request(request, requestOptions);
|
|
1036
1046
|
},
|
|
1037
1047
|
/**
|
|
1038
1048
|
* 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 +1082,7 @@ function createAnalyticsClient({
|
|
|
1072
1082
|
queryParameters,
|
|
1073
1083
|
headers
|
|
1074
1084
|
};
|
|
1075
|
-
return transporter.request(request, requestOptions);
|
|
1085
|
+
return this.transporter.request(request, requestOptions);
|
|
1076
1086
|
}
|
|
1077
1087
|
};
|
|
1078
1088
|
}
|