From 2c0a063975e0352512c4efac236b8ec6d6d4cd11 Mon Sep 17 00:00:00 2001 From: MarconLP <13001502+MarconLP@users.noreply.github.com> Date: Sun, 23 Apr 2023 14:45:01 +0200 Subject: [PATCH] add ShareModal events --- src/components/ShareModal.tsx | 44 ++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/components/ShareModal.tsx b/src/components/ShareModal.tsx index 5b89157..b63dfa3 100644 --- a/src/components/ShareModal.tsx +++ b/src/components/ShareModal.tsx @@ -3,6 +3,7 @@ import { Fragment, useState } from "react"; import { ModernSwitch } from "~/components/ModernSwitch"; import { api, type RouterOutputs } from "~/utils/api"; import ExpireDateSelectMenu from "~/components/ExpireDateSelectMenu"; +import { usePostHog } from "posthog-js/react"; interface Props { video: RouterOutputs["video"]["get"]; @@ -11,6 +12,23 @@ interface Props { export function ShareModal({ video }: Props) { const utils = api.useContext(); const [open, setOpen] = useState(false); + const posthog = usePostHog(); + + const openModal = () => { + setOpen(true); + posthog?.capture("open video share modal", { + videoSharing: video.sharing, + videoId: video.id, + }); + }; + + const closeModal = () => { + setOpen(false); + posthog?.capture("close video share modal", { + videoSharing: video.sharing, + videoId: video.id, + }); + }; const setSharingMutation = api.video.setSharing.useMutation({ onMutate: async ({ videoId, sharing }) => { @@ -58,23 +76,24 @@ export function ShareModal({ video }: Props) { setTimeout(() => { setLinkCopied(false); }, 5000); + + posthog?.capture("public video link copied", { + videoSharing: video.sharing, + videoId: video.id, + }); }; return ( <> setOpen(true)} + onClick={openModal} className="ml-4 cursor-pointer rounded border border-[#0000001a] px-2 py-2 text-sm text-[#292d34] hover:bg-[#fafbfc]" > Share - setOpen(false)} - > + - {/*
*/} - {/* Share link with search engines*/} - {/* console.log("test")}*/} - {/* />*/} - {/*
*/} - {/*
*/} - {/* Embed code*/} - {/* */} - {/*
*/} ) : null}