Skip to content

Commit 8be9aa1

Browse files
committed
Add telemetry logging to Tips
commit-id: I58b2f796
1 parent e025307 commit 8be9aa1

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • git-jaspr/src/main/kotlin/sims/michael/gitjaspr

git-jaspr/src/main/kotlin/sims/michael/gitjaspr/Tips.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,23 @@ class TipProvider(
3333
private val logger = LoggerFactory.getLogger(TipProvider::class.java)
3434
private val json = Json { ignoreUnknownKeys = true }
3535

36+
init {
37+
logger.info("Using state file {}", stateFile.absolutePath)
38+
}
39+
3640
/**
3741
* Returns a tip if it's time to show one, or null otherwise. Updates state as a side effect.
3842
*/
3943
fun getNextTip(): String? {
44+
logger.trace("getNextTip")
4045
if (tips.isEmpty()) return null
4146

4247
val state = loadState()
48+
logger.trace("getNextTip state loaded: {}", state)
4349
val nextCount = state.invocationsSinceLastTip + 1
4450

4551
if (nextCount < TIP_INTERVAL) {
52+
logger.trace("Not time to show tip yet, invocationsSinceLastTip: {}", nextCount)
4653
saveState(state.copy(invocationsSinceLastTip = nextCount))
4754
return null
4855
}
@@ -65,6 +72,7 @@ class TipProvider(
6572
}
6673

6774
private fun saveState(state: TipsState) {
75+
logger.trace("Saving tips state: {}", state)
6876
try {
6977
stateFile.parentFile?.mkdirs()
7078
stateFile.writeText(json.encodeToString(state))

0 commit comments

Comments
 (0)