send analytic events for each digest channel
This commit is contained in:
@ -28,6 +28,7 @@ import {
|
|||||||
findUserAndPersonalization,
|
findUserAndPersonalization,
|
||||||
sendPushNotifications,
|
sendPushNotifications,
|
||||||
} from '../../services/user'
|
} from '../../services/user'
|
||||||
|
import { analytics } from '../../utils/analytics'
|
||||||
import { enqueueSendEmail } from '../../utils/createTask'
|
import { enqueueSendEmail } from '../../utils/createTask'
|
||||||
import { wordsCount } from '../../utils/helpers'
|
import { wordsCount } from '../../utils/helpers'
|
||||||
import { logger } from '../../utils/logger'
|
import { logger } from '../../utils/logger'
|
||||||
@ -716,15 +717,27 @@ const sendToChannels = async (
|
|||||||
deduplicateChannels.map(async (channel) => {
|
deduplicateChannels.map(async (channel) => {
|
||||||
switch (channel) {
|
switch (channel) {
|
||||||
case 'push':
|
case 'push':
|
||||||
return sendPushNotification(user.id, digest)
|
await sendPushNotification(user.id, digest)
|
||||||
|
break
|
||||||
case 'email':
|
case 'email':
|
||||||
return sendEmail(user, digest, deduplicateChannels)
|
await sendEmail(user, digest, deduplicateChannels)
|
||||||
|
break
|
||||||
case 'library':
|
case 'library':
|
||||||
return moveDigestToLibrary(user, digest)
|
await moveDigestToLibrary(user, digest)
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
logger.error('Unknown channel', { channel })
|
logger.error('Unknown channel', { channel })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
analytics.capture({
|
||||||
|
distinctId: user.id,
|
||||||
|
event: 'digest_created',
|
||||||
|
properties: {
|
||||||
|
channel,
|
||||||
|
digestId: digest.id,
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ class PostHogClient implements AnalyticClient {
|
|||||||
properties: {
|
properties: {
|
||||||
...properties,
|
...properties,
|
||||||
client,
|
client,
|
||||||
|
env: env.server.apiEnv,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user