Skip to content

Commit b8a14c7

Browse files
committed
remove refresh events
1 parent 3a3a6b1 commit b8a14c7

File tree

6 files changed

+40
-11
lines changed

6 files changed

+40
-11
lines changed

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ tasks {
301301
"kotlinx.coroutines.debug" to "",
302302
"org.digma.plugin.report.all.errors" to "true",
303303

304+
//to debug AuthManager
305+
//"org.digma.plugin.auth.debug" to "true",
306+
304307
// "idea.ProcessCanceledException" to "disabled"
305308

306309

ide-common/src/main/kotlin/org/digma/intellij/plugin/auth/AuthManager.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,13 @@ class AuthManager(private val cs: CoroutineScope) : Disposable {
395395

396396
Log.log(logger::trace, "in fireChange, auth info changed , firing event {}", myLatestAuthInfo)
397397

398-
reportAuthPosthogEvent(
399-
"fire auth info changed",
400-
this.javaClass.simpleName,
401-
mapOf("user.id" to myLatestAuthInfo.userId.toString(), "listeners" to listeners.size)
402-
)
398+
withAuthManagerDebug {
399+
reportAuthPosthogEvent(
400+
"fire auth info changed",
401+
this.javaClass.simpleName,
402+
mapOf("user.id" to myLatestAuthInfo.userId.toString(), "listeners" to listeners.size)
403+
)
404+
}
403405

404406
Log.log(
405407
logger::trace, "firing authInfoChanged, default account {}, analytics url {}",

ide-common/src/main/kotlin/org/digma/intellij/plugin/auth/AuthUtils.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ fun reportAuthPosthogEvent(evenName: String, caller: String, details: Map<String
1111
ActivityMonitor.getInstance(project).registerAuthEvent(evenName, detailsToSend)
1212
}
1313
}
14+
15+
16+
//if we want to debug issues in auth manager wrap some code that will run only if debug is on.
17+
//set the property in runIde task
18+
fun withAuthManagerDebug(block: () -> Unit) {
19+
if (System.getProperty("org.digma.plugin.auth.debug") != null) {
20+
block.invoke()
21+
}
22+
}

ide-common/src/main/kotlin/org/digma/intellij/plugin/auth/account/AbstractLoginHandler.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.digma.intellij.plugin.analytics.RestAnalyticsProvider
77
import org.digma.intellij.plugin.auth.AuthApiClient
88
import org.digma.intellij.plugin.auth.credentials.DigmaCredentials
99
import org.digma.intellij.plugin.auth.reportAuthPosthogEvent
10+
import org.digma.intellij.plugin.auth.withAuthManagerDebug
1011
import org.digma.intellij.plugin.common.ExceptionUtils
1112
import org.digma.intellij.plugin.errorreporting.ErrorReporter
1213
import kotlin.coroutines.coroutineContext
@@ -84,14 +85,18 @@ abstract class AbstractLoginHandler(protected val analyticsProvider: RestAnalyti
8485

8586
trace("refresh called for url {},trigger {}", analyticsProvider.apiUrl, trigger)
8687

87-
reportAuthPosthogEvent("refresh token", this.javaClass.simpleName, mapOf("refresh trigger" to trigger))
88+
withAuthManagerDebug {
89+
reportAuthPosthogEvent("refresh token", this.javaClass.simpleName, mapOf("refresh trigger" to trigger))
90+
}
8891

8992
val newCredentials = authApiClient.refreshToken(account, credentials)
9093
SingletonAccountUpdater.updateAccount(account, newCredentials)
9194

9295
trace("refresh success for url {}, updated account {},trigger {}", analyticsProvider.apiUrl, getDefaultAccount(), trigger)
9396

94-
reportAuthPosthogEvent("refresh token success", this.javaClass.simpleName, mapOf("refresh trigger" to trigger))
97+
withAuthManagerDebug {
98+
reportAuthPosthogEvent("refresh token success", this.javaClass.simpleName, mapOf("refresh trigger" to trigger))
99+
}
95100

96101
true
97102

ide-common/src/main/kotlin/org/digma/intellij/plugin/auth/account/CentralizedLoginHandler.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.digma.intellij.plugin.auth.account
22

33
import org.digma.intellij.plugin.analytics.RestAnalyticsProvider
44
import org.digma.intellij.plugin.auth.reportAuthPosthogEvent
5+
import org.digma.intellij.plugin.auth.withAuthManagerDebug
56
import org.digma.intellij.plugin.common.ExceptionUtils
67
import org.digma.intellij.plugin.errorreporting.ErrorReporter
78
import kotlin.time.Duration.Companion.seconds
@@ -16,7 +17,9 @@ class CentralizedLoginHandler(analyticsProvider: RestAnalyticsProvider) : Abstra
1617

1718
trace("loginOrRefresh called, url: {},trigger {}", analyticsProvider.apiUrl, trigger)
1819

19-
reportAuthPosthogEvent("loginOrRefresh", this.javaClass.simpleName, mapOf("loginOrRefresh trigger" to trigger))
20+
withAuthManagerDebug {
21+
reportAuthPosthogEvent("loginOrRefresh", this.javaClass.simpleName, mapOf("loginOrRefresh trigger" to trigger))
22+
}
2023

2124
val digmaAccount = getDefaultAccount()
2225

@@ -103,7 +106,9 @@ class CentralizedLoginHandler(analyticsProvider: RestAnalyticsProvider) : Abstra
103106
logout("${this.javaClass.simpleName}: error in loginOrRefresh $e")
104107
throw e
105108
} finally {
106-
reportAuthPosthogEvent("loginOrRefresh completed", this.javaClass.simpleName, mapOf("loginOrRefresh trigger" to trigger))
109+
withAuthManagerDebug {
110+
reportAuthPosthogEvent("loginOrRefresh completed", this.javaClass.simpleName, mapOf("loginOrRefresh trigger" to trigger))
111+
}
107112
}
108113

109114
}

ide-common/src/main/kotlin/org/digma/intellij/plugin/auth/account/LocalLoginHandler.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.digma.intellij.plugin.auth.account
33
import kotlinx.coroutines.CoroutineName
44
import org.digma.intellij.plugin.analytics.RestAnalyticsProvider
55
import org.digma.intellij.plugin.auth.reportAuthPosthogEvent
6+
import org.digma.intellij.plugin.auth.withAuthManagerDebug
67
import org.digma.intellij.plugin.common.ExceptionUtils
78
import org.digma.intellij.plugin.errorreporting.ErrorReporter
89
import kotlin.coroutines.coroutineContext
@@ -21,7 +22,9 @@ class LocalLoginHandler(analyticsProvider: RestAnalyticsProvider) : AbstractLogi
2122

2223
trace("loginOrRefresh called, url: {},trigger {}", analyticsProvider.apiUrl, trigger)
2324

24-
reportAuthPosthogEvent("loginOrRefresh", this.javaClass.simpleName, mapOf("loginOrRefresh trigger" to trigger))
25+
withAuthManagerDebug {
26+
reportAuthPosthogEvent("loginOrRefresh", this.javaClass.simpleName, mapOf("loginOrRefresh trigger" to trigger))
27+
}
2528

2629
val digmaAccount = getDefaultAccount()
2730

@@ -139,7 +142,9 @@ class LocalLoginHandler(analyticsProvider: RestAnalyticsProvider) : AbstractLogi
139142

140143
false
141144
} finally {
142-
reportAuthPosthogEvent("loginOrRefresh completed", this.javaClass.simpleName, mapOf("loginOrRefresh trigger" to trigger))
145+
withAuthManagerDebug {
146+
reportAuthPosthogEvent("loginOrRefresh completed", this.javaClass.simpleName, mapOf("loginOrRefresh trigger" to trigger))
147+
}
143148
}
144149

145150
}

0 commit comments

Comments
 (0)