📈 Conditionally initialize posthog (#586)

This commit is contained in:
Luke Vella 2023-03-20 20:04:39 +00:00 committed by GitHub
parent 4062b572a0
commit d9061d45fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 79 additions and 53 deletions

View file

@ -1,9 +1,10 @@
import { useRouter } from "next/router";
import { useTranslation } from "next-i18next";
import posthog from "posthog-js";
import React from "react";
import { useSessionStorage } from "react-use";
import { usePostHog } from "@/utils/posthog";
import { encodeDateOption } from "../utils/date-time-utils";
import { trpc } from "../utils/trpc";
import { Button } from "./button";
@ -89,10 +90,12 @@ const Page: React.FunctionComponent<CreatePollPageProps> = ({
const [isRedirecting, setIsRedirecting] = React.useState(false);
const posthog = usePostHog();
const createPoll = trpc.polls.create.useMutation({
onSuccess: (res) => {
setIsRedirecting(true);
posthog.capture("created poll", {
posthog?.capture("created poll", {
pollId: res.id,
numberOfOptions: formData.options?.options?.length,
optionsView: formData?.options?.view,