@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
|
@@ -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.1";
|
|
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,20 @@ 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
|
+
if (!authMode || authMode === "WithinHeaders") {
|
|
72
|
+
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
|
|
73
|
+
} else {
|
|
74
|
+
this.transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
|
|
75
|
+
}
|
|
62
76
|
},
|
|
63
77
|
/**
|
|
64
78
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -81,7 +95,7 @@ function createAnalyticsClient({
|
|
|
81
95
|
queryParameters,
|
|
82
96
|
headers
|
|
83
97
|
};
|
|
84
|
-
return transporter.request(request, requestOptions);
|
|
98
|
+
return this.transporter.request(request, requestOptions);
|
|
85
99
|
},
|
|
86
100
|
/**
|
|
87
101
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -104,7 +118,7 @@ function createAnalyticsClient({
|
|
|
104
118
|
queryParameters,
|
|
105
119
|
headers
|
|
106
120
|
};
|
|
107
|
-
return transporter.request(request, requestOptions);
|
|
121
|
+
return this.transporter.request(request, requestOptions);
|
|
108
122
|
},
|
|
109
123
|
/**
|
|
110
124
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -129,7 +143,7 @@ function createAnalyticsClient({
|
|
|
129
143
|
headers,
|
|
130
144
|
data: body ? body : {}
|
|
131
145
|
};
|
|
132
|
-
return transporter.request(request, requestOptions);
|
|
146
|
+
return this.transporter.request(request, requestOptions);
|
|
133
147
|
},
|
|
134
148
|
/**
|
|
135
149
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -154,7 +168,7 @@ function createAnalyticsClient({
|
|
|
154
168
|
headers,
|
|
155
169
|
data: body ? body : {}
|
|
156
170
|
};
|
|
157
|
-
return transporter.request(request, requestOptions);
|
|
171
|
+
return this.transporter.request(request, requestOptions);
|
|
158
172
|
},
|
|
159
173
|
/**
|
|
160
174
|
* 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 +208,7 @@ function createAnalyticsClient({
|
|
|
194
208
|
queryParameters,
|
|
195
209
|
headers
|
|
196
210
|
};
|
|
197
|
-
return transporter.request(request, requestOptions);
|
|
211
|
+
return this.transporter.request(request, requestOptions);
|
|
198
212
|
},
|
|
199
213
|
/**
|
|
200
214
|
* 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 +248,7 @@ function createAnalyticsClient({
|
|
|
234
248
|
queryParameters,
|
|
235
249
|
headers
|
|
236
250
|
};
|
|
237
|
-
return transporter.request(request, requestOptions);
|
|
251
|
+
return this.transporter.request(request, requestOptions);
|
|
238
252
|
},
|
|
239
253
|
/**
|
|
240
254
|
* 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 +288,7 @@ function createAnalyticsClient({
|
|
|
274
288
|
queryParameters,
|
|
275
289
|
headers
|
|
276
290
|
};
|
|
277
|
-
return transporter.request(request, requestOptions);
|
|
291
|
+
return this.transporter.request(request, requestOptions);
|
|
278
292
|
},
|
|
279
293
|
/**
|
|
280
294
|
* 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 +328,7 @@ function createAnalyticsClient({
|
|
|
314
328
|
queryParameters,
|
|
315
329
|
headers
|
|
316
330
|
};
|
|
317
|
-
return transporter.request(request, requestOptions);
|
|
331
|
+
return this.transporter.request(request, requestOptions);
|
|
318
332
|
},
|
|
319
333
|
/**
|
|
320
334
|
* 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 +368,7 @@ function createAnalyticsClient({
|
|
|
354
368
|
queryParameters,
|
|
355
369
|
headers
|
|
356
370
|
};
|
|
357
|
-
return transporter.request(request, requestOptions);
|
|
371
|
+
return this.transporter.request(request, requestOptions);
|
|
358
372
|
},
|
|
359
373
|
/**
|
|
360
374
|
* 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 +408,7 @@ function createAnalyticsClient({
|
|
|
394
408
|
queryParameters,
|
|
395
409
|
headers
|
|
396
410
|
};
|
|
397
|
-
return transporter.request(request, requestOptions);
|
|
411
|
+
return this.transporter.request(request, requestOptions);
|
|
398
412
|
},
|
|
399
413
|
/**
|
|
400
414
|
* 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 +448,7 @@ function createAnalyticsClient({
|
|
|
434
448
|
queryParameters,
|
|
435
449
|
headers
|
|
436
450
|
};
|
|
437
|
-
return transporter.request(request, requestOptions);
|
|
451
|
+
return this.transporter.request(request, requestOptions);
|
|
438
452
|
},
|
|
439
453
|
/**
|
|
440
454
|
* 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 +488,7 @@ function createAnalyticsClient({
|
|
|
474
488
|
queryParameters,
|
|
475
489
|
headers
|
|
476
490
|
};
|
|
477
|
-
return transporter.request(request, requestOptions);
|
|
491
|
+
return this.transporter.request(request, requestOptions);
|
|
478
492
|
},
|
|
479
493
|
/**
|
|
480
494
|
* 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 +528,7 @@ function createAnalyticsClient({
|
|
|
514
528
|
queryParameters,
|
|
515
529
|
headers
|
|
516
530
|
};
|
|
517
|
-
return transporter.request(request, requestOptions);
|
|
531
|
+
return this.transporter.request(request, requestOptions);
|
|
518
532
|
},
|
|
519
533
|
/**
|
|
520
534
|
* 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 +568,7 @@ function createAnalyticsClient({
|
|
|
554
568
|
queryParameters,
|
|
555
569
|
headers
|
|
556
570
|
};
|
|
557
|
-
return transporter.request(request, requestOptions);
|
|
571
|
+
return this.transporter.request(request, requestOptions);
|
|
558
572
|
},
|
|
559
573
|
/**
|
|
560
574
|
* Retrieves the most popular searches that didn\'t lead to any clicks, from the 1,000 most frequent searches.
|
|
@@ -602,7 +616,7 @@ function createAnalyticsClient({
|
|
|
602
616
|
queryParameters,
|
|
603
617
|
headers
|
|
604
618
|
};
|
|
605
|
-
return transporter.request(request, requestOptions);
|
|
619
|
+
return this.transporter.request(request, requestOptions);
|
|
606
620
|
},
|
|
607
621
|
/**
|
|
608
622
|
* Retrieves the most popular searches that didn\'t return any results.
|
|
@@ -650,7 +664,7 @@ function createAnalyticsClient({
|
|
|
650
664
|
queryParameters,
|
|
651
665
|
headers
|
|
652
666
|
};
|
|
653
|
-
return transporter.request(request, requestOptions);
|
|
667
|
+
return this.transporter.request(request, requestOptions);
|
|
654
668
|
},
|
|
655
669
|
/**
|
|
656
670
|
* Retrieves the time when the Analytics data for the specified index was last updated. The Analytics data is updated every 5 minutes.
|
|
@@ -678,7 +692,7 @@ function createAnalyticsClient({
|
|
|
678
692
|
queryParameters,
|
|
679
693
|
headers
|
|
680
694
|
};
|
|
681
|
-
return transporter.request(request, requestOptions);
|
|
695
|
+
return this.transporter.request(request, requestOptions);
|
|
682
696
|
},
|
|
683
697
|
/**
|
|
684
698
|
* Retrieves the countries with the most searches to your index.
|
|
@@ -726,7 +740,7 @@ function createAnalyticsClient({
|
|
|
726
740
|
queryParameters,
|
|
727
741
|
headers
|
|
728
742
|
};
|
|
729
|
-
return transporter.request(request, requestOptions);
|
|
743
|
+
return this.transporter.request(request, requestOptions);
|
|
730
744
|
},
|
|
731
745
|
/**
|
|
732
746
|
* Retrieves the most frequently used filter attributes. These are attributes of your records that you included in the `attributesForFaceting` setting.
|
|
@@ -778,7 +792,7 @@ function createAnalyticsClient({
|
|
|
778
792
|
queryParameters,
|
|
779
793
|
headers
|
|
780
794
|
};
|
|
781
|
-
return transporter.request(request, requestOptions);
|
|
795
|
+
return this.transporter.request(request, requestOptions);
|
|
782
796
|
},
|
|
783
797
|
/**
|
|
784
798
|
* 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 +848,7 @@ function createAnalyticsClient({
|
|
|
834
848
|
queryParameters,
|
|
835
849
|
headers
|
|
836
850
|
};
|
|
837
|
-
return transporter.request(request, requestOptions);
|
|
851
|
+
return this.transporter.request(request, requestOptions);
|
|
838
852
|
},
|
|
839
853
|
/**
|
|
840
854
|
* 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 +900,7 @@ function createAnalyticsClient({
|
|
|
886
900
|
queryParameters,
|
|
887
901
|
headers
|
|
888
902
|
};
|
|
889
|
-
return transporter.request(request, requestOptions);
|
|
903
|
+
return this.transporter.request(request, requestOptions);
|
|
890
904
|
},
|
|
891
905
|
/**
|
|
892
906
|
* Retrieves the object IDs of the most frequent search results.
|
|
@@ -946,7 +960,7 @@ function createAnalyticsClient({
|
|
|
946
960
|
queryParameters,
|
|
947
961
|
headers
|
|
948
962
|
};
|
|
949
|
-
return transporter.request(request, requestOptions);
|
|
963
|
+
return this.transporter.request(request, requestOptions);
|
|
950
964
|
},
|
|
951
965
|
/**
|
|
952
966
|
* Returns the most popular search terms.
|
|
@@ -1021,7 +1035,7 @@ function createAnalyticsClient({
|
|
|
1021
1035
|
queryParameters,
|
|
1022
1036
|
headers
|
|
1023
1037
|
};
|
|
1024
|
-
return transporter.request(request, requestOptions);
|
|
1038
|
+
return this.transporter.request(request, requestOptions);
|
|
1025
1039
|
},
|
|
1026
1040
|
/**
|
|
1027
1041
|
* 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 +1075,7 @@ function createAnalyticsClient({
|
|
|
1061
1075
|
queryParameters,
|
|
1062
1076
|
headers
|
|
1063
1077
|
};
|
|
1064
|
-
return transporter.request(request, requestOptions);
|
|
1078
|
+
return this.transporter.request(request, requestOptions);
|
|
1065
1079
|
}
|
|
1066
1080
|
};
|
|
1067
1081
|
}
|