feat: 구름 합치기 GA4 이벤트 — game_start(첫 그림)·game_round(라운드 깸)·game_over(넘침)

This commit is contained in:
minaChoi committed 2026-10-29 09:06:46 +09:00
1 parent 7aad7f929c
commit 2f4a0c3bad
3 files changed
+17

No files matched your search

+4
View File
@@ -55,8 +55,12 @@ GA4 태그(`gtag.js`, 측정 ID `G-D378J4X373`)를 `index.html`에 심고, 화
| `today_icon` | 오늘 탭 아이콘 줄에서 아이콘을 누름 | `icon`(`tarot`·`saju`·`game`·`foliage`·`shorts`·`myGak`·`talk`) | `todayIcons.tsx` `TodayIcons` |
| `saju_input` | 날씨 사주 생년월일을 넣음 (생년월일 값은 보내지 않음) | `with_time` | `SajuPage.tsx` `BirthForm` |
| `saju_view` | 날씨 사주 결과가 뜸 | `scene`(내 기운 이름), `score` | `SajuPage.tsx` `Reading` |
| `game_start` | 구름 합치기 한 판의 첫 그림을 떨어뜨림 (페이지만 열고 안 한 사람과 구분) | `again`(다시 하기로 시작), `logged_in`, `wind_ms`(오늘 우리 구 풍속) | `CloudMergePage.tsx` `onUp` |
| `game_round` | 구름 합치기 라운드를 깸 | `round`(깬 라운드), `score`(그때 총점), `logged_in`(각을 받는지) | `CloudMergePage.tsx` `onScore` |
| `game_over` | 구름 합치기가 넘쳐서 끝남 | `round`(끝난 라운드), `score`, `best`(최고 기록 갱신), `drops`(떨어뜨린 횟수) | `CloudMergePage.tsx` `onOver` |
- 공유창에서 사용자가 취소하면 `share`를 보내지 않는다.
- 구름 합치기 게임 방법 창은 `sheet_open`(`sheet: 'gameHelp'`)으로 잡혀 따로 보내지 않는다.
- 토스판은 로그인이 없어 `login` `toss`는 나가지 않는다. `id`·`sign_up`도 지금 화면에 아이디 가입이 없어 나가지 않는다.
- 점수 근거·댓글창 열기처럼 창으로 여는 기능은 따로 이벤트를 두지 않고 `sheet_open`의 `sheet`로 나눠 본다.
- `region_change`의 `location`은 처음 온 사람의 자동 위치 맞춤도 포함한다.
+10
View File
@@ -7,6 +7,7 @@ import { gameRound, gameStart } from '@nalssigak/shared/api/client/sdk.gen'
import type { ResLevel } from '@nalssigak/shared/api/client/types.gen'
import { kst } from '@nalssigak/shared/lib'
import { slotAt } from '@nalssigak/shared/lib/weatherText'
import { track } from '../lib/analytics'
import { cx } from '../lib/utils'
import { useAuth } from './authContext'
import { createGame, DROP_Y, H, LEVELS, LINE_Y, loadBest, randomLevel, roundTarget, saveBest, W, windDir, type Game } from './cloudMerge'
@@ -106,6 +107,8 @@ export function CloudMergePage() {
const [next, setNext] = useState(randomLevel)
const nextRef = useRef(next)
const coolRef = useRef(0)
// 이번 판에 떨어뜨린 횟수: 0 이면 아직 시작 전(첫 그림에서 game_start)
const dropsRef = useRef(0)
const [score, setScore] = useState(0)
const [best, setBest] = useState(loadBest)
const [over, setOver] = useState(false)
@@ -124,6 +127,8 @@ export function CloudMergePage() {
canvas.height = H * ratio
ctx.scale(ratio, ratio)
let roundNo = 1
let total = 0
dropsRef.current = 0
let base = 0
let flashTimer: ReturnType<typeof setTimeout> | undefined
let ticket: Promise<string | undefined> = Promise.resolve(undefined)
@@ -154,6 +159,7 @@ export function CloudMergePage() {
}
const game = createGame(windMs, dir, {
onScore: (s) => {
total = s
setScore(s)
if (s - base >= roundTarget(roundNo)) {
roundNo += 1
@@ -164,6 +170,7 @@ export function CloudMergePage() {
clearTimeout(flashTimer)
flashTimer = setTimeout(() => setFlash(false), 1400)
void claim(roundNo - 1)
track('game_round', { round: roundNo - 1, score: s, logged_in: loggedIn })
}
setRoundGot(s - base)
if (s > loadBest()) {
@@ -173,6 +180,7 @@ export function CloudMergePage() {
},
onOver: () => {
setOver(true)
track('game_over', { round: roundNo, score: total, best: total > 0 && total >= loadBest(), drops: dropsRef.current })
settle()
},
})
@@ -205,6 +213,8 @@ export function CloudMergePage() {
const onUp = (e: PointerEvent<HTMLCanvasElement>) => {
const game = gameRef.current
if (!game || over || performance.now() < coolRef.current) return
if (dropsRef.current === 0) track('game_start', { again: play > 0, logged_in: loggedIn, wind_ms: windMs })
dropsRef.current += 1
game.drop(nextRef.current, toX(e))
coolRef.current = performance.now() + 450
nextRef.current = randomLevel()
+3
View File
@@ -33,6 +33,9 @@ type Events = {
today_icon: { icon: string }
saju_input: { with_time: boolean }
saju_view: { scene: string; score: number }
game_start: { again: boolean; logged_in: boolean; wind_ms: number }
game_round: { round: number; score: number; logged_in: boolean }
game_over: { round: number; score: number; best: boolean; drops: number }
toss_intro_start: Record<string, never>
install_banner_close: Record<string, never>
}