This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 02eacec918 Feat(ui): Add UTM tracking to all help buttons for website
analytics (#6076) (#6092)
02eacec918 is described below
commit 02eacec918dd3f1a01bb827d27ed2fe5eb5e12b3
Author: lance <[email protected]>
AuthorDate: Tue Dec 2 21:40:27 2025 +0800
Feat(ui): Add UTM tracking to all help buttons for website analytics
(#6076) (#6092)
* feat(Ui) Add UTM tracking to all help buttons for website analytics
Signed-off-by: lance <[email protected]>
* Add switch for HopWeb and HopGui
---------
Signed-off-by: lance <[email protected]>
Co-authored-by: Hans Van Akelyen <[email protected]>
---
.../java/org/apache/hop/ui/util/HelpUtils.java | 37 +++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/ui/src/main/java/org/apache/hop/ui/util/HelpUtils.java
b/ui/src/main/java/org/apache/hop/ui/util/HelpUtils.java
index 3a165249ce..d5dd2327ad 100644
--- a/ui/src/main/java/org/apache/hop/ui/util/HelpUtils.java
+++ b/ui/src/main/java/org/apache/hop/ui/util/HelpUtils.java
@@ -19,11 +19,15 @@ package org.apache.hop.ui.util;
import static org.apache.hop.core.Const.getDocUrl;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import org.apache.hop.core.HopEnvironment;
import org.apache.hop.core.database.DatabasePluginType;
import org.apache.hop.core.plugins.ActionPluginType;
import org.apache.hop.core.plugins.IPlugin;
import org.apache.hop.core.plugins.TransformPluginType;
import org.apache.hop.core.util.StringUtil;
+import org.apache.hop.core.util.Utils;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.ErrorDialog;
@@ -85,7 +89,9 @@ public class HelpUtils {
}
if (isPluginDocumented(plugin)) {
try {
-
EnvironmentUtils.getInstance().openUrl(getDocUrl(plugin.getDocumentationUrl()));
+ String originalUrl = getDocUrl(plugin.getDocumentationUrl());
+ String trackedUrl = appendUtmParameters(originalUrl);
+ EnvironmentUtils.getInstance().openUrl(trackedUrl);
} catch (Exception ex) {
new ErrorDialog(shell, "Error", "Error opening URL", ex);
}
@@ -108,4 +114,33 @@ public class HelpUtils {
mb.open();
}
}
+
+ /**
+ * Add analytics tracking parameters for help-button <code>
+ * mtm_campaign=hopgui&mtm_source=help_btn&mtm_kwd=write to log
+ * </code>
+ */
+ private static String appendUtmParameters(String url) {
+ if (url == null || url.isEmpty()) {
+ return url;
+ }
+
+ // campaign: hop gui, source: hop version
+ String utmCampaign;
+ utmCampaign = EnvironmentUtils.getInstance().isWeb() ? "HopWeb" : "hopGui";
+ String utmSource =
HopEnvironment.class.getPackage().getImplementationVersion();
+ String utmParams = "mtm_campaign=" + encode(utmCampaign) + "&mtm_source="
+ encode(utmSource);
+
+ String separator = url.contains("?") ? "&" : "?";
+ return url + separator + utmParams;
+ }
+
+ /** url params encode. */
+ private static String encode(String field) {
+ if (Utils.isEmpty(field)) {
+ return field;
+ }
+
+ return URLEncoder.encode(field, StandardCharsets.UTF_8);
+ }
}