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
2fde44f9
Commit
2fde44f9
authored
Mar 10, 2022
by
Samantha Ming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add page load tracking for vulnerability details
Issue:
https://gitlab.com/gitlab-org/gitlab/-/issues/355479
parent
9f9b9070
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
16 deletions
+43
-16
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_training.vue
...pts/vulnerabilities/components/vulnerability_training.vue
+15
-9
ee/spec/frontend/vulnerabilities/vulnerability_training_spec.js
...c/frontend/vulnerabilities/vulnerability_training_spec.js
+28
-7
No files found.
ee/app/assets/javascripts/vulnerabilities/components/vulnerability_training.vue
View file @
2fde44f9
...
...
@@ -8,7 +8,10 @@ import { TYPE_VULNERABILITY } from '~/graphql_shared/constants';
import
{
convertToGraphQLId
}
from
'
~/graphql_shared/utils
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
Tracking
from
'
~/tracking
'
;
import
{
TRACK_CLICK_TRAINING_LINK_ACTION
}
from
'
~/security_configuration/constants
'
;
import
{
TRACK_CLICK_TRAINING_LINK_ACTION
,
TRACK_TRAINING_LOADED_ACTION
,
}
from
'
~/security_configuration/constants
'
;
import
{
TEMP_PROVIDER_LOGOS
}
from
'
~/security_configuration/components/constants
'
;
import
{
SUPPORTED_IDENTIFIER_TYPES
,
SECURITY_TRAINING_URL_STATUS_COMPLETED
}
from
'
../constants
'
;
...
...
@@ -101,7 +104,13 @@ export default {
);
},
hasSecurityTrainingUrls
()
{
return
this
.
vulnerability
?.
securityTrainingUrls
?.
length
>
0
;
const
hasSecurityTrainingUrls
=
this
.
vulnerability
?.
securityTrainingUrls
?.
length
>
0
;
if
(
hasSecurityTrainingUrls
)
{
this
.
track
(
TRACK_TRAINING_LOADED_ACTION
,
{
property
:
this
.
projectFullPath
,
});
}
return
hasSecurityTrainingUrls
;
},
securityTrainingUrls
()
{
return
this
.
vulnerability
?.
securityTrainingUrls
;
...
...
@@ -116,13 +125,10 @@ export default {
},
},
methods
:
{
clickTrainingLink
(
name
,
url
)
{
this
.
triggerMetric
(
TRACK_CLICK_TRAINING_LINK_ACTION
,
name
,
url
);
},
triggerMetric
(
action
,
name
,
url
)
{
this
.
track
(
action
,
{
property
:
url
,
clickTrainingLink
(
name
)
{
this
.
track
(
TRACK_CLICK_TRAINING_LINK_ACTION
,
{
label
:
`vendor_
${
name
}
`
,
property
:
this
.
projectFullPath
,
});
},
},
...
...
@@ -149,7 +155,7 @@ export default {
</span>
<span
class=
"gl-font-weight-bold gl-font-base"
>
{{
name
}}
</span>
</div>
<gl-link
:href=
"url"
target=
"_blank"
@
click=
"clickTrainingLink(name
, url
)"
>
<gl-link
:href=
"url"
target=
"_blank"
@
click=
"clickTrainingLink(name)"
>
{{
$options
.
i18n
.
viewTraining
}}
<gl-icon
class=
"gl-ml-2"
name=
"external-link"
:size=
"12"
/>
</gl-link>
...
...
ee/spec/frontend/vulnerabilities/vulnerability_training_spec.js
View file @
2fde44f9
...
...
@@ -13,7 +13,10 @@ import {
SUPPORTED_IDENTIFIER_TYPES
,
SECURITY_TRAINING_URL_STATUS_PENDING
,
}
from
'
ee/vulnerabilities/constants
'
;
import
{
TRACK_CLICK_TRAINING_LINK_ACTION
}
from
'
~/security_configuration/constants
'
;
import
{
TRACK_CLICK_TRAINING_LINK_ACTION
,
TRACK_TRAINING_LOADED_ACTION
,
}
from
'
~/security_configuration/constants
'
;
import
createMockApollo
from
'
helpers/mock_apollo_helper
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
...
...
@@ -40,6 +43,8 @@ const createTrainingData = (first = {}, second = {}, urls) =>
},
});
const
projectFullPath
=
'
namespace/project
'
;
const
TEST_TRAINING_PROVIDERS_ALL_DISABLED
=
getSecurityTrainingProvidersData
();
const
TEST_TRAINING_PROVIDERS_FIRST_ENABLED
=
getSecurityTrainingProvidersData
({
providerOverrides
:
{
first
:
{
isEnabled
:
true
}
},
...
...
@@ -76,7 +81,7 @@ describe('VulnerabilityTraining component', () => {
slots
,
apolloProvider
,
provide
:
{
projectFullPath
:
'
namespace/project
'
,
projectFullPath
,
glFeatures
:
{
secureVulnerabilityTraining
,
},
...
...
@@ -297,11 +302,8 @@ describe('VulnerabilityTraining component', () => {
describe
(
'
metrics
'
,
()
=>
{
let
trackingSpy
;
beforeEach
(
async
()
=>
{
beforeEach
(()
=>
{
trackingSpy
=
mockTracking
(
undefined
,
wrapper
.
element
,
jest
.
spyOn
);
createApolloProvider
();
createComponent
();
await
waitForQueryToBeLoaded
();
});
afterEach
(()
=>
{
...
...
@@ -309,11 +311,30 @@ describe('VulnerabilityTraining component', () => {
});
const
expectedTrackingOptions
=
(
index
)
=>
({
property
:
testTrainingUrls
[
index
],
label
:
`vendor_
${
testProviderName
[
index
]}
`
,
property
:
projectFullPath
,
});
it
(
'
tracks when the training link is loading
'
,
async
()
=>
{
createApolloProvider
({
vulnerabilityQueryHandler
:
jest
.
fn
().
mockResolvedValue
(
createTrainingData
({
status
:
SECURITY_TRAINING_URL_STATUS_PENDING
,
}).
response
,
),
});
createComponent
();
await
waitForQueryToBeLoaded
();
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
undefined
,
TRACK_TRAINING_LOADED_ACTION
,
{
property
:
projectFullPath
,
});
});
it
.
each
([
0
,
1
])(
'
tracks when training link %s gets clicked
'
,
async
(
index
)
=>
{
createApolloProvider
();
createComponent
();
await
waitForQueryToBeLoaded
();
await
findTrainingItemLinks
().
at
(
index
).
vm
.
$emit
(
'
click
'
);
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
...
...
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