Skip to content

Commit dcd80bf

Browse files
authored
fix: use a fresh builder each time a new msg is built (#72)
* fix: use a fresh builder each time a new msg is built * corrected imports and instance var ordering Signed-off-by: Andre Dietisheim <adietish@redhat.com>
1 parent fea20f6 commit dcd80bf

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

src/main/java/com/redhat/devtools/intellij/telemetry/core/service/TelemetryMessageBuilder.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,24 @@
1010
******************************************************************************/
1111
package com.redhat.devtools.intellij.telemetry.core.service;
1212

13-
import com.intellij.ide.AppLifecycleListener;
14-
import com.intellij.openapi.application.ApplicationManager;
15-
import com.intellij.openapi.components.ComponentManager;
16-
import com.intellij.openapi.components.ServiceManager;
17-
import com.intellij.openapi.diagnostic.Logger;
18-
import com.intellij.util.messages.MessageBusConnection;
19-
import com.redhat.devtools.intellij.telemetry.core.ITelemetryService;
20-
import com.redhat.devtools.intellij.telemetry.core.util.TimeUtils;
13+
import static com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.Type.ACTION;
14+
import static com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.Type.SHUTDOWN;
15+
import static com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.Type.STARTUP;
16+
import static com.redhat.devtools.intellij.telemetry.core.util.AnonymizeUtils.anonymize;
17+
import static com.redhat.devtools.intellij.telemetry.core.util.TimeUtils.toLocalTime;
2118

2219
import java.time.Duration;
2320
import java.time.LocalDateTime;
2421
import java.util.HashMap;
2522
import java.util.Map;
2623

27-
import static com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.Type;
28-
import static com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.Type.ACTION;
29-
import static com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.Type.SHUTDOWN;
30-
import static com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.Type.STARTUP;
31-
import static com.redhat.devtools.intellij.telemetry.core.util.AnonymizeUtils.anonymize;
32-
import static com.redhat.devtools.intellij.telemetry.core.util.TimeUtils.toLocalTime;
24+
import com.intellij.ide.AppLifecycleListener;
25+
import com.intellij.openapi.application.ApplicationManager;
26+
import com.intellij.openapi.diagnostic.Logger;
27+
import com.intellij.util.messages.MessageBusConnection;
28+
import com.redhat.devtools.intellij.telemetry.core.ITelemetryService;
29+
import com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.Type;
30+
import com.redhat.devtools.intellij.telemetry.core.util.TimeUtils;
3331

3432
public class TelemetryMessageBuilder {
3533

src/main/java/com/redhat/devtools/intellij/telemetry/core/service/TelemetryService.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010
******************************************************************************/
1111
package com.redhat.devtools.intellij.telemetry.core.service;
1212

13+
import static com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration.KEY_MODE;
14+
15+
import java.util.concurrent.atomic.AtomicBoolean;
16+
1317
import com.intellij.openapi.application.ApplicationManager;
1418
import com.intellij.openapi.diagnostic.Logger;
1519
import com.intellij.util.messages.MessageBusConnection;
1620
import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
1721
import com.redhat.devtools.intellij.telemetry.core.ITelemetryService;
1822
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration;
23+
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration.ConfigurationChangedListener;
24+
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration.Mode;
25+
import com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.Type;
1926
import com.redhat.devtools.intellij.telemetry.core.util.CircularBuffer;
2027
import com.redhat.devtools.intellij.telemetry.ui.TelemetryNotifications;
2128

22-
import java.util.Objects;
23-
import java.util.concurrent.atomic.AtomicBoolean;
24-
25-
import static com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration.*;
26-
import static com.redhat.devtools.intellij.telemetry.core.service.TelemetryEvent.*;
27-
2829
public class TelemetryService implements ITelemetryService {
2930

3031
private static final Logger LOGGER = Logger.getInstance(TelemetryService.class);

src/main/java/com/redhat/devtools/intellij/telemetry/core/service/TelemetryServiceFactory.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
******************************************************************************/
1111
package com.redhat.devtools.intellij.telemetry.core.service;
1212

13-
import com.intellij.openapi.application.ApplicationInfo;
14-
import com.intellij.openapi.application.ApplicationNamesInfo;
1513
import com.intellij.openapi.project.DumbAware;
1614
import com.redhat.devtools.intellij.telemetry.core.IMessageBroker;
1715
import com.redhat.devtools.intellij.telemetry.core.configuration.TelemetryConfiguration;
@@ -20,12 +18,15 @@
2018

2119
public class TelemetryServiceFactory implements DumbAware {
2220

23-
private final Environment.Builder builder = new Environment.Builder()
24-
.ide(new IDE.Factory().create()
25-
.setJavaVersion());
21+
private final IDE ide = new IDE.Factory()
22+
.create()
23+
.setJavaVersion();
2624

2725
public TelemetryService create(ClassLoader classLoader) {
28-
Environment environment = builder.plugin(classLoader).build();
26+
Environment environment = new Environment.Builder()
27+
.ide(ide)
28+
.plugin(classLoader)
29+
.build();
2930
TelemetryConfiguration configuration = TelemetryConfiguration.getInstance();
3031
IMessageBroker broker = createSegmentBroker(configuration.isDebug(), classLoader, environment);
3132
return new TelemetryService(configuration, broker);

src/main/java/com/redhat/devtools/intellij/telemetry/core/service/segment/IdentifyTraitsPersistence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
*/
2727
public class IdentifyTraitsPersistence {
2828

29+
public static final IdentifyTraitsPersistence INSTANCE = new IdentifyTraitsPersistence();
2930
private static final Logger LOGGER = Logger.getInstance(IdentifyTraitsPersistence.class);
3031

31-
public static final IdentifyTraitsPersistence INSTANCE = new IdentifyTraitsPersistence();
3232
private static final Path FILE = Directories.RED_HAT.resolve("segment-identify-traits.json");
3333

3434
private IdentifyTraits identifyTraits = null;

0 commit comments

Comments
 (0)