add update video shareLinkExpiresAt event

This commit is contained in:
MarconLP 2023-04-23 14:33:21 +02:00
parent 8f40b1279f
commit fe2081bdea
No known key found for this signature in database
GPG key ID: A08A9C8B623F5EA5

View file

@ -238,11 +238,11 @@ export const videoRouter = createTRPCRouter({
shareLinkExpiresAt: z.nullable(z.date()),
})
)
.mutation(async ({ ctx, input }) => {
const updateVideo = await ctx.prisma.video.updateMany({
.mutation(async ({ ctx: { prisma, session, posthog }, input }) => {
const updateVideo = await prisma.video.updateMany({
where: {
id: input.videoId,
userId: ctx.session.user.id,
userId: session.user.id,
},
data: {
shareLinkExpiresAt: input.shareLinkExpiresAt,
@ -253,6 +253,16 @@ export const videoRouter = createTRPCRouter({
throw new TRPCError({ code: "FORBIDDEN" });
}
posthog.capture({
distinctId: session.user.id,
event: "update video shareLinkExpiresAt",
properties: {
videoId: input.videoId,
shareLinkExpiresAt: input.shareLinkExpiresAt,
},
});
void posthog.shutdownAsync();
return {
success: true,
updateVideo,