Skip to content

Commit

Permalink
added backward compatibility for TelemetryMessageBuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish committed Jul 4, 2024
1 parent 20af4b3 commit e26403c
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package com.redhat.devtools.intellij.telemetry.core.service;

import com.intellij.ide.AppLifecycleListener;
import com.intellij.ide.plugins.cl.PluginAwareClassLoader;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.PluginDescriptor;
import com.intellij.util.messages.MessageBusConnection;
Expand Down Expand Up @@ -38,6 +39,11 @@ public class TelemetryMessageBuilder {
private final IService telemetryFacade;
private final IService feedbackFacade;

@Deprecated
public TelemetryMessageBuilder(ClassLoader classLoader) {
this(getDescriptor(classLoader));
}

public TelemetryMessageBuilder(PluginDescriptor descriptor) {
this(createEnvironment(descriptor), descriptor);
}
Expand Down Expand Up @@ -251,4 +257,12 @@ private static Environment createEnvironment(PluginDescriptor descriptor) {
.build();
}

private static PluginDescriptor getDescriptor(ClassLoader classLoader) {
if (classLoader instanceof PluginAwareClassLoader) {
return ((PluginAwareClassLoader) classLoader).getPluginDescriptor();
} else {
return null;
}
}

}

0 comments on commit e26403c

Please sign in to comment.