Skip to content

Commit 8ed82f4

Browse files
committed
app names constants
1 parent 9326e15 commit 8ed82f4

File tree

2 files changed

+45
-25
lines changed

2 files changed

+45
-25
lines changed

ide-common/src/main/kotlin/org/digma/intellij/plugin/posthog/ActivityMonitor.kt

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -719,15 +719,6 @@ class ActivityMonitor(private val project: Project, cs: CoroutineScope) : Dispos
719719
postHog?.capture(UniqueGeneratedUserId.userId, "plugin first-init")
720720
}
721721

722-
fun registerUIUpdate(eventName: String, details: Map<String, Any>) {
723-
//here use postHog.capture directly, this event is called from UIVersioningService while its initializing,
724-
// it cannot call the common capture method because it may cause a circular dependency between UIVersioningService
725-
// and ActivityMonitor because the capture method will call UIVersioningService.getInstance().getCurrentUiVersion().
726-
//although UIVersioningService initialize fast enough, there may be a race condition if the capture method calls
727-
// UIVersioningService.getInstance().getCurrentUiVersion() before UIVersioningService constructor completes.
728-
// also, this event doesn't need all the common properties.
729-
postHog?.capture(UniqueGeneratedUserId.userId, eventName,details)
730-
}
731722

732723
fun registerProjectOpened(openProjects: Int) {
733724
capture("project opened", mapOf("open.projects" to openProjects))
@@ -1138,5 +1129,34 @@ class ActivityMonitor(private val project: Project, cs: CoroutineScope) : Dispos
11381129

11391130
}
11401131

1132+
fun registerUIUpdate(
1133+
bundledVersion: String,
1134+
currentVersion: String,
1135+
latestDownloadedUiVersion: String,
1136+
updateToVersion: String,
1137+
isOnStartup: Boolean,
1138+
isForceUpdate: Boolean
1139+
) {
1140+
1141+
//here use postHog.capture directly, this event is called from UIVersioningService while its initializing,
1142+
// it cannot call the common capture method because it may cause a circular dependency between UIVersioningService
1143+
// and ActivityMonitor because the capture method will call UIVersioningService.getInstance().getCurrentUiVersion().
1144+
//although UIVersioningService initialize fast enough, there may be a race condition if the capture method calls
1145+
// UIVersioningService.getInstance().getCurrentUiVersion() before UIVersioningService constructor completes.
1146+
// also, this event doesn't need all the common properties.
1147+
1148+
val details = mapOf(
1149+
"bundledVersion" to bundledVersion,
1150+
"currentVersion" to currentVersion,
1151+
"latestDownloadedUiVersion" to latestDownloadedUiVersion,
1152+
"updateToVersion" to updateToVersion,
1153+
"isOnStartup" to isOnStartup,
1154+
"isForceUpdate" to isForceUpdate
1155+
)
1156+
1157+
postHog?.capture(UniqueGeneratedUserId.userId, "ui update", details)
1158+
1159+
}
1160+
11411161

11421162
}

ide-common/src/main/kotlin/org/digma/intellij/plugin/updates/ui/UIVersioningService.kt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ class UIVersioningService(val cs: CoroutineScope) : DisposableAdaptor {
174174

175175
findActiveProject()?.let {
176176
ActivityMonitor.getInstance(it).registerUIUpdate(
177-
"ui update on startup", mapOf(
178-
"update to version" to latestDownloadedUiVersion,
179-
"current ui version" to getCurrentUiVersion(),
180-
"latest downloaded version" to latestDownloadedUiVersion,
181-
"bundled version" to bundledUiVersion
182-
)
177+
bundledUiVersion,
178+
getCurrentUiVersion(),
179+
latestDownloadedUiVersion,
180+
latestDownloadedUiVersion,
181+
isOnStartup = true,
182+
isForceUpdate = false
183183
)
184184
}
185185

@@ -331,7 +331,8 @@ class UIVersioningService(val cs: CoroutineScope) : DisposableAdaptor {
331331
}
332332

333333
private fun fireNewUIVersionAvailable() {
334-
ApplicationManager.getApplication().messageBus.syncPublisher(NewUIVersionAvailableEvent.NEW_UI_VERSION_AVAILABLE_EVENT_TOPIC).newUIVersionAvailable()
334+
ApplicationManager.getApplication().messageBus.syncPublisher(NewUIVersionAvailableEvent.NEW_UI_VERSION_AVAILABLE_EVENT_TOPIC)
335+
.newUIVersionAvailable()
335336
}
336337

337338

@@ -360,7 +361,7 @@ class UIVersioningService(val cs: CoroutineScope) : DisposableAdaptor {
360361
)
361362
setLatestDownloadedVersion(null)
362363
}
363-
}else{
364+
} else {
364365
ErrorReporter.getInstance().reportError(
365366
"UIVersioningService.updateToLatestDownloaded",
366367
"updateToLatestDownloaded called but latestDownloadedUiVersion property is null", mapOf(
@@ -399,20 +400,19 @@ class UIVersioningService(val cs: CoroutineScope) : DisposableAdaptor {
399400

400401
findActiveProject()?.let {
401402
ActivityMonitor.getInstance(it).registerUIUpdate(
402-
"ui update", mapOf(
403-
"update to version" to uiVersion,
404-
"current ui version" to getCurrentUiVersion(),
405-
"latest downloaded version" to getLatestDownloadedVersion().toString(),
406-
"bundled version" to bundledUiVersion,
407-
"isForceUpdate" to isForceUpdate
408-
)
403+
bundledUiVersion,
404+
getCurrentUiVersion(),
405+
getLatestDownloadedVersion().toString(),
406+
uiVersion,
407+
false,
408+
isForceUpdate
409409
)
410410
}
411411

412412
deleteUiBundle(getCurrentUiVersion())
413413
setCurrentUiVersion(uiVersion)
414414
service<ReloadService>().reloadAllProjects(ReloadSource.UI_UPDATE)
415-
}else{
415+
} else {
416416
ErrorReporter.getInstance().reportError(
417417
"UIVersioningService.updateToDownloadedVersion", "updateToDownloadedVersion called but ui bundle file does not exist",
418418
mapOf(

0 commit comments

Comments
 (0)