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
b9e6a4df
Commit
b9e6a4df
authored
Feb 22, 2022
by
Samantha Ming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add metric when training material is loaded
Issue:
https://gitlab.com/gitlab-org/gitlab/-/issues/348593
parent
8737e446
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
11 deletions
+39
-11
app/assets/javascripts/security_configuration/constants.js
app/assets/javascripts/security_configuration/constants.js
+1
-0
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_training.vue
...pts/vulnerabilities/components/vulnerability_training.vue
+9
-2
ee/spec/frontend/vulnerabilities/vulnerability_training_spec.js
...c/frontend/vulnerabilities/vulnerability_training_spec.js
+29
-9
No files found.
app/assets/javascripts/security_configuration/constants.js
View file @
b9e6a4df
...
...
@@ -3,3 +3,4 @@ export const TRACK_TOGGLE_TRAINING_PROVIDER_LABEL = 'update_security_training_pr
export
const
TRACK_CLICK_TRAINING_LINK
=
'
click_security_training_link
'
;
export
const
TRACK_PROVIDER_LEARN_MORE_CLICK_ACTION
=
'
click_link
'
;
export
const
TRACK_PROVIDER_LEARN_MORE_CLICK_LABEL
=
'
security_training_provider
'
;
export
const
TRACK_TRAINING_LOADED_ACTION
=
'
security_training_link_loaded
'
;
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_training.vue
View file @
b9e6a4df
...
...
@@ -6,7 +6,10 @@ import securityTrainingProvidersQuery from '~/security_configuration/graphql/sec
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Tracking
from
'
~/tracking
'
;
import
{
TRACK_CLICK_TRAINING_LINK
}
from
'
~/security_configuration/constants
'
;
import
{
TRACK_CLICK_TRAINING_LINK
,
TRACK_TRAINING_LOADED_ACTION
,
}
from
'
~/security_configuration/constants
'
;
import
{
SUPPORTED_IDENTIFIER_TYPES
}
from
'
../constants
'
;
export
const
i18n
=
{
...
...
@@ -115,6 +118,7 @@ export default {
const
{
data
:
{
url
},
}
=
await
axios
.
get
(
path
,
{
params
});
this
.
triggerMetric
(
TRACK_TRAINING_LOADED_ACTION
);
this
.
training
=
{
name
,
url
};
}
catch
{
this
.
hasError
=
true
;
...
...
@@ -123,10 +127,13 @@ export default {
}
},
clickTrainingLink
()
{
this
.
triggerMetric
(
TRACK_CLICK_TRAINING_LINK
);
},
triggerMetric
(
action
)
{
const
{
name
}
=
this
.
supportedIdentifier
;
const
{
id
}
=
mockProvider
;
this
.
track
(
TRACK_CLICK_TRAINING_LINK
,
{
this
.
track
(
action
,
{
label
:
`vendor_
${
id
}
`
,
property
:
name
,
});
...
...
ee/spec/frontend/vulnerabilities/vulnerability_training_spec.js
View file @
b9e6a4df
...
...
@@ -14,7 +14,10 @@ import VulnerabilityTraining, {
import
securityTrainingProvidersQuery
from
'
~/security_configuration/graphql/security_training_providers.query.graphql
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
SUPPORTED_IDENTIFIER_TYPES
}
from
'
ee/vulnerabilities/constants
'
;
import
{
TRACK_CLICK_TRAINING_LINK
}
from
'
~/security_configuration/constants
'
;
import
{
TRACK_CLICK_TRAINING_LINK
,
TRACK_TRAINING_LOADED_ACTION
,
}
from
'
~/security_configuration/constants
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
...
...
@@ -204,21 +207,38 @@ describe('VulnerabilityTraining component', () => {
describe
(
'
metrics
'
,
()
=>
{
let
trackingSpy
;
beforeEach
(
async
()
=>
{
trackingSpy
=
mockTracking
(
undefined
,
wrapper
.
element
,
jest
.
spyOn
);
await
mockTrainingSuccess
();
createComponent
();
await
waitForQueryToBeLoaded
();
});
afterEach
(()
=>
{
unmockTracking
();
});
const
expectedTrackingOptions
=
{
property
:
defaultProps
.
identifiers
[
0
].
name
,
label
:
`vendor_
${
mockProvider
.
id
}
`
,
};
it
(
'
tracks when the training link gets loaded
'
,
()
=>
{
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
undefined
,
TRACK_TRAINING_LOADED_ACTION
,
expectedTrackingOptions
,
);
});
it
(
'
tracks when a training link gets clicked
'
,
async
()
=>
{
await
mockTrainingSuccess
();
createComponent
();
trackingSpy
=
mockTracking
(
undefined
,
wrapper
.
element
,
jest
.
spyOn
);
await
waitForQueryToBeLoaded
();
await
findTrainingItemLink
().
vm
.
$emit
(
'
click
'
);
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
undefined
,
TRACK_CLICK_TRAINING_LINK
,
{
property
:
defaultProps
.
identifiers
[
0
].
name
,
label
:
`vendor_
${
mockProvider
.
id
}
`
,
});
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
undefined
,
TRACK_CLICK_TRAINING_LINK
,
expectedTrackingOptions
,
);
});
});
...
...
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