From b87776dd7d9b43d706cdecdfbc88a55ca0b25906 Mon Sep 17 00:00:00 2001
From: Yaroslav Afenkin <91559310+yaroslavafenkin@users.noreply.github.com>
Date: Tue, 12 Nov 2024 17:57:38 +0200
Subject: [PATCH 1/2] [JENKINS-74067] Extract inline JavaScript from
`BuildMonitorView/index.jelly`
---
.../BuildMonitorView/collect-usage-stats.js | 31 ++++++
.../buildmonitor/BuildMonitorView/index.jelly | 94 +++----------------
.../BuildMonitorView/init-build-monitor.js | 19 ++++
.../BuildMonitorView/replace-stapler-proxy.js | 26 +++++
.../BuildMonitorView/restore-stapler-proxy.js | 7 ++
5 files changed, 97 insertions(+), 80 deletions(-)
create mode 100644 build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/collect-usage-stats.js
create mode 100644 build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/init-build-monitor.js
create mode 100644 build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/replace-stapler-proxy.js
create mode 100644 build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/restore-stapler-proxy.js
diff --git a/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/collect-usage-stats.js b/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/collect-usage-stats.js
new file mode 100644
index 00000000..764510b5
--- /dev/null
+++ b/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/collect-usage-stats.js
@@ -0,0 +1,31 @@
+window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
+
+const {
+ buildMonitorVersion,
+ jenkinsVersion,
+ installationSize,
+ itemsSize,
+ installationAudience,
+ anonymousCorrelationId
+} = document.querySelector('.build-monitor-ga-data-holder').dataset;
+
+ga('create', 'UA-61694827-4', 'auto', {
+ 'userId': anonymousCorrelationId,
+ 'sampleRate': 1
+});
+
+ga('set', {
+ 'forceSSL': true,
+ 'appName': 'Build Monitor',
+ 'appId': 'build-monitor-plugin',
+
+ 'appVersion': buildMonitorVersion,
+ 'appInstallerId': jenkinsVersion,
+
+ 'dimension1': installationSize,
+ 'dimension2': itemsSize,
+ 'dimension3': installationAudience,
+ 'dimension4': anonymousCorrelationId
+});
+
+ga('send', 'screenview', {screenName: 'Dashboard'});
diff --git a/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/index.jelly b/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/index.jelly
index 39ab2634..a5a30cab 100644
--- a/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/index.jelly
+++ b/build-monitor-plugin/src/main/resources/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorView/index.jelly
@@ -55,30 +55,14 @@
-
+
+
@@ -128,44 +112,9 @@
-
+
-
+
@@ -180,26 +129,11 @@
-
+
+