Skip to content

Commit 38c1992

Browse files
authored
fix: langfuse tracing is always enabled (#190)
1 parent 213b400 commit 38c1992

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/honest-coats-march.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"hai-build-code-generator": patch
3+
---
4+
5+
Added a check to ensure telemetry is enabled before initializing or creating Langfuse traces. This prevents unintended data collection when telemetry is turned off.

src/services/posthog/telemetry/TelemetryService.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ class PostHogClient {
146146
}
147147

148148
private createLangfuseTraceClient(taskId: string, isNew: boolean = false) {
149+
// Only create traces if telemetry is enabled
150+
if (!this.telemetryEnabled) {
151+
return
152+
}
153+
149154
// Start / Re-Create a new trace in Langfuse
150155
this.langfuseTraceClient = this.langfuse.trace({
151156
id: taskId,
@@ -384,7 +389,8 @@ class PostHogClient {
384389
},
385390
})
386391

387-
if (tokensIn > 0 || tokensOut > 0) {
392+
// Only send to Langfuse if telemetry is enabled
393+
if (this.telemetryEnabled && (tokensIn > 0 || tokensOut > 0)) {
388394
this.langfuseTraceClient?.generation({
389395
model: model,
390396
startTime: startTime,

0 commit comments

Comments
 (0)