Skip to content

Commit

Permalink
feat: add OSCR's location to PostHog capture (#3895)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeucapua authored Aug 8, 2024
2 parents e04bbeb + 93fbada commit bbf8ee5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/Contributors/Oscr.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LockIcon } from "@primer/octicons-react";
import { usePostHog } from "posthog-js/react";
import { useRouter } from "next/router";
import Pill from "components/atoms/Pill/pill";
import Tooltip from "components/atoms/Tooltip/tooltip";
import Button from "components/shared/Button/button";
Expand All @@ -17,6 +18,7 @@ interface OscrProps {
export const OSCR_LOGIN_TEXT = "Log in to view Open Source Contributor Rating (OSCR)";

export const OscrPill = ({ rating, hideRating, signIn = DEFAULT_SIGN_IN, calculated }: OscrProps) => {
const router = useRouter();
const posthog = usePostHog();
let ratingToRender = calculated ? (rating ? Math.ceil(rating) : 0) : "-";

Expand All @@ -31,7 +33,9 @@ export const OscrPill = ({ rating, hideRating, signIn = DEFAULT_SIGN_IN, calcula
variant="primary"
className="flex items-center gap-2 !p-1 !text-xs z-0"
onClick={() => {
posthog.capture("OSCR Login Button Clicked");
posthog.capture("OSCR Login Button Clicked", {
pathname: router.pathname,
});
signIn({ provider: "github", options: { redirectTo: window.location.href } });
}}
>
Expand Down

0 comments on commit bbf8ee5

Please sign in to comment.