Skip to content

Commit

Permalink
feat: add share tracking (#1250)
Browse files Browse the repository at this point in the history
* add share tracking

* usePostHogContex

* npm run format

* Update components/molecules/ContributorProfileHeader/contributor-profile-header.tsx
  • Loading branch information
bdougie committed Jun 6, 2023
1 parent 0526b41 commit 5b7d331
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -8,6 +8,7 @@ import { MarkGithubIcon } from "@primer/octicons-react";
import { User } from "@supabase/supabase-js";
import { FiCopy } from "react-icons/fi";
import { useToast } from "lib/hooks/useToast";
import { usePostHogContext } from "posthog-js/react";

interface ContributorProfileHeaderProps {
avatarUrl?: string;
Expand All @@ -33,6 +34,7 @@ const ContributorProfileHeader = ({
handleSignIn,
isOwner
}: ContributorProfileHeaderProps) => {
const posthog = usePostHogContext();
const { toast } = useToast();
const [host, setHost] = useState("");
const handleFollowClick = () => {
Expand All @@ -45,6 +47,12 @@ const ContributorProfileHeader = ({

const handleCopyToClipboard = async (content: string) => {
const url = new URL(content).toString();
posthog.capture(
"clicked: profile copied",
{
profile: user?.user_metadata.user_name,
});

try {
await navigator.clipboard.writeText(url);
toast({ description: "Copied to clipboard", variant: "success" });
Expand Down

0 comments on commit 5b7d331

Please sign in to comment.