통계 콘텐츠 세션 원장 추가

This commit is contained in:
2026-07-29 14:48:14 +09:00
parent 1a5a1542b7
commit 4e7e12d8fe
15 changed files with 481 additions and 47 deletions

View File

@@ -7,6 +7,7 @@ import {
} from '../../lib/analytics.js'
import { getPageBySlug, getPostBySlug } from '../repositories/content-repository.js'
import {
createContentSessionHashFromEvent,
createSessionHashFromEvent,
recordAnalyticsHeartbeat
} from '../repositories/analytics-repository.js'
@@ -18,6 +19,7 @@ const heartbeatInputSchema = z.object({
postSlug: z.string().trim().max(200).optional().default(''),
pageSlug: z.string().trim().max(200).optional().default(''),
clientSessionId: z.string().trim().min(8).max(120),
contentSessionId: z.string().trim().max(120).optional().default(''),
durationSeconds: z.number().int().min(0).max(1800),
maxScrollRatio: z.number().min(0).max(1)
})
@@ -78,10 +80,14 @@ export const handleAnalyticsHeartbeat = async (event) => {
}
const sessionHash = createSessionHashFromEvent(event, body.clientSessionId)
const contentSessionHash = body.contentSessionId
? createContentSessionHashFromEvent(event, body.contentSessionId)
: ''
await recordAnalyticsHeartbeat({
event,
sessionHash,
contentSessionHash,
path: body.path,
postId,
postSlug,