Skip to content

Commit edff491

Browse files
authored
Merge pull request #2420 from digma-ai/fix-first-connection-event
fix first time connection established event
2 parents ee0972e + 8331ddf commit edff491

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,10 +617,15 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
617617
}
618618

619619

620-
//todo: not thread safe so the block may be invoked more then once
621620
if (!PersistenceService.getInstance().isFirstTimeConnectionEstablished()) {
622-
ActivityMonitor.getInstance(project).registerFirstConnectionEstablished();
623-
PersistenceService.getInstance().setFirstTimeConnectionEstablished();
621+
//if this block is not synchronized the event may be sent more than once.
622+
//synchronization only happens on first time because of double check
623+
synchronized (this) {
624+
if (!PersistenceService.getInstance().isFirstTimeConnectionEstablished()) {
625+
ActivityMonitor.getInstance(project).registerFirstConnectionEstablished();
626+
PersistenceService.getInstance().setFirstTimeConnectionEstablished();
627+
}
628+
}
624629
}
625630

626631
PersistenceService.getInstance().updateLastConnectionTimestamp();

ide-common/src/main/kotlin/org/digma/intellij/plugin/persistence/PersistenceState.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ internal open class PersistenceState : PersistentStateComponent<PersistenceData>
3333

3434
//todo: backwards compatibility, remove firstTimeConnectionEstablishedTimestampNew in January 2025
3535
// renamed without the new suffix
36-
myPersistenceData.firstTimeConnectionEstablishedTimestamp = myPersistenceData.firstTimeConnectionEstablishedTimestampNew
36+
if (myPersistenceData.firstTimeConnectionEstablishedTimestampNew != null &&
37+
myPersistenceData.firstTimeConnectionEstablishedTimestamp == null
38+
) {
39+
myPersistenceData.firstTimeConnectionEstablishedTimestamp = myPersistenceData.firstTimeConnectionEstablishedTimestampNew
40+
}
3741
}
3842

3943

0 commit comments

Comments
 (0)