11package org.digma.intellij.plugin.debugger
22
33import com.intellij.openapi.diagnostic.Logger
4+ import com.intellij.openapi.progress.ProgressIndicator
5+ import com.intellij.openapi.progress.Task
46import com.intellij.openapi.project.Project
57import com.intellij.xdebugger.XDebugSessionListener
68import org.digma.intellij.plugin.analytics.AnalyticsService
79import 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