-
Notifications
You must be signed in to change notification settings - Fork 1
chore : GA4 이벤트 추가 #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c440af8
feat : 5. 중간지점 산출
kim3360 6a813c5
Merge branch 'main' into feature/GA-Evaluation-Metric
kim3360 6af4503
fix : 중간지점 조회 수정
kim3360 cf4841f
feat : 6. 중간지점 비교 추가
kim3360 6f868bc
fix : 6. 중간지점 조회 수정
kim3360 5755eb6
feat : 7. 장소리스트 중 하나의 장소 탐색
kim3360 d7ce582
feat : 8. 카카오맵 외부 검증 시도 추가
kim3360 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,37 @@ export default function Page() { | |
|
|
||
| const [selectedResultId, setSelectedResultId] = useState<number>(1); | ||
|
|
||
| // 중간지점 후보 조회 GA 이벤트 | ||
| const trackMidpointCandidateViewed = useCallback( | ||
| (candidateRankOrder: number, candidateId: string) => { | ||
| if (typeof window === 'undefined' || !id) return; | ||
| const browserId = localStorage.getItem('browser_id'); | ||
| const isHost = localStorage.getItem(`is_host_${id}`) === 'true'; | ||
| const userRole = isHost ? 'host' : 'participant'; | ||
|
|
||
| sendGAEvent('event', 'midpoint_candidate_viewed', { | ||
| meeting_url_id: id, | ||
| user_cookie_id: browserId, | ||
| role: userRole, | ||
| candidate_rank_order: candidateRankOrder, | ||
| candidate_id: candidateId, | ||
| }); | ||
| }, | ||
| [id] | ||
| ); | ||
|
|
||
| // 장소 리스트에서 결과보기 페이지로 돌아왔을 때 midpoint_candidate_viewed 전송 | ||
| useEffect(() => { | ||
| if (typeof window === 'undefined' || !id || locationResults.length === 0) return; | ||
| const fromRecommend = sessionStorage.getItem(`from_recommend_${id}`); | ||
| if (fromRecommend !== '1') return; | ||
|
|
||
| sessionStorage.removeItem(`from_recommend_${id}`); | ||
| const selected = locationResults.find((r) => r.id === selectedResultId) ?? locationResults[0]; | ||
| const candidateId = `mid_${selected.endStation.replace(/\s+/g, '_')}`; | ||
| trackMidpointCandidateViewed(selected.id, candidateId); | ||
| }, [id, locationResults, selectedResultId, trackMidpointCandidateViewed]); | ||
|
Comment on lines
+171
to
+181
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추천 페이지 복귀 시 잘못된 후보가 집계될 수 있습니다. Line 315에서 수정 제안- const fromRecommend = sessionStorage.getItem(`from_recommend_${id}`);
- if (fromRecommend !== '1') return;
+ const fromRecommendRank = sessionStorage.getItem(`from_recommend_${id}`);
+ if (!fromRecommendRank) return;
- sessionStorage.removeItem(`from_recommend_${id}`);
- const selected = locationResults.find((r) => r.id === selectedResultId) ?? locationResults[0];
+ const parsedRank = Number(fromRecommendRank);
+ sessionStorage.removeItem(`from_recommend_${id}`);
+ const selected =
+ locationResults.find((r) => r.id === parsedRank) ??
+ locationResults.find((r) => r.id === selectedResultId) ??
+ locationResults[0];
const candidateId = `mid_${selected.endStation.replace(/\s+/g, '_')}`;
trackMidpointCandidateViewed(selected.id, candidateId);- if (typeof window !== 'undefined') {
- sessionStorage.setItem(`from_recommend_${id}`, '1');
- }
+ if (typeof window !== 'undefined') {
+ sessionStorage.setItem(`from_recommend_${id}`, String(result.id));
+ }Also applies to: 314-316 🤖 Prompt for AI Agents |
||
|
|
||
| // 뒤로 가기 클릭 시 캐시 데이터 무효화 | ||
| const clearRelatedCache = useCallback(() => { | ||
| queryClient.removeQueries({ queryKey: ['midpoint', id] }); | ||
|
|
@@ -280,13 +311,20 @@ export default function Page() { | |
| if (meetingType) params.append('meetingType', meetingType); | ||
| if (categoryParam) params.append('category', categoryParam); | ||
|
|
||
| if (typeof window !== 'undefined') { | ||
| sessionStorage.setItem(`from_recommend_${id}`, '1'); | ||
| } | ||
| router.push(`/recommend?${params.toString()}`); | ||
| }; | ||
|
|
||
| return ( | ||
| <div | ||
| key={result.id} | ||
| onClick={() => setSelectedResultId(result.id)} | ||
| onClick={() => { | ||
| setSelectedResultId(result.id); | ||
| const candidateId = `mid_${result.endStation.replace(/\s+/g, '_')}`; | ||
| trackMidpointCandidateViewed(result.id, candidateId); | ||
| }} | ||
| className={`flex cursor-pointer flex-col gap-3.75 rounded border bg-white p-5 ${ | ||
| selectedResultId === result.id | ||
| ? 'border-blue-5 border-2' | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calculation_type가 사실상 항상recalculated로 전송됩니다.Line 174는
id존재 여부로 분기하고 있는데,/meeting/[id]경로에서는id가 항상 존재해first가 전송되지 않습니다. 그리고 Line 177은browser_id가 없을 때null이 전송될 수 있습니다.수정 제안
🤖 Prompt for AI Agents