mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-23 13:56:18 +02:00
📈 Conditionally initialize posthog (#586)
This commit is contained in:
parent
4062b572a0
commit
d9061d45fa
12 changed files with 79 additions and 53 deletions
|
@ -1,9 +1,10 @@
|
|||
import clsx from "clsx";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import posthog from "posthog-js";
|
||||
import * as React from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import { usePostHog } from "@/utils/posthog";
|
||||
|
||||
import { useDayjs } from "../../utils/dayjs";
|
||||
import { requiredString } from "../../utils/form-validation";
|
||||
import { trpc } from "../../utils/trpc";
|
||||
|
@ -38,10 +39,11 @@ const Discussion: React.FunctionComponent = () => {
|
|||
trpc: {},
|
||||
},
|
||||
);
|
||||
const posthog = usePostHog();
|
||||
|
||||
const addComment = trpc.polls.comments.add.useMutation({
|
||||
onSuccess: (newComment) => {
|
||||
posthog.capture("created comment");
|
||||
posthog?.capture("created comment");
|
||||
|
||||
queryClient.polls.comments.list.setData(
|
||||
{ pollId },
|
||||
|
@ -62,7 +64,7 @@ const Discussion: React.FunctionComponent = () => {
|
|||
);
|
||||
},
|
||||
onSuccess: () => {
|
||||
posthog.capture("deleted comment");
|
||||
posthog?.capture("deleted comment");
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue