Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ksearch: properly use cloudChoice #1900

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/answers-search-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ class AnswersSearchBar {
onVerticalSearch: parsedConfig.onVerticalSearch,
onUniversalSearch: parsedConfig.onUniversalSearch,
environment: parsedConfig.environment,
componentManager: this.components
componentManager: this.components,
cloudChoice: parsedConfig.cloudChoice
});

if (parsedConfig.onStateChange && typeof parsedConfig.onStateChange === 'function') {
Expand Down
3 changes: 2 additions & 1 deletion src/answers-umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ class Answers {
onUniversalSearch: parsedConfig.onUniversalSearch,
environment: parsedConfig.environment,
componentManager: this.components,
additionalHttpHeaders: parsedConfig.additionalHttpHeaders
additionalHttpHeaders: parsedConfig.additionalHttpHeaders,
cloudChoice: parsedConfig.cloudChoice
});

if (parsedConfig.onStateChange && typeof parsedConfig.onStateChange === 'function') {
Expand Down
5 changes: 5 additions & 0 deletions src/core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export const SPEECH_RECOGNITION_LOCALES_SUPPORTED_BY_EDGE = '@@SPEECH_RECOGNITIO

/** The cloud region being used, injected by the build process */
export const CLOUD_REGION = '@@CLOUD_REGION';
/** The identifier for all cloud providers */
export const GLOBAL_MULTI = 'multi';

/** The identifier for using GCP */
export const GLOBAL_GCP = 'gcp';

/** The identifier of the production environment */
export const PRODUCTION = 'production';
Expand Down
7 changes: 4 additions & 3 deletions src/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import FilterRegistry from './filters/filterregistry';
import DirectAnswer from './models/directanswer';
import AutoCompleteResponseTransformer from './search/autocompleteresponsetransformer';

import { PRODUCTION, LIB_VERSION, CLOUD_REGION, SANDBOX } from './constants';
import { PRODUCTION, LIB_VERSION, CLOUD_REGION, SANDBOX, GLOBAL_MULTI, GLOBAL_GCP } from './constants';
import { SearchParams } from '../ui';
import SearchStates from './storage/searchstates';
import Searcher from './models/searcher';
Expand Down Expand Up @@ -124,7 +124,7 @@ export default class Core {
* Determines the cloud choice of the api endpoints used when making search requests.
* @type {string}
*/
this._cloudChoice = config.cloudChoice || CloudChoice.GLOBAL_MULTI;
this._cloudChoice = config.cloudChoice || GLOBAL_MULTI;

/** @type {string} */
this._verticalKey = config.verticalKey;
Expand All @@ -150,6 +150,7 @@ export default class Core {
*/
init (config) {
const environment = this._environment === SANDBOX ? Environment.SANDBOX : Environment.PROD;
const cloudChoice = this._cloudChoice === GLOBAL_GCP ? CloudChoice.GLOBAL_GCP : CloudChoice.GLOBAL_MULTI;
const params = {
...(this._token && { token: this._token }),
...(this._apiKey && { apiKey: this._apiKey }),
Expand All @@ -160,7 +161,7 @@ export default class Core {
jsLibVersion: LIB_VERSION
},
cloudRegion: this._cloudRegion,
cloudChoice: this._cloudChoice,
cloudChoice,
environment,
...config
};
Expand Down
Loading