@algolia/client-analytics 5.3.1 → 5.3.2

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.
@@ -1,6 +1,6 @@
1
1
  // src/analyticsClient.ts
2
2
  import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
3
- var apiClientVersion = "5.3.1";
3
+ var apiClientVersion = "5.3.2";
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,25 +15,26 @@ function createAnalyticsClient({
15
15
  ...options
16
16
  }) {
17
17
  const auth = createAuth(appIdOption, apiKeyOption, authMode);
18
- return {
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
- }
18
+ const transporter = createTransporter({
19
+ hosts: getDefaultHosts(regionOption),
20
+ ...options,
21
+ algoliaAgent: getAlgoliaAgent({
22
+ algoliaAgents,
23
+ client: "Analytics",
24
+ version: apiClientVersion
36
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
+ return {
37
+ transporter,
37
38
  /**
38
39
  * The `appId` currently in use.
39
40
  */
@@ -42,15 +43,13 @@ function createAnalyticsClient({
42
43
  * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
43
44
  */
44
45
  clearCache() {
45
- return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
46
- () => void 0
47
- );
46
+ return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
48
47
  },
49
48
  /**
50
49
  * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
51
50
  */
52
51
  get _ua() {
53
- return this.transporter.algoliaAgent.value;
52
+ return transporter.algoliaAgent.value;
54
53
  },
55
54
  /**
56
55
  * Adds a `segment` to the `x-algolia-agent` sent with every requests.
@@ -59,7 +58,7 @@ function createAnalyticsClient({
59
58
  * @param version - The version of the agent.
60
59
  */
61
60
  addAlgoliaAgent(segment, version) {
62
- this.transporter.algoliaAgent.add({ segment, version });
61
+ transporter.algoliaAgent.add({ segment, version });
63
62
  },
64
63
  /**
65
64
  * Helper method to switch the API key used to authenticate the requests.
@@ -69,9 +68,9 @@ function createAnalyticsClient({
69
68
  */
70
69
  setClientApiKey({ apiKey }) {
71
70
  if (!authMode || authMode === "WithinHeaders") {
72
- this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
71
+ transporter.baseHeaders["x-algolia-api-key"] = apiKey;
73
72
  } else {
74
- this.transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
73
+ transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
75
74
  }
76
75
  },
77
76
  /**
@@ -95,7 +94,7 @@ function createAnalyticsClient({
95
94
  queryParameters,
96
95
  headers
97
96
  };
98
- return this.transporter.request(request, requestOptions);
97
+ return transporter.request(request, requestOptions);
99
98
  },
100
99
  /**
101
100
  * This method allow you to send requests to the Algolia REST API.
@@ -118,7 +117,7 @@ function createAnalyticsClient({
118
117
  queryParameters,
119
118
  headers
120
119
  };
121
- return this.transporter.request(request, requestOptions);
120
+ return transporter.request(request, requestOptions);
122
121
  },
123
122
  /**
124
123
  * This method allow you to send requests to the Algolia REST API.
@@ -143,7 +142,7 @@ function createAnalyticsClient({
143
142
  headers,
144
143
  data: body ? body : {}
145
144
  };
146
- return this.transporter.request(request, requestOptions);
145
+ return transporter.request(request, requestOptions);
147
146
  },
148
147
  /**
149
148
  * This method allow you to send requests to the Algolia REST API.
@@ -168,7 +167,7 @@ function createAnalyticsClient({
168
167
  headers,
169
168
  data: body ? body : {}
170
169
  };
171
- return this.transporter.request(request, requestOptions);
170
+ return transporter.request(request, requestOptions);
172
171
  },
173
172
  /**
174
173
  * 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.
@@ -208,7 +207,7 @@ function createAnalyticsClient({
208
207
  queryParameters,
209
208
  headers
210
209
  };
211
- return this.transporter.request(request, requestOptions);
210
+ return transporter.request(request, requestOptions);
212
211
  },
213
212
  /**
214
213
  * 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.
@@ -248,7 +247,7 @@ function createAnalyticsClient({
248
247
  queryParameters,
249
248
  headers
250
249
  };
251
- return this.transporter.request(request, requestOptions);
250
+ return transporter.request(request, requestOptions);
252
251
  },
253
252
  /**
254
253
  * 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.
@@ -288,7 +287,7 @@ function createAnalyticsClient({
288
287
  queryParameters,
289
288
  headers
290
289
  };
291
- return this.transporter.request(request, requestOptions);
290
+ return transporter.request(request, requestOptions);
292
291
  },
293
292
  /**
294
293
  * 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.
@@ -328,7 +327,7 @@ function createAnalyticsClient({
328
327
  queryParameters,
329
328
  headers
330
329
  };
331
- return this.transporter.request(request, requestOptions);
330
+ return transporter.request(request, requestOptions);
332
331
  },
333
332
  /**
334
333
  * 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.
@@ -368,7 +367,7 @@ function createAnalyticsClient({
368
367
  queryParameters,
369
368
  headers
370
369
  };
371
- return this.transporter.request(request, requestOptions);
370
+ return transporter.request(request, requestOptions);
372
371
  },
373
372
  /**
374
373
  * 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.
@@ -408,7 +407,7 @@ function createAnalyticsClient({
408
407
  queryParameters,
409
408
  headers
410
409
  };
411
- return this.transporter.request(request, requestOptions);
410
+ return transporter.request(request, requestOptions);
412
411
  },
413
412
  /**
414
413
  * 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.
@@ -448,7 +447,7 @@ function createAnalyticsClient({
448
447
  queryParameters,
449
448
  headers
450
449
  };
451
- return this.transporter.request(request, requestOptions);
450
+ return transporter.request(request, requestOptions);
452
451
  },
453
452
  /**
454
453
  * 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.
@@ -488,7 +487,7 @@ function createAnalyticsClient({
488
487
  queryParameters,
489
488
  headers
490
489
  };
491
- return this.transporter.request(request, requestOptions);
490
+ return transporter.request(request, requestOptions);
492
491
  },
493
492
  /**
494
493
  * 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.
@@ -528,7 +527,7 @@ function createAnalyticsClient({
528
527
  queryParameters,
529
528
  headers
530
529
  };
531
- return this.transporter.request(request, requestOptions);
530
+ return transporter.request(request, requestOptions);
532
531
  },
533
532
  /**
534
533
  * 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.
@@ -568,7 +567,7 @@ function createAnalyticsClient({
568
567
  queryParameters,
569
568
  headers
570
569
  };
571
- return this.transporter.request(request, requestOptions);
570
+ return transporter.request(request, requestOptions);
572
571
  },
573
572
  /**
574
573
  * Retrieves the most popular searches that didn\'t lead to any clicks, from the 1,000 most frequent searches.
@@ -616,7 +615,7 @@ function createAnalyticsClient({
616
615
  queryParameters,
617
616
  headers
618
617
  };
619
- return this.transporter.request(request, requestOptions);
618
+ return transporter.request(request, requestOptions);
620
619
  },
621
620
  /**
622
621
  * Retrieves the most popular searches that didn\'t return any results.
@@ -664,7 +663,7 @@ function createAnalyticsClient({
664
663
  queryParameters,
665
664
  headers
666
665
  };
667
- return this.transporter.request(request, requestOptions);
666
+ return transporter.request(request, requestOptions);
668
667
  },
669
668
  /**
670
669
  * Retrieves the time when the Analytics data for the specified index was last updated. The Analytics data is updated every 5 minutes.
@@ -692,7 +691,7 @@ function createAnalyticsClient({
692
691
  queryParameters,
693
692
  headers
694
693
  };
695
- return this.transporter.request(request, requestOptions);
694
+ return transporter.request(request, requestOptions);
696
695
  },
697
696
  /**
698
697
  * Retrieves the countries with the most searches to your index.
@@ -740,7 +739,7 @@ function createAnalyticsClient({
740
739
  queryParameters,
741
740
  headers
742
741
  };
743
- return this.transporter.request(request, requestOptions);
742
+ return transporter.request(request, requestOptions);
744
743
  },
745
744
  /**
746
745
  * Retrieves the most frequently used filter attributes. These are attributes of your records that you included in the `attributesForFaceting` setting.
@@ -792,7 +791,7 @@ function createAnalyticsClient({
792
791
  queryParameters,
793
792
  headers
794
793
  };
795
- return this.transporter.request(request, requestOptions);
794
+ return transporter.request(request, requestOptions);
796
795
  },
797
796
  /**
798
797
  * Retrieves the most frequent filter (facet) values for a filter attribute. These are attributes of your records that you included in the `attributesForFaceting` setting.
@@ -848,7 +847,7 @@ function createAnalyticsClient({
848
847
  queryParameters,
849
848
  headers
850
849
  };
851
- return this.transporter.request(request, requestOptions);
850
+ return transporter.request(request, requestOptions);
852
851
  },
853
852
  /**
854
853
  * 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.
@@ -900,7 +899,7 @@ function createAnalyticsClient({
900
899
  queryParameters,
901
900
  headers
902
901
  };
903
- return this.transporter.request(request, requestOptions);
902
+ return transporter.request(request, requestOptions);
904
903
  },
905
904
  /**
906
905
  * Retrieves the object IDs of the most frequent search results.
@@ -960,7 +959,7 @@ function createAnalyticsClient({
960
959
  queryParameters,
961
960
  headers
962
961
  };
963
- return this.transporter.request(request, requestOptions);
962
+ return transporter.request(request, requestOptions);
964
963
  },
965
964
  /**
966
965
  * Returns the most popular search terms.
@@ -1035,7 +1034,7 @@ function createAnalyticsClient({
1035
1034
  queryParameters,
1036
1035
  headers
1037
1036
  };
1038
- return this.transporter.request(request, requestOptions);
1037
+ return transporter.request(request, requestOptions);
1039
1038
  },
1040
1039
  /**
1041
1040
  * 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.
@@ -1075,7 +1074,7 @@ function createAnalyticsClient({
1075
1074
  queryParameters,
1076
1075
  headers
1077
1076
  };
1078
- return this.transporter.request(request, requestOptions);
1077
+ return transporter.request(request, requestOptions);
1079
1078
  }
1080
1079
  };
1081
1080
  }