<commit_before>import { removeUndefined, validateRSQuery } from '../../utils/index';

/**
 * ReactiveSearch suggestions API for v3
 * @param {Array<Object>} query
 * @param {Object} settings
 * @param {boolean} settings.recordAnalytics
 * @param {boolean} settings.userId
 * @param {boolean} settings.enableQueryRules
 * @param {boolean} settings.customEvents
 */
function getSuggestionsv3Api(query, settings) {
  const parsedSettings = removeUndefined(settings);

  // Validate query
  const valid = validateRSQuery(query);

  if (valid !== true) {
    throw valid;
  }

  const body = {
    settings: parsedSettings,
    query,
  };

  return this.performFetchRequest({
    method: 'POST',
    path: '_reactivesearch.v3',
    body,
    isRSAPI: true,
    isSuggestionsAPI: true,
  });
}

export default getSuggestionsv3Api;<commit_msg>fix: telemetry headers now set for getSuggestionsmethodveapi method<commit_after>import { removeUndefined, validateRSQuery } from '../../utils/index';

/**
 * ReactiveSearch suggestions API for v3
 * @param {Array<Object>} query
 * @param {Object} settings
 * @param {boolean} settings.recordAnalytics
 * @param {boolean} settings.userId
 * @param {boolean} settings.enableQueryRules
 * @param {boolean} settings.customEvents
 */
function getSuggestionsv3Api(query, settings) {
  const parsedSettings = removeUndefined(settings);

  // Validate query
  const valid = validateRSQuery(query);

  if (valid !== true) {
    throw valid;
  }

  const body = {
    settings: parsedSettings,
    query,
  };
  const headers = {};

  Object.assign(headers, {
    'X-Search-Client': 'Appbase JS',
  });
  if (this.enableTelemetry === false) {
    Object.assign(headers, {
      'X-Enable-Telemetry': this.enableTelemetry,
    });
  }

  return this.performFetchRequest({
    method: 'POST',
    path: '_reactivesearch.v3',
    body,
    headers,
    isRSAPI: true,
    isSuggestionsAPI: true,
  });
}

export default getSuggestionsv3Api;
{'fraction_non_alphanumeric': 0.1267175572519084, 'fraction_numerical': 0.004071246819338422, 'mean_word_length': 3.8784119106699753, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7641610', 'n_tokens_mistral': 605, 'n_tokens_neox': 593, 'n_words': 145}