Skip to content

Commit

Permalink
Answers SDK: add cloudChoice support
Browse files Browse the repository at this point in the history
Now that cloudChoice is a param inside of search-core,
this CR adds support for setting it in the SDK, in the
init() function, including setting the old behavior as
the default. It is not needed elsewhere like with the
CLOUD_REGION setting, as that is used for things like
analytics tracking.

J=WAT-4375
TEST=auto

Ran test suite
  • Loading branch information
Fondryext committed Sep 11, 2024
1 parent 2725725 commit 108d15a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@mapbox/mapbox-gl-language": "^0.10.1",
"@yext/answers-storage": "^1.1.0",
"@yext/rtf-converter": "^1.7.1",
"@yext/search-core": "^2.5.1",
"@yext/search-core": "^2.5.4",
"bowser": "^2.11.0",
"cross-fetch": "^3.1.5",
"css-vars-ponyfill": "^2.4.3",
Expand Down
9 changes: 8 additions & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @module Core */
import { provideCore } from '@yext/search-core/lib/commonjs';
// Using the ESM build for importing the Environment enum due to an issue importing the commonjs version
import { Environment } from '@yext/search-core';
import { CloudChoice, Environment } from '@yext/search-core';
import { generateUUID } from './utils/uuid';
import SearchDataTransformer from './search/searchdatatransformer';

Expand Down Expand Up @@ -120,6 +120,12 @@ export default class Core {
*/
this._cloudRegion = CLOUD_REGION;

/**
* Determines the cloud choice of the api endpoints used when making search requests.
* @type {string}
*/
this._cloudChoice = config.cloudChoice || CloudChoice.GLOBAL_MULTI;

/** @type {string} */
this._verticalKey = config.verticalKey;

Expand Down Expand Up @@ -154,6 +160,7 @@ export default class Core {
jsLibVersion: LIB_VERSION
},
cloudRegion: this._cloudRegion,
cloudChoice: this._cloudChoice,
environment,
...config
};
Expand Down

0 comments on commit 108d15a

Please sign in to comment.