Skip to content

Commit

Permalink
Merge commit '7663046873490efd10b40933a69122ca7217b7a6' into plugin-s…
Browse files Browse the repository at this point in the history
…ystem
  • Loading branch information
ramboz committed Nov 6, 2023
2 parents c99dcea + 7663046 commit 8c1fefa
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions plugins/experimentation/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function inferEmptyPercentageSplits(variants) {
* @param {string} instantExperiment The list of varaints
* @returns {object} the experiment manifest
*/
export function getConfigForInstantExperiment(
function getConfigForInstantExperiment(
experimentId,
instantExperiment,
pluginOptions,
Expand Down Expand Up @@ -287,8 +287,15 @@ export function getConfigForInstantExperiment(
* @param {object} pluginOptions The plugin options
* @returns {object} containing the experiment manifest
*/
export async function getConfigForFullExperiment(experimentId, pluginOptions, context) {
const path = `${pluginOptions.experimentsRoot}/${experimentId}/${pluginOptions.experimentsConfigFile}`;
async function getConfigForFullExperiment(experimentId, pluginOptions, context) {
let path;
if (experimentId.includes(`/${pluginOptions.experimentsConfigFile}`)) {
path = new URL(experimentId).href;
// eslint-disable-next-line no-param-reassign
[experimentId] = path.split('/').splice(-2, 1);
} else {
path = `${pluginOptions.experimentsRoot}/${experimentId}/${pluginOptions.experimentsConfigFile}`;
}
try {
const resp = await fetch(path);
if (!resp.ok) {
Expand Down Expand Up @@ -336,7 +343,7 @@ function getDecisionPolicy(config) {
return decisionPolicy;
}

export async function getConfig(experiment, instantExperiment, pluginOptions, context) {
async function getConfig(experiment, instantExperiment, pluginOptions, context) {
const usp = new URLSearchParams(window.location.search);
const [forcedExperiment, forcedVariant] = usp.has(pluginOptions.experimentsQueryParameter)
? usp.get(pluginOptions.experimentsQueryParameter).split('/')
Expand All @@ -357,7 +364,7 @@ export async function getConfig(experiment, instantExperiment, pluginOptions, co
: null;

experimentConfig.resolvedAudiences = await getResolvedAudiences(
experimentConfig.audiences,
experimentConfig.audiences.map(context.toClassName),
pluginOptions,
context,
);
Expand Down Expand Up @@ -517,7 +524,7 @@ export async function serveAudience(document, options, context) {
}

const audiences = await getResolvedAudiences(
Object.keys(configuredAudiences),
Object.keys(configuredAudiences).map(context.toClassName),
pluginOptions,
context,
);
Expand Down

0 comments on commit 8c1fefa

Please sign in to comment.