2022-08-16 08:12:38 -04:00
|
|
|
import Tracking from '~/tracking';
|
|
|
|
|
2022-08-24 14:12:18 -04:00
|
|
|
const eventsToTrack = [
|
|
|
|
{ selector: '.file-line-blame', property: 'blame' },
|
|
|
|
{ selector: '.file-line-num', property: 'link' },
|
|
|
|
];
|
|
|
|
|
|
|
|
function addBlobLinksTracking() {
|
|
|
|
const containerEl = document.querySelector('.file-holder');
|
2022-08-16 08:12:38 -04:00
|
|
|
|
|
|
|
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;
|