Welcome to mirror list, hosted at ThFree Co, Russian Federation.

blob_links_tracking.js « blob « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9a49aa8b0fc0ce6d5930d87ce670fc906f370a4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;