diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-18 03:07:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-18 03:07:45 +0300 |
commit | 7c077d960393e14b56d43cceaa7f609c703ac55f (patch) | |
tree | c3a5d79554b9be1d7434c8e9a8fcae35ab64af32 /app/assets/javascripts/monitoring/utils.js | |
parent | da35510cdad8f8d3cb6c119682dc2735531983cd (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/monitoring/utils.js')
-rw-r--r-- | app/assets/javascripts/monitoring/utils.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/app/assets/javascripts/monitoring/utils.js b/app/assets/javascripts/monitoring/utils.js index a134b4e3c33..9049695b992 100644 --- a/app/assets/javascripts/monitoring/utils.js +++ b/app/assets/javascripts/monitoring/utils.js @@ -45,4 +45,47 @@ export const graphDataValidatorForValues = (isValues, graphData) => { ); }; +/* eslint-disable @gitlab/i18n/no-non-i18n-strings */ +/** + * Checks that element that triggered event is located on cluster health check dashboard + * @param {HTMLElement} element to check against + * @returns {boolean} + */ +const isClusterHealthBoard = () => (document.body.dataset.page || '').includes(':clusters:show'); + +/** + * Tracks snowplow event when user generates link to metric chart + * @param {String} chart link that will be sent as a property for the event + * @return {Object} config object for event tracking + */ +export const generateLinkToChartOptions = chartLink => { + const isCLusterHealthBoard = isClusterHealthBoard(); + + const category = isCLusterHealthBoard + ? 'Cluster Monitoring' + : 'Incident Management::Embedded metrics'; + const action = isCLusterHealthBoard + ? 'generate_link_to_cluster_metric_chart' + : 'generate_link_to_metrics_chart'; + + return { category, action, label: 'Chart link', property: chartLink }; +}; + +/** + * Tracks snowplow event when user downloads CSV of cluster metric + * @param {String} chart title that will be sent as a property for the event + */ +export const downloadCSVOptions = title => { + const isCLusterHealthBoard = isClusterHealthBoard(); + + const category = isCLusterHealthBoard + ? 'Cluster Monitoring' + : 'Incident Management::Embedded metrics'; + const action = isCLusterHealthBoard + ? 'download_csv_of_cluster_metric_chart' + : 'download_csv_of_metrics_dashboard_chart'; + + return { category, action, label: 'Chart title', property: title }; +}; + export default {}; |