관리자 통계 제외와 콘텐츠 링크 정리
This commit is contained in:
@@ -4,7 +4,7 @@ import { pageStatusSchema } from './content-schema.js'
|
||||
|
||||
export const adminPageInputSchema = z.object({
|
||||
title: z.string().trim().min(1),
|
||||
slug: z.string().trim().min(1).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
|
||||
slug: z.string().trim().min(1).regex(/^[a-z0-9가-힣]+(?:[-_][a-z0-9가-힣]+)*$/),
|
||||
renderMode: z.enum(['markdown', 'html_document']).default('html_document'),
|
||||
status: pageStatusSchema.default('published'),
|
||||
content: z.string().default(''),
|
||||
|
||||
@@ -9,7 +9,7 @@ export const adminPostInputSchema = z.object({
|
||||
const t = String(val ?? '').trim()
|
||||
return t.length ? t : ADMIN_POST_PLACEHOLDER_TITLE
|
||||
}, z.string().min(1)),
|
||||
slug: z.string().trim().min(1).regex(/^[a-z0-9가-힣]+(?:-[a-z0-9가-힣]+)*$/),
|
||||
slug: z.string().trim().min(1).regex(/^[a-z0-9가-힣]+(?:[-_][a-z0-9가-힣]+)*$/),
|
||||
content: z.preprocess(normalizeMarkdownContent, z.string()).default(''),
|
||||
excerpt: z.string().default(''),
|
||||
featuredImage: z.string()
|
||||
|
||||
8
server/utils/analytics-admin-exclusion.js
Normal file
8
server/utils/analytics-admin-exclusion.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { getAdminSession } from './admin-auth.js'
|
||||
|
||||
/**
|
||||
* 관리자 세션의 통계 수집 제외 여부를 확인한다.
|
||||
* @param {import('h3').H3Event} event - 요청 이벤트
|
||||
* @returns {boolean} 통계 수집 제외 여부
|
||||
*/
|
||||
export const shouldExcludeAdminAnalytics = (event) => Boolean(getAdminSession(event))
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
createSessionHashFromEvent,
|
||||
recordAnalyticsHeartbeat
|
||||
} from '../repositories/analytics-repository.js'
|
||||
import { shouldExcludeAdminAnalytics } from './analytics-admin-exclusion.js'
|
||||
|
||||
const heartbeatInputSchema = z.object({
|
||||
path: z.string().trim().min(1).max(500),
|
||||
@@ -46,6 +47,10 @@ export const handleAnalyticsHeartbeat = async (event) => {
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
if (shouldExcludeAdminAnalytics(event)) {
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
const postSlug = normalizePostSlugForAnalytics(body.postSlug)
|
||||
const pageSlug = normalizePageSlugForAnalytics(body.pageSlug)
|
||||
let postId = null
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
createVisitorHashFromEvent,
|
||||
recordAnalyticsPageview
|
||||
} from '../repositories/analytics-repository.js'
|
||||
import { shouldExcludeAdminAnalytics } from './analytics-admin-exclusion.js'
|
||||
|
||||
const pageviewInputSchema = z.object({
|
||||
path: z.string().trim().min(1).max(500),
|
||||
@@ -50,6 +51,10 @@ export const handleAnalyticsPageview = async (event) => {
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
if (shouldExcludeAdminAnalytics(event)) {
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
const postSlug = normalizePostSlugForAnalytics(body.postSlug)
|
||||
const pageSlug = normalizePageSlugForAnalytics(body.pageSlug)
|
||||
let postId = null
|
||||
|
||||
Reference in New Issue
Block a user