diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 08:17:02 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-18 08:17:02 +0000 |
commit | b39512ed755239198a9c294b6a45e65c05900235 (patch) | |
tree | d234a3efade1de67c46b9e5a38ce813627726aa7 /app/assets/javascripts/blob | |
parent | d31474cf3b17ece37939d20082b07f6657cc79a9 (diff) | |
download | gitlab-ce-b39512ed755239198a9c294b6a45e65c05900235.tar.gz |
Add latest changes from gitlab-org/gitlab@15-3-stable-eev15.3.0-rc42
Diffstat (limited to 'app/assets/javascripts/blob')
-rw-r--r-- | app/assets/javascripts/blob/blob_links_tracking.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/assets/javascripts/blob/blob_links_tracking.js b/app/assets/javascripts/blob/blob_links_tracking.js new file mode 100644 index 00000000000..9a49aa8b0fc --- /dev/null +++ b/app/assets/javascripts/blob/blob_links_tracking.js @@ -0,0 +1,25 @@ +import Tracking from '~/tracking'; + +function addBlobLinksTracking(containerSelector, eventsToTrack) { + const containerEl = document.querySelector(containerSelector); + + if (!containerEl) { + return; + } + + const eventName = 'click_link'; + const label = 'file_line_action'; + + containerEl.addEventListener('click', (e) => { + eventsToTrack.forEach((event) => { + if (e.target.matches(event.selector)) { + Tracking.event(undefined, eventName, { + label, + property: event.property, + }); + } + }); + }); +} + +export default addBlobLinksTracking; |