diff options
Diffstat (limited to 'app/assets/javascripts/experimentation/utils.js')
-rw-r--r-- | app/assets/javascripts/experimentation/utils.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/assets/javascripts/experimentation/utils.js b/app/assets/javascripts/experimentation/utils.js index 572907f226d..e572280a62c 100644 --- a/app/assets/javascripts/experimentation/utils.js +++ b/app/assets/javascripts/experimentation/utils.js @@ -1,11 +1,20 @@ // This file only applies to use of experiments through https://gitlab.com/gitlab-org/gitlab-experiment import { get } from 'lodash'; -import { DEFAULT_VARIANT, CANDIDATE_VARIANT } from './constants'; +import { DEFAULT_VARIANT, CANDIDATE_VARIANT, TRACKING_CONTEXT_SCHEMA } from './constants'; export function getExperimentData(experimentName) { return get(window, ['gon', 'experiment', experimentName]); } +export function getExperimentContexts(...experimentNames) { + return experimentNames + .map((name) => { + const data = getExperimentData(name); + return data && { schema: TRACKING_CONTEXT_SCHEMA, data }; + }) + .filter((context) => context); +} + export function isExperimentVariant(experimentName, variantName) { return getExperimentData(experimentName)?.variant === variantName; } |