Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
82d63a75
Commit
82d63a75
authored
Nov 12, 2021
by
Dallas Reedy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only send gitlab_experiment context data allowed by the schema
parent
e249f499
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
app/assets/javascripts/experimentation/utils.js
app/assets/javascripts/experimentation/utils.js
+9
-1
spec/frontend/experimentation/utils_spec.js
spec/frontend/experimentation/utils_spec.js
+13
-0
No files found.
app/assets/javascripts/experimentation/utils.js
View file @
82d63a75
...
...
@@ -12,7 +12,15 @@ function getExperimentsData() {
}
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
)
{
...
...
spec/frontend/experimentation/utils_spec.js
View file @
82d63a75
...
...
@@ -72,6 +72,19 @@ describe('experiment Utilities', () => {
it
(
'
returns an empty array if there are no experiments
'
,
()
=>
{
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
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment