Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions features/auth/auth.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useMutation } from '@tanstack/react-query';
import { useCallback, useEffect, useState } from 'react';
import { useForm, useWatch } from 'react-hook-form';

import { trackEvent } from '@/shared/lib/analytics';
import { ApiError } from '@/shared/lib/api';

import type { SignupStepId } from './auth.constants';
Expand Down Expand Up @@ -58,6 +59,8 @@ export const useSignupForm = () => {
positions: data.positions,
links: sanitizedLinks,
});

trackEvent('sign_up', { method: 'kakao' });
} catch (error) {
let message = '서버 오류가 발생했어요. 잠시 후 다시 시도해 주세요.';

Expand Down
6 changes: 5 additions & 1 deletion features/profile/profile.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useForm } from 'react-hook-form';

import { useBooleanState } from '@/shared/hooks/use-boolean-state';
import { useCopyLinkFeedback } from '@/shared/hooks/use-copy-link-feedback';
import { trackEvent } from '@/shared/lib/analytics';
import { ApiError } from '@/shared/lib/api';
import { buildPathWithSearch, setSearchParam } from '@/shared/lib/url/search-params';

Expand Down Expand Up @@ -162,7 +163,10 @@ export const useProfileShare = ({ userLink, userName }: UseProfileShareParams) =
} = useCopyLinkFeedback();

const shareProfile = useCallback(async () => {
await copyLink(buildProfileShareClipboardText(userLink, userName));
const copied = await copyLink(buildProfileShareClipboardText(userLink, userName));
if (copied) {
trackEvent('share_profile', { method: 'copy_link' });
}
}, [copyLink, userLink, userName]);

return {
Expand Down
2 changes: 2 additions & 0 deletions features/project/project.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useForm } from 'react-hook-form';

import { useMyProfile } from '@/features/profile';
import { trackEvent } from '@/shared/lib/analytics';
import { ApiError } from '@/shared/lib/api';

import type {
Expand Down Expand Up @@ -308,6 +309,7 @@ export const useCreateProjectModal = ({ onOpenChange }: CreateProjectModalParams
});

setCreatedProjectLink(createdProject.projectLink);
trackEvent('create_review_link');
} catch (error) {
form.setError('root', {
message:
Expand Down
2 changes: 2 additions & 0 deletions features/review/review.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useForm } from 'react-hook-form';

import { useMyProfile } from '@/features/profile';
import { projectKeys, useProject } from '@/features/project';
import { trackEvent } from '@/shared/lib/analytics';

import type { ReviewStepId } from './review.constants';
import type { ReviewWriteFormData } from './review.types';
Expand Down Expand Up @@ -136,6 +137,7 @@ export const useWriteReviewFlow = ({ projectId, revieweeId }: UseWriteReviewFlow
tagIds,
spectrums,
});
trackEvent('complete_review');
setSubmitDialogOpen(false);
router.push(`/projects/${projectId}?reviewSubmitted=1`);
} catch {
Expand Down
6 changes: 0 additions & 6 deletions shared/components/google-analytics-page-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import { useEffect, useRef } from 'react';

const GA_MEASUREMENT_ID = process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID;

declare global {
interface Window {
gtag?: (...args: unknown[]) => void;
}
}

export const GoogleAnalyticsPageView = () => {
const pathname = usePathname();
const searchParams = useSearchParams();
Expand Down
1 change: 1 addition & 0 deletions shared/hooks/use-copy-link-feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const useCopyLinkFeedback = () => {
const copied = await copyTextToClipboard(text);
setMessage(copied ? COPY_SUCCESS_MESSAGE : COPY_FAILURE_MESSAGE);
setOpen(true);
return copied;
}, []);

return { open, message, close, copyLink };
Expand Down
12 changes: 12 additions & 0 deletions shared/lib/analytics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
declare global {
interface Window {
gtag?: (...args: unknown[]) => void;
}
}

export const trackEvent = (eventName: string, params?: Record<string, string>) => {
if (typeof window === 'undefined' || !window.gtag) {
return;
}
window.gtag('event', eventName, params);
};
Loading