Browse Source

feat: REPORT-106669 报表埋点补充

- 将切换操作包上一层,然后在外层进行记录和触发操作。不然插件有可能记录不到埋点信息。
feature/x
Harrison 1 year ago
parent
commit
d38aa7607b
  1. 109
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

109
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -127,53 +127,105 @@ public class EnvChangeEntrance {
}
}
/**
* 切换到新环境
*
* @param envName 新工作环境名称
* @param strategy 提示策略
* @return 是否成功
*/
private boolean switch2Env(final String envName, PopTipStrategy strategy) {
PerformancePoint performancePoint = PerformancePoint.create();
boolean switchStatus = doSwitch2Env(envName, strategy);
// 记录切换耗时
recordSwitchElapsed(performancePoint);
// 触发切换埋点
triggerSwitchMetric(switchStatus);
return switchStatus;
}
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName));
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv);
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
/**
* 由云端运维触发切换埋点
* 内部空实现
*
* @param switchStatus 切换状态
*/
private void triggerSwitchMetric(boolean switchStatus) {
}
/**
* 切换到新环境
* 1. 先获取选中的环境
* 2. 生成工作目录
* 3. 验证工作目录
* 4. 触发切换操作
* 5. 触发可能存在异常的切换后动作
* 6. 触发切换后动作
*
* @param envName 新工作环境名称
* @return 是否成功
*/
private boolean doSwitch2Env(final String envName, PopTipStrategy strategy) {
DesignerWorkspaceInfo selectedEnv = getSelectedEnv(envName);
try {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace != null && selectedEnv.checkValid();
if (!checkValid) {
if (notValid(workspace, selectedEnv)) {
return false;
}
//如果是相同环境
if (isSameEnv(workspace)) {
//目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了
switch2SameEnv(envName);
} else {
//切换到新环境,做下封装
switch2OtherEnv(workspace, envName);
}
// REPORT-25688如果是war包部署的服务器,给与提示
if (WorkContext.getCurrent().isWarDeploy()) {
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE);
}
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(template)) {
template.refreshToolArea();
}
PluginErrorDesignReminder.getInstance().remindStartFailedPlugins();
doSwitchAction(envName, workspace);
afterSwitchWithEx();
} catch (Exception exception) {
// 失败的处理
WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv);
// 记录切换耗时
recordSwitchElapsed(performancePoint);
return false;
}
afterSwitch();
return true;
}
private DesignerWorkspaceInfo getSelectedEnv(String envName) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = customUserName(envManager.getWorkspaceInfo(envName));
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv);
return selectedEnv;
}
private static boolean notValid(Workspace workspace, DesignerWorkspaceInfo selectedEnv) throws Exception {
boolean checkValid = workspace != null && selectedEnv.checkValid();
return !checkValid;
}
private void doSwitchAction(String envName, Workspace workspace) {
//如果是相同环境
if (isSameEnv(workspace)) {
//目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了
switch2SameEnv(envName);
} else {
//切换到新环境,做下封装
switch2OtherEnv(workspace, envName);
}
}
private static void afterSwitchWithEx() {
// REPORT-25688如果是war包部署的服务器,给与提示
if (WorkContext.getCurrent().isWarDeploy()) {
FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE);
}
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(template)) {
template.refreshToolArea();
}
PluginErrorDesignReminder.getInstance().remindStartFailedPlugins();
}
private static void afterSwitch() {
TemplateTreePane.getInstance().refreshDockingView();
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter();
if (model != null) {
@ -182,9 +234,6 @@ public class EnvChangeEntrance {
NotificationCenter.getInstance().clearAllNotifications();
//切换环境后,清空粘贴板里面的内容
TemplateTreeClipboard.getInstance().reset();
// 记录切换耗时
recordSwitchElapsed(performancePoint);
return true;
}
private static void recordSwitchElapsed(PerformancePoint performancePoint) {

Loading…
Cancel
Save