debian-mirror-gitlab/app/assets/javascripts/blob/blob_links_tracking.js
2022-08-27 11:52:29 +05:30

25 lines
586 B
JavaScript

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;