Skip to content

Commit f00f82a

Browse files
authored
send debugger event in background (#211)
1 parent 472a660 commit f00f82a

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/analytics/AnalyticsService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ private String getCurrentEnvironment() throws AnalyticsServiceException {
153153
}
154154

155155

156-
public void sendDebuggerEvent(int eventType) throws AnalyticsServiceException {
156+
public void sendDebuggerEvent(int eventType,String timestamp) throws AnalyticsServiceException {
157157
executeCatching(() -> {
158-
analyticsProviderProxy.sendDebuggerEvent(new DebuggerEventRequest(String.valueOf(eventType), CommonUtils.getLocalHostname(), String.valueOf(System.currentTimeMillis())));
158+
analyticsProviderProxy.sendDebuggerEvent(new DebuggerEventRequest(String.valueOf(eventType), CommonUtils.getLocalHostname(), timestamp));
159159
return null;
160160
});
161161
}
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.digma.intellij.plugin.debugger
22

33
import com.intellij.openapi.diagnostic.Logger
4+
import com.intellij.openapi.progress.ProgressIndicator
5+
import com.intellij.openapi.progress.Task
46
import com.intellij.openapi.project.Project
57
import com.intellij.xdebugger.XDebugSessionListener
68
import org.digma.intellij.plugin.analytics.AnalyticsService
79
import org.digma.intellij.plugin.log.Log
810

9-
class SessionListener(project: Project) : XDebugSessionListener {
11+
class SessionListener(private val project: Project) : XDebugSessionListener {
1012

1113
private val logger: Logger = Logger.getInstance(SessionListener::class.java)
1214

@@ -20,20 +22,30 @@ class SessionListener(project: Project) : XDebugSessionListener {
2022

2123
override fun sessionPaused() {
2224
paused = true
23-
try {
24-
analyticsService.sendDebuggerEvent(0)
25-
}catch (e:Exception){
26-
Log.log(logger::debug, "exception calling sendDebuggerEvent {}. ", e.message)
27-
}
25+
val timestamp = System.currentTimeMillis().toString()
26+
object : Task.Backgroundable(project, "Digma:Send Debugger Session Paused") {
27+
override fun run(indicator: ProgressIndicator) {
28+
try {
29+
analyticsService.sendDebuggerEvent(0,timestamp)
30+
} catch (e: Exception) {
31+
Log.log(logger::debug, "exception calling sendDebuggerEvent {}. ", e.message)
32+
}
33+
}
34+
}.queue()
2835
}
2936

3037
override fun sessionResumed() {
3138
paused = false
32-
try {
33-
analyticsService.sendDebuggerEvent(1)
34-
}catch (e:Exception){
35-
Log.log(logger::debug, "exception calling sendDebuggerEvent {}. ", e.message)
36-
}
39+
val timestamp = System.currentTimeMillis().toString()
40+
object : Task.Backgroundable(project, "Digma:Send Debugger Session Resumed") {
41+
override fun run(indicator: ProgressIndicator) {
42+
try {
43+
analyticsService.sendDebuggerEvent(1,timestamp)
44+
} catch (e: Exception) {
45+
Log.log(logger::debug, "exception calling sendDebuggerEvent {}. ", e.message)
46+
}
47+
}
48+
}.queue()
3749
}
3850

3951
}

0 commit comments

Comments
 (0)