Update analytics (#432)

This commit is contained in:
Luke Vella 2023-01-24 14:04:13 +00:00 committed by GitHub
parent a4ca5f1676
commit b0aa9db26d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 122 additions and 106 deletions

View file

@ -1,7 +1,7 @@
import clsx from "clsx";
import { AnimatePresence, motion } from "framer-motion";
import { useTranslation } from "next-i18next";
import { usePlausible } from "next-plausible";
import posthog from "posthog-js";
import * as React from "react";
import { Controller, useForm } from "react-hook-form";
@ -39,18 +39,16 @@ const Discussion: React.VoidFunctionComponent = () => {
},
);
const plausible = usePlausible();
const addComment = trpc.useMutation("polls.comments.add", {
onSuccess: (newComment) => {
session.refresh();
posthog.capture("created comment");
queryClient.setQueryData(
["polls.comments.list", { pollId }],
(existingComments = []) => {
return [...existingComments, newComment];
},
);
plausible("Created comment");
},
});
@ -64,7 +62,7 @@ const Discussion: React.VoidFunctionComponent = () => {
);
},
onSuccess: () => {
plausible("Deleted comment");
posthog.capture("deleted comment");
},
});