@algolia/client-analytics 5.0.0-alpha.52 → 5.0.0-alpha.54

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.
Files changed (53) hide show
  1. package/dist/builds/browser.d.ts +5 -5
  2. package/dist/builds/node.d.ts +5 -5
  3. package/dist/client-analytics.cjs.js +922 -922
  4. package/dist/client-analytics.esm.browser.js +1046 -1046
  5. package/dist/client-analytics.esm.node.js +922 -922
  6. package/dist/client-analytics.umd.js +2 -2
  7. package/dist/model/averageClickEvent.d.ts +14 -14
  8. package/dist/model/clickPosition.d.ts +10 -10
  9. package/dist/model/clickThroughRateEvent.d.ts +18 -18
  10. package/dist/model/clientMethodProps.d.ts +507 -507
  11. package/dist/model/conversionRateEvent.d.ts +18 -18
  12. package/dist/model/direction.d.ts +1 -1
  13. package/dist/model/errorBase.d.ts +6 -6
  14. package/dist/model/getAverageClickPositionResponse.d.ts +15 -15
  15. package/dist/model/getClickPositionsResponse.d.ts +7 -7
  16. package/dist/model/getClickThroughRateResponse.d.ts +19 -19
  17. package/dist/model/getConversationRateResponse.d.ts +19 -19
  18. package/dist/model/getNoClickRateResponse.d.ts +19 -19
  19. package/dist/model/getNoResultsRateResponse.d.ts +19 -19
  20. package/dist/model/getSearchesCountResponse.d.ts +11 -11
  21. package/dist/model/getSearchesNoClicksResponse.d.ts +7 -7
  22. package/dist/model/getSearchesNoResultsResponse.d.ts +7 -7
  23. package/dist/model/getStatusResponse.d.ts +6 -6
  24. package/dist/model/getTopCountriesResponse.d.ts +7 -7
  25. package/dist/model/getTopFilterAttribute.d.ts +10 -10
  26. package/dist/model/getTopFilterAttributesResponse.d.ts +7 -7
  27. package/dist/model/getTopFilterForAttribute.d.ts +18 -18
  28. package/dist/model/getTopFilterForAttributeResponse.d.ts +7 -7
  29. package/dist/model/getTopFiltersNoResultsResponse.d.ts +7 -7
  30. package/dist/model/getTopFiltersNoResultsValue.d.ts +14 -14
  31. package/dist/model/getTopFiltersNoResultsValues.d.ts +11 -11
  32. package/dist/model/getTopHitsResponse.d.ts +3 -3
  33. package/dist/model/getTopSearchesResponse.d.ts +3 -3
  34. package/dist/model/getUsersCountResponse.d.ts +11 -11
  35. package/dist/model/index.d.ts +44 -44
  36. package/dist/model/noClickRateEvent.d.ts +18 -18
  37. package/dist/model/noResultsRateEvent.d.ts +18 -18
  38. package/dist/model/orderBy.d.ts +1 -1
  39. package/dist/model/searchEvent.d.ts +10 -10
  40. package/dist/model/searchNoClickEvent.d.ts +14 -14
  41. package/dist/model/searchNoResultEvent.d.ts +14 -14
  42. package/dist/model/topCountry.d.ts +10 -10
  43. package/dist/model/topHit.d.ts +10 -10
  44. package/dist/model/topHitWithAnalytics.d.ts +30 -30
  45. package/dist/model/topHitsResponse.d.ts +7 -7
  46. package/dist/model/topHitsResponseWithAnalytics.d.ts +7 -7
  47. package/dist/model/topSearch.d.ts +14 -14
  48. package/dist/model/topSearchWithAnalytics.d.ts +38 -38
  49. package/dist/model/topSearchesResponse.d.ts +7 -7
  50. package/dist/model/topSearchesResponseWithAnalytics.d.ts +7 -7
  51. package/dist/model/userWithDate.d.ts +10 -10
  52. package/dist/src/analyticsClient.d.ts +318 -318
  53. package/package.json +6 -6
