Skip to content

Commit

Permalink
fix: update the button clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyLv committed Mar 6, 2023
1 parent b8e5cd1 commit 4a9c0d2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
31 changes: 23 additions & 8 deletions components/SignIn.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
import { useUser } from "@supabase/auth-helpers-react";
import { AnimatePresence, motion } from "framer-motion";
import { useEffect } from "react";
import { useAnalytics } from "~/components/context/analytics";
import { useSignInModal } from "~/components/sign-in-modal";
import UserDropdown from "~/components/user-dropdown";
import { FADE_IN_ANIMATION_SETTINGS } from "~/utils/constants";

export default function SignIn() {
const user = useUser();
const { analytics } = useAnalytics();
const { SignInModal, setShowSignInModal } = useSignInModal();

if (user) {
analytics.identify(user.id, {
email: user.email,
});
}

function handleSignIn() {
setShowSignInModal(true);
analytics.track("SignInButton Clicked");
}

/*useEffect(() => {
async function loadData() {
const { data } = await supabaseClient.from('test').select('*')
setData(data)
}
// Only run query once user is logged in.
if (user) loadData()
}, [user])*/
async function loadData() {
const { data } = await supabaseClient.from('test').select('*')
setData(data)
}
// Only run query once user is logged in.
if (user) loadData()
}, [user])*/
return (
<div>
<SignInModal />
Expand All @@ -25,7 +40,7 @@ export default function SignIn() {
) : (
<motion.button
className="rounded-full border border-black bg-black p-1.5 px-1 text-sm text-white transition-all hover:bg-white hover:text-black md:px-4"
onClick={() => setShowSignInModal(true)}
onClick={handleSignIn}
{...FADE_IN_ANIMATION_SETTINGS}
>
登录
Expand Down
13 changes: 3 additions & 10 deletions components/sign-in-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { useSupabaseClient } from "@supabase/auth-helpers-react";
import { Auth } from "@supabase/auth-ui-react";
import { ThemeSupa } from "@supabase/auth-ui-shared";
import React, {
Dispatch,
SetStateAction,
useCallback,
useMemo,
useState,
} from "react";
import Modal from "~/components/shared/modal";
import Image from "next/image";
import { BASE_DOMAIN, LOGIN_LIMIT_COUNT } from "~/utils/constants";
import Link from "next/link";
import { isDev } from "~/utils/env";
import React, { Dispatch, SetStateAction, useCallback, useMemo, useState } from "react";
import Modal from "~/components/shared/modal";
import { BASE_DOMAIN, LOGIN_LIMIT_COUNT } from "~/utils/constants";

const SignInModal = ({
showSignInModal,
Expand Down
6 changes: 5 additions & 1 deletion pages/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const Home: NextPage = () => {
console.log("========e========", e.target.value);
e.preventDefault();
await generateSummary();
analytics.track("GenerateButton Clicked");
};

const summaryArray = summary.split("- ");
Expand Down Expand Up @@ -140,7 +141,10 @@ export const Home: NextPage = () => {
console.log("================", checked);
setShouldShowTimestamp(checked);
analytics
.track(`click handleShowTimestamp: ${checked}`)
.track(`ShowTimestamp Clicked`, {
bvId: currentBvId,
shouldShowTimestamp: checked,
})
.then((res) => console.log("tracked!", res))
.catch(console.error);
// throw new Error("Sentry Frontend Error");
Expand Down

1 comment on commit 4a9c0d2

@vercel
Copy link

@vercel vercel bot commented on 4a9c0d2 Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.