mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #4015 from omnivore-app/content-fetch-event
fix: only send content_fetch_failure event to analytics
This commit is contained in:
commit
9494ef8bcd
2 changed files with 7 additions and 9 deletions
|
|
@ -202,11 +202,9 @@ const rankCandidates = async (
|
|||
return candidates
|
||||
}
|
||||
|
||||
const unscoredCandidates = candidates.filter((item) => item.score === 0)
|
||||
|
||||
const data = {
|
||||
user_id: userId,
|
||||
items: unscoredCandidates.reduce((acc, item) => {
|
||||
items: candidates.reduce((acc, item) => {
|
||||
acc[item.id] = {
|
||||
library_item_id: item.id,
|
||||
title: item.title,
|
||||
|
|
@ -227,14 +225,14 @@ const rankCandidates = async (
|
|||
}, {} as Record<string, Feature>),
|
||||
}
|
||||
|
||||
const newScores = await getScores(data)
|
||||
const scores = await getScores(data)
|
||||
// update scores for candidates
|
||||
unscoredCandidates.forEach((item) => {
|
||||
item.score = newScores[item.id]['score'] || 0
|
||||
candidates.forEach((item) => {
|
||||
item.score = scores[item.id]['score'] || 0
|
||||
})
|
||||
|
||||
// rank candidates by score in ascending order
|
||||
candidates.sort((a, b) => a.score - b.score)
|
||||
// rank candidates by score in descending order
|
||||
candidates.sort((a, b) => b.score - a.score)
|
||||
|
||||
return candidates
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class PostHogClient implements AnalyticClient {
|
|||
}
|
||||
|
||||
capture(userIds: string[], { properties, result }: AnalyticEvent) {
|
||||
if (process.env.SEND_ANALYTICS) {
|
||||
if (process.env.SEND_ANALYTICS && result === 'failure') {
|
||||
userIds.forEach((userId) => {
|
||||
this.client.capture({
|
||||
distinctId: userId,
|
||||
|
|
|
|||
Loading…
Reference in a new issue