Skip to content

Commit 94823fe

Browse files
authored
Merge pull request #644 from bettersg/bug/langfuse-not-updating-comments
fix: langfuse traceId not updating
2 parents 44a9e1f + 568bb16 commit 94823fe

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

functions/src/definitions/eventHandlers/onVoteRequestUpdate.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ const onVoteRequestUpdateV2 = onDocumentUpdated(
112112
totalCheckerTestersCount,
113113
} = await getVoteCounts(messageRef)
114114

115-
116115
const isBigSus = susCount > thresholds.isBigSus * validResponsesCount
117116
const isSus =
118117
isBigSus || susCount > thresholds.isSus * validResponsesCount
@@ -170,9 +169,10 @@ const onVoteRequestUpdateV2 = onDocumentUpdated(
170169
thresholds.endVoteAbsolute //10
171170
))
172171

173-
// Check if unacceptableCount is more than 50%
172+
// Check if unacceptableCount is more than 50%
174173
// if unacceptableCount > 50% of validResponsesCount and message is considered assessed
175-
const isUnacceptable = (unacceptableCount > 0.5 * validResponsesCount) && isAssessed
174+
const isUnacceptable =
175+
unacceptableCount > 0.5 * validResponsesCount && isAssessed
176176
const isAssessedUnacceptable = isUnacceptable
177177

178178
let primaryCategory
@@ -313,6 +313,11 @@ const onVoteRequestUpdateV2 = onDocumentUpdated(
313313
}
314314
//update langfuse
315315
try {
316+
const checkId = messageSnap.get("checkId")
317+
if (!checkId) {
318+
functions.logger.error("Check ID not found")
319+
throw new Error("Check ID not found, cannot log to langfuse")
320+
}
316321
const communityNoteCategory = postChangeData.communityNoteCategory
317322

318323
if (communityNoteCategory) {
@@ -326,7 +331,7 @@ const onVoteRequestUpdateV2 = onDocumentUpdated(
326331
const checkerId = postChangeData.factCheckerDocRef.id
327332
await langfuse.score({
328333
id: `${messageRef.id}-${checkerId}`,
329-
traceId: messageRef.id,
334+
traceId: checkId,
330335
name: "communityNoteRating",
331336
value: communityNoteCategory,
332337
dataType: "CATEGORICAL",

0 commit comments

Comments
 (0)