From 21f5447e404b92f1a5a2528ea5db96d0b352135c Mon Sep 17 00:00:00 2001 From: Vishnu Gp Date: Wed, 4 May 2022 20:39:03 +0530 Subject: [PATCH] Functional breakdown for authentication analytics feature --- .../server/solutions/ce/EnvManagerCEImpl.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCEImpl.java index f9a48c30a0..7c05b182c0 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/EnvManagerCEImpl.java @@ -329,14 +329,7 @@ public class EnvManagerCEImpl implements EnvManagerCE { Map properties = new HashMap<>(){{ put("provider", authEnv); }}; - // Authentication configuration added - if (!changes.get(authEnv).isEmpty() && originalVariables.get(authEnv).isEmpty()) { - properties.put("action", "Added"); - } - // Authentication configuration removed - else if (changes.get(authEnv).isEmpty() && !originalVariables.get(authEnv).isEmpty()) { - properties.put("action", "Removed"); - } + properties = setAnalyticsEventAction(properties, changes.get(authEnv), originalVariables.get(authEnv), authEnv); if(properties.containsKey("action")){ analyticsEvents.add(properties); } @@ -346,6 +339,27 @@ public class EnvManagerCEImpl implements EnvManagerCE { return analyticsEvents; } + /** + * Sets the correct action to analytics event properties template(s) according to the env variable changes + * @param properties + * @param newVariable Updated env variable value + * @param originalVariable Already existing env variable value + * @param authEnv Env variable name + * @return + */ + public Map setAnalyticsEventAction(Map properties, String newVariable, String originalVariable, String authEnv){ + // Authentication configuration added + if (!newVariable.isEmpty() && originalVariable.isEmpty()) { + properties.put("action", "Added"); + } + // Authentication configuration removed + else if (newVariable.isEmpty() && !originalVariable.isEmpty()) { + properties.put("action", "Removed"); + } + + return properties; + } + /** * Adds or removes admin user policy from users. * If an email is removed from admin emails, it'll remove the policy from that user.