From 0a1ee59161fa4d7e75120c8e48eb3ccb1de3e74a Mon Sep 17 00:00:00 2001 From: "Svetlana.Zemlyanskaya" Date: Wed, 8 Jan 2020 19:54:15 +0100 Subject: [PATCH] FUS: extract sending log into separate module (for IDEA-228935) GitOrigin-RevId: 5152b1206f527ef784f6b13a1fcd95a5f2ce95c4 --- .idea/modules.xml | 1 + .../build/impl/DistributionJARsBuilder.groovy | 1 + .../logger/FeatureUsageEventLoggerTest.kt | 2 +- .../statistic/actions/SendEventLogAction.java | 22 +++- .../TestParseEventLogWhitelistDialog.java | 8 +- .../intellij.platform.statistics.iml | 1 + .../intellij.platform.statistics.sender.iml | 25 +++++ .../connect/SettingsConnectionService.java | 2 +- .../connect/StatServiceException.java | 0 .../statistic/connect/StatisticsResult.java | 0 .../statistic/connect/StatisticsService.java | 0 .../eventLog/DeviceConfiguration.java | 22 ++++ .../eventLog/EventLogApplication.java | 10 ++ .../statistic/eventLog/EventLogBuildType.kt | 0 .../statistic/eventLog/EventLogFile.kt | 0 .../eventLog/EventLogFilesProvider.kt | 26 +++++ .../eventLog/EventLogResultDecorator.java | 0 .../eventLog/EventLogSettingsService.java | 0 .../eventLog/EventLogStatisticsService.java | 39 ++++--- .../EventLogUploadSettingsService.java | 89 +++++++++++++++ .../statistic/eventLog/LogEventFilter.kt | 2 +- .../eventLog/LogEventRecordRequest.kt | 4 +- .../statistic/eventLog/LogEventSerializer.kt | 2 +- .../internal/statistic/eventLog/LogEvents.kt | 0 .../eventLog/StatisticsEventEscaper.java | 0 .../statistic/service/fus/FUSWhitelist.java | 0 .../FUStatisticsWhiteListGroupsService.java | 10 +- .../eventLog/EventLogApplicationImpl.java | 28 +++++ .../EventLogExternalSettingsService.java | 105 ++---------------- .../eventLog/EventLogNotificationProxy.kt | 2 +- .../eventLog/EventLogRecorderConfigImpl.java | 29 +++++ .../eventLog/StatisticsEventLogWriter.kt | 8 +- .../eventLog/StatisticsEventLogger.kt | 12 +- .../eventLog/StatisticsFileEventLogger.kt | 4 +- .../EventLogWhitelistPersistence.java | 7 +- .../utils/StatisticsUploadAssistant.java | 14 ++- 36 files changed, 327 insertions(+), 148 deletions(-) create mode 100644 platform/statistics/sender/intellij.platform.statistics.sender.iml rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/connect/SettingsConnectionService.java (97%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/connect/StatServiceException.java (100%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/connect/StatisticsResult.java (100%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/connect/StatisticsService.java (100%) create mode 100644 platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/DeviceConfiguration.java create mode 100644 platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogApplication.java rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/EventLogBuildType.kt (100%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/EventLogFile.kt (100%) create mode 100644 platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogFilesProvider.kt rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/EventLogResultDecorator.java (100%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/EventLogSettingsService.java (100%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java (80%) create mode 100644 platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogUploadSettingsService.java rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/LogEventFilter.kt (94%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/LogEventRecordRequest.kt (95%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/LogEventSerializer.kt (99%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/LogEvents.kt (100%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/eventLog/StatisticsEventEscaper.java (100%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/service/fus/FUSWhitelist.java (100%) rename platform/statistics/{ => sender}/src/com/intellij/internal/statistic/service/fus/FUStatisticsWhiteListGroupsService.java (94%) create mode 100644 platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogApplicationImpl.java create mode 100644 platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogRecorderConfigImpl.java diff --git a/.idea/modules.xml b/.idea/modules.xml index 5d11a3e8b3f0..1112fc001876 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -662,6 +662,7 @@ + diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy index 80fb3230318a..56bd071d6d8d 100644 --- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy +++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy @@ -144,6 +144,7 @@ class DistributionJARsBuilder { withModule("intellij.spellchecker") withModule("intellij.platform.images") withModule("intellij.platform.statistics") + withModule("intellij.platform.statistics.sender") withModule("intellij.platform.statistics.devkit") withModule("intellij.relaxng", "intellij-xml.jar") diff --git a/platform/platform-tests/testSrc/com/intellij/internal/statistics/logger/FeatureUsageEventLoggerTest.kt b/platform/platform-tests/testSrc/com/intellij/internal/statistics/logger/FeatureUsageEventLoggerTest.kt index 16912b28b650..04556d34d437 100644 --- a/platform/platform-tests/testSrc/com/intellij/internal/statistics/logger/FeatureUsageEventLoggerTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/internal/statistics/logger/FeatureUsageEventLoggerTest.kt @@ -328,7 +328,7 @@ class TestFeatureUsageEventWriter : StatisticsEventLogWriter { } override fun getActiveFile(): EventLogFile? = null - override fun getFiles(): List = emptyList() + override fun getLogFilesProvider(): EventLogFilesProvider = EmptyEventLogFilesProvider override fun cleanup() = Unit override fun rollOver() = Unit } \ No newline at end of file diff --git a/platform/statistics/devkit/src/com/intellij/internal/statistic/actions/SendEventLogAction.java b/platform/statistics/devkit/src/com/intellij/internal/statistic/actions/SendEventLogAction.java index 366eea81479f..f8052799f536 100644 --- a/platform/statistics/devkit/src/com/intellij/internal/statistic/actions/SendEventLogAction.java +++ b/platform/statistics/devkit/src/com/intellij/internal/statistic/actions/SendEventLogAction.java @@ -33,7 +33,6 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; -import static com.intellij.internal.statistic.eventLog.EventLogStatisticsService.send; import static com.intellij.openapi.command.WriteCommandAction.writeCommandAction; public class SendEventLogAction extends AnAction { @@ -49,7 +48,7 @@ public class SendEventLogAction extends AnAction { ProgressManager.getInstance().run(new Task.Backgroundable(project, "Send Feature Usage Event Log", false) { @Override public void run(@NotNull ProgressIndicator indicator) { - final StatisticsResult result = send(FUS_RECORDER, new EventLogTestSettingsService(), new EventLogTestResultDecorator()); + final StatisticsResult result = send(); final StatisticsResult.ResultCode code = result.getCode(); if (code == StatisticsResult.ResultCode.SENT_WITH_ERRORS || code == StatisticsResult.ResultCode.SEND) { final boolean succeed = tryToOpenInScratch(project, result.getDescription()); @@ -63,12 +62,21 @@ public class SendEventLogAction extends AnAction { StringUtil.replace(result.getDescription(), ";", "\n"), null, null), ModalityState.NON_MODAL, project.getDisposed()); } + + private StatisticsResult send() { + return EventLogStatisticsService.send( + new DeviceConfiguration(EventLogConfiguration.INSTANCE.getDeviceId(), EventLogConfiguration.INSTANCE.getBucket()), + new EventLogRecorderConfigImpl(FUS_RECORDER), + new EventLogTestSettingsService(), + new EventLogTestResultDecorator() + ); + } }); } - private static class EventLogTestSettingsService extends EventLogExternalSettingsService implements EventLogSettingsService { + private static class EventLogTestSettingsService extends EventLogUploadSettingsService implements EventLogSettingsService { private EventLogTestSettingsService() { - super(FUS_RECORDER, true); + super(FUS_RECORDER, new EventLogTestApplication()); } @Override @@ -82,6 +90,12 @@ public class SendEventLogAction extends AnAction { final FUSWhitelist whitelist = getWhitelistedGroups(); return new LogEventWhitelistFilter(whitelist != null ? whitelist : FUSWhitelist.empty()); } + } + + private static class EventLogTestApplication extends EventLogApplicationImpl { + private EventLogTestApplication() { + super(true); + } @Override public boolean isInternal() { diff --git a/platform/statistics/devkit/src/com/intellij/internal/statistic/actions/TestParseEventLogWhitelistDialog.java b/platform/statistics/devkit/src/com/intellij/internal/statistic/actions/TestParseEventLogWhitelistDialog.java index 9f115124f83c..8ef638a751b2 100644 --- a/platform/statistics/devkit/src/com/intellij/internal/statistic/actions/TestParseEventLogWhitelistDialog.java +++ b/platform/statistics/devkit/src/com/intellij/internal/statistic/actions/TestParseEventLogWhitelistDialog.java @@ -3,10 +3,7 @@ package com.intellij.internal.statistic.actions; import com.intellij.ide.scratch.RootType; import com.intellij.ide.scratch.ScratchFileService; -import com.intellij.internal.statistic.eventLog.LogEventFilter; -import com.intellij.internal.statistic.eventLog.LogEventRecordRequest; -import com.intellij.internal.statistic.eventLog.LogEventSerializer; -import com.intellij.internal.statistic.eventLog.LogEventWhitelistFilter; +import com.intellij.internal.statistic.eventLog.*; import com.intellij.internal.statistic.service.fus.FUSWhitelist; import com.intellij.internal.statistic.service.fus.FUStatisticsWhiteListGroupsService; import com.intellij.lang.Language; @@ -212,7 +209,8 @@ public class TestParseEventLogWhitelistDialog extends DialogWrapper { final File log = FileUtil.createTempFile("feature-event-log", ".log"); try { FileUtil.writeToFile(log, text); - final LogEventRecordRequest request = LogEventRecordRequest.Companion.create(log, "FUS", filter, true); + final String deviceId = EventLogConfiguration.INSTANCE.getDeviceId(); + final LogEventRecordRequest request = LogEventRecordRequest.Companion.create(log, "FUS", deviceId, filter, true); if (request == null) { throw new ParseEventLogWhitelistException("Failed parsing event log"); } diff --git a/platform/statistics/intellij.platform.statistics.iml b/platform/statistics/intellij.platform.statistics.iml index ccf038c971f2..e8e0a355e00f 100644 --- a/platform/statistics/intellij.platform.statistics.iml +++ b/platform/statistics/intellij.platform.statistics.iml @@ -15,5 +15,6 @@ + \ No newline at end of file diff --git a/platform/statistics/sender/intellij.platform.statistics.sender.iml b/platform/statistics/sender/intellij.platform.statistics.sender.iml new file mode 100644 index 000000000000..408bf16eb12e --- /dev/null +++ b/platform/statistics/sender/intellij.platform.statistics.sender.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/platform/statistics/src/com/intellij/internal/statistic/connect/SettingsConnectionService.java b/platform/statistics/sender/src/com/intellij/internal/statistic/connect/SettingsConnectionService.java similarity index 97% rename from platform/statistics/src/com/intellij/internal/statistic/connect/SettingsConnectionService.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/connect/SettingsConnectionService.java index 61000af363d1..b8ed355dfe0d 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/connect/SettingsConnectionService.java +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/connect/SettingsConnectionService.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.statistic.connect; import com.intellij.openapi.diagnostic.Logger; diff --git a/platform/statistics/src/com/intellij/internal/statistic/connect/StatServiceException.java b/platform/statistics/sender/src/com/intellij/internal/statistic/connect/StatServiceException.java similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/connect/StatServiceException.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/connect/StatServiceException.java diff --git a/platform/statistics/src/com/intellij/internal/statistic/connect/StatisticsResult.java b/platform/statistics/sender/src/com/intellij/internal/statistic/connect/StatisticsResult.java similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/connect/StatisticsResult.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/connect/StatisticsResult.java diff --git a/platform/statistics/src/com/intellij/internal/statistic/connect/StatisticsService.java b/platform/statistics/sender/src/com/intellij/internal/statistic/connect/StatisticsService.java similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/connect/StatisticsService.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/connect/StatisticsService.java diff --git a/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/DeviceConfiguration.java b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/DeviceConfiguration.java new file mode 100644 index 000000000000..eb96dd8cb4eb --- /dev/null +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/DeviceConfiguration.java @@ -0,0 +1,22 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.internal.statistic.eventLog; + +import org.jetbrains.annotations.NotNull; + +public class DeviceConfiguration { + private String myDeviceId; + private int myBucket; + + public DeviceConfiguration(@NotNull String deviceId, int bucket) { + myDeviceId = deviceId; + myBucket = bucket; + } + + public String getDeviceId() { + return myDeviceId; + } + + public int getBucket() { + return myBucket; + } +} diff --git a/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogApplication.java b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogApplication.java new file mode 100644 index 000000000000..9765e338c0b4 --- /dev/null +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogApplication.java @@ -0,0 +1,10 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.internal.statistic.eventLog; + +public interface EventLogApplication { + String getTemplateUrl(); + + boolean isInternal(); + + boolean isTest(); +} diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogBuildType.kt b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogBuildType.kt similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogBuildType.kt rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogBuildType.kt diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogFile.kt b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogFile.kt similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogFile.kt rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogFile.kt diff --git a/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogFilesProvider.kt b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogFilesProvider.kt new file mode 100644 index 000000000000..5aa6c811fa4f --- /dev/null +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogFilesProvider.kt @@ -0,0 +1,26 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.internal.statistic.eventLog + +import com.intellij.openapi.util.text.StringUtil +import java.io.File +import java.nio.file.Path + +interface EventLogRecorderConfig { + fun getRecorderId(): String + + fun isSendEnabled(): Boolean + + fun getLogFilesProvider(): EventLogFilesProvider +} + +interface EventLogFilesProvider { + fun getLogFiles(): List +} + +class DefaultEventLogFilesProvider(val dir: Path, private val activeFileProvider: () -> String?): EventLogFilesProvider { + override fun getLogFiles(): List { + val activeFile = activeFileProvider() + val files = File(dir.toUri()).listFiles { f: File -> activeFile == null || !StringUtil.equals(f.name, activeFile) } + return files?.map { EventLogFile(it) }?.toList() ?: emptyList() + } +} \ No newline at end of file diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogResultDecorator.java b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogResultDecorator.java similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogResultDecorator.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogResultDecorator.java diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogSettingsService.java b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogSettingsService.java similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogSettingsService.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogSettingsService.java diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java similarity index 80% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java index 34cbbf917094..e7aa1beb5c1b 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java @@ -1,4 +1,4 @@ -// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.statistic.eventLog; import com.intellij.internal.statistic.connect.StatServiceException; @@ -27,22 +27,27 @@ public class EventLogStatisticsService implements StatisticsService { private static final int MAX_FILES_TO_SEND = 5; - private final String myRecorder; + private final DeviceConfiguration myDeviceConfiguration; private final EventLogSettingsService mySettingsService; + private final EventLogRecorderConfig myRecorderConfiguration; - public EventLogStatisticsService(@NotNull String recorder) { - myRecorder = recorder; - mySettingsService = new EventLogExternalSettingsService(recorder); + public EventLogStatisticsService(@NotNull DeviceConfiguration device, + @NotNull EventLogRecorderConfig config, + @NotNull EventLogApplication application) { + myDeviceConfiguration = device; + myRecorderConfiguration = config; + mySettingsService = new EventLogUploadSettingsService(config.getRecorderId(), application); } @Override public StatisticsResult send() { - return send(myRecorder, mySettingsService, new EventLogCounterResultDecorator()); + return send(myDeviceConfiguration, myRecorderConfiguration, mySettingsService, new EventLogCounterResultDecorator()); } - public static StatisticsResult send(@NotNull String recorder, @NotNull EventLogSettingsService settings, @NotNull EventLogResultDecorator decorator) { - final StatisticsEventLoggerProvider config = StatisticsEventLoggerKt.getEventLogProvider(recorder); - + public static StatisticsResult send(@NotNull DeviceConfiguration device, + @NotNull EventLogRecorderConfig config, + @NotNull EventLogSettingsService settings, + @NotNull EventLogResultDecorator decorator) { final List logs = getLogFiles(config); if (!config.isSendEnabled()) { cleanupEventLogFiles(logs); @@ -58,7 +63,7 @@ public class EventLogStatisticsService implements StatisticsService { return new StatisticsResult(StatisticsResult.ResultCode.ERROR_IN_CONFIG, "ERROR: unknown Statistics Service URL."); } - if (!isSendLogsEnabled(settings.getPermittedTraffic())) { + if (!isSendLogsEnabled(device, settings.getPermittedTraffic())) { cleanupEventLogFiles(logs); return new StatisticsResult(StatisticsResult.ResultCode.NOT_PERMITTED_SERVER, "NOT_PERMITTED"); } @@ -70,7 +75,8 @@ public class EventLogStatisticsService implements StatisticsService { int size = Math.min(MAX_FILES_TO_SEND, logs.size()); for (int i = 0; i < size; i++) { final File file = logs.get(i).getFile(); - final LogEventRecordRequest recordRequest = LogEventRecordRequest.Companion.create(file, config.getRecorderId(), filter, settings.isInternal()); + final String deviceId = device.getDeviceId(); + final LogEventRecordRequest recordRequest = LogEventRecordRequest.Companion.create(file, config.getRecorderId(), deviceId, filter, settings.isInternal()); final String error = validate(recordRequest, file); if (StringUtil.isNotEmpty(error) || recordRequest == null) { if (LOG.isTraceEnabled()) { @@ -121,7 +127,8 @@ public class EventLogStatisticsService implements StatisticsService { } cleanupFiles(toRemove); - EventLogSystemLogger.logFilesSend(config.getRecorderId(), logs.size(), size, failed); + //TODO: add listeners + //EventLogSystemLogger.logFilesSend(config.getRecorderId(), logs.size(), size, failed); return decorator.toResult(); } catch (Exception e) { @@ -140,11 +147,11 @@ public class EventLogStatisticsService implements StatisticsService { } } - private static boolean isSendLogsEnabled(int percent) { + private static boolean isSendLogsEnabled(@NotNull DeviceConfiguration userData, int percent) { if (percent == 0) { return false; } - return EventLogConfiguration.INSTANCE.getBucket() < percent * 2.56; + return userData.getBucket() < percent * 2.56; } @Nullable @@ -175,9 +182,9 @@ public class EventLogStatisticsService implements StatisticsService { } @NotNull - protected static List getLogFiles(StatisticsEventLoggerProvider config) { + protected static List getLogFiles(@NotNull EventLogRecorderConfig provider) { try { - return config.getLogFiles(); + return provider.getLogFilesProvider().getLogFiles(); } catch (Exception e) { LOG.info(e); diff --git a/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogUploadSettingsService.java b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogUploadSettingsService.java new file mode 100644 index 000000000000..7283f217e2d6 --- /dev/null +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/EventLogUploadSettingsService.java @@ -0,0 +1,89 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.internal.statistic.eventLog; + +import com.intellij.internal.statistic.connect.SettingsConnectionService; +import com.intellij.internal.statistic.service.fus.FUSWhitelist; +import com.intellij.internal.statistic.service.fus.FUStatisticsWhiteListGroupsService; +import com.intellij.openapi.application.ApplicationInfo; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.util.ArrayUtil; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import static com.intellij.util.ObjectUtils.notNull; + +public class EventLogUploadSettingsService extends SettingsConnectionService implements EventLogSettingsService { + private static final Logger LOG = Logger.getInstance(EventLogUploadSettingsService.class); + + private static final String APPROVED_GROUPS_SERVICE = "white-list-service"; + private static final String DICTIONARY_SERVICE = "dictionary-service"; + private static final String PERCENT_TRAFFIC = "percent-traffic"; + + private boolean myInternal; + + public EventLogUploadSettingsService(@NotNull String recorderId, @NotNull EventLogApplication application) { + super(getConfigUrl(recorderId, application.getTemplateUrl(), application.isTest()), null); + myInternal = application.isInternal(); + } + + @NotNull + private static String getConfigUrl(@NotNull String recorderId, @NotNull String templateUrl, boolean isTest) { + if (isTest) { + return String.format(templateUrl, "test/" + recorderId); + } + return String.format(templateUrl, recorderId); + } + + @Override + public String @NotNull [] getAttributeNames() { + return ArrayUtil.mergeArrays(super.getAttributeNames(), PERCENT_TRAFFIC, APPROVED_GROUPS_SERVICE, DICTIONARY_SERVICE); + } + + @Override + public int getPermittedTraffic() { + final String permitted = getSettingValue(PERCENT_TRAFFIC); + if (permitted != null) { + try { + return Integer.parseInt(permitted); + } + catch (NumberFormatException e) { + LOG.trace("Permitted traffic is not defined or has invalid format: '" + permitted + "'"); + } + } + return 0; + } + + @Override + @Nullable + public String getDictionaryServiceUrl() { + return getSettingValue(DICTIONARY_SERVICE); + } + + @Override + @NotNull + public LogEventFilter getEventFilter() { + final FUSWhitelist whitelist = notNull(getWhitelistedGroups(), FUSWhitelist.empty()); + return new LogEventCompositeFilter(new LogEventWhitelistFilter(whitelist), LogEventSnapshotBuildFilter.INSTANCE); + } + + @Override + public boolean isInternal() { + return myInternal; + } + + @Nullable + protected FUSWhitelist getWhitelistedGroups() { + final String productUrl = getWhiteListProductUrl(); + if (productUrl == null) return null; + return FUStatisticsWhiteListGroupsService.getApprovedGroups(productUrl); + } + + @NonNls + @Nullable + public String getWhiteListProductUrl() { + final String approvedGroupsServiceUrl = getSettingValue(APPROVED_GROUPS_SERVICE); + if (approvedGroupsServiceUrl == null) return null; + return approvedGroupsServiceUrl + ApplicationInfo.getInstance().getBuild().getProductCode() + ".json"; + } +} diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEventFilter.kt b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEventFilter.kt similarity index 94% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEventFilter.kt rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEventFilter.kt index 7050fe7986aa..1fde45a5f1d8 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEventFilter.kt +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEventFilter.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.statistic.eventLog import com.intellij.internal.statistic.service.fus.FUSWhitelist diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEventRecordRequest.kt b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEventRecordRequest.kt similarity index 95% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEventRecordRequest.kt rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEventRecordRequest.kt index 581488c74f2b..0c75da6c7534 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEventRecordRequest.kt +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEventRecordRequest.kt @@ -16,9 +16,9 @@ class LogEventRecordRequest(val recorder: String, val product : String, val devi private const val RECORD_SIZE = 1000 * 1000 // 1000KB private val LOG = Logger.getInstance(LogEventRecordRequest::class.java) - fun create(file: File, recorder: String, filter: LogEventFilter, internal: Boolean): LogEventRecordRequest? { + fun create(file: File, recorder: String, deviceId: String, filter: LogEventFilter, internal: Boolean): LogEventRecordRequest? { try { - return create(file, recorder, ApplicationInfo.getInstance().build.productCode, EventLogConfiguration.deviceId, RECORD_SIZE, filter, internal) + return create(file, recorder, ApplicationInfo.getInstance().build.productCode, deviceId, RECORD_SIZE, filter, internal) } catch (e: Exception) { LOG.warn("Failed reading event log file", e) diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEventSerializer.kt b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEventSerializer.kt similarity index 99% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEventSerializer.kt rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEventSerializer.kt index 81346881ae37..55d6a9dfec5d 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEventSerializer.kt +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEventSerializer.kt @@ -3,8 +3,8 @@ */ package com.intellij.internal.statistic.eventLog -import com.google.common.reflect.TypeToken import com.google.gson.* +import com.google.gson.reflect.TypeToken import com.intellij.openapi.diagnostic.Logger import java.io.OutputStreamWriter import java.lang.reflect.Type diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEvents.kt b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEvents.kt similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/LogEvents.kt rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/LogEvents.kt diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventEscaper.java b/platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/StatisticsEventEscaper.java similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventEscaper.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/eventLog/StatisticsEventEscaper.java diff --git a/platform/statistics/src/com/intellij/internal/statistic/service/fus/FUSWhitelist.java b/platform/statistics/sender/src/com/intellij/internal/statistic/service/fus/FUSWhitelist.java similarity index 100% rename from platform/statistics/src/com/intellij/internal/statistic/service/fus/FUSWhitelist.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/service/fus/FUSWhitelist.java diff --git a/platform/statistics/src/com/intellij/internal/statistic/service/fus/FUStatisticsWhiteListGroupsService.java b/platform/statistics/sender/src/com/intellij/internal/statistic/service/fus/FUStatisticsWhiteListGroupsService.java similarity index 94% rename from platform/statistics/src/com/intellij/internal/statistic/service/fus/FUStatisticsWhiteListGroupsService.java rename to platform/statistics/sender/src/com/intellij/internal/statistic/service/fus/FUStatisticsWhiteListGroupsService.java index d141918743db..3ae9d2970352 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/service/fus/FUStatisticsWhiteListGroupsService.java +++ b/platform/statistics/sender/src/com/intellij/internal/statistic/service/fus/FUStatisticsWhiteListGroupsService.java @@ -1,9 +1,8 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.statistic.service.fus; -import com.google.common.annotations.VisibleForTesting; import com.google.gson.GsonBuilder; -import com.intellij.internal.statistic.eventLog.EventLogExternalSettingsService; +import com.intellij.internal.statistic.eventLog.EventLogUploadSettingsService; import com.intellij.internal.statistic.service.fus.FUSWhitelist.BuildRange; import com.intellij.internal.statistic.service.fus.FUSWhitelist.GroupFilterCondition; import com.intellij.internal.statistic.service.fus.FUSWhitelist.VersionRange; @@ -54,11 +53,11 @@ public class FUStatisticsWhiteListGroupsService { } @Nullable - public static String loadWhiteListFromServer(@NotNull EventLogExternalSettingsService settingsService) { + public static String loadWhiteListFromServer(@NotNull EventLogUploadSettingsService settingsService) { return getFUSWhiteListContent(settingsService.getWhiteListProductUrl()); } - public static long lastModifiedWhitelist(@NotNull EventLogExternalSettingsService settingsService) { + public static long lastModifiedWhitelist(@NotNull EventLogUploadSettingsService settingsService) { return lastModifiedWhitelist(settingsService.getWhiteListProductUrl()); } @@ -105,7 +104,6 @@ public class FUStatisticsWhiteListGroupsService { return groups; } - @VisibleForTesting @NotNull public static FUSWhitelist parseApprovedGroups(@Nullable String content) { final WLGroups groups = parseWhiteListContent(content); diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogApplicationImpl.java b/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogApplicationImpl.java new file mode 100644 index 000000000000..6d5a266969b5 --- /dev/null +++ b/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogApplicationImpl.java @@ -0,0 +1,28 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.internal.statistic.eventLog; + +import com.intellij.internal.statistic.utils.StatisticsUploadAssistant; +import com.intellij.openapi.application.impl.ApplicationInfoImpl; + +public class EventLogApplicationImpl implements EventLogApplication { + private boolean myIsTest; + + public EventLogApplicationImpl(boolean isTest) { + myIsTest = isTest; + } + + @Override + public String getTemplateUrl() { + return ((ApplicationInfoImpl)ApplicationInfoImpl.getShadowInstance()).getEventLogSettingsUrl(); + } + + @Override + public boolean isInternal() { + return StatisticsUploadAssistant.isTestStatisticsEnabled(); + } + + @Override + public boolean isTest() { + return myIsTest; + } +} diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogExternalSettingsService.java b/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogExternalSettingsService.java index a6cf7846ece2..fe8ec633cd97 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogExternalSettingsService.java +++ b/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogExternalSettingsService.java @@ -1,26 +1,18 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.statistic.eventLog; -import com.intellij.internal.statistic.connect.SettingsConnectionService; -import com.intellij.internal.statistic.service.fus.FUSWhitelist; -import com.intellij.internal.statistic.service.fus.FUStatisticsWhiteListGroupsService; -import com.intellij.internal.statistic.utils.StatisticsUploadAssistant; -import com.intellij.openapi.application.ApplicationInfo; -import com.intellij.openapi.application.impl.ApplicationInfoImpl; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.BuildNumber; -import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import static com.intellij.util.ObjectUtils.notNull; - -public class EventLogExternalSettingsService extends SettingsConnectionService implements EventLogSettingsService { - private static final Logger LOG = Logger.getInstance(EventLogExternalSettingsService.class); - - private static final String APPROVED_GROUPS_SERVICE = "white-list-service"; - private static final String DICTIONARY_SERVICE = "dictionary-service"; - private static final String PERCENT_TRAFFIC = "percent-traffic"; +/** + * This class is a wrapper around {@link EventLogUploadSettingsService} it isn't deleted yet for backward compatibility. + * + * @deprecated Use {@link EventLogUploadSettingsService} directly. + */ +@Deprecated +public class EventLogExternalSettingsService extends EventLogUploadSettingsService { + public EventLogExternalSettingsService(@NotNull String recorderId) { + super(recorderId, new EventLogApplicationImpl(false)); + } /** * @deprecated Use {@link EventLogExternalSettingsService#getFeatureUsageSettings()} or create new instance with custom recorder id. @@ -34,77 +26,4 @@ public class EventLogExternalSettingsService extends SettingsConnectionService i public static EventLogExternalSettingsService getFeatureUsageSettings() { return new EventLogExternalSettingsService("FUS"); } - - public EventLogExternalSettingsService(@NotNull String recorderId) { - super(getConfigUrl(recorderId, false), null); - } - - public EventLogExternalSettingsService(@NotNull String recorderId, boolean isTest) { - super(getConfigUrl(recorderId, isTest), null); - } - - @NotNull - private static String getConfigUrl(@NotNull String recorderId, boolean isTest) { - final String templateUrl = ((ApplicationInfoImpl)ApplicationInfoImpl.getShadowInstance()).getEventLogSettingsUrl(); - if (isTest) { - return String.format(templateUrl, "test/" + recorderId); - } - return String.format(templateUrl, recorderId); - } - - @Override - public String @NotNull [] getAttributeNames() { - return ArrayUtil.mergeArrays(super.getAttributeNames(), PERCENT_TRAFFIC, APPROVED_GROUPS_SERVICE, DICTIONARY_SERVICE); - } - - @Override - public int getPermittedTraffic() { - final String permitted = getSettingValue(PERCENT_TRAFFIC); - if (permitted != null) { - try { - return Integer.parseInt(permitted); - } - catch (NumberFormatException e) { - LOG.trace("Permitted traffic is not defined or has invalid format: '" + permitted + "'"); - } - } - return 0; - } - - @Override - @Nullable - public String getDictionaryServiceUrl() { - return getSettingValue(DICTIONARY_SERVICE); - } - - @Override - @NotNull - public LogEventFilter getEventFilter() { - final FUSWhitelist whitelist = notNull(getWhitelistedGroups(), FUSWhitelist.empty()); - return new LogEventCompositeFilter(new LogEventWhitelistFilter(whitelist), LogEventSnapshotBuildFilter.INSTANCE); - } - - @Override - public boolean isInternal() { - return StatisticsUploadAssistant.isTestStatisticsEnabled(); - } - - @Nullable - protected FUSWhitelist getWhitelistedGroups() { - final String productUrl = getWhiteListProductUrl(); - if (productUrl == null) return null; - return FUStatisticsWhiteListGroupsService.getApprovedGroups(productUrl); - } - - @Nullable - public String getWhiteListProductUrl() { - final String approvedGroupsServiceUrl = getSettingValue(APPROVED_GROUPS_SERVICE); - if (approvedGroupsServiceUrl == null) return null; - return approvedGroupsServiceUrl + ApplicationInfo.getInstance().getBuild().getProductCode() + ".json"; - } - - @NotNull - private static BuildNumber getCurrentBuild() { - return BuildNumber.fromString(EventLogConfiguration.INSTANCE.getBuild()); - } -} +} \ No newline at end of file diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogNotificationProxy.kt b/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogNotificationProxy.kt index 6d6005dd336e..216fb16053d3 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogNotificationProxy.kt +++ b/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogNotificationProxy.kt @@ -12,7 +12,7 @@ class EventLogNotificationProxy(private val writer: StatisticsEventLogWriter, override fun getActiveFile(): EventLogFile? = writer.getActiveFile() - override fun getFiles(): List = writer.getFiles() + override fun getLogFilesProvider(): EventLogFilesProvider = writer.getLogFilesProvider() override fun cleanup() = writer.cleanup() diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogRecorderConfigImpl.java b/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogRecorderConfigImpl.java new file mode 100644 index 000000000000..43eaa9998252 --- /dev/null +++ b/platform/statistics/src/com/intellij/internal/statistic/eventLog/EventLogRecorderConfigImpl.java @@ -0,0 +1,29 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.internal.statistic.eventLog; + +import org.jetbrains.annotations.NotNull; + +public class EventLogRecorderConfigImpl implements EventLogRecorderConfig { + private String myRecorderId; + + public EventLogRecorderConfigImpl(@NotNull String recorderId) { + myRecorderId = recorderId; + } + + @NotNull + @Override + public String getRecorderId() { + return myRecorderId; + } + + @Override + public boolean isSendEnabled() { + return StatisticsEventLoggerKt.getEventLogProvider(myRecorderId).isSendEnabled(); + } + + @NotNull + @Override + public EventLogFilesProvider getLogFilesProvider() { + return StatisticsEventLoggerKt.getEventLogProvider(myRecorderId).getLogFilesProvider(); + } +} diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventLogWriter.kt b/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventLogWriter.kt index 27b9bb9e8901..0713b1bd231a 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventLogWriter.kt +++ b/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventLogWriter.kt @@ -16,7 +16,7 @@ interface StatisticsEventLogWriter { fun getActiveFile(): EventLogFile? - fun getFiles(): List + fun getLogFilesProvider(): EventLogFilesProvider fun cleanup() @@ -68,10 +68,8 @@ class StatisticsEventLogFileWriter(private val recorderId: String, return EventLogFile(File(File(getEventLogDir().toUri()), activeLog)) } - override fun getFiles(): List { - val activeLog = fileAppender?.activeLogName - val files = File(getEventLogDir().toUri()).listFiles { f: File -> !StringUtil.equals(f.name, activeLog) } - return files?.map { EventLogFile(it) }?.toList() ?: emptyList() + override fun getLogFilesProvider(): EventLogFilesProvider { + return DefaultEventLogFilesProvider(getEventLogDir()) { fileAppender?.activeLogName } } override fun cleanup() { diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventLogger.kt b/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventLogger.kt index 3932ca668717..c4f1cf39ebb2 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventLogger.kt +++ b/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsEventLogger.kt @@ -14,7 +14,7 @@ interface StatisticsEventLogger { fun log(group: EventLogGroup, eventId: String, isState: Boolean) fun log(group: EventLogGroup, eventId: String, data: Map, isState: Boolean) fun getActiveLogFile(): EventLogFile? - fun getLogFiles(): List + fun getLogFilesProvider(): EventLogFilesProvider fun cleanup() fun rollOver() } @@ -32,8 +32,8 @@ abstract class StatisticsEventLoggerProvider(val recorderId: String, return logger.getActiveLogFile() } - fun getLogFiles(): List { - return logger.getLogFiles() + fun getLogFilesProvider(): EventLogFilesProvider { + return logger.getLogFilesProvider() } private fun createLogger(): StatisticsEventLogger { @@ -62,11 +62,15 @@ internal class EmptyStatisticsEventLogger : StatisticsEventLogger { override fun log(group: EventLogGroup, eventId: String, isState: Boolean) = Unit override fun log(group: EventLogGroup, eventId: String, data: Map, isState: Boolean) = Unit override fun getActiveLogFile(): EventLogFile? = null - override fun getLogFiles(): List = emptyList() + override fun getLogFilesProvider(): EventLogFilesProvider = EmptyEventLogFilesProvider override fun cleanup() = Unit override fun rollOver() = Unit } +object EmptyEventLogFilesProvider: EventLogFilesProvider { + override fun getLogFiles(): List = emptyList() +} + fun getEventLogProviders(): List { return EP_NAME.extensionsIfPointIsRegistered } diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsFileEventLogger.kt b/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsFileEventLogger.kt index 5ce5effaed12..9112da527537 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsFileEventLogger.kt +++ b/platform/statistics/src/com/intellij/internal/statistic/eventLog/StatisticsFileEventLogger.kt @@ -69,8 +69,8 @@ open class StatisticsFileEventLogger(private val recorderId: String, return writer.getActiveFile() } - override fun getLogFiles(): List { - return writer.getFiles() + override fun getLogFilesProvider(): EventLogFilesProvider { + return writer.getLogFilesProvider() } override fun cleanup() { diff --git a/platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/persistence/EventLogWhitelistPersistence.java b/platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/persistence/EventLogWhitelistPersistence.java index dfb73afdec92..37c2f8f9bfd1 100644 --- a/platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/persistence/EventLogWhitelistPersistence.java +++ b/platform/statistics/src/com/intellij/internal/statistic/eventLog/validator/persistence/EventLogWhitelistPersistence.java @@ -1,8 +1,9 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.statistic.eventLog.validator.persistence; -import com.intellij.internal.statistic.eventLog.EventLogExternalSettingsService; +import com.intellij.internal.statistic.eventLog.EventLogUploadSettingsService; import com.intellij.internal.statistic.service.fus.FUStatisticsWhiteListGroupsService; +import com.intellij.internal.statistic.utils.StatisticsUploadAssistant; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; @@ -22,11 +23,11 @@ public class EventLogWhitelistPersistence extends BaseEventLogWhitelistPersisten @NotNull private final String myRecorderId; @NotNull - private final EventLogExternalSettingsService mySettingsService; + private final EventLogUploadSettingsService mySettingsService; public EventLogWhitelistPersistence(@NotNull String recorderId) { myRecorderId = recorderId; - mySettingsService = new EventLogExternalSettingsService(recorderId); + mySettingsService = StatisticsUploadAssistant.createExternalSettings(recorderId, false); } @Override diff --git a/platform/statistics/src/com/intellij/internal/statistic/utils/StatisticsUploadAssistant.java b/platform/statistics/src/com/intellij/internal/statistic/utils/StatisticsUploadAssistant.java index 922cbed0508c..5cdd653dc1e7 100755 --- a/platform/statistics/src/com/intellij/internal/statistic/utils/StatisticsUploadAssistant.java +++ b/platform/statistics/src/com/intellij/internal/statistic/utils/StatisticsUploadAssistant.java @@ -2,7 +2,7 @@ package com.intellij.internal.statistic.utils; import com.intellij.internal.statistic.connect.StatisticsService; -import com.intellij.internal.statistic.eventLog.EventLogStatisticsService; +import com.intellij.internal.statistic.eventLog.*; import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ public class StatisticsUploadAssistant { public static final Object LOCK = new Object(); - private StatisticsUploadAssistant(){} + private StatisticsUploadAssistant() {} public static long getSendPeriodInMillis() { return UsageStatisticsPersistenceComponent.getInstance().getPeriod().getMillis(); @@ -54,6 +54,14 @@ public class StatisticsUploadAssistant { @NotNull public static StatisticsService getEventLogStatisticsService(@NotNull String recorderId) { - return new EventLogStatisticsService(recorderId); + return new EventLogStatisticsService( + new DeviceConfiguration(EventLogConfiguration.INSTANCE.getDeviceId(), EventLogConfiguration.INSTANCE.getBucket()), + new EventLogRecorderConfigImpl(recorderId), + new EventLogApplicationImpl(false) + ); + } + + public static EventLogUploadSettingsService createExternalSettings(@NotNull String recorderId, boolean isTest) { + return new EventLogUploadSettingsService(recorderId, new EventLogApplicationImpl(isTest)); } }