Browse Source

Pull request #9749: REPORT-76068 【迭代】【起始页】埋点没记

Merge in DESIGN/design from ~HARRISON/design:feature/x to feature/x

* commit 'd3d23f7fd19723c562d7aee354f933bac029031d':
  REPORT-76068 【迭代】【起始页】埋点没记  1-恢复默认开启的状态  2-补充国际化  3-补充埋点
feature/x
Harrison 2 years ago
parent
commit
d435121afe
  1. 14
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 11
      designer-base/src/main/java/com/fr/design/utils/DesignerPort.java
  3. 2
      designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java
  4. 7
      designer-base/src/main/java/com/fr/start/common/DesignerStartupConfig.java
  5. 10
      designer-base/src/main/java/com/fr/start/common/DesignerStartupContext.java
  6. 22
      designer-base/src/main/java/com/fr/startup/metric/DesignerMetrics.java
  7. 193
      designer-base/src/main/java/com/fr/startup/metric/DesignerStartupModel.java
  8. 71
      designer-base/src/main/java/com/fr/startup/metric/DesignerStartupPageStatistic.java
  9. 24
      designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java

14
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -242,8 +242,8 @@ public class PreferencePane extends BasicPane {
createLanPane(generalPane); createLanPane(generalPane);
// 先屏蔽下 createStartupPagePane(generalPane);
// createStartupPagePane(generalPane);
createLengthPane(advancePane); createLengthPane(advancePane);
createServerPane(advancePane); createServerPane(advancePane);
@ -655,13 +655,13 @@ public class PreferencePane extends BasicPane {
// ben:选择版本语言; // ben:选择版本语言;
JPanel startupPagePaneWrapper = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane(); JPanel startupPagePaneWrapper = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane();
JPanel startupPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane("启动页配置"); JPanel startupPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Startup_Page_Config"));
generalPane.add(startupPagePaneWrapper); generalPane.add(startupPagePaneWrapper);
startupPagePaneWrapper.add(startupPane); startupPagePaneWrapper.add(startupPane);
startupPageEnabledCheckBox = new UICheckBox("启动设计器时,自动打开启动页"); startupPageEnabledCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Startup_Page_Config_Check_Text"));
startupPane.add(startupPageEnabledCheckBox); startupPane.add(startupPageEnabledCheckBox);
UILabel descLabel = new UILabel("注意:若在远程环境下直接关闭,再次启动时,启动速度会变慢"); UILabel descLabel = new UILabel(Toolkit.i18nText("Fine-Design_Startup_Page_Config_Desc"));
descLabel.setForeground(new Color(51, 51, 52, (int)Math.round(0.5 * 255))); descLabel.setForeground(new Color(51, 51, 52, (int)Math.round(0.5 * 255)));
startupPane.add(descLabel); startupPane.add(descLabel);
} }
@ -854,7 +854,7 @@ public class PreferencePane extends BasicPane {
previewResolutionBtnM.setEnabled(enabled); previewResolutionBtnM.setEnabled(enabled);
this.cloudAnalyticsDelayCheckBox.setSelected(designerEnvManager.isCloudAnalyticsDelay()); this.cloudAnalyticsDelayCheckBox.setSelected(designerEnvManager.isCloudAnalyticsDelay());
// this.startupPageEnabledCheckBox.setSelected(designerEnvManager.isStartupPageEnabled()); this.startupPageEnabledCheckBox.setSelected(designerEnvManager.isStartupPageEnabled());
} }
private int chooseCase(int sign) { private int chooseCase(int sign) {
@ -921,7 +921,7 @@ public class PreferencePane extends BasicPane {
vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected());
vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected()); vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected());
vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected()); vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected());
// designerEnvManager.setStartupPageEnabled(this.startupPageEnabledCheckBox.isSelected()); designerEnvManager.setStartupPageEnabled(this.startupPageEnabledCheckBox.isSelected());
Configurations.update(new Worker() { Configurations.update(new Worker() {
@Override @Override
public void run() { public void run() {

11
designer-base/src/main/java/com/fr/design/utils/DesignerPort.java

@ -4,7 +4,6 @@ import com.fr.common.report.ReportState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.dialog.TipDialog; import com.fr.design.dialog.TipDialog;
import com.fr.design.fun.DesignerPortProvider;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
@ -18,16 +17,20 @@ import com.fr.general.IOUtils;
import com.fr.process.engine.core.CarryMessageEvent; import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessContext;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;

2
designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java

@ -1,6 +1,7 @@
package com.fr.start.common; package com.fr.start.common;
import com.fr.base.svg.IconUtils; import com.fr.base.svg.IconUtils;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -55,6 +56,7 @@ public class DesignerOpenEmptyPanel extends JPanel {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
DesignerFrame df = DesignerContext.getDesignerFrame(); DesignerFrame df = DesignerContext.getDesignerFrame();
HistoryTemplateListCache.getInstance().setCurrentEditingTemplate(null);
df.addAndActivateJTemplate(); df.addAndActivateJTemplate();
// 如果没有模板,则需要确认一下 // 如果没有模板,则需要确认一下
MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());

7
designer-base/src/main/java/com/fr/start/common/DesignerStartupConfig.java

@ -20,7 +20,7 @@ public class DesignerStartupConfig implements XMLable {
/** /**
* 默认值是 false * 默认值是 false
*/ */
private boolean enabled = false; private boolean enabled = true;
public boolean isEnabled() { public boolean isEnabled() {
return enabled; return enabled;
@ -30,18 +30,17 @@ public class DesignerStartupConfig implements XMLable {
this.enabled = enabled; this.enabled = enabled;
} }
@Override @Override
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
DesignerStartupConfig config = new DesignerStartupConfig(); DesignerStartupConfig config = new DesignerStartupConfig();
config.setEnabled(true); config.setEnabled(enabled);
return config; return config;
} }
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isAttr()) { if (reader.isAttr()) {
this.setEnabled(reader.getAttrAsBoolean("isEnabled", false)); this.setEnabled(reader.getAttrAsBoolean("isEnabled", true));
} }
} }

10
designer-base/src/main/java/com/fr/start/common/DesignerStartupContext.java

@ -4,6 +4,7 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.start.module.StartupArgs; import com.fr.start.module.StartupArgs;
import com.fr.startup.metric.DesignerMetrics;
import com.fr.startup.ui.StartupPageModel; import com.fr.startup.ui.StartupPageModel;
import com.fr.third.guava.collect.Lists; import com.fr.third.guava.collect.Lists;
import com.fr.third.org.apache.commons.lang3.time.StopWatch; import com.fr.third.org.apache.commons.lang3.time.StopWatch;
@ -28,6 +29,11 @@ public class DesignerStartupContext {
*/ */
private StartupPageModel startupPageModel; private StartupPageModel startupPageModel;
/**
* 设计器启动埋点
*/
private final DesignerMetrics designerMetrics = new DesignerMetrics();
/** /**
* 是否在起始页打开的等待过程中 * 是否在起始页打开的等待过程中
*/ */
@ -75,6 +81,10 @@ public class DesignerStartupContext {
return STOP_WATCH; return STOP_WATCH;
} }
public DesignerMetrics getDesignerMetrics() {
return designerMetrics;
}
/* 启动模式 */ /* 启动模式 */
/** /**

22
designer-base/src/main/java/com/fr/startup/metric/DesignerMetrics.java

@ -0,0 +1,22 @@
package com.fr.startup.metric;
/**
* created by Harrison on 2022/08/12
**/
public class DesignerMetrics {
private DesignerStartupModel model = new DesignerStartupModel();
private DesignerStartupPageStatistic statistic = new DesignerStartupPageStatistic();
public DesignerMetrics() {
}
public DesignerStartupModel getModel() {
return model;
}
public DesignerStartupPageStatistic getStatistic() {
return statistic;
}
}

193
designer-base/src/main/java/com/fr/startup/metric/DesignerStartupModel.java

@ -0,0 +1,193 @@
package com.fr.startup.metric;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginManager;
import com.fr.stable.os.AbstractOperatingSystem;
import com.fr.stable.os.OperatingSystem;
import com.fr.start.common.DesignerStartupConfig;
import com.fr.workspace.WorkContext;
import java.lang.management.ManagementFactory;
import java.util.List;
import java.util.stream.Collectors;
/**
* 设计器启动数据
*
* created by Harrison on 2022/08/12
**/
public class DesignerStartupModel {
/**
* landingTime用户从双击图标/.bat启动等到出现起始页的时间
*/
private long landingTime;
/**
* startingTime用户从起始页进入设计器完全可用的时间
*/
private long startingTime;
/**
* info设计器环境的详细信息记录环境信息机器信息远程or本地插件信息
*/
private MachineInfo info;
/**
* mode模式0-有设计器起动页1-无设计器起始页
*/
private int mode;
public DesignerStartupModel() {
}
public DesignerStartupModel(long landingTime, long startingTime, MachineInfo info, int mode) {
this.landingTime = landingTime;
this.startingTime = startingTime;
this.info = info;
this.mode = mode;
}
public long getLandingTime() {
return landingTime;
}
public void setLandingTime(long landingTime) {
this.landingTime = landingTime;
}
public long getStartingTime() {
return startingTime;
}
public void setStartingTime(long startingTime) {
this.startingTime = startingTime;
}
public MachineInfo getInfo() {
return info;
}
public void setInfo(MachineInfo info) {
this.info = info;
}
public int getMode() {
return mode;
}
public void setMode(int mode) {
this.mode = mode;
}
private void fillInfo() {
MachineInfo info = new MachineInfo();
AbstractOperatingSystem operatingSystem = OperatingSystem.getOperatingSystem();
info.setSystem(operatingSystem.getDisplayString());
try {
final int byteToMb = 1024 * 1024;
com.sun.management.OperatingSystemMXBean operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
long free = operatingSystemMXBean.getFreePhysicalMemorySize() / byteToMb;
long total = operatingSystemMXBean.getTotalPhysicalMemorySize() / byteToMb;
long used = total - free;
JSONObject jo = new JSONObject();
jo.put("free", free);
jo.put("used", used);
jo.put("total", total);
info.setMachine(jo.toString());
} catch (Exception ignored) {
}
boolean local = WorkContext.getCurrent().isLocal();
info.setWork(local ? 1 : 0);
List<PluginContext> contexts = PluginManager.getContexts();
List<String> contextNames = contexts.stream()
.map(PluginContext::getName)
.collect(Collectors.toList());
JSONArray contextNameJa = new JSONArray(contextNames);
info.setPlugins(contextNameJa.toString());
this.setInfo(info);
}
private void fillMode() {
this.setMode(DesignerStartupConfig.getInstance().isEnabled() ? 0 : 1);
}
public void fill() {
fillInfo();
fillMode();
}
private static class MachineInfo {
/**
* 系统信息
*/
private String system;
/**
* 机器信息
*/
private String machine;
/**
* work0-远程1-本地
*/
private int work;
/**
* 插件列表
*/
private String plugins;
public MachineInfo() {
}
public MachineInfo(String system, String machine, int work, String plugins) {
this.system = system;
this.machine = machine;
this.work = work;
this.plugins = plugins;
}
public String getSystem() {
return system;
}
public void setSystem(String system) {
this.system = system;
}
public String getMachine() {
return machine;
}
public void setMachine(String machine) {
this.machine = machine;
}
public int getWork() {
return work;
}
public void setWork(int work) {
this.work = work;
}
public String getPlugins() {
return plugins;
}
public void setPlugins(String plugins) {
this.plugins = plugins;
}
}
}

71
designer-base/src/main/java/com/fr/startup/metric/DesignerStartupPageStatistic.java

@ -0,0 +1,71 @@
package com.fr.startup.metric;
/**
* 设计器启动页使用数据
*
* created by Harrison on 2022/08/12
**/
public class DesignerStartupPageStatistic {
/**
* operate0-双击工作目录进入 点击蓝色箭头进入1-切换其他工作目录2-点击展开全部3-点击工作目录中的模版直接打开 直接点击蓝色箭头进入
*/
private int operate;
/**
* workplace工作目录名称当operate为 0或1时记录
*/
private String workspace;
/**
* workplaceNumber工作目录的个数当operate为 0或1或2或3时记录
*/
private String workspaceNum;
/**
* template模板名称当operate为 3时记录
*/
private String template;
public DesignerStartupPageStatistic(int operate, String workspace, String workspaceNum, String template) {
this.operate = operate;
this.workspace = workspace;
this.workspaceNum = workspaceNum;
this.template = template;
}
public DesignerStartupPageStatistic() {
}
public int getOperate() {
return operate;
}
public void setOperate(int operate) {
this.operate = operate;
}
public String getWorkspace() {
return workspace;
}
public void setWorkspace(String workspace) {
this.workspace = workspace;
}
public String getWorkspaceNum() {
return workspaceNum;
}
public void setWorkspaceNum(String workspaceNum) {
this.workspaceNum = workspaceNum;
}
public String getTemplate() {
return template;
}
public void setTemplate(String template) {
this.template = template;
}
}

24
designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java

@ -9,6 +9,8 @@ import com.fr.start.common.DesignerStartupContext;
import com.fr.start.module.StartupArgs; import com.fr.start.module.StartupArgs;
import com.fr.start.util.DesignerStartupPageUtil; import com.fr.start.util.DesignerStartupPageUtil;
import com.fr.start.warmup.DesignerPreWarmTask; import com.fr.start.warmup.DesignerPreWarmTask;
import com.fr.startup.metric.DesignerMetrics;
import com.fr.startup.metric.DesignerStartupModel;
import com.fr.startup.ui.StartupPageModel; import com.fr.startup.ui.StartupPageModel;
import com.fr.startup.ui.StartupPageWindow; import com.fr.startup.ui.StartupPageWindow;
import com.fr.startup.ui.StartupWorkspaceBean; import com.fr.startup.ui.StartupWorkspaceBean;
@ -58,7 +60,7 @@ public class DesignerStartupPageActivator extends Activator {
warmTask.start(); warmTask.start();
// 即时暂停 // 即时暂停
DesignerStartupContext.getRecorder().suspend(); suspendRecorder(context);
UIUtil.invokeLaterIfNeeded(() -> { UIUtil.invokeLaterIfNeeded(() -> {
@ -89,9 +91,20 @@ public class DesignerStartupPageActivator extends Activator {
StartupPageWindow window = new StartupPageWindow(model); StartupPageWindow window = new StartupPageWindow(model);
window.setVisible(true); window.setVisible(true);
context.setOnWaiting(true); context.setOnWaiting(true);
}); });
} }
private void suspendRecorder(DesignerStartupContext context) {
DesignerMetrics designerMetrics = context.getDesignerMetrics();
DesignerStartupModel designerStartupModel = designerMetrics.getModel();
StopWatch recorder = DesignerStartupContext.getRecorder();
recorder.suspend();
long time = recorder.getTime(TimeUnit.MILLISECONDS);
designerStartupModel.setLandingTime(time);
}
private void handleModel(StartupPageModel model) { private void handleModel(StartupPageModel model) {
// 将选中的环境设置为当前环境 // 将选中的环境设置为当前环境
@ -118,12 +131,21 @@ public class DesignerStartupPageActivator extends Activator {
UIUtil.invokeLaterIfNeeded(() -> { UIUtil.invokeLaterIfNeeded(() -> {
// 换到 awt 线程中关闭,不然异步会出现问题。 // 换到 awt 线程中关闭,不然异步会出现问题。
DesignerStartupContext.getInstance().setOnStartup(false); DesignerStartupContext.getInstance().setOnStartup(false);
recordStartupEnd(stopWatch);
}); });
} }
FineLoggerFactory.getLogger().debug("designer-startup-page started cost {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS)); FineLoggerFactory.getLogger().debug("designer-startup-page started cost {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS));
} }
private void recordStartupEnd(StopWatch stopWatch) {
DesignerMetrics designerMetrics = DesignerStartupContext.getInstance().getDesignerMetrics();
DesignerStartupModel model = designerMetrics.getModel();
model.setStartingTime(stopWatch.getTime(TimeUnit.MILLISECONDS));
model.fill();
}
@Override @Override
public void stop() { public void stop() {

Loading…
Cancel
Save