diff --git a/components/login-form.tsx b/components/login-form.tsx index 47a6314e4..196a322e1 100644 --- a/components/login-form.tsx +++ b/components/login-form.tsx @@ -1,6 +1,7 @@ import axios from "axios"; import clsx from "clsx"; import { useRouter } from "next/router"; +import { usePlausible } from "next-plausible"; import * as React from "react"; import { useForm } from "react-hook-form"; import { validEmail } from "utils/form-validation"; @@ -12,6 +13,7 @@ const LoginForm: React.VoidFunctionComponent = () => { const { register, formState, handleSubmit, getValues } = useForm<{ email: string }>(); + const plausible = usePlausible(); const router = useRouter(); return (
@@ -23,6 +25,7 @@ const LoginForm: React.VoidFunctionComponent = () => { {!formState.isSubmitSuccessful ? (
{ + plausible("Login requested"); await axios.post("/api/login", { email, path: router.asPath }); })} > diff --git a/pages/login.tsx b/pages/login.tsx index 74f8adf59..f87299339 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -1,6 +1,7 @@ import { GetServerSideProps, NextPage } from "next"; import Head from "next/head"; import { useRouter } from "next/router"; +import { usePlausible } from "next-plausible"; import React from "react"; import toast from "react-hot-toast"; import { useTimeoutFn } from "react-use"; @@ -16,12 +17,15 @@ const Page: NextPage<{ success: boolean; redirectTo: string }> = ({ redirectTo, }) => { const router = useRouter(); - + const pluasible = usePlausible(); if (!success) { toast.error("Login failed! Link is expired or invalid"); } useTimeoutFn(() => { + if (success) { + pluasible("Login completed"); + } router.replace(redirectTo); }, 100);