@@ -9,12 +9,13 @@ import com.intellij.ide.BrowserUtil
9
9
import com.intellij.notification.NotificationAction
10
10
import com.intellij.notification.NotificationType
11
11
import com.intellij.openapi.Disposable
12
- import com.intellij.openapi.client.ClientProjectSession
12
+ import com.intellij.openapi.client.ClientSessionsManager
13
13
import com.intellij.openapi.components.service
14
14
import com.intellij.openapi.diagnostic.thisLogger
15
15
import com.intellij.openapi.fileEditor.FileEditorManagerEvent
16
16
import com.intellij.openapi.fileEditor.FileEditorManagerListener
17
17
import com.intellij.openapi.fileTypes.LanguageFileType
18
+ import com.intellij.openapi.project.Project
18
19
import com.intellij.remoteDev.util.onTerminationOrNow
19
20
import com.intellij.util.application
20
21
import com.jetbrains.rd.util.lifetime.Lifetime
@@ -32,12 +33,11 @@ import java.util.concurrent.CancellationException
32
33
import java.util.concurrent.CompletableFuture
33
34
34
35
@Suppress(" UnstableApiUsage" , " OPT_IN_USAGE" )
35
- class GitpodClientProjectSessionTracker (
36
- private val session : ClientProjectSession
37
- ) : Disposable {
36
+ class GitpodClientProjectSessionTracker (private val project : Project ) : Disposable {
38
37
39
38
private val manager = service<GitpodManager >()
40
39
private val portsService = service<GitpodPortsService >()
40
+ private val session = ClientSessionsManager .getProjectSession(project)
41
41
42
42
private lateinit var info: Info .WorkspaceInfoResponse
43
43
private val lifetime = Lifetime .Eternal .createNested()
@@ -89,7 +89,7 @@ class GitpodClientProjectSessionTracker(
89
89
notification.addAction(makePublicAction)
90
90
}
91
91
92
- ClientId .withClientId(session.clientId) {
92
+ ClientId .withClientId(session? .clientId) {
93
93
notification.notify(null )
94
94
}
95
95
}
@@ -108,7 +108,7 @@ class GitpodClientProjectSessionTracker(
108
108
}
109
109
110
110
private fun openBrowser (url : String ) {
111
- ClientId .withClientId(session.clientId) {
111
+ ClientId .withClientId(session? .clientId) {
112
112
BrowserUtil .browse(url)
113
113
}
114
114
}
@@ -196,7 +196,7 @@ class GitpodClientProjectSessionTracker(
196
196
197
197
private fun registerActiveLanguageAnalytics () {
198
198
val activeLanguages = mutableSetOf<String >()
199
- session. project.messageBus.connect().subscribe(FileEditorManagerListener .FILE_EDITOR_MANAGER , object : FileEditorManagerListener {
199
+ project.messageBus.connect().subscribe(FileEditorManagerListener .FILE_EDITOR_MANAGER , object : FileEditorManagerListener {
200
200
override fun selectionChanged (event : FileEditorManagerEvent ) {
201
201
super .selectionChanged(event)
202
202
if (event.manager.selectedEditor == null ) {
@@ -219,6 +219,7 @@ class GitpodClientProjectSessionTracker(
219
219
}
220
220
221
221
private fun trackEvent (eventName : String , props : Map <String , Any ?>) {
222
+ if (session == null ) return
222
223
manager.trackEvent(eventName, mapOf (
223
224
" sessionId" to session.clientId.value
224
225
).plus(props))
0 commit comments