import { Http } from "./http"; type ABServiceResponse = { experiment: string; variant: { id: string; }; }; /** * Gets variant for a user from AB Experiment service * @param {string} userId Stable Identifier for a given user. * @export * @return {Promise} AB Variant Identifier, composed of experiment and variant ids. */ export async function getAbVariantId(userId: string): Promise { const response = await Http.get(`${window._RecSys.Bundle.Properties.osiris.variant.path}/${userId}`); if (!Http.ok(response.status)) return "null-null"; const body: ABServiceResponse = await response.json(); return `${body.experiment}-${body.variant.id}`; }