@@ -368,16 +368,16 @@ function createTransporter({
368
368
  return {
369
369
  hosts: compatibleHostsAvailable,
370
370
  getTimeout(timeoutsCount, baseTimeout) {
371
- /**
372
- * Imagine that you have 4 hosts, if timeouts will increase
373
- * on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
374
- *
375
- * Note that, the very next request, we start from the previous timeout.
376
- *
377
- * 5 (timed out) > 6 (timed out) > 7 ...
378
- *
379
- * This strategy may need to be reviewed, but is the strategy on the our
380
- * current v3 version.
371
+ /**
372
+ * Imagine that you have 4 hosts, if timeouts will increase
373
+ * on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
374
+ *
375
+ * Note that, the very next request, we start from the previous timeout.
376
+ *
377
+ * 5 (timed out) > 6 (timed out) > 7 ...
378
+ *
379
+ * This strategy may need to be reviewed, but is the strategy on the our
380
+ * current v3 version.
381
381
  */
382
382
  const timeoutMultiplier = hostsTimedOut.length === 0 && timeoutsCount === 0 ? 1 : hostsTimedOut.length + 3 + timeoutsCount;
383
383
  return timeoutMultiplier * baseTimeout;
@@ -386,8 +386,8 @@ function createTransporter({
386
386
  }
387
387
  async function retryableRequest(request, requestOptions, isRead = true) {
388
388
  const stackTrace = [];
389
- /**
390
- * First we prepare the payload that do not depend from hosts.
389
+ /**
390
+ * First we prepare the payload that do not depend from hosts.
391
391
  */
392
392
  const data = serializeData(request, requestOptions);
393
393
  const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
@@ -418,8 +418,8 @@ function createTransporter({
418
418
  }
419
419
  let timeoutsCount = 0;
420
420
  const retry = async (retryableHosts, getTimeout) => {
421
- /**
422
- * We iterate on each host, until there is no host left.
421
+ /**
422
+ * We iterate on each host, until there is no host left.
423
423
  */
424
424
  const host = retryableHosts.pop();
425
425
  if (host === undefined) {
@@ -437,10 +437,10 @@ function createTransporter({
437
437
  connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
438
438
  responseTimeout: getTimeout(timeoutsCount, responseTimeout)
439
439
  };
440
- /**
441
- * The stackFrame is pushed to the stackTrace so we
442
- * can have information about onRetry and onFailure
443
- * decisions.
440
+ /**
441
+ * The stackFrame is pushed to the stackTrace so we
442
+ * can have information about onRetry and onFailure
443
+ * decisions.
444
444
  */
445
445
  const pushToStackTrace = response => {
446
446
  const stackFrame = {
@@ -459,17 +459,17 @@ function createTransporter({
459
459
  if (response.isTimedOut) {
460
460
  timeoutsCount++;
461
461
  }
462
- /**
463
- * Failures are individually sent to the logger, allowing
464
- * the end user to debug / store stack frames even
465
- * when a retry error does not happen.
462
+ /**
463
+ * Failures are individually sent to the logger, allowing
464
+ * the end user to debug / store stack frames even
465
+ * when a retry error does not happen.
466
466
  */
467
467
  // eslint-disable-next-line no-console -- this will be fixed by exposing a `logger` to the transporter
468
468
  console.log('Retryable failure', stackFrameWithoutCredentials(stackFrame));
469
- /**
470
- * We also store the state of the host in failure cases. If the host, is
471
- * down it will remain down for the next 2 minutes. In a timeout situation,
472
- * this host will be added end of the list of hosts on the next request.
469
+ /**
470
+ * We also store the state of the host in failure cases. If the host, is
471
+ * down it will remain down for the next 2 minutes. In a timeout situation,
472
+ * this host will be added end of the list of hosts on the next request.
473
473
  */
474
474
  await hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down'));
475
475
  return retry(retryableHosts, getTimeout);
@@ -480,56 +480,56 @@ function createTransporter({
480
480
  pushToStackTrace(response);
481
481
  throw deserializeFailure(response, stackTrace);
482
482
  };
483
- /**
484
- * Finally, for each retryable host perform request until we got a non
485
- * retryable response. Some notes here:
486
- *
487
- * 1. The reverse here is applied so we can apply a `pop` later on => more performant.
488
- * 2. We also get from the retryable options a timeout multiplier that is tailored
489
- * for the current context.
483
+ /**
484
+ * Finally, for each retryable host perform request until we got a non
485
+ * retryable response. Some notes here:
486
+ *
487
+ * 1. The reverse here is applied so we can apply a `pop` later on => more performant.
488
+ * 2. We also get from the retryable options a timeout multiplier that is tailored
489
+ * for the current context.
490
490
  */
491
491
  const compatibleHosts = hosts.filter(host => host.accept === 'readWrite' || (isRead ? host.accept === 'read' : host.accept === 'write'));
492
492
  const options = await createRetryableOptions(compatibleHosts);
493
493
  return retry([...options.hosts].reverse(), options.getTimeout);
494
494
  }
495
495
  function createRequest(request, requestOptions = {}) {
496
- /**
497
- * A read request is either a `GET` request, or a request that we make
498
- * via the `read` transporter (e.g. `search`).
496
+ /**
497
+ * A read request is either a `GET` request, or a request that we make
498
+ * via the `read` transporter (e.g. `search`).
499
499
  */
500
500
  const isRead = request.useReadTransporter || request.method === 'GET';
501
501
  if (!isRead) {
502
- /**
503
- * On write requests, no cache mechanisms are applied, and we
504
- * proxy the request immediately to the requester.
502
+ /**
503
+ * On write requests, no cache mechanisms are applied, and we
504
+ * proxy the request immediately to the requester.
505
505
  */
506
506
  return retryableRequest(request, requestOptions, isRead);
507
507
  }
508
508
  const createRetryableRequest = () => {
509
- /**
510
- * Then, we prepare a function factory that contains the construction of
511
- * the retryable request. At this point, we may *not* perform the actual
512
- * request. But we want to have the function factory ready.
509
+ /**
510
+ * Then, we prepare a function factory that contains the construction of
511
+ * the retryable request. At this point, we may *not* perform the actual
512
+ * request. But we want to have the function factory ready.
513
513
  */
514
514
  return retryableRequest(request, requestOptions);
515
515
  };
516
- /**
517
- * Once we have the function factory ready, we need to determine of the
518
- * request is "cacheable" - should be cached. Note that, once again,
519
- * the user can force this option.
516
+ /**
517
+ * Once we have the function factory ready, we need to determine of the
518
+ * request is "cacheable" - should be cached. Note that, once again,
519
+ * the user can force this option.
520
520
  */
521
521
  const cacheable = requestOptions.cacheable || request.cacheable;
522
- /**
523
- * If is not "cacheable", we immediately trigger the retryable request, no
524
- * need to check cache implementations.
522
+ /**
523
+ * If is not "cacheable", we immediately trigger the retryable request, no
524
+ * need to check cache implementations.
525
525
  */
526
526
  if (cacheable !== true) {
527
527
  return createRetryableRequest();
528
528
  }
529
- /**
530
- * If the request is "cacheable", we need to first compute the key to ask
531
- * the cache implementations if this request is on progress or if the
532
- * response already exists on the cache.
529
+ /**
530
+ * If the request is "cacheable", we need to first compute the key to ask
531
+ * the cache implementations if this request is on progress or if the
532
+ * response already exists on the cache.
533
533
  */
534
534
  const key = {
535
535
  request,
@@ -539,27 +539,27 @@ function createTransporter({
539
539
  headers: baseHeaders
540
540
  }
541
541
  };
542
- /**
543
- * With the computed key, we first ask the responses cache
544
- * implementation if this request was been resolved before.
542
+ /**
543
+ * With the computed key, we first ask the responses cache
544
+ * implementation if this request was been resolved before.
545
545
  */
546
546
  return responsesCache.get(key, () => {
547
- /**
548
- * If the request has never resolved before, we actually ask if there
549
- * is a current request with the same key on progress.
547
+ /**
548
+ * If the request has never resolved before, we actually ask if there
549
+ * is a current request with the same key on progress.
550
550
  */
551
551
  return requestsCache.get(key, () =>
552
- /**
553
- * Finally, if there is no request in progress with the same key,
554
- * this `createRetryableRequest()` will actually trigger the
555
- * retryable request.
552
+ /**
553
+ * Finally, if there is no request in progress with the same key,
554
+ * this `createRetryableRequest()` will actually trigger the
555
+ * retryable request.
556
556
  */
557
557
  requestsCache.set(key, createRetryableRequest()).then(response => Promise.all([requestsCache.delete(key), response]), err => Promise.all([requestsCache.delete(key), Promise.reject(err)])).then(([_, response]) => response));
558
558
  }, {
559
- /**
560
- * Of course, once we get this response back from the server, we
561
- * tell response cache to actually store the received response
562
- * to be used later.
559
+ /**
560
+ * Of course, once we get this response back from the server, we
561
+ * tell response cache to actually store the received response
562
+ * to be used later.
563
563
  */
564
564
  miss: response => responsesCache.set(key, response)
565
565
  });
@@ -609,988 +609,988 @@ const DEFAULT_CONNECT_TIMEOUT_BROWSER = 1000;
609
609
  const DEFAULT_READ_TIMEOUT_BROWSER = 2000;
610
610
  const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
611
611
 
612
- function createXhrRequester() {
613
- function send(request) {
614
- return new Promise((resolve) => {
615
- const baseRequester = new XMLHttpRequest();
616
- baseRequester.open(request.method, request.url, true);
617
- Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
618
- const createTimeout = (timeout, content) => {
619
- return setTimeout(() => {
620
- baseRequester.abort();
621
- resolve({
622
- status: 0,
623
- content,
624
- isTimedOut: true,
625
- });
626
- }, timeout);
627
- };
628
- const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
629
- let responseTimeout;
630
- baseRequester.onreadystatechange = () => {
631
- if (baseRequester.readyState > baseRequester.OPENED &&
632
- responseTimeout === undefined) {
633
- clearTimeout(connectTimeout);
634
- responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
635
- }
636
- };
637
- baseRequester.onerror = () => {
638
- // istanbul ignore next
639
- if (baseRequester.status === 0) {
640
- clearTimeout(connectTimeout);
641
- clearTimeout(responseTimeout);
642
- resolve({
643
- content: baseRequester.responseText || 'Network request failed',
644
- status: baseRequester.status,
645
- isTimedOut: false,
646
- });
647
- }
648
- };
649
- baseRequester.onload = () => {
650
- clearTimeout(connectTimeout);
651
- clearTimeout(responseTimeout);
652
- resolve({
653
- content: baseRequester.responseText,
654
- status: baseRequester.status,
655
- isTimedOut: false,
656
- });
657
- };
658
- baseRequester.send(request.data);
659
- });
660
- }
661
- return { send };
612
+ function createXhrRequester() {
613
+ function send(request) {
614
+ return new Promise((resolve) => {
615
+ const baseRequester = new XMLHttpRequest();
616
+ baseRequester.open(request.method, request.url, true);
617
+ Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
618
+ const createTimeout = (timeout, content) => {
619
+ return setTimeout(() => {
620
+ baseRequester.abort();
621
+ resolve({
622
+ status: 0,
623
+ content,
624
+ isTimedOut: true,
625
+ });
626
+ }, timeout);
627
+ };
628
+ const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
629
+ let responseTimeout;
630
+ baseRequester.onreadystatechange = () => {
631
+ if (baseRequester.readyState > baseRequester.OPENED &&
632
+ responseTimeout === undefined) {
633
+ clearTimeout(connectTimeout);
634
+ responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
635
+ }
636
+ };
637
+ baseRequester.onerror = () => {
638
+ // istanbul ignore next
639
+ if (baseRequester.status === 0) {
640
+ clearTimeout(connectTimeout);
641
+ clearTimeout(responseTimeout);
642
+ resolve({
643
+ content: baseRequester.responseText || 'Network request failed',
644
+ status: baseRequester.status,
645
+ isTimedOut: false,
646
+ });
647
+ }
648
+ };
649
+ baseRequester.onload = () => {
650
+ clearTimeout(connectTimeout);
651
+ clearTimeout(responseTimeout);
652
+ resolve({
653
+ content: baseRequester.responseText,
654
+ status: baseRequester.status,
655
+ isTimedOut: false,
656
+ });
657
+ };
658
+ baseRequester.send(request.data);
659
+ });
660
+ }
661
+ return { send };
662
662
  }
663
663
 
664
- // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
665
- const apiClientVersion = '5.0.0-alpha.52';
666
- const REGIONS = ['de', 'us'];
667
- function getDefaultHosts(region) {
668
- const url = !region
669
- ? 'analytics.algolia.com'
670
- : 'analytics.{region}.algolia.com'.replace('{region}', region);
671
- return [{ url, accept: 'readWrite', protocol: 'https' }];
672
- }
673
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
674
- function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
675
- const auth = createAuth(appIdOption, apiKeyOption, authMode);
676
- const transporter = createTransporter({
677
- hosts: getDefaultHosts(regionOption),
678
- ...options,
679
- algoliaAgent: getAlgoliaAgent({
680
- algoliaAgents,
681
- client: 'Analytics',
682
- version: apiClientVersion,
683
- }),
684
- baseHeaders: {
685
- 'content-type': 'text/plain',
686
- ...auth.headers(),
687
- ...options.baseHeaders,
688
- },
689
- baseQueryParameters: {
690
- ...auth.queryParameters(),
691
- ...options.baseQueryParameters,
692
- },
693
- });
694
- return {
695
- transporter,
696
- /**
697
- * The `appId` currently in use.
698
- */
699
- appId: appIdOption,
700
- /**
701
- * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
702
- */
703
- clearCache() {
704
- return Promise.all([
705
- transporter.requestsCache.clear(),
706
- transporter.responsesCache.clear(),
707
- ]).then(() => undefined);
708
- },
709
- /**
710
- * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
711
- */
712
- get _ua() {
713
- return transporter.algoliaAgent.value;
714
- },
715
- /**
716
- * Adds a `segment` to the `x-algolia-agent` sent with every requests.
717
- *
718
- * @param segment - The algolia agent (user-agent) segment to add.
719
- * @param version - The version of the agent.
720
- */
721
- addAlgoliaAgent(segment, version) {
722
- transporter.algoliaAgent.add({ segment, version });
723
- },
724
- /**
725
- * This method allow you to send requests to the Algolia REST API.
726
- *
727
- * @summary Send requests to the Algolia REST API.
728
- * @param del - The del object.
729
- * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
730
- * @param del.parameters - Query parameters to be applied to the current query.
731
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
732
- */
733
- del({ path, parameters }, requestOptions) {
734
- if (!path) {
735
- throw new Error('Parameter `path` is required when calling `del`.');
736
- }
737
- const requestPath = '/1{path}'.replace('{path}', path);
738
- const headers = {};
739
- const queryParameters = parameters ? parameters : {};
740
- const request = {
741
- method: 'DELETE',
742
- path: requestPath,
743
- queryParameters,
744
- headers,
745
- };
746
- return transporter.request(request, requestOptions);
747
- },
748
- /**
749
- * This method allow you to send requests to the Algolia REST API.
750
- *
751
- * @summary Send requests to the Algolia REST API.
752
- * @param get - The get object.
753
- * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
754
- * @param get.parameters - Query parameters to be applied to the current query.
755
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
756
- */
757
- get({ path, parameters }, requestOptions) {
758
- if (!path) {
759
- throw new Error('Parameter `path` is required when calling `get`.');
760
- }
761
- const requestPath = '/1{path}'.replace('{path}', path);
762
- const headers = {};
763
- const queryParameters = parameters ? parameters : {};
764
- const request = {
765
- method: 'GET',
766
- path: requestPath,
767
- queryParameters,
768
- headers,
769
- };
770
- return transporter.request(request, requestOptions);
771
- },
772
- /**
773
- * Returns the average click position. The endpoint returns a value for the complete given time range, as well as a value per day.
774
- *
775
- * @summary Get average click position.
776
- * @param getAverageClickPosition - The getAverageClickPosition object.
777
- * @param getAverageClickPosition.index - The index name to target.
778
- * @param getAverageClickPosition.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
779
- * @param getAverageClickPosition.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
780
- * @param getAverageClickPosition.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
781
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
782
- */
783
- getAverageClickPosition({ index, startDate, endDate, tags }, requestOptions) {
784
- if (!index) {
785
- throw new Error('Parameter `index` is required when calling `getAverageClickPosition`.');
786
- }
787
- const requestPath = '/2/clicks/averageClickPosition';
788
- const headers = {};
789
- const queryParameters = {};
790
- if (index !== undefined) {
791
- queryParameters.index = index.toString();
792
- }
793
- if (startDate !== undefined) {
794
- queryParameters.startDate = startDate.toString();
795
- }
796
- if (endDate !== undefined) {
797
- queryParameters.endDate = endDate.toString();
798
- }
799
- if (tags !== undefined) {
800
- queryParameters.tags = tags.toString();
801
- }
802
- const request = {
803
- method: 'GET',
804
- path: requestPath,
805
- queryParameters,
806
- headers,
807
- };
808
- return transporter.request(request, requestOptions);
809
- },
810
- /**
811
- * Returns the distribution of clicks per range of positions. If the groups all have a count of 0, it means Algolia didn’t receive any click events for the queries with the clickAnalytics search parameter set to true. The count is 0 until Algolia receives at least one click event.
812
- *
813
- * @summary Get clicks per positions.
814
- * @param getClickPositions - The getClickPositions object.
815
- * @param getClickPositions.index - The index name to target.
816
- * @param getClickPositions.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
817
- * @param getClickPositions.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
818
- * @param getClickPositions.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
819
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
820
- */
821
- getClickPositions({ index, startDate, endDate, tags }, requestOptions) {
822
- if (!index) {
823
- throw new Error('Parameter `index` is required when calling `getClickPositions`.');
824
- }
825
- const requestPath = '/2/clicks/positions';
826
- const headers = {};
827
- const queryParameters = {};
828
- if (index !== undefined) {
829
- queryParameters.index = index.toString();
830
- }
831
- if (startDate !== undefined) {
832
- queryParameters.startDate = startDate.toString();
833
- }
834
- if (endDate !== undefined) {
835
- queryParameters.endDate = endDate.toString();
836
- }
837
- if (tags !== undefined) {
838
- queryParameters.tags = tags.toString();
839
- }
840
- const request = {
841
- method: 'GET',
842
- path: requestPath,
843
- queryParameters,
844
- headers,
845
- };
846
- return transporter.request(request, requestOptions);
847
- },
848
- /**
849
- * Returns a click-through rate (CTR). The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of clicks and searches used to compute the rates.
850
- *
851
- * @summary Get click-through rate (CTR).
852
- * @param getClickThroughRate - The getClickThroughRate object.
853
- * @param getClickThroughRate.index - The index name to target.
854
- * @param getClickThroughRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
855
- * @param getClickThroughRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
856
- * @param getClickThroughRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
857
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
858
- */
859
- getClickThroughRate({ index, startDate, endDate, tags }, requestOptions) {
860
- if (!index) {
861
- throw new Error('Parameter `index` is required when calling `getClickThroughRate`.');
862
- }
863
- const requestPath = '/2/clicks/clickThroughRate';
864
- const headers = {};
865
- const queryParameters = {};
866
- if (index !== undefined) {
867
- queryParameters.index = index.toString();
868
- }
869
- if (startDate !== undefined) {
870
- queryParameters.startDate = startDate.toString();
871
- }
872
- if (endDate !== undefined) {
873
- queryParameters.endDate = endDate.toString();
874
- }
875
- if (tags !== undefined) {
876
- queryParameters.tags = tags.toString();
877
- }
878
- const request = {
879
- method: 'GET',
880
- path: requestPath,
881
- queryParameters,
882
- headers,
883
- };
884
- return transporter.request(request, requestOptions);
885
- },
886
- /**
887
- * Returns a conversion rate (CR). The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of conversion and searches used to compute the rates.
888
- *
889
- * @summary Get conversion rate (CR).
890
- * @param getConversationRate - The getConversationRate object.
891
- * @param getConversationRate.index - The index name to target.
892
- * @param getConversationRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
893
- * @param getConversationRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
894
- * @param getConversationRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
895
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
896
- */
897
- getConversationRate({ index, startDate, endDate, tags }, requestOptions) {
898
- if (!index) {
899
- throw new Error('Parameter `index` is required when calling `getConversationRate`.');
900
- }
901
- const requestPath = '/2/conversions/conversionRate';
902
- const headers = {};
903
- const queryParameters = {};
904
- if (index !== undefined) {
905
- queryParameters.index = index.toString();
906
- }
907
- if (startDate !== undefined) {
908
- queryParameters.startDate = startDate.toString();
909
- }
910
- if (endDate !== undefined) {
911
- queryParameters.endDate = endDate.toString();
912
- }
913
- if (tags !== undefined) {
914
- queryParameters.tags = tags.toString();
915
- }
916
- const request = {
917
- method: 'GET',
918
- path: requestPath,
919
- queryParameters,
920
- headers,
921
- };
922
- return transporter.request(request, requestOptions);
923
- },
924
- /**
925
- * Returns the rate at which searches didn\'t lead to any clicks. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without clicks.
926
- *
927
- * @summary Get no click rate.
928
- * @param getNoClickRate - The getNoClickRate object.
929
- * @param getNoClickRate.index - The index name to target.
930
- * @param getNoClickRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
931
- * @param getNoClickRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
932
- * @param getNoClickRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
933
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
934
- */
935
- getNoClickRate({ index, startDate, endDate, tags }, requestOptions) {
936
- if (!index) {
937
- throw new Error('Parameter `index` is required when calling `getNoClickRate`.');
938
- }
939
- const requestPath = '/2/searches/noClickRate';
940
- const headers = {};
941
- const queryParameters = {};
942
- if (index !== undefined) {
943
- queryParameters.index = index.toString();
944
- }
945
- if (startDate !== undefined) {
946
- queryParameters.startDate = startDate.toString();
947
- }
948
- if (endDate !== undefined) {
949
- queryParameters.endDate = endDate.toString();
950
- }
951
- if (tags !== undefined) {
952
- queryParameters.tags = tags.toString();
953
- }
954
- const request = {
955
- method: 'GET',
956
- path: requestPath,
957
- queryParameters,
958
- headers,
959
- };
960
- return transporter.request(request, requestOptions);
961
- },
962
- /**
963
- * Returns the rate at which searches didn\'t return any results. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without results used to compute the rates.
964
- *
965
- * @summary Get no results rate.
966
- * @param getNoResultsRate - The getNoResultsRate object.
967
- * @param getNoResultsRate.index - The index name to target.
968
- * @param getNoResultsRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
969
- * @param getNoResultsRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
970
- * @param getNoResultsRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
971
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
972
- */
973
- getNoResultsRate({ index, startDate, endDate, tags }, requestOptions) {
974
- if (!index) {
975
- throw new Error('Parameter `index` is required when calling `getNoResultsRate`.');
976
- }
977
- const requestPath = '/2/searches/noResultRate';
978
- const headers = {};
979
- const queryParameters = {};
980
- if (index !== undefined) {
981
- queryParameters.index = index.toString();
982
- }
983
- if (startDate !== undefined) {
984
- queryParameters.startDate = startDate.toString();
985
- }
986
- if (endDate !== undefined) {
987
- queryParameters.endDate = endDate.toString();
988
- }
989
- if (tags !== undefined) {
990
- queryParameters.tags = tags.toString();
991
- }
992
- const request = {
993
- method: 'GET',
994
- path: requestPath,
995
- queryParameters,
996
- headers,
997
- };
998
- return transporter.request(request, requestOptions);
999
- },
1000
- /**
1001
- * Returns the number of searches across the given time range. The endpoint returns a value for the complete given time range, as well as a value per day.
1002
- *
1003
- * @summary Get searches count.
1004
- * @param getSearchesCount - The getSearchesCount object.
1005
- * @param getSearchesCount.index - The index name to target.
1006
- * @param getSearchesCount.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1007
- * @param getSearchesCount.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1008
- * @param getSearchesCount.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1009
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1010
- */
1011
- getSearchesCount({ index, startDate, endDate, tags }, requestOptions) {
1012
- if (!index) {
1013
- throw new Error('Parameter `index` is required when calling `getSearchesCount`.');
1014
- }
1015
- const requestPath = '/2/searches/count';
1016
- const headers = {};
1017
- const queryParameters = {};
1018
- if (index !== undefined) {
1019
- queryParameters.index = index.toString();
1020
- }
1021
- if (startDate !== undefined) {
1022
- queryParameters.startDate = startDate.toString();
1023
- }
1024
- if (endDate !== undefined) {
1025
- queryParameters.endDate = endDate.toString();
1026
- }
1027
- if (tags !== undefined) {
1028
- queryParameters.tags = tags.toString();
1029
- }
1030
- const request = {
1031
- method: 'GET',
1032
- path: requestPath,
1033
- queryParameters,
1034
- headers,
1035
- };
1036
- return transporter.request(request, requestOptions);
1037
- },
1038
- /**
1039
- * Returns top searches that didn\'t lead to any clicks. Limited to the 1000 most frequent ones. For each search, also returns the average number of found hits.
1040
- *
1041
- * @summary Get top searches with no clicks.
1042
- * @param getSearchesNoClicks - The getSearchesNoClicks object.
1043
- * @param getSearchesNoClicks.index - The index name to target.
1044
- * @param getSearchesNoClicks.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1045
- * @param getSearchesNoClicks.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1046
- * @param getSearchesNoClicks.limit - Number of records to return. Limit is the size of the page.
1047
- * @param getSearchesNoClicks.offset - Position of the starting record. Used for paging. 0 is the first record.
1048
- * @param getSearchesNoClicks.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1049
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1050
- */
1051
- getSearchesNoClicks({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
1052
- if (!index) {
1053
- throw new Error('Parameter `index` is required when calling `getSearchesNoClicks`.');
1054
- }
1055
- const requestPath = '/2/searches/noClicks';
1056
- const headers = {};
1057
- const queryParameters = {};
1058
- if (index !== undefined) {
1059
- queryParameters.index = index.toString();
1060
- }
1061
- if (startDate !== undefined) {
1062
- queryParameters.startDate = startDate.toString();
1063
- }
1064
- if (endDate !== undefined) {
1065
- queryParameters.endDate = endDate.toString();
1066
- }
1067
- if (limit !== undefined) {
1068
- queryParameters.limit = limit.toString();
1069
- }
1070
- if (offset !== undefined) {
1071
- queryParameters.offset = offset.toString();
1072
- }
1073
- if (tags !== undefined) {
1074
- queryParameters.tags = tags.toString();
1075
- }
1076
- const request = {
1077
- method: 'GET',
1078
- path: requestPath,
1079
- queryParameters,
1080
- headers,
1081
- };
1082
- return transporter.request(request, requestOptions);
1083
- },
1084
- /**
1085
- * Returns top searches that didn\'t return any results. Limited to the 1000 most frequent ones.
1086
- *
1087
- * @summary Get top searches with no results.
1088
- * @param getSearchesNoResults - The getSearchesNoResults object.
1089
- * @param getSearchesNoResults.index - The index name to target.
1090
- * @param getSearchesNoResults.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1091
- * @param getSearchesNoResults.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1092
- * @param getSearchesNoResults.limit - Number of records to return. Limit is the size of the page.
1093
- * @param getSearchesNoResults.offset - Position of the starting record. Used for paging. 0 is the first record.
1094
- * @param getSearchesNoResults.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1095
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1096
- */
1097
- getSearchesNoResults({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
1098
- if (!index) {
1099
- throw new Error('Parameter `index` is required when calling `getSearchesNoResults`.');
1100
- }
1101
- const requestPath = '/2/searches/noResults';
1102
- const headers = {};
1103
- const queryParameters = {};
1104
- if (index !== undefined) {
1105
- queryParameters.index = index.toString();
1106
- }
1107
- if (startDate !== undefined) {
1108
- queryParameters.startDate = startDate.toString();
1109
- }
1110
- if (endDate !== undefined) {
1111
- queryParameters.endDate = endDate.toString();
1112
- }
1113
- if (limit !== undefined) {
1114
- queryParameters.limit = limit.toString();
1115
- }
1116
- if (offset !== undefined) {
1117
- queryParameters.offset = offset.toString();
1118
- }
1119
- if (tags !== undefined) {
1120
- queryParameters.tags = tags.toString();
1121
- }
1122
- const request = {
1123
- method: 'GET',
1124
- path: requestPath,
1125
- queryParameters,
1126
- headers,
1127
- };
1128
- return transporter.request(request, requestOptions);
1129
- },
1130
- /**
1131
- * Returns the latest update time of the analytics API for a given index. If the index has been recently created and/or no search has been performed yet the updated time will be null.
1132
- *
1133
- * @summary Get Analytics API status.
1134
- * @param getStatus - The getStatus object.
1135
- * @param getStatus.index - The index name to target.
1136
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1137
- */
1138
- getStatus({ index }, requestOptions) {
1139
- if (!index) {
1140
- throw new Error('Parameter `index` is required when calling `getStatus`.');
1141
- }
1142
- const requestPath = '/2/status';
1143
- const headers = {};
1144
- const queryParameters = {};
1145
- if (index !== undefined) {
1146
- queryParameters.index = index.toString();
1147
- }
1148
- const request = {
1149
- method: 'GET',
1150
- path: requestPath,
1151
- queryParameters,
1152
- headers,
1153
- };
1154
- return transporter.request(request, requestOptions);
1155
- },
1156
- /**
1157
- * Returns top countries. Limited to the 1000 most frequent ones.
1158
- *
1159
- * @summary Get top countries.
1160
- * @param getTopCountries - The getTopCountries object.
1161
- * @param getTopCountries.index - The index name to target.
1162
- * @param getTopCountries.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1163
- * @param getTopCountries.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1164
- * @param getTopCountries.limit - Number of records to return. Limit is the size of the page.
1165
- * @param getTopCountries.offset - Position of the starting record. Used for paging. 0 is the first record.
1166
- * @param getTopCountries.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1167
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1168
- */
1169
- getTopCountries({ index, startDate, endDate, limit, offset, tags }, requestOptions) {
1170
- if (!index) {
1171
- throw new Error('Parameter `index` is required when calling `getTopCountries`.');
1172
- }
1173
- const requestPath = '/2/countries';
1174
- const headers = {};
1175
- const queryParameters = {};
1176
- if (index !== undefined) {
1177
- queryParameters.index = index.toString();
1178
- }
1179
- if (startDate !== undefined) {
1180
- queryParameters.startDate = startDate.toString();
1181
- }
1182
- if (endDate !== undefined) {
1183
- queryParameters.endDate = endDate.toString();
1184
- }
1185
- if (limit !== undefined) {
1186
- queryParameters.limit = limit.toString();
1187
- }
1188
- if (offset !== undefined) {
1189
- queryParameters.offset = offset.toString();
1190
- }
1191
- if (tags !== undefined) {
1192
- queryParameters.tags = tags.toString();
1193
- }
1194
- const request = {
1195
- method: 'GET',
1196
- path: requestPath,
1197
- queryParameters,
1198
- headers,
1199
- };
1200
- return transporter.request(request, requestOptions);
1201
- },
1202
- /**
1203
- * Returns top filter attributes. Limited to the 1000 most used filters.
1204
- *
1205
- * @summary Get top filter attributes.
1206
- * @param getTopFilterAttributes - The getTopFilterAttributes object.
1207
- * @param getTopFilterAttributes.index - The index name to target.
1208
- * @param getTopFilterAttributes.search - The query term to search for. Must match the exact user input.
1209
- * @param getTopFilterAttributes.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1210
- * @param getTopFilterAttributes.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1211
- * @param getTopFilterAttributes.limit - Number of records to return. Limit is the size of the page.
1212
- * @param getTopFilterAttributes.offset - Position of the starting record. Used for paging. 0 is the first record.
1213
- * @param getTopFilterAttributes.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1214
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1215
- */
1216
- getTopFilterAttributes({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1217
- if (!index) {
1218
- throw new Error('Parameter `index` is required when calling `getTopFilterAttributes`.');
1219
- }
1220
- const requestPath = '/2/filters';
1221
- const headers = {};
1222
- const queryParameters = {};
1223
- if (index !== undefined) {
1224
- queryParameters.index = index.toString();
1225
- }
1226
- if (search !== undefined) {
1227
- queryParameters.search = search.toString();
1228
- }
1229
- if (startDate !== undefined) {
1230
- queryParameters.startDate = startDate.toString();
1231
- }
1232
- if (endDate !== undefined) {
1233
- queryParameters.endDate = endDate.toString();
1234
- }
1235
- if (limit !== undefined) {
1236
- queryParameters.limit = limit.toString();
1237
- }
1238
- if (offset !== undefined) {
1239
- queryParameters.offset = offset.toString();
1240
- }
1241
- if (tags !== undefined) {
1242
- queryParameters.tags = tags.toString();
1243
- }
1244
- const request = {
1245
- method: 'GET',
1246
- path: requestPath,
1247
- queryParameters,
1248
- headers,
1249
- };
1250
- return transporter.request(request, requestOptions);
1251
- },
1252
- /**
1253
- * Returns top filters for the given attribute. Limited to the 1000 most used filters.
1254
- *
1255
- * @summary Get top filters for the an attribute.
1256
- * @param getTopFilterForAttribute - The getTopFilterForAttribute object.
1257
- * @param getTopFilterForAttribute.attribute - The exact name of the attribute.
1258
- * @param getTopFilterForAttribute.index - The index name to target.
1259
- * @param getTopFilterForAttribute.search - The query term to search for. Must match the exact user input.
1260
- * @param getTopFilterForAttribute.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1261
- * @param getTopFilterForAttribute.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1262
- * @param getTopFilterForAttribute.limit - Number of records to return. Limit is the size of the page.
1263
- * @param getTopFilterForAttribute.offset - Position of the starting record. Used for paging. 0 is the first record.
1264
- * @param getTopFilterForAttribute.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1265
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1266
- */
1267
- getTopFilterForAttribute({ attribute, index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1268
- if (!attribute) {
1269
- throw new Error('Parameter `attribute` is required when calling `getTopFilterForAttribute`.');
1270
- }
1271
- if (!index) {
1272
- throw new Error('Parameter `index` is required when calling `getTopFilterForAttribute`.');
1273
- }
1274
- const requestPath = '/2/filters/{attribute}'.replace('{attribute}', encodeURIComponent(attribute));
1275
- const headers = {};
1276
- const queryParameters = {};
1277
- if (index !== undefined) {
1278
- queryParameters.index = index.toString();
1279
- }
1280
- if (search !== undefined) {
1281
- queryParameters.search = search.toString();
1282
- }
1283
- if (startDate !== undefined) {
1284
- queryParameters.startDate = startDate.toString();
1285
- }
1286
- if (endDate !== undefined) {
1287
- queryParameters.endDate = endDate.toString();
1288
- }
1289
- if (limit !== undefined) {
1290
- queryParameters.limit = limit.toString();
1291
- }
1292
- if (offset !== undefined) {
1293
- queryParameters.offset = offset.toString();
1294
- }
1295
- if (tags !== undefined) {
1296
- queryParameters.tags = tags.toString();
1297
- }
1298
- const request = {
1299
- method: 'GET',
1300
- path: requestPath,
1301
- queryParameters,
1302
- headers,
1303
- };
1304
- return transporter.request(request, requestOptions);
1305
- },
1306
- /**
1307
- * Returns top filters with no results. Limited to the 1000 most used filters.
1308
- *
1309
- * @summary Get top filters for a no result search.
1310
- * @param getTopFiltersNoResults - The getTopFiltersNoResults object.
1311
- * @param getTopFiltersNoResults.index - The index name to target.
1312
- * @param getTopFiltersNoResults.search - The query term to search for. Must match the exact user input.
1313
- * @param getTopFiltersNoResults.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1314
- * @param getTopFiltersNoResults.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1315
- * @param getTopFiltersNoResults.limit - Number of records to return. Limit is the size of the page.
1316
- * @param getTopFiltersNoResults.offset - Position of the starting record. Used for paging. 0 is the first record.
1317
- * @param getTopFiltersNoResults.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1318
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1319
- */
1320
- getTopFiltersNoResults({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1321
- if (!index) {
1322
- throw new Error('Parameter `index` is required when calling `getTopFiltersNoResults`.');
1323
- }
1324
- const requestPath = '/2/filters/noResults';
1325
- const headers = {};
1326
- const queryParameters = {};
1327
- if (index !== undefined) {
1328
- queryParameters.index = index.toString();
1329
- }
1330
- if (search !== undefined) {
1331
- queryParameters.search = search.toString();
1332
- }
1333
- if (startDate !== undefined) {
1334
- queryParameters.startDate = startDate.toString();
1335
- }
1336
- if (endDate !== undefined) {
1337
- queryParameters.endDate = endDate.toString();
1338
- }
1339
- if (limit !== undefined) {
1340
- queryParameters.limit = limit.toString();
1341
- }
1342
- if (offset !== undefined) {
1343
- queryParameters.offset = offset.toString();
1344
- }
1345
- if (tags !== undefined) {
1346
- queryParameters.tags = tags.toString();
1347
- }
1348
- const request = {
1349
- method: 'GET',
1350
- path: requestPath,
1351
- queryParameters,
1352
- headers,
1353
- };
1354
- return transporter.request(request, requestOptions);
1355
- },
1356
- /**
1357
- * Returns top hits. Limited to the 1000 most frequent ones.
1358
- *
1359
- * @summary Get top hits.
1360
- * @param getTopHits - The getTopHits object.
1361
- * @param getTopHits.index - The index name to target.
1362
- * @param getTopHits.search - The query term to search for. Must match the exact user input.
1363
- * @param getTopHits.clickAnalytics - Whether to include the click-through and conversion rates for a search.
1364
- * @param getTopHits.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1365
- * @param getTopHits.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1366
- * @param getTopHits.limit - Number of records to return. Limit is the size of the page.
1367
- * @param getTopHits.offset - Position of the starting record. Used for paging. 0 is the first record.
1368
- * @param getTopHits.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1369
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1370
- */
1371
- getTopHits({ index, search, clickAnalytics, startDate, endDate, limit, offset, tags, }, requestOptions) {
1372
- if (!index) {
1373
- throw new Error('Parameter `index` is required when calling `getTopHits`.');
1374
- }
1375
- const requestPath = '/2/hits';
1376
- const headers = {};
1377
- const queryParameters = {};
1378
- if (index !== undefined) {
1379
- queryParameters.index = index.toString();
1380
- }
1381
- if (search !== undefined) {
1382
- queryParameters.search = search.toString();
1383
- }
1384
- if (clickAnalytics !== undefined) {
1385
- queryParameters.clickAnalytics = clickAnalytics.toString();
1386
- }
1387
- if (startDate !== undefined) {
1388
- queryParameters.startDate = startDate.toString();
1389
- }
1390
- if (endDate !== undefined) {
1391
- queryParameters.endDate = endDate.toString();
1392
- }
1393
- if (limit !== undefined) {
1394
- queryParameters.limit = limit.toString();
1395
- }
1396
- if (offset !== undefined) {
1397
- queryParameters.offset = offset.toString();
1398
- }
1399
- if (tags !== undefined) {
1400
- queryParameters.tags = tags.toString();
1401
- }
1402
- const request = {
1403
- method: 'GET',
1404
- path: requestPath,
1405
- queryParameters,
1406
- headers,
1407
- };
1408
- return transporter.request(request, requestOptions);
1409
- },
1410
- /**
1411
- * Returns top searches. Limited to the 1000 most frequent ones. For each search, also returns the average number of hits returned.
1412
- *
1413
- * @summary Get top searches.
1414
- * @param getTopSearches - The getTopSearches object.
1415
- * @param getTopSearches.index - The index name to target.
1416
- * @param getTopSearches.clickAnalytics - Whether to include the click-through and conversion rates for a search.
1417
- * @param getTopSearches.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1418
- * @param getTopSearches.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1419
- * @param getTopSearches.orderBy - Reorder the results.
1420
- * @param getTopSearches.direction - The sorting of the result.
1421
- * @param getTopSearches.limit - Number of records to return. Limit is the size of the page.
1422
- * @param getTopSearches.offset - Position of the starting record. Used for paging. 0 is the first record.
1423
- * @param getTopSearches.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1424
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1425
- */
1426
- getTopSearches({ index, clickAnalytics, startDate, endDate, orderBy, direction, limit, offset, tags, }, requestOptions) {
1427
- if (!index) {
1428
- throw new Error('Parameter `index` is required when calling `getTopSearches`.');
1429
- }
1430
- const requestPath = '/2/searches';
1431
- const headers = {};
1432
- const queryParameters = {};
1433
- if (index !== undefined) {
1434
- queryParameters.index = index.toString();
1435
- }
1436
- if (clickAnalytics !== undefined) {
1437
- queryParameters.clickAnalytics = clickAnalytics.toString();
1438
- }
1439
- if (startDate !== undefined) {
1440
- queryParameters.startDate = startDate.toString();
1441
- }
1442
- if (endDate !== undefined) {
1443
- queryParameters.endDate = endDate.toString();
1444
- }
1445
- if (orderBy !== undefined) {
1446
- queryParameters.orderBy = orderBy.toString();
1447
- }
1448
- if (direction !== undefined) {
1449
- queryParameters.direction = direction.toString();
1450
- }
1451
- if (limit !== undefined) {
1452
- queryParameters.limit = limit.toString();
1453
- }
1454
- if (offset !== undefined) {
1455
- queryParameters.offset = offset.toString();
1456
- }
1457
- if (tags !== undefined) {
1458
- queryParameters.tags = tags.toString();
1459
- }
1460
- const request = {
1461
- method: 'GET',
1462
- path: requestPath,
1463
- queryParameters,
1464
- headers,
1465
- };
1466
- return transporter.request(request, requestOptions);
1467
- },
1468
- /**
1469
- * Returns the distinct count of users across the given time range. The endpoint returns a value for the complete given time range, as well as a value per day.
1470
- *
1471
- * @summary Get users count.
1472
- * @param getUsersCount - The getUsersCount object.
1473
- * @param getUsersCount.index - The index name to target.
1474
- * @param getUsersCount.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1475
- * @param getUsersCount.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1476
- * @param getUsersCount.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1477
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1478
- */
1479
- getUsersCount({ index, startDate, endDate, tags }, requestOptions) {
1480
- if (!index) {
1481
- throw new Error('Parameter `index` is required when calling `getUsersCount`.');
1482
- }
1483
- const requestPath = '/2/users/count';
1484
- const headers = {};
1485
- const queryParameters = {};
1486
- if (index !== undefined) {
1487
- queryParameters.index = index.toString();
1488
- }
1489
- if (startDate !== undefined) {
1490
- queryParameters.startDate = startDate.toString();
1491
- }
1492
- if (endDate !== undefined) {
1493
- queryParameters.endDate = endDate.toString();
1494
- }
1495
- if (tags !== undefined) {
1496
- queryParameters.tags = tags.toString();
1497
- }
1498
- const request = {
1499
- method: 'GET',
1500
- path: requestPath,
1501
- queryParameters,
1502
- headers,
1503
- };
1504
- return transporter.request(request, requestOptions);
1505
- },
1506
- /**
1507
- * This method allow you to send requests to the Algolia REST API.
1508
- *
1509
- * @summary Send requests to the Algolia REST API.
1510
- * @param post - The post object.
1511
- * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1512
- * @param post.parameters - Query parameters to be applied to the current query.
1513
- * @param post.body - The parameters to send with the custom request.
1514
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1515
- */
1516
- post({ path, parameters, body }, requestOptions) {
1517
- if (!path) {
1518
- throw new Error('Parameter `path` is required when calling `post`.');
1519
- }
1520
- const requestPath = '/1{path}'.replace('{path}', path);
1521
- const headers = {};
1522
- const queryParameters = parameters ? parameters : {};
1523
- const request = {
1524
- method: 'POST',
1525
- path: requestPath,
1526
- queryParameters,
1527
- headers,
1528
- data: body ? body : {},
1529
- };
1530
- return transporter.request(request, requestOptions);
1531
- },
1532
- /**
1533
- * This method allow you to send requests to the Algolia REST API.
1534
- *
1535
- * @summary Send requests to the Algolia REST API.
1536
- * @param put - The put object.
1537
- * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1538
- * @param put.parameters - Query parameters to be applied to the current query.
1539
- * @param put.body - The parameters to send with the custom request.
1540
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1541
- */
1542
- put({ path, parameters, body }, requestOptions) {
1543
- if (!path) {
1544
- throw new Error('Parameter `path` is required when calling `put`.');
1545
- }
1546
- const requestPath = '/1{path}'.replace('{path}', path);
1547
- const headers = {};
1548
- const queryParameters = parameters ? parameters : {};
1549
- const request = {
1550
- method: 'PUT',
1551
- path: requestPath,
1552
- queryParameters,
1553
- headers,
1554
- data: body ? body : {},
1555
- };
1556
- return transporter.request(request, requestOptions);
1557
- },
1558
- };
664
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
665
+ const apiClientVersion = '5.0.0-alpha.54';
666
+ const REGIONS = ['de', 'us'];
667
+ function getDefaultHosts(region) {
668
+ const url = !region
669
+ ? 'analytics.algolia.com'
670
+ : 'analytics.{region}.algolia.com'.replace('{region}', region);
671
+ return [{ url, accept: 'readWrite', protocol: 'https' }];
672
+ }
673
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
674
+ function createAnalyticsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
675
+ const auth = createAuth(appIdOption, apiKeyOption, authMode);
676
+ const transporter = createTransporter({
677
+ hosts: getDefaultHosts(regionOption),
678
+ ...options,
679
+ algoliaAgent: getAlgoliaAgent({
680
+ algoliaAgents,
681
+ client: 'Analytics',
682
+ version: apiClientVersion,
683
+ }),
684
+ baseHeaders: {
685
+ 'content-type': 'text/plain',
686
+ ...auth.headers(),
687
+ ...options.baseHeaders,
688
+ },
689
+ baseQueryParameters: {
690
+ ...auth.queryParameters(),
691
+ ...options.baseQueryParameters,
692
+ },
693
+ });
694
+ return {
695
+ transporter,
696
+ /**
697
+ * The `appId` currently in use.
698
+ */
699
+ appId: appIdOption,
700
+ /**
701
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
702
+ */
703
+ clearCache() {
704
+ return Promise.all([
705
+ transporter.requestsCache.clear(),
706
+ transporter.responsesCache.clear(),
707
+ ]).then(() => undefined);
708
+ },
709
+ /**
710
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
711
+ */
712
+ get _ua() {
713
+ return transporter.algoliaAgent.value;
714
+ },
715
+ /**
716
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
717
+ *
718
+ * @param segment - The algolia agent (user-agent) segment to add.
719
+ * @param version - The version of the agent.
720
+ */
721
+ addAlgoliaAgent(segment, version) {
722
+ transporter.algoliaAgent.add({ segment, version });
723
+ },
724
+ /**
725
+ * This method allow you to send requests to the Algolia REST API.
726
+ *
727
+ * @summary Send requests to the Algolia REST API.
728
+ * @param del - The del object.
729
+ * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
730
+ * @param del.parameters - Query parameters to be applied to the current query.
731
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
732
+ */
733
+ del({ path, parameters }, requestOptions) {
734
+ if (!path) {
735
+ throw new Error('Parameter `path` is required when calling `del`.');
736
+ }
737
+ const requestPath = '/1{path}'.replace('{path}', path);
738
+ const headers = {};
739
+ const queryParameters = parameters ? parameters : {};
740
+ const request = {
741
+ method: 'DELETE',
742
+ path: requestPath,
743
+ queryParameters,
744
+ headers,
745
+ };
746
+ return transporter.request(request, requestOptions);
747
+ },
748
+ /**
749
+ * This method allow you to send requests to the Algolia REST API.
750
+ *
751
+ * @summary Send requests to the Algolia REST API.
752
+ * @param get - The get object.
753
+ * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
754
+ * @param get.parameters - Query parameters to be applied to the current query.
755
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
756
+ */
757
+ get({ path, parameters }, requestOptions) {
758
+ if (!path) {
759
+ throw new Error('Parameter `path` is required when calling `get`.');
760
+ }
761
+ const requestPath = '/1{path}'.replace('{path}', path);
762
+ const headers = {};
763
+ const queryParameters = parameters ? parameters : {};
764
+ const request = {
765
+ method: 'GET',
766
+ path: requestPath,
767
+ queryParameters,
768
+ headers,
769
+ };
770
+ return transporter.request(request, requestOptions);
771
+ },
772
+ /**
773
+ * Returns the average click position. The endpoint returns a value for the complete given time range, as well as a value per day.
774
+ *
775
+ * @summary Get average click position.
776
+ * @param getAverageClickPosition - The getAverageClickPosition object.
777
+ * @param getAverageClickPosition.index - The index name to target.
778
+ * @param getAverageClickPosition.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
779
+ * @param getAverageClickPosition.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
780
+ * @param getAverageClickPosition.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
781
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
782
+ */
783
+ getAverageClickPosition({ index, startDate, endDate, tags }, requestOptions) {
784
+ if (!index) {
785
+ throw new Error('Parameter `index` is required when calling `getAverageClickPosition`.');
786
+ }
787
+ const requestPath = '/2/clicks/averageClickPosition';
788
+ const headers = {};
789
+ const queryParameters = {};
790
+ if (index !== undefined) {
791
+ queryParameters.index = index.toString();
792
+ }
793
+ if (startDate !== undefined) {
794
+ queryParameters.startDate = startDate.toString();
795
+ }
796
+ if (endDate !== undefined) {
797
+ queryParameters.endDate = endDate.toString();
798
+ }
799
+ if (tags !== undefined) {
800
+ queryParameters.tags = tags.toString();
801
+ }
802
+ const request = {
803
+ method: 'GET',
804
+ path: requestPath,
805
+ queryParameters,
806
+ headers,
807
+ };
808
+ return transporter.request(request, requestOptions);
809
+ },
810
+ /**
811
+ * Returns the distribution of clicks per range of positions. If the groups all have a count of 0, it means Algolia didn’t receive any click events for the queries with the clickAnalytics search parameter set to true. The count is 0 until Algolia receives at least one click event.
812
+ *
813
+ * @summary Get clicks per positions.
814
+ * @param getClickPositions - The getClickPositions object.
815
+ * @param getClickPositions.index - The index name to target.
816
+ * @param getClickPositions.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
817
+ * @param getClickPositions.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
818
+ * @param getClickPositions.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
819
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
820
+ */
821
+ getClickPositions({ index, startDate, endDate, tags }, requestOptions) {
822
+ if (!index) {
823
+ throw new Error('Parameter `index` is required when calling `getClickPositions`.');
824
+ }
825
+ const requestPath = '/2/clicks/positions';
826
+ const headers = {};
827
+ const queryParameters = {};
828
+ if (index !== undefined) {
829
+ queryParameters.index = index.toString();
830
+ }
831
+ if (startDate !== undefined) {
832
+ queryParameters.startDate = startDate.toString();
833
+ }
834
+ if (endDate !== undefined) {
835
+ queryParameters.endDate = endDate.toString();
836
+ }
837
+ if (tags !== undefined) {
838
+ queryParameters.tags = tags.toString();
839
+ }
840
+ const request = {
841
+ method: 'GET',
842
+ path: requestPath,
843
+ queryParameters,
844
+ headers,
845
+ };
846
+ return transporter.request(request, requestOptions);
847
+ },
848
+ /**
849
+ * Returns a click-through rate (CTR). The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of clicks and searches used to compute the rates.
850
+ *
851
+ * @summary Get click-through rate (CTR).
852
+ * @param getClickThroughRate - The getClickThroughRate object.
853
+ * @param getClickThroughRate.index - The index name to target.
854
+ * @param getClickThroughRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
855
+ * @param getClickThroughRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
856
+ * @param getClickThroughRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
857
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
858
+ */
859
+ getClickThroughRate({ index, startDate, endDate, tags }, requestOptions) {
860
+ if (!index) {
861
+ throw new Error('Parameter `index` is required when calling `getClickThroughRate`.');
862
+ }
863
+ const requestPath = '/2/clicks/clickThroughRate';
864
+ const headers = {};
865
+ const queryParameters = {};
866
+ if (index !== undefined) {
867
+ queryParameters.index = index.toString();
868
+ }
869
+ if (startDate !== undefined) {
870
+ queryParameters.startDate = startDate.toString();
871
+ }
872
+ if (endDate !== undefined) {
873
+ queryParameters.endDate = endDate.toString();
874
+ }
875
+ if (tags !== undefined) {
876
+ queryParameters.tags = tags.toString();
877
+ }
878
+ const request = {
879
+ method: 'GET',
880
+ path: requestPath,
881
+ queryParameters,
882
+ headers,
883
+ };
884
+ return transporter.request(request, requestOptions);
885
+ },
886
+ /**
887
+ * Returns a conversion rate (CR). The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of conversion and searches used to compute the rates.
888
+ *
889
+ * @summary Get conversion rate (CR).
890
+ * @param getConversationRate - The getConversationRate object.
891
+ * @param getConversationRate.index - The index name to target.
892
+ * @param getConversationRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
893
+ * @param getConversationRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
894
+ * @param getConversationRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
895
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
896
+ */
897
+ getConversationRate({ index, startDate, endDate, tags }, requestOptions) {
898
+ if (!index) {
899
+ throw new Error('Parameter `index` is required when calling `getConversationRate`.');
900
+ }
901
+ const requestPath = '/2/conversions/conversionRate';
902
+ const headers = {};
903
+ const queryParameters = {};
904
+ if (index !== undefined) {
905
+ queryParameters.index = index.toString();
906
+ }
907
+ if (startDate !== undefined) {
908
+ queryParameters.startDate = startDate.toString();
909
+ }
910
+ if (endDate !== undefined) {
911
+ queryParameters.endDate = endDate.toString();
912
+ }
913
+ if (tags !== undefined) {
914
+ queryParameters.tags = tags.toString();
915
+ }
916
+ const request = {
917
+ method: 'GET',
918
+ path: requestPath,
919
+ queryParameters,
920
+ headers,
921
+ };
922
+ return transporter.request(request, requestOptions);
923
+ },
924
+ /**
925
+ * Returns the rate at which searches didn\'t lead to any clicks. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without clicks.
926
+ *
927
+ * @summary Get no click rate.
928
+ * @param getNoClickRate - The getNoClickRate object.
929
+ * @param getNoClickRate.index - The index name to target.
930
+ * @param getNoClickRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
931
+ * @param getNoClickRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
932
+ * @param getNoClickRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
933
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
934
+ */
935
+ getNoClickRate({ index, startDate, endDate, tags }, requestOptions) {
936
+ if (!index) {
937
+ throw new Error('Parameter `index` is required when calling `getNoClickRate`.');
938
+ }
939
+ const requestPath = '/2/searches/noClickRate';
940
+ const headers = {};
941
+ const queryParameters = {};
942
+ if (index !== undefined) {
943
+ queryParameters.index = index.toString();
944
+ }
945
+ if (startDate !== undefined) {
946
+ queryParameters.startDate = startDate.toString();
947
+ }
948
+ if (endDate !== undefined) {
949
+ queryParameters.endDate = endDate.toString();
950
+ }
951
+ if (tags !== undefined) {
952
+ queryParameters.tags = tags.toString();
953
+ }
954
+ const request = {
955
+ method: 'GET',
956
+ path: requestPath,
957
+ queryParameters,
958
+ headers,
959
+ };
960
+ return transporter.request(request, requestOptions);
961
+ },
962
+ /**
963
+ * Returns the rate at which searches didn\'t return any results. The endpoint returns a value for the complete given time range, as well as a value per day. It also returns the count of searches and searches without results used to compute the rates.
964
+ *
965
+ * @summary Get no results rate.
966
+ * @param getNoResultsRate - The getNoResultsRate object.
967
+ * @param getNoResultsRate.index - The index name to target.
968
+ * @param getNoResultsRate.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
969
+ * @param getNoResultsRate.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
970
+ * @param getNoResultsRate.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
971
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
972
+ */
973
+ getNoResultsRate({ index, startDate, endDate, tags }, requestOptions) {
974
+ if (!index) {
975
+ throw new Error('Parameter `index` is required when calling `getNoResultsRate`.');
976
+ }
977
+ const requestPath = '/2/searches/noResultRate';
978
+ const headers = {};
979
+ const queryParameters = {};
980
+ if (index !== undefined) {
981
+ queryParameters.index = index.toString();
982
+ }
983
+ if (startDate !== undefined) {
984
+ queryParameters.startDate = startDate.toString();
985
+ }
986
+ if (endDate !== undefined) {
987
+ queryParameters.endDate = endDate.toString();
988
+ }
989
+ if (tags !== undefined) {
990
+ queryParameters.tags = tags.toString();
991
+ }
992
+ const request = {
993
+ method: 'GET',
994
+ path: requestPath,
995
+ queryParameters,
996
+ headers,
997
+ };
998
+ return transporter.request(request, requestOptions);
999
+ },
1000
+ /**
1001
+ * Returns the number of searches across the given time range. The endpoint returns a value for the complete given time range, as well as a value per day.
1002
+ *
1003
+ * @summary Get searches count.
1004
+ * @param getSearchesCount - The getSearchesCount object.
1005
+ * @param getSearchesCount.index - The index name to target.
1006
+ * @param getSearchesCount.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1007
+ * @param getSearchesCount.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1008
+ * @param getSearchesCount.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1009
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1010
+ */
1011
+ getSearchesCount({ index, startDate, endDate, tags }, requestOptions) {
1012
+ if (!index) {
1013
+ throw new Error('Parameter `index` is required when calling `getSearchesCount`.');
1014
+ }
1015
+ const requestPath = '/2/searches/count';
1016
+ const headers = {};
1017
+ const queryParameters = {};
1018
+ if (index !== undefined) {
1019
+ queryParameters.index = index.toString();
1020
+ }
1021
+ if (startDate !== undefined) {
1022
+ queryParameters.startDate = startDate.toString();
1023
+ }
1024
+ if (endDate !== undefined) {
1025
+ queryParameters.endDate = endDate.toString();
1026
+ }
1027
+ if (tags !== undefined) {
1028
+ queryParameters.tags = tags.toString();
1029
+ }
1030
+ const request = {
1031
+ method: 'GET',
1032
+ path: requestPath,
1033
+ queryParameters,
1034
+ headers,
1035
+ };
1036
+ return transporter.request(request, requestOptions);
1037
+ },
1038
+ /**
1039
+ * Returns top searches that didn\'t lead to any clicks. Limited to the 1000 most frequent ones. For each search, also returns the average number of found hits.
1040
+ *
1041
+ * @summary Get top searches with no clicks.
1042
+ * @param getSearchesNoClicks - The getSearchesNoClicks object.
1043
+ * @param getSearchesNoClicks.index - The index name to target.
1044
+ * @param getSearchesNoClicks.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1045
+ * @param getSearchesNoClicks.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1046
+ * @param getSearchesNoClicks.limit - Number of records to return. Limit is the size of the page.
1047
+ * @param getSearchesNoClicks.offset - Position of the starting record. Used for paging. 0 is the first record.
1048
+ * @param getSearchesNoClicks.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1049
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1050
+ */
1051
+ getSearchesNoClicks({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
1052
+ if (!index) {
1053
+ throw new Error('Parameter `index` is required when calling `getSearchesNoClicks`.');
1054
+ }
1055
+ const requestPath = '/2/searches/noClicks';
1056
+ const headers = {};
1057
+ const queryParameters = {};
1058
+ if (index !== undefined) {
1059
+ queryParameters.index = index.toString();
1060
+ }
1061
+ if (startDate !== undefined) {
1062
+ queryParameters.startDate = startDate.toString();
1063
+ }
1064
+ if (endDate !== undefined) {
1065
+ queryParameters.endDate = endDate.toString();
1066
+ }
1067
+ if (limit !== undefined) {
1068
+ queryParameters.limit = limit.toString();
1069
+ }
1070
+ if (offset !== undefined) {
1071
+ queryParameters.offset = offset.toString();
1072
+ }
1073
+ if (tags !== undefined) {
1074
+ queryParameters.tags = tags.toString();
1075
+ }
1076
+ const request = {
1077
+ method: 'GET',
1078
+ path: requestPath,
1079
+ queryParameters,
1080
+ headers,
1081
+ };
1082
+ return transporter.request(request, requestOptions);
1083
+ },
1084
+ /**
1085
+ * Returns top searches that didn\'t return any results. Limited to the 1000 most frequent ones.
1086
+ *
1087
+ * @summary Get top searches with no results.
1088
+ * @param getSearchesNoResults - The getSearchesNoResults object.
1089
+ * @param getSearchesNoResults.index - The index name to target.
1090
+ * @param getSearchesNoResults.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1091
+ * @param getSearchesNoResults.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1092
+ * @param getSearchesNoResults.limit - Number of records to return. Limit is the size of the page.
1093
+ * @param getSearchesNoResults.offset - Position of the starting record. Used for paging. 0 is the first record.
1094
+ * @param getSearchesNoResults.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1095
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1096
+ */
1097
+ getSearchesNoResults({ index, startDate, endDate, limit, offset, tags, }, requestOptions) {
1098
+ if (!index) {
1099
+ throw new Error('Parameter `index` is required when calling `getSearchesNoResults`.');
1100
+ }
1101
+ const requestPath = '/2/searches/noResults';
1102
+ const headers = {};
1103
+ const queryParameters = {};
1104
+ if (index !== undefined) {
1105
+ queryParameters.index = index.toString();
1106
+ }
1107
+ if (startDate !== undefined) {
1108
+ queryParameters.startDate = startDate.toString();
1109
+ }
1110
+ if (endDate !== undefined) {
1111
+ queryParameters.endDate = endDate.toString();
1112
+ }
1113
+ if (limit !== undefined) {
1114
+ queryParameters.limit = limit.toString();
1115
+ }
1116
+ if (offset !== undefined) {
1117
+ queryParameters.offset = offset.toString();
1118
+ }
1119
+ if (tags !== undefined) {
1120
+ queryParameters.tags = tags.toString();
1121
+ }
1122
+ const request = {
1123
+ method: 'GET',
1124
+ path: requestPath,
1125
+ queryParameters,
1126
+ headers,
1127
+ };
1128
+ return transporter.request(request, requestOptions);
1129
+ },
1130
+ /**
1131
+ * Returns the latest update time of the analytics API for a given index. If the index has been recently created and/or no search has been performed yet the updated time will be null.
1132
+ *
1133
+ * @summary Get Analytics API status.
1134
+ * @param getStatus - The getStatus object.
1135
+ * @param getStatus.index - The index name to target.
1136
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1137
+ */
1138
+ getStatus({ index }, requestOptions) {
1139
+ if (!index) {
1140
+ throw new Error('Parameter `index` is required when calling `getStatus`.');
1141
+ }
1142
+ const requestPath = '/2/status';
1143
+ const headers = {};
1144
+ const queryParameters = {};
1145
+ if (index !== undefined) {
1146
+ queryParameters.index = index.toString();
1147
+ }
1148
+ const request = {
1149
+ method: 'GET',
1150
+ path: requestPath,
1151
+ queryParameters,
1152
+ headers,
1153
+ };
1154
+ return transporter.request(request, requestOptions);
1155
+ },
1156
+ /**
1157
+ * Returns top countries. Limited to the 1000 most frequent ones.
1158
+ *
1159
+ * @summary Get top countries.
1160
+ * @param getTopCountries - The getTopCountries object.
1161
+ * @param getTopCountries.index - The index name to target.
1162
+ * @param getTopCountries.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1163
+ * @param getTopCountries.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1164
+ * @param getTopCountries.limit - Number of records to return. Limit is the size of the page.
1165
+ * @param getTopCountries.offset - Position of the starting record. Used for paging. 0 is the first record.
1166
+ * @param getTopCountries.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1167
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1168
+ */
1169
+ getTopCountries({ index, startDate, endDate, limit, offset, tags }, requestOptions) {
1170
+ if (!index) {
1171
+ throw new Error('Parameter `index` is required when calling `getTopCountries`.');
1172
+ }
1173
+ const requestPath = '/2/countries';
1174
+ const headers = {};
1175
+ const queryParameters = {};
1176
+ if (index !== undefined) {
1177
+ queryParameters.index = index.toString();
1178
+ }
1179
+ if (startDate !== undefined) {
1180
+ queryParameters.startDate = startDate.toString();
1181
+ }
1182
+ if (endDate !== undefined) {
1183
+ queryParameters.endDate = endDate.toString();
1184
+ }
1185
+ if (limit !== undefined) {
1186
+ queryParameters.limit = limit.toString();
1187
+ }
1188
+ if (offset !== undefined) {
1189
+ queryParameters.offset = offset.toString();
1190
+ }
1191
+ if (tags !== undefined) {
1192
+ queryParameters.tags = tags.toString();
1193
+ }
1194
+ const request = {
1195
+ method: 'GET',
1196
+ path: requestPath,
1197
+ queryParameters,
1198
+ headers,
1199
+ };
1200
+ return transporter.request(request, requestOptions);
1201
+ },
1202
+ /**
1203
+ * Returns top filter attributes. Limited to the 1000 most used filters.
1204
+ *
1205
+ * @summary Get top filter attributes.
1206
+ * @param getTopFilterAttributes - The getTopFilterAttributes object.
1207
+ * @param getTopFilterAttributes.index - The index name to target.
1208
+ * @param getTopFilterAttributes.search - The query term to search for. Must match the exact user input.
1209
+ * @param getTopFilterAttributes.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1210
+ * @param getTopFilterAttributes.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1211
+ * @param getTopFilterAttributes.limit - Number of records to return. Limit is the size of the page.
1212
+ * @param getTopFilterAttributes.offset - Position of the starting record. Used for paging. 0 is the first record.
1213
+ * @param getTopFilterAttributes.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1214
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1215
+ */
1216
+ getTopFilterAttributes({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1217
+ if (!index) {
1218
+ throw new Error('Parameter `index` is required when calling `getTopFilterAttributes`.');
1219
+ }
1220
+ const requestPath = '/2/filters';
1221
+ const headers = {};
1222
+ const queryParameters = {};
1223
+ if (index !== undefined) {
1224
+ queryParameters.index = index.toString();
1225
+ }
1226
+ if (search !== undefined) {
1227
+ queryParameters.search = search.toString();
1228
+ }
1229
+ if (startDate !== undefined) {
1230
+ queryParameters.startDate = startDate.toString();
1231
+ }
1232
+ if (endDate !== undefined) {
1233
+ queryParameters.endDate = endDate.toString();
1234
+ }
1235
+ if (limit !== undefined) {
1236
+ queryParameters.limit = limit.toString();
1237
+ }
1238
+ if (offset !== undefined) {
1239
+ queryParameters.offset = offset.toString();
1240
+ }
1241
+ if (tags !== undefined) {
1242
+ queryParameters.tags = tags.toString();
1243
+ }
1244
+ const request = {
1245
+ method: 'GET',
1246
+ path: requestPath,
1247
+ queryParameters,
1248
+ headers,
1249
+ };
1250
+ return transporter.request(request, requestOptions);
1251
+ },
1252
+ /**
1253
+ * Returns top filters for the given attribute. Limited to the 1000 most used filters.
1254
+ *
1255
+ * @summary Get top filters for the an attribute.
1256
+ * @param getTopFilterForAttribute - The getTopFilterForAttribute object.
1257
+ * @param getTopFilterForAttribute.attribute - The exact name of the attribute.
1258
+ * @param getTopFilterForAttribute.index - The index name to target.
1259
+ * @param getTopFilterForAttribute.search - The query term to search for. Must match the exact user input.
1260
+ * @param getTopFilterForAttribute.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1261
+ * @param getTopFilterForAttribute.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1262
+ * @param getTopFilterForAttribute.limit - Number of records to return. Limit is the size of the page.
1263
+ * @param getTopFilterForAttribute.offset - Position of the starting record. Used for paging. 0 is the first record.
1264
+ * @param getTopFilterForAttribute.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1265
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1266
+ */
1267
+ getTopFilterForAttribute({ attribute, index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1268
+ if (!attribute) {
1269
+ throw new Error('Parameter `attribute` is required when calling `getTopFilterForAttribute`.');
1270
+ }
1271
+ if (!index) {
1272
+ throw new Error('Parameter `index` is required when calling `getTopFilterForAttribute`.');
1273
+ }
1274
+ const requestPath = '/2/filters/{attribute}'.replace('{attribute}', encodeURIComponent(attribute));
1275
+ const headers = {};
1276
+ const queryParameters = {};
1277
+ if (index !== undefined) {
1278
+ queryParameters.index = index.toString();
1279
+ }
1280
+ if (search !== undefined) {
1281
+ queryParameters.search = search.toString();
1282
+ }
1283
+ if (startDate !== undefined) {
1284
+ queryParameters.startDate = startDate.toString();
1285
+ }
1286
+ if (endDate !== undefined) {
1287
+ queryParameters.endDate = endDate.toString();
1288
+ }
1289
+ if (limit !== undefined) {
1290
+ queryParameters.limit = limit.toString();
1291
+ }
1292
+ if (offset !== undefined) {
1293
+ queryParameters.offset = offset.toString();
1294
+ }
1295
+ if (tags !== undefined) {
1296
+ queryParameters.tags = tags.toString();
1297
+ }
1298
+ const request = {
1299
+ method: 'GET',
1300
+ path: requestPath,
1301
+ queryParameters,
1302
+ headers,
1303
+ };
1304
+ return transporter.request(request, requestOptions);
1305
+ },
1306
+ /**
1307
+ * Returns top filters with no results. Limited to the 1000 most used filters.
1308
+ *
1309
+ * @summary Get top filters for a no result search.
1310
+ * @param getTopFiltersNoResults - The getTopFiltersNoResults object.
1311
+ * @param getTopFiltersNoResults.index - The index name to target.
1312
+ * @param getTopFiltersNoResults.search - The query term to search for. Must match the exact user input.
1313
+ * @param getTopFiltersNoResults.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1314
+ * @param getTopFiltersNoResults.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1315
+ * @param getTopFiltersNoResults.limit - Number of records to return. Limit is the size of the page.
1316
+ * @param getTopFiltersNoResults.offset - Position of the starting record. Used for paging. 0 is the first record.
1317
+ * @param getTopFiltersNoResults.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1318
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1319
+ */
1320
+ getTopFiltersNoResults({ index, search, startDate, endDate, limit, offset, tags, }, requestOptions) {
1321
+ if (!index) {
1322
+ throw new Error('Parameter `index` is required when calling `getTopFiltersNoResults`.');
1323
+ }
1324
+ const requestPath = '/2/filters/noResults';
1325
+ const headers = {};
1326
+ const queryParameters = {};
1327
+ if (index !== undefined) {
1328
+ queryParameters.index = index.toString();
1329
+ }
1330
+ if (search !== undefined) {
1331
+ queryParameters.search = search.toString();
1332
+ }
1333
+ if (startDate !== undefined) {
1334
+ queryParameters.startDate = startDate.toString();
1335
+ }
1336
+ if (endDate !== undefined) {
1337
+ queryParameters.endDate = endDate.toString();
1338
+ }
1339
+ if (limit !== undefined) {
1340
+ queryParameters.limit = limit.toString();
1341
+ }
1342
+ if (offset !== undefined) {
1343
+ queryParameters.offset = offset.toString();
1344
+ }
1345
+ if (tags !== undefined) {
1346
+ queryParameters.tags = tags.toString();
1347
+ }
1348
+ const request = {
1349
+ method: 'GET',
1350
+ path: requestPath,
1351
+ queryParameters,
1352
+ headers,
1353
+ };
1354
+ return transporter.request(request, requestOptions);
1355
+ },
1356
+ /**
1357
+ * Returns top hits. Limited to the 1000 most frequent ones.
1358
+ *
1359
+ * @summary Get top hits.
1360
+ * @param getTopHits - The getTopHits object.
1361
+ * @param getTopHits.index - The index name to target.
1362
+ * @param getTopHits.search - The query term to search for. Must match the exact user input.
1363
+ * @param getTopHits.clickAnalytics - Whether to include the click-through and conversion rates for a search.
1364
+ * @param getTopHits.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1365
+ * @param getTopHits.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1366
+ * @param getTopHits.limit - Number of records to return. Limit is the size of the page.
1367
+ * @param getTopHits.offset - Position of the starting record. Used for paging. 0 is the first record.
1368
+ * @param getTopHits.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1369
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1370
+ */
1371
+ getTopHits({ index, search, clickAnalytics, startDate, endDate, limit, offset, tags, }, requestOptions) {
1372
+ if (!index) {
1373
+ throw new Error('Parameter `index` is required when calling `getTopHits`.');
1374
+ }
1375
+ const requestPath = '/2/hits';
1376
+ const headers = {};
1377
+ const queryParameters = {};
1378
+ if (index !== undefined) {
1379
+ queryParameters.index = index.toString();
1380
+ }
1381
+ if (search !== undefined) {
1382
+ queryParameters.search = search.toString();
1383
+ }
1384
+ if (clickAnalytics !== undefined) {
1385
+ queryParameters.clickAnalytics = clickAnalytics.toString();
1386
+ }
1387
+ if (startDate !== undefined) {
1388
+ queryParameters.startDate = startDate.toString();
1389
+ }
1390
+ if (endDate !== undefined) {
1391
+ queryParameters.endDate = endDate.toString();
1392
+ }
1393
+ if (limit !== undefined) {
1394
+ queryParameters.limit = limit.toString();
1395
+ }
1396
+ if (offset !== undefined) {
1397
+ queryParameters.offset = offset.toString();
1398
+ }
1399
+ if (tags !== undefined) {
1400
+ queryParameters.tags = tags.toString();
1401
+ }
1402
+ const request = {
1403
+ method: 'GET',
1404
+ path: requestPath,
1405
+ queryParameters,
1406
+ headers,
1407
+ };
1408
+ return transporter.request(request, requestOptions);
1409
+ },
1410
+ /**
1411
+ * Returns top searches. Limited to the 1000 most frequent ones. For each search, also returns the average number of hits returned.
1412
+ *
1413
+ * @summary Get top searches.
1414
+ * @param getTopSearches - The getTopSearches object.
1415
+ * @param getTopSearches.index - The index name to target.
1416
+ * @param getTopSearches.clickAnalytics - Whether to include the click-through and conversion rates for a search.
1417
+ * @param getTopSearches.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1418
+ * @param getTopSearches.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1419
+ * @param getTopSearches.orderBy - Reorder the results.
1420
+ * @param getTopSearches.direction - The sorting of the result.
1421
+ * @param getTopSearches.limit - Number of records to return. Limit is the size of the page.
1422
+ * @param getTopSearches.offset - Position of the starting record. Used for paging. 0 is the first record.
1423
+ * @param getTopSearches.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1424
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1425
+ */
1426
+ getTopSearches({ index, clickAnalytics, startDate, endDate, orderBy, direction, limit, offset, tags, }, requestOptions) {
1427
+ if (!index) {
1428
+ throw new Error('Parameter `index` is required when calling `getTopSearches`.');
1429
+ }
1430
+ const requestPath = '/2/searches';
1431
+ const headers = {};
1432
+ const queryParameters = {};
1433
+ if (index !== undefined) {
1434
+ queryParameters.index = index.toString();
1435
+ }
1436
+ if (clickAnalytics !== undefined) {
1437
+ queryParameters.clickAnalytics = clickAnalytics.toString();
1438
+ }
1439
+ if (startDate !== undefined) {
1440
+ queryParameters.startDate = startDate.toString();
1441
+ }
1442
+ if (endDate !== undefined) {
1443
+ queryParameters.endDate = endDate.toString();
1444
+ }
1445
+ if (orderBy !== undefined) {
1446
+ queryParameters.orderBy = orderBy.toString();
1447
+ }
1448
+ if (direction !== undefined) {
1449
+ queryParameters.direction = direction.toString();
1450
+ }
1451
+ if (limit !== undefined) {
1452
+ queryParameters.limit = limit.toString();
1453
+ }
1454
+ if (offset !== undefined) {
1455
+ queryParameters.offset = offset.toString();
1456
+ }
1457
+ if (tags !== undefined) {
1458
+ queryParameters.tags = tags.toString();
1459
+ }
1460
+ const request = {
1461
+ method: 'GET',
1462
+ path: requestPath,
1463
+ queryParameters,
1464
+ headers,
1465
+ };
1466
+ return transporter.request(request, requestOptions);
1467
+ },
1468
+ /**
1469
+ * Returns the distinct count of users across the given time range. The endpoint returns a value for the complete given time range, as well as a value per day.
1470
+ *
1471
+ * @summary Get users count.
1472
+ * @param getUsersCount - The getUsersCount object.
1473
+ * @param getUsersCount.index - The index name to target.
1474
+ * @param getUsersCount.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1475
+ * @param getUsersCount.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze.
1476
+ * @param getUsersCount.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded.
1477
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1478
+ */
1479
+ getUsersCount({ index, startDate, endDate, tags }, requestOptions) {
1480
+ if (!index) {
1481
+ throw new Error('Parameter `index` is required when calling `getUsersCount`.');
1482
+ }
1483
+ const requestPath = '/2/users/count';
1484
+ const headers = {};
1485
+ const queryParameters = {};
1486
+ if (index !== undefined) {
1487
+ queryParameters.index = index.toString();
1488
+ }
1489
+ if (startDate !== undefined) {
1490
+ queryParameters.startDate = startDate.toString();
1491
+ }
1492
+ if (endDate !== undefined) {
1493
+ queryParameters.endDate = endDate.toString();
1494
+ }
1495
+ if (tags !== undefined) {
1496
+ queryParameters.tags = tags.toString();
1497
+ }
1498
+ const request = {
1499
+ method: 'GET',
1500
+ path: requestPath,
1501
+ queryParameters,
1502
+ headers,
1503
+ };
1504
+ return transporter.request(request, requestOptions);
1505
+ },
1506
+ /**
1507
+ * This method allow you to send requests to the Algolia REST API.
1508
+ *
1509
+ * @summary Send requests to the Algolia REST API.
1510
+ * @param post - The post object.
1511
+ * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1512
+ * @param post.parameters - Query parameters to be applied to the current query.
1513
+ * @param post.body - The parameters to send with the custom request.
1514
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1515
+ */
1516
+ post({ path, parameters, body }, requestOptions) {
1517
+ if (!path) {
1518
+ throw new Error('Parameter `path` is required when calling `post`.');
1519
+ }
1520
+ const requestPath = '/1{path}'.replace('{path}', path);
1521
+ const headers = {};
1522
+ const queryParameters = parameters ? parameters : {};
1523
+ const request = {
1524
+ method: 'POST',
1525
+ path: requestPath,
1526
+ queryParameters,
1527
+ headers,
1528
+ data: body ? body : {},
1529
+ };
1530
+ return transporter.request(request, requestOptions);
1531
+ },
1532
+ /**
1533
+ * This method allow you to send requests to the Algolia REST API.
1534
+ *
1535
+ * @summary Send requests to the Algolia REST API.
1536
+ * @param put - The put object.
1537
+ * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1538
+ * @param put.parameters - Query parameters to be applied to the current query.
1539
+ * @param put.body - The parameters to send with the custom request.
1540
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1541
+ */
1542
+ put({ path, parameters, body }, requestOptions) {
1543
+ if (!path) {
1544
+ throw new Error('Parameter `path` is required when calling `put`.');
1545
+ }
1546
+ const requestPath = '/1{path}'.replace('{path}', path);
1547
+ const headers = {};
1548
+ const queryParameters = parameters ? parameters : {};
1549
+ const request = {
1550
+ method: 'PUT',
1551
+ path: requestPath,
1552
+ queryParameters,
1553
+ headers,
1554
+ data: body ? body : {},
1555
+ };
1556
+ return transporter.request(request, requestOptions);
1557
+ },
1558
+ };
1559
1559
  }
1560
1560
 
1561
- // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
1562
- function analyticsClient(appId, apiKey, region, options) {
1563
- if (!appId || typeof appId !== 'string') {
1564
- throw new Error('`appId` is missing.');
1565
- }
1566
- if (!apiKey || typeof apiKey !== 'string') {
1567
- throw new Error('`apiKey` is missing.');
1568
- }
1569
- if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
1570
- throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
1571
- }
1572
- return createAnalyticsClient({
1573
- appId,
1574
- apiKey,
1575
- region,
1576
- timeouts: {
1577
- connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
1578
- read: DEFAULT_READ_TIMEOUT_BROWSER,
1579
- write: DEFAULT_WRITE_TIMEOUT_BROWSER,
1580
- },
1581
- requester: createXhrRequester(),
1582
- algoliaAgents: [{ segment: 'Browser' }],
1583
- authMode: 'WithinQueryParameters',
1584
- responsesCache: createMemoryCache(),
1585
- requestsCache: createMemoryCache({ serializable: false }),
1586
- hostsCache: createFallbackableCache({
1587
- caches: [
1588
- createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
1589
- createMemoryCache(),
1590
- ],
1591
- }),
1592
- ...options,
1593
- });
1561
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
1562
+ function analyticsClient(appId, apiKey, region, options) {
1563
+ if (!appId || typeof appId !== 'string') {
1564
+ throw new Error('`appId` is missing.');
1565
+ }
1566
+ if (!apiKey || typeof apiKey !== 'string') {
1567
+ throw new Error('`apiKey` is missing.');
1568
+ }
1569
+ if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
1570
+ throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
1571
+ }
1572
+ return createAnalyticsClient({
1573
+ appId,
1574
+ apiKey,
1575
+ region,
1576
+ timeouts: {
1577
+ connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
1578
+ read: DEFAULT_READ_TIMEOUT_BROWSER,
1579
+ write: DEFAULT_WRITE_TIMEOUT_BROWSER,
1580
+ },
1581
+ requester: createXhrRequester(),
1582
+ algoliaAgents: [{ segment: 'Browser' }],
1583
+ authMode: 'WithinQueryParameters',
1584
+ responsesCache: createMemoryCache(),
1585
+ requestsCache: createMemoryCache({ serializable: false }),
1586
+ hostsCache: createFallbackableCache({
1587
+ caches: [
1588
+ createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
1589
+ createMemoryCache(),
1590
+ ],
1591
+ }),
1592
+ ...options,
1593
+ });
1594
1594
  }
1595
1595
 
1596
1596
  export { analyticsClient, apiClientVersion };