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

track_event.js « directives « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d1c05c5c26701f7e21d314b572e8e474a32c335d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Tracking from '~/tracking';

export default {
  bind(el, binding) {
    el.dataset.trackingOptions = JSON.stringify(binding.value || {});

    el.addEventListener('click', () => {
      const { category, action, label, property, value } = JSON.parse(el.dataset.trackingOptions);
      if (!category || !action) {
        return;
      }
      Tracking.event(category, action, { label, property, value });
    });
  },
  update(el, binding) {
    if (binding.value !== binding.oldValue) {
      el.dataset.trackingOptions = JSON.stringify(binding.value || {});
    }
  },
};