add update video setSharing event

This commit is contained in:
MarconLP 2023-04-23 14:30:32 +02:00
parent 9eb531a3e8
commit 78f6005942
No known key found for this signature in database
GPG key ID: A08A9C8B623F5EA5

View file

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