mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Do not send statistics and persist usage information at the same time
This commit is contained in:
+21
-18
@@ -1,6 +1,7 @@
|
||||
package com.intellij.internal.statistic.connect;
|
||||
|
||||
import com.intellij.internal.statistic.StatisticsUploadAssistant;
|
||||
import com.intellij.internal.statistic.persistence.ApplicationStatisticsPersistenceComponent;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
@@ -28,30 +29,32 @@ public class RemotelyConfigurableStatisticsService implements StatisticsService
|
||||
|
||||
@Override
|
||||
public StatisticsResult send() {
|
||||
final String serviceUrl = myConnectionService.getServiceUrl();
|
||||
synchronized (ApplicationStatisticsPersistenceComponent.class) {
|
||||
final String serviceUrl = myConnectionService.getServiceUrl();
|
||||
|
||||
if (serviceUrl == null) {
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.ERROR_IN_CONFIG, "ERROR");
|
||||
}
|
||||
if (serviceUrl == null) {
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.ERROR_IN_CONFIG, "ERROR");
|
||||
}
|
||||
|
||||
if (!myConnectionService.isTransmissionPermitted()) {
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.NOT_PERMITTED_SERVER, "NOT_PERMITTED");
|
||||
}
|
||||
if (!myConnectionService.isTransmissionPermitted()) {
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.NOT_PERMITTED_SERVER, "NOT_PERMITTED");
|
||||
}
|
||||
|
||||
String content = myAssistant.getData(myConnectionService.getDisabledGroups());
|
||||
String content = myAssistant.getData(myConnectionService.getDisabledGroups());
|
||||
|
||||
if (StringUtil.isEmptyOrSpaces(content)) {
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.NOTHING_TO_SEND, "NOTHING_TO_SEND");
|
||||
}
|
||||
if (StringUtil.isEmptyOrSpaces(content)) {
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.NOTHING_TO_SEND, "NOTHING_TO_SEND");
|
||||
}
|
||||
|
||||
try {
|
||||
sender.send(serviceUrl, content);
|
||||
StatisticsUploadAssistant.updateSentTime();
|
||||
try {
|
||||
sender.send(serviceUrl, content);
|
||||
StatisticsUploadAssistant.updateSentTime();
|
||||
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.SEND, content);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.SENT_WITH_ERRORS, e.getMessage() != null ? e.getMessage() : "NPE");
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.SEND, content);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return new StatisticsResult(StatisticsResult.ResultCode.SENT_WITH_ERRORS, e.getMessage() != null ? e.getMessage() : "NPE");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-9
@@ -173,9 +173,7 @@ public class ApplicationStatisticsPersistenceComponent extends ApplicationStatis
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
@Override
|
||||
public void appClosing() {
|
||||
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
doPersistProjectUsages(project);
|
||||
}
|
||||
persistOpenedProjects();
|
||||
persistOnClosing = false;
|
||||
}
|
||||
});
|
||||
@@ -190,14 +188,22 @@ public class ApplicationStatisticsPersistenceComponent extends ApplicationStatis
|
||||
});
|
||||
}
|
||||
|
||||
private static void doPersistProjectUsages(@NotNull Project project) {
|
||||
if (!project.isInitialized() || DumbService.isDumb(project)) {
|
||||
return;
|
||||
private static void persistOpenedProjects() {
|
||||
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
doPersistProjectUsages(project);
|
||||
}
|
||||
}
|
||||
|
||||
for (UsagesCollector usagesCollector : Extensions.getExtensions(UsagesCollector.EP_NAME)) {
|
||||
if (usagesCollector instanceof AbstractApplicationUsagesCollector) {
|
||||
((AbstractApplicationUsagesCollector)usagesCollector).persistProjectUsages(project);
|
||||
private static void doPersistProjectUsages(@NotNull Project project) {
|
||||
synchronized (ApplicationStatisticsPersistenceComponent.class) {
|
||||
if (!project.isInitialized() || DumbService.isDumb(project)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (UsagesCollector usagesCollector : Extensions.getExtensions(UsagesCollector.EP_NAME)) {
|
||||
if (usagesCollector instanceof AbstractApplicationUsagesCollector) {
|
||||
((AbstractApplicationUsagesCollector)usagesCollector).persistProjectUsages(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user