add update video setSharing event
This commit is contained in:
parent
9eb531a3e8
commit
78f6005942
1 changed files with 13 additions and 3 deletions
|
|
@ -167,11 +167,11 @@ export const videoRouter = createTRPCRouter({
|
||||||
}),
|
}),
|
||||||
setSharing: protectedProcedure
|
setSharing: protectedProcedure
|
||||||
.input(z.object({ videoId: z.string(), sharing: z.boolean() }))
|
.input(z.object({ videoId: z.string(), sharing: z.boolean() }))
|
||||||
.mutation(async ({ ctx, input }) => {
|
.mutation(async ({ ctx: { prisma, session, posthog }, input }) => {
|
||||||
const updateVideo = await ctx.prisma.video.updateMany({
|
const updateVideo = await prisma.video.updateMany({
|
||||||
where: {
|
where: {
|
||||||
id: input.videoId,
|
id: input.videoId,
|
||||||
userId: ctx.session.user.id,
|
userId: session.user.id,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
sharing: input.sharing,
|
sharing: input.sharing,
|
||||||
|
|
@ -182,6 +182,16 @@ export const videoRouter = createTRPCRouter({
|
||||||
throw new TRPCError({ code: "FORBIDDEN" });
|
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 {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue