📈 (posthog) Send user last login event
This commit is contained in:
@ -20,6 +20,7 @@ import got from 'got'
|
||||
import { env } from '@typebot.io/env'
|
||||
import * as Sentry from '@sentry/nextjs'
|
||||
import { getIp } from '@typebot.io/lib/getIp'
|
||||
import { trackEvents } from '@typebot.io/lib/telemetry/trackEvents'
|
||||
|
||||
const providers: Provider[] = []
|
||||
|
||||
@ -218,11 +219,18 @@ const updateLastActivityDate = async (user: User) => {
|
||||
first.getMonth() === second.getMonth() &&
|
||||
first.getDate() === second.getDate()
|
||||
|
||||
if (!datesAreOnSameDay(user.lastActivityAt, new Date()))
|
||||
if (!datesAreOnSameDay(user.lastActivityAt, new Date())) {
|
||||
await prisma.user.updateMany({
|
||||
where: { id: user.id },
|
||||
data: { lastActivityAt: new Date() },
|
||||
})
|
||||
await trackEvents([
|
||||
{
|
||||
name: 'User logged in',
|
||||
userId: user.id,
|
||||
},
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
const getUserGroups = async (account: Account): Promise<string[]> => {
|
||||
|
Reference in New Issue
Block a user