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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-18 03:07:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-18 03:07:45 +0300
commit7c077d960393e14b56d43cceaa7f609c703ac55f (patch)
treec3a5d79554b9be1d7434c8e9a8fcae35ab64af32 /app/assets/javascripts/monitoring/utils.js
parentda35510cdad8f8d3cb6c119682dc2735531983cd (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.js43
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 {};