mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-07 01:22:09 +08:00
[resumes][feat] add ga for comments (#459)
Co-authored-by: Terence Ho <>
This commit is contained in:
@ -3,6 +3,8 @@ import type { SubmitHandler } from 'react-hook-form';
|
|||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { Button, Dialog, TextArea } from '@tih/ui';
|
import { Button, Dialog, TextArea } from '@tih/ui';
|
||||||
|
|
||||||
|
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
|
||||||
|
|
||||||
import { trpc } from '~/utils/trpc';
|
import { trpc } from '~/utils/trpc';
|
||||||
|
|
||||||
type ResumeCommentsFormProps = Readonly<{
|
type ResumeCommentsFormProps = Readonly<{
|
||||||
@ -25,6 +27,8 @@ export default function ResumeCommentsForm({
|
|||||||
setShowCommentsForm,
|
setShowCommentsForm,
|
||||||
}: ResumeCommentsFormProps) {
|
}: ResumeCommentsFormProps) {
|
||||||
const [showDialog, setShowDialog] = useState(false);
|
const [showDialog, setShowDialog] = useState(false);
|
||||||
|
const { event: gaEvent } = useGoogleAnalytics();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -50,6 +54,11 @@ export default function ResumeCommentsForm({
|
|||||||
trpcContext.invalidateQueries(['resumes.resume.findAll']);
|
trpcContext.invalidateQueries(['resumes.resume.findAll']);
|
||||||
trpcContext.invalidateQueries(['resumes.resume.user.findUserStarred']);
|
trpcContext.invalidateQueries(['resumes.resume.user.findUserStarred']);
|
||||||
trpcContext.invalidateQueries(['resumes.resume.user.findUserCreated']);
|
trpcContext.invalidateQueries(['resumes.resume.user.findUserCreated']);
|
||||||
|
gaEvent({
|
||||||
|
action: 'resumes.comment_submit',
|
||||||
|
category: 'engagement',
|
||||||
|
label: 'Submit comment',
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -3,6 +3,8 @@ import { useForm } from 'react-hook-form';
|
|||||||
import type { ResumesSection } from '@prisma/client';
|
import type { ResumesSection } from '@prisma/client';
|
||||||
import { Button, TextArea } from '@tih/ui';
|
import { Button, TextArea } from '@tih/ui';
|
||||||
|
|
||||||
|
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
|
||||||
|
|
||||||
import { trpc } from '~/utils/trpc';
|
import { trpc } from '~/utils/trpc';
|
||||||
|
|
||||||
type ResumeCommentEditFormProps = {
|
type ResumeCommentEditFormProps = {
|
||||||
@ -33,6 +35,7 @@ export default function ResumeCommentReplyForm({
|
|||||||
description: '',
|
description: '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const { event: gaEvent } = useGoogleAnalytics();
|
||||||
|
|
||||||
const trpcContext = trpc.useContext();
|
const trpcContext = trpc.useContext();
|
||||||
const commentReplyMutation = trpc.useMutation('resumes.comments.user.reply', {
|
const commentReplyMutation = trpc.useMutation('resumes.comments.user.reply', {
|
||||||
@ -58,6 +61,12 @@ export default function ResumeCommentReplyForm({
|
|||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
setIsReplyingComment(false);
|
setIsReplyingComment(false);
|
||||||
|
|
||||||
|
gaEvent({
|
||||||
|
action: 'resumes.comment_reply',
|
||||||
|
category: 'engagement',
|
||||||
|
label: 'Reply comment',
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -7,6 +7,8 @@ import {
|
|||||||
} from '@heroicons/react/20/solid';
|
} from '@heroicons/react/20/solid';
|
||||||
import { Vote } from '@prisma/client';
|
import { Vote } from '@prisma/client';
|
||||||
|
|
||||||
|
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
|
||||||
|
|
||||||
import { trpc } from '~/utils/trpc';
|
import { trpc } from '~/utils/trpc';
|
||||||
|
|
||||||
type ResumeCommentVoteButtonsProps = {
|
type ResumeCommentVoteButtonsProps = {
|
||||||
@ -20,6 +22,7 @@ export default function ResumeCommentVoteButtons({
|
|||||||
}: ResumeCommentVoteButtonsProps) {
|
}: ResumeCommentVoteButtonsProps) {
|
||||||
const [upvoteAnimation, setUpvoteAnimation] = useState(false);
|
const [upvoteAnimation, setUpvoteAnimation] = useState(false);
|
||||||
const [downvoteAnimation, setDownvoteAnimation] = useState(false);
|
const [downvoteAnimation, setDownvoteAnimation] = useState(false);
|
||||||
|
const { event: gaEvent } = useGoogleAnalytics();
|
||||||
|
|
||||||
const trpcContext = trpc.useContext();
|
const trpcContext = trpc.useContext();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -35,6 +38,11 @@ export default function ResumeCommentVoteButtons({
|
|||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
// Comment updated, invalidate query to trigger refetch
|
// Comment updated, invalidate query to trigger refetch
|
||||||
trpcContext.invalidateQueries(['resumes.comments.votes.list']);
|
trpcContext.invalidateQueries(['resumes.comments.votes.list']);
|
||||||
|
gaEvent({
|
||||||
|
action: 'resumes.comment_vote',
|
||||||
|
category: 'engagement',
|
||||||
|
label: 'Upvote/Downvote comment',
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -44,6 +52,11 @@ export default function ResumeCommentVoteButtons({
|
|||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
// Comment updated, invalidate query to trigger refetch
|
// Comment updated, invalidate query to trigger refetch
|
||||||
trpcContext.invalidateQueries(['resumes.comments.votes.list']);
|
trpcContext.invalidateQueries(['resumes.comments.votes.list']);
|
||||||
|
gaEvent({
|
||||||
|
action: 'resumes.comment_unvote',
|
||||||
|
category: 'engagement',
|
||||||
|
label: 'Unvote comment',
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user