Commit 2c206a8a authored by Peter Hegman's avatar Peter Hegman

Merge branch...

Merge branch '345622-resolve-bad-events-due-to-unsupported-gitlab_experiment-context-properties' into 'master'

Resolve BAD events due to unsupported gitlab_experiment context properties

See merge request gitlab-org/gitlab!74443
parents 1db72e61 82d63a75
...@@ -12,7 +12,15 @@ function getExperimentsData() { ...@@ -12,7 +12,15 @@ function getExperimentsData() {
} }
function convertExperimentDataToExperimentContext(experimentData) { function convertExperimentDataToExperimentContext(experimentData) {
return { schema: TRACKING_CONTEXT_SCHEMA, data: experimentData }; // Bandaid to allow-list only the properties which the current gitlab_experiment context schema suppports.
// See TRACKING_CONTEXT_SCHEMA for current version (1-0-0)
// https://gitlab.com/gitlab-org/iglu/-/blob/master/public/schemas/com.gitlab/gitlab_experiment/jsonschema/1-0-0
const { experiment: experimentName, key, variant, migration_keys } = experimentData;
return {
schema: TRACKING_CONTEXT_SCHEMA,
data: { experiment: experimentName, key, variant, migration_keys },
};
} }
export function getExperimentData(experimentName) { export function getExperimentData(experimentName) {
......
...@@ -72,6 +72,19 @@ describe('experiment Utilities', () => { ...@@ -72,6 +72,19 @@ describe('experiment Utilities', () => {
it('returns an empty array if there are no experiments', () => { it('returns an empty array if there are no experiments', () => {
expect(experimentUtils.getAllExperimentContexts()).toEqual([]); expect(experimentUtils.getAllExperimentContexts()).toEqual([]);
}); });
it('only collects the data properties which are supported by the schema', () => {
origGl = window.gl;
window.gl.experiments = {
my_experiment: { experiment: 'my_experiment', variant: 'control', excluded: false },
};
expect(experimentUtils.getAllExperimentContexts()).toEqual([
{ schema, data: { experiment: 'my_experiment', variant: 'control' } },
]);
window.gl = origGl;
});
}); });
describe('isExperimentVariant', () => { describe('isExperimentVariant', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment