@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/analyticsClient.ts
|
|
2
2
|
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
3
|
-
var apiClientVersion = "5.
|
|
3
|
+
var apiClientVersion = "5.3.0";
|
|
4
4
|
var REGIONS = ["de", "us"];
|
|
5
5
|
function getDefaultHosts(region) {
|
|
6
6
|
const url = !region ? "analytics.algolia.com" : "analytics.{region}.algolia.com".replace("{region}", region);
|
|
@@ -15,26 +15,25 @@ function createAnalyticsClient({
|
|
|
15
15
|
...options
|
|
16
16
|
}) {
|
|
17
17
|
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
18
|
-
const transporter = createTransporter({
|
|
19
|
-
hosts: getDefaultHosts(regionOption),
|
|
20
|
-
...options,
|
|
21
|
-
algoliaAgent: getAlgoliaAgent({
|
|
22
|
-
algoliaAgents,
|
|
23
|
-
client: "Analytics",
|
|
24
|
-
version: apiClientVersion
|
|
25
|
-
}),
|
|
26
|
-
baseHeaders: {
|
|
27
|
-
"content-type": "text/plain",
|
|
28
|
-
...auth.headers(),
|
|
29
|
-
...options.baseHeaders
|
|
30
|
-
},
|
|
31
|
-
baseQueryParameters: {
|
|
32
|
-
...auth.queryParameters(),
|
|
33
|
-
...options.baseQueryParameters
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
18
|
return {
|
|
37
|
-
transporter
|
|
19
|
+
transporter: createTransporter({
|
|
20
|
+
hosts: getDefaultHosts(regionOption),
|
|
21
|
+
...options,
|
|
22
|
+
algoliaAgent: getAlgoliaAgent({
|
|
23
|
+
algoliaAgents,
|
|
24
|
+
client: "Analytics",
|
|
25
|
+
version: apiClientVersion
|
|
26
|
+
}),
|
|
27
|
+
baseHeaders: {
|
|
28
|
+
"content-type": "text/plain",
|
|
29
|
+
...auth.headers(),
|
|
30
|
+
...options.baseHeaders
|
|
31
|
+
},
|
|
32
|
+
baseQueryParameters: {
|
|
33
|
+
...auth.queryParameters(),
|
|
34
|
+
...options.baseQueryParameters
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
38
37
|
/**
|
|
39
38
|
* The `appId` currently in use.
|
|
40
39
|
*/
|
|
@@ -43,13 +42,15 @@ function createAnalyticsClient({
|
|
|
43
42
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
44
43
|
*/
|
|
45
44
|
clearCache() {
|
|
46
|
-
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(
|
|
45
|
+
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
|
|
46
|
+
() => void 0
|
|
47
|
+
);
|
|
47
48
|
},
|
|
48
49
|
/**
|
|
49
50
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
50
51
|
*/
|
|
51
52
|
get _ua() {
|
|
52
|
-
return transporter.algoliaAgent.value;
|
|
53
|
+
return this.transporter.algoliaAgent.value;
|
|
53
54
|
},
|
|
54
55
|
/**
|
|
55
56
|
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
@@ -58,7 +59,16 @@ function createAnalyticsClient({
|
|
|
58
59
|
* @param version - The version of the agent.
|
|
59
60
|
*/
|
|
60
61
|
addAlgoliaAgent(segment, version) {
|
|
61
|
-
transporter.algoliaAgent.add({ segment, version });
|
|
62
|
+
this.transporter.algoliaAgent.add({ segment, version });
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Helper method to switch the API key used to authenticate the requests.
|
|
66
|
+
*
|
|
67
|
+
* @param params - Method params.
|
|
68
|
+
* @param params.apiKey - The new API Key to use.
|
|
69
|
+
*/
|
|
70
|
+
setClientApiKey({ apiKey }) {
|
|
71
|
+
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
|
|
62
72
|
},
|
|
63
73
|
/**
|
|
64
74
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -81,7 +91,7 @@ function createAnalyticsClient({
|
|
|
81
91
|
queryParameters,
|
|
82
92
|
headers
|
|
83
93
|
};
|
|
84
|
-
return transporter.request(request, requestOptions);
|
|
94
|
+
return this.transporter.request(request, requestOptions);
|
|
85
95
|
},
|
|
86
96
|
/**
|
|
87
97
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -104,7 +114,7 @@ function createAnalyticsClient({
|
|
|
104
114
|
queryParameters,
|
|
105
115
|
headers
|
|
106
116
|
};
|
|
107
|
-
return transporter.request(request, requestOptions);
|
|
117
|
+
return this.transporter.request(request, requestOptions);
|
|
108
118
|
},
|
|
109
119
|
/**
|
|
110
120
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -129,7 +139,7 @@ function createAnalyticsClient({
|
|
|
129
139
|
headers,
|
|
130
140
|
data: body ? body : {}
|
|
131
141
|
};
|
|
132
|
-
return transporter.request(request, requestOptions);
|
|
142
|
+
return this.transporter.request(request, requestOptions);
|
|
133
143
|
},
|
|
134
144
|
/**
|
|
135
145
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -154,7 +164,7 @@ function createAnalyticsClient({
|
|
|
154
164
|
headers,
|
|
155
165
|
data: body ? body : {}
|
|
156
166
|
};
|
|
157
|
-
return transporter.request(request, requestOptions);
|
|
167
|
+
return this.transporter.request(request, requestOptions);
|
|
158
168
|
},
|
|
159
169
|
/**
|
|
160
170
|
* 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.
|
|
@@ -194,7 +204,7 @@ function createAnalyticsClient({
|
|
|
194
204
|
queryParameters,
|
|
195
205
|
headers
|
|
196
206
|
};
|
|
197
|
-
return transporter.request(request, requestOptions);
|
|
207
|
+
return this.transporter.request(request, requestOptions);
|
|
198
208
|
},
|
|
199
209
|
/**
|
|
200
210
|
* 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.
|
|
@@ -234,7 +244,7 @@ function createAnalyticsClient({
|
|
|
234
244
|
queryParameters,
|
|
235
245
|
headers
|
|
236
246
|
};
|
|
237
|
-
return transporter.request(request, requestOptions);
|
|
247
|
+
return this.transporter.request(request, requestOptions);
|
|
238
248
|
},
|
|
239
249
|
/**
|
|
240
250
|
* 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.
|
|
@@ -274,7 +284,7 @@ function createAnalyticsClient({
|
|
|
274
284
|
queryParameters,
|
|
275
285
|
headers
|
|
276
286
|
};
|
|
277
|
-
return transporter.request(request, requestOptions);
|
|
287
|
+
return this.transporter.request(request, requestOptions);
|
|
278
288
|
},
|
|
279
289
|
/**
|
|
280
290
|
* 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.
|
|
@@ -314,7 +324,7 @@ function createAnalyticsClient({
|
|
|
314
324
|
queryParameters,
|
|
315
325
|
headers
|
|
316
326
|
};
|
|
317
|
-
return transporter.request(request, requestOptions);
|
|
327
|
+
return this.transporter.request(request, requestOptions);
|
|
318
328
|
},
|
|
319
329
|
/**
|
|
320
330
|
* 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.
|
|
@@ -354,7 +364,7 @@ function createAnalyticsClient({
|
|
|
354
364
|
queryParameters,
|
|
355
365
|
headers
|
|
356
366
|
};
|
|
357
|
-
return transporter.request(request, requestOptions);
|
|
367
|
+
return this.transporter.request(request, requestOptions);
|
|
358
368
|
},
|
|
359
369
|
/**
|
|
360
370
|
* 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.
|
|
@@ -394,7 +404,7 @@ function createAnalyticsClient({
|
|
|
394
404
|
queryParameters,
|
|
395
405
|
headers
|
|
396
406
|
};
|
|
397
|
-
return transporter.request(request, requestOptions);
|
|
407
|
+
return this.transporter.request(request, requestOptions);
|
|
398
408
|
},
|
|
399
409
|
/**
|
|
400
410
|
* 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.
|
|
@@ -434,7 +444,7 @@ function createAnalyticsClient({
|
|
|
434
444
|
queryParameters,
|
|
435
445
|
headers
|
|
436
446
|
};
|
|
437
|
-
return transporter.request(request, requestOptions);
|
|
447
|
+
return this.transporter.request(request, requestOptions);
|
|
438
448
|
},
|
|
439
449
|
/**
|
|
440
450
|
* 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.
|
|
@@ -474,7 +484,7 @@ function createAnalyticsClient({
|
|
|
474
484
|
queryParameters,
|
|
475
485
|
headers
|
|
476
486
|
};
|
|
477
|
-
return transporter.request(request, requestOptions);
|
|
487
|
+
return this.transporter.request(request, requestOptions);
|
|
478
488
|
},
|
|
479
489
|
/**
|
|
480
490
|
* 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.
|
|
@@ -514,7 +524,7 @@ function createAnalyticsClient({
|
|
|
514
524
|
queryParameters,
|
|
515
525
|
headers
|
|
516
526
|
};
|
|
517
|
-
return transporter.request(request, requestOptions);
|
|
527
|
+
return this.transporter.request(request, requestOptions);
|
|
518
528
|
},
|
|
519
529
|
/**
|
|
520
530
|
* 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.
|
|
@@ -554,7 +564,7 @@ function createAnalyticsClient({
|
|
|
554
564
|
queryParameters,
|
|
555
565
|
headers
|
|
556
566
|
};
|
|
557
|
-
return transporter.request(request, requestOptions);
|
|
567
|
+
return this.transporter.request(request, requestOptions);
|
|
558
568
|
},
|
|
559
569
|
/**
|
|
560
570
|
* Retrieves the most popular searches that didn\'t lead to any clicks, from the 1,000 most frequent searches.
|
|
@@ -602,7 +612,7 @@ function createAnalyticsClient({
|
|
|
602
612
|
queryParameters,
|
|
603
613
|
headers
|
|
604
614
|
};
|
|
605
|
-
return transporter.request(request, requestOptions);
|
|
615
|
+
return this.transporter.request(request, requestOptions);
|
|
606
616
|
},
|
|
607
617
|
/**
|
|
608
618
|
* Retrieves the most popular searches that didn\'t return any results.
|
|
@@ -650,7 +660,7 @@ function createAnalyticsClient({
|
|
|
650
660
|
queryParameters,
|
|
651
661
|
headers
|
|
652
662
|
};
|
|
653
|
-
return transporter.request(request, requestOptions);
|
|
663
|
+
return this.transporter.request(request, requestOptions);
|
|
654
664
|
},
|
|
655
665
|
/**
|
|
656
666
|
* Retrieves the time when the Analytics data for the specified index was last updated. The Analytics data is updated every 5 minutes.
|
|
@@ -678,7 +688,7 @@ function createAnalyticsClient({
|
|
|
678
688
|
queryParameters,
|
|
679
689
|
headers
|
|
680
690
|
};
|
|
681
|
-
return transporter.request(request, requestOptions);
|
|
691
|
+
return this.transporter.request(request, requestOptions);
|
|
682
692
|
},
|
|
683
693
|
/**
|
|
684
694
|
* Retrieves the countries with the most searches to your index.
|
|
@@ -726,7 +736,7 @@ function createAnalyticsClient({
|
|
|
726
736
|
queryParameters,
|
|
727
737
|
headers
|
|
728
738
|
};
|
|
729
|
-
return transporter.request(request, requestOptions);
|
|
739
|
+
return this.transporter.request(request, requestOptions);
|
|
730
740
|
},
|
|
731
741
|
/**
|
|
732
742
|
* Retrieves the most frequently used filter attributes. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
@@ -778,7 +788,7 @@ function createAnalyticsClient({
|
|
|
778
788
|
queryParameters,
|
|
779
789
|
headers
|
|
780
790
|
};
|
|
781
|
-
return transporter.request(request, requestOptions);
|
|
791
|
+
return this.transporter.request(request, requestOptions);
|
|
782
792
|
},
|
|
783
793
|
/**
|
|
784
794
|
* Retrieves the most frequent filter (facet) values for a filter attribute. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
@@ -834,7 +844,7 @@ function createAnalyticsClient({
|
|
|
834
844
|
queryParameters,
|
|
835
845
|
headers
|
|
836
846
|
};
|
|
837
|
-
return transporter.request(request, requestOptions);
|
|
847
|
+
return this.transporter.request(request, requestOptions);
|
|
838
848
|
},
|
|
839
849
|
/**
|
|
840
850
|
* 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.
|
|
@@ -886,7 +896,7 @@ function createAnalyticsClient({
|
|
|
886
896
|
queryParameters,
|
|
887
897
|
headers
|
|
888
898
|
};
|
|
889
|
-
return transporter.request(request, requestOptions);
|
|
899
|
+
return this.transporter.request(request, requestOptions);
|
|
890
900
|
},
|
|
891
901
|
/**
|
|
892
902
|
* Retrieves the object IDs of the most frequent search results.
|
|
@@ -946,7 +956,7 @@ function createAnalyticsClient({
|
|
|
946
956
|
queryParameters,
|
|
947
957
|
headers
|
|
948
958
|
};
|
|
949
|
-
return transporter.request(request, requestOptions);
|
|
959
|
+
return this.transporter.request(request, requestOptions);
|
|
950
960
|
},
|
|
951
961
|
/**
|
|
952
962
|
* Returns the most popular search terms.
|
|
@@ -1021,7 +1031,7 @@ function createAnalyticsClient({
|
|
|
1021
1031
|
queryParameters,
|
|
1022
1032
|
headers
|
|
1023
1033
|
};
|
|
1024
|
-
return transporter.request(request, requestOptions);
|
|
1034
|
+
return this.transporter.request(request, requestOptions);
|
|
1025
1035
|
},
|
|
1026
1036
|
/**
|
|
1027
1037
|
* 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.
|
|
@@ -1061,7 +1071,7 @@ function createAnalyticsClient({
|
|
|
1061
1071
|
queryParameters,
|
|
1062
1072
|
headers
|
|
1063
1073
|
};
|
|
1064
|
-
return transporter.request(request, requestOptions);
|
|
1074
|
+
return this.transporter.request(request, requestOptions);
|
|
1065
1075
|
}
|
|
1066
1076
|
};
|
|
1067
1077
|
}
|