add update video delete_after_link_expires event

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

View file

@ -201,11 +201,11 @@ export const videoRouter = createTRPCRouter({
.input(
z.object({ videoId: z.string(), delete_after_link_expires: z.boolean() })
)
.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: {
delete_after_link_expires: input.delete_after_link_expires,
@ -216,6 +216,16 @@ export const videoRouter = createTRPCRouter({
throw new TRPCError({ code: "FORBIDDEN" });
}
posthog.capture({
distinctId: session.user.id,
event: "update video delete_after_link_expires",
properties: {
videoId: input.videoId,
delete_after_link_expires: input.delete_after_link_expires,
},
});
void posthog.shutdownAsync();
return {
success: true,
updateVideo,