[Feature/#228] AI 요약하기 API 연동#235
Conversation
|
Warning Review limit reached
More reviews will be available in 42 minutes and 49 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthrough백엔드 AI 분석 API와 통합하는 새로운 타입 시스템 및 폴링 훅을 추가하고, AiSummaryCard를 실제 데이터 기반으로 재구성하며, 플랫폼 타입을 모든 대시보드 컴포넌트에서 일관되게 사용하도록 정렬합니다. 총 30개 파일에서 500줄 이상이 추가되어 AI 분석 기능과 플랫폼 타입 시스템이 통합됩니다. ChangesAI 광고 성과 분석 기능
플랫폼 타입 및 컴포넌트 정렬
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📚 Storybook 배포 완료
|
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/dashboard/platform/SinglePlatformView.tsx (1)
28-35: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
PLATFORM_LOGOS를TProviderType기준으로 강타입화해 주세요지금
Record<string, ...>라서 provider 누락이 컴파일 타임에 잡히지 않습니다.platform이 이미TProviderType이므로 동일 타입으로 맞추는 게 안전합니다.수정 예시
-const PLATFORM_LOGOS: Record< - string, - { component: React.FC<React.SVGProps<SVGSVGElement>>; className: string } -> = { +const PLATFORM_LOGOS: Record< + TProviderType, + { component: React.FC<React.SVGProps<SVGSVGElement>>; className: string } +> = { GOOGLE: { component: GoogleLogo, className: "h-10" }, NAVER: { component: NaverLogo, className: "h-6 ml-2" }, META: { component: MetaLogo, className: "h-6 ml-2" }, };Also applies to: 86-86
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/dashboard/platform/SinglePlatformView.tsx` around lines 28 - 35, PLATFORM_LOGOS is typed as Record<string,...> which hides missing providers; change its type to Record<TProviderType, { component: React.FC<React.SVGProps<SVGSVGElement>>; className: string }> by importing/using TProviderType and replacing the Record<string,...> declaration in the PLATFORM_LOGOS definition, then ensure the object includes an entry for every TProviderType key (or switch to Partial<Record<TProviderType,...>> if some providers are intentionally omitted); apply the same type change to the other similar declaration referenced around the second occurrence (line ~86) so both are strongly typed against TProviderType.
🧹 Nitpick comments (2)
src/hooks/dashboard/usePlatformMetricFacts.ts (1)
56-63: ⚡ Quick win
TProviderType타입 출처를provider.ts로 통일해 주세요.이 훅만
@/types/dashboard/overview의TProviderType을 사용하면 타입 정의가 분기될 수 있습니다. 다른 대시보드 코드와 동일하게@/types/dashboard/provider를 단일 출처로 맞추는 게 안전합니다.🔧 제안 코드
-import type { TProviderType } from "`@/types/dashboard/overview`"; +import type { TProviderType } from "`@/types/dashboard/provider`";🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/hooks/dashboard/usePlatformMetricFacts.ts` around lines 56 - 63, The hook usePlatformMetricFacts currently imports/uses TProviderType from a different module; change its TProviderType import to match the rest of the dashboard code by using the single source "`@/types/dashboard/provider`". Update the import in src/hooks/dashboard/usePlatformMetricFacts.ts so the function usePlatformMetricFacts and any type annotations referencing TProviderType point to "`@/types/dashboard/provider`" instead of "`@/types/dashboard/overview`", ensuring the provider type is unified across the dashboard codebase.src/components/dashboard/ai-report/components/AiSummaryCard.tsx (1)
138-140: 💤 Low value
"—"매직 스트링 비교 대신 명시적인 빈 배열 체크 권장
formatNumberedList가 반환하는"—"문자열과 직접 비교하는 방식은 유틸 함수 구현이 변경될 경우 깨질 수 있어요.data.cautionPoint를 직접 체크하는 방식이 더 안전합니다.♻️ 제안하는 수정
-const cautionList = formatNumberedList(data.cautionPoint); -const cautionContent = - cautionList === "—" ? "특별히 주의가 필요한 항목이 없습니다." : cautionList; +const hasCautionItems = data.cautionPoint?.length > 0; +const cautionContent = hasCautionItems + ? formatNumberedList(data.cautionPoint) + : "특별히 주의가 필요한 항목이 없습니다.";🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/dashboard/ai-report/components/AiSummaryCard.tsx` around lines 138 - 140, 현재 cautionContent가 formatNumberedList의 반환값과 매직 스트링 "—"를 비교하는 방식으로 빈 상태를 판별하고 있어 유틸 구현 변경 시 깨질 수 있습니다; 대신 data.cautionPoint 존재 여부와 배열 길이로 빈 배열을 체크하고, 비어있지 않을 때에만 formatNumberedList(data.cautionPoint)를 호출하여 cautionList/cautionContent를 설정하도록 변경하세요 (참조: formatNumberedList, cautionList, cautionContent, data.cautionPoint).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/api/dashboard/aiAnalysis.ts`:
- Around line 26-31: The getAiReportByAccessToken function injects accessToken
directly into the request path which can break if the token contains
URL-reserved characters; wrap the accessToken with encodeURIComponent before
building the URL passed to axiosInstance.get (the call in
getAiReportByAccessToken that requests `/api/ai/reports/${accessToken}`) so the
path parameter is safely encoded and the IReportStatusResponse retrieval
succeeds.
In `@src/components/dashboard/platform/SinglePlatformView.tsx`:
- Line 118: platformColor is set to a hardcoded hex fallback and
PLATFORM_THEME_COLORS uses hex values, violating theme-token rules; replace
direct hex usage by mapping platforms to theme tokens or token-based CSS class
names and ensure SinglePlatformView uses those tokens (e.g., use token keys from
tokens.css instead of "`#1877f2`", update PLATFORM_THEME_COLORS to return token
strings or class names, and change any chart option consumers of platformColor
to resolve the CSS token/class at render time so all chart colors come from
`@theme` tokens).
In `@src/constants/dashboard/overviewMetricsRange.ts`:
- Around line 2-5: The constant OVERVIEW_DAILY_METRICS_RANGE is hardcoded
causing stale queries; replace the static export with a runtime-calculated value
or injectable provider (e.g., export a function getOverviewDailyMetricsRange or
a factory) that computes startDate/endDate relative to current date (or reads a
server-provided range/ENV) and returns the same shape as the constant so callers
(ROAS/AI summary code) continue to work unchanged; update any imports to call
the function or use the injected value instead of relying on the compile-time
const.
In `@src/hooks/dashboard/useAiAnalysisReport.ts`:
- Around line 132-136: In the orgId missing branch inside useAiAnalysisReport
(the block that currently checks `if (!orgId) { setWorkspaceErrorShown(true);
toast.error(WORKSPACE_REQUIRED_MESSAGE); return; }`), call the hook's `reset()`
function first to clear previous `reportData`/`accessToken` state, then set
`setWorkspaceErrorShown(true)` and show the toast before returning; this ensures
stale analysis state is cleared when no workspace is selected.
In `@src/types/dashboard/provider.ts`:
- Around line 16-20: PLATFORM_CHART_COLORS currently contains hardcoded HEX
values; replace each hex with the corresponding `@theme` token from tokens.css
(use the theme token string values for GOOGLE, NAVER, META) so the
Record<TProviderType,string> maps to theme tokens instead of arbitrary colors;
update PLATFORM_CHART_COLORS in src/types/dashboard/provider.ts to reference the
exact `@theme` token names from tokens.css for each provider (preserve the object
shape and type, e.g., PLATFORM_CHART_COLORS.GOOGLE ->
"<`@theme-token-for-google`>") and ensure any consumer code expecting strings
still receives the token string.
---
Outside diff comments:
In `@src/components/dashboard/platform/SinglePlatformView.tsx`:
- Around line 28-35: PLATFORM_LOGOS is typed as Record<string,...> which hides
missing providers; change its type to Record<TProviderType, { component:
React.FC<React.SVGProps<SVGSVGElement>>; className: string }> by importing/using
TProviderType and replacing the Record<string,...> declaration in the
PLATFORM_LOGOS definition, then ensure the object includes an entry for every
TProviderType key (or switch to Partial<Record<TProviderType,...>> if some
providers are intentionally omitted); apply the same type change to the other
similar declaration referenced around the second occurrence (line ~86) so both
are strongly typed against TProviderType.
---
Nitpick comments:
In `@src/components/dashboard/ai-report/components/AiSummaryCard.tsx`:
- Around line 138-140: 현재 cautionContent가 formatNumberedList의 반환값과 매직 스트링 "—"를
비교하는 방식으로 빈 상태를 판별하고 있어 유틸 구현 변경 시 깨질 수 있습니다; 대신 data.cautionPoint 존재 여부와 배열 길이로
빈 배열을 체크하고, 비어있지 않을 때에만 formatNumberedList(data.cautionPoint)를 호출하여
cautionList/cautionContent를 설정하도록 변경하세요 (참조: formatNumberedList, cautionList,
cautionContent, data.cautionPoint).
In `@src/hooks/dashboard/usePlatformMetricFacts.ts`:
- Around line 56-63: The hook usePlatformMetricFacts currently imports/uses
TProviderType from a different module; change its TProviderType import to match
the rest of the dashboard code by using the single source
"`@/types/dashboard/provider`". Update the import in
src/hooks/dashboard/usePlatformMetricFacts.ts so the function
usePlatformMetricFacts and any type annotations referencing TProviderType point
to "`@/types/dashboard/provider`" instead of "`@/types/dashboard/overview`",
ensuring the provider type is unified across the dashboard codebase.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 04df15a2-bc7d-4a30-ab83-c41dee65f4f8
📒 Files selected for processing (30)
src/api/dashboard/aiAnalysis.tssrc/components/dashboard/ai-report/components/AiSummaryCard.tsxsrc/components/dashboard/ai-report/components/DashboardAiSummarySection.tsxsrc/components/dashboard/ai-report/print/AiSummaryPrintReport.tsxsrc/components/dashboard/ai-report/utils/aiReport.utils.tssrc/components/dashboard/charts/PerformanceEfficiencyChart.tsxsrc/components/dashboard/platform/AllPlatformTrafficChart.tsxsrc/components/dashboard/platform/AllPlatformView.tsxsrc/components/dashboard/platform/PlatformDetailCard.tsxsrc/components/dashboard/platform/PlatformRoasTable.tsxsrc/components/dashboard/platform/SinglePlatformView.tsxsrc/components/dashboard/platform/TopPerformanceList.tsxsrc/components/landing/GuidePlatform.tsxsrc/components/landing/LandingFeatures.tsxsrc/constants/dashboard/overviewMetricsRange.tssrc/hooks/dashboard/useAiAnalysisReport.tssrc/hooks/dashboard/useOverviewRoasRankings.tssrc/hooks/dashboard/usePlatformBudget.tssrc/hooks/dashboard/usePlatformMetricFacts.tssrc/hooks/dashboard/usePlatformMetrics.tssrc/hooks/dashboard/usePlatformPerformance.tssrc/pages/dashboard/overview/OverviewDashboard.tsxsrc/pages/dashboard/overview/mock/aiReport.mock.tssrc/pages/dashboard/overview/sections/OverviewCampaignSnapshotCard.tsxsrc/pages/dashboard/platform/PlatformDashboard.tsxsrc/types/dashboard/aiAnalysis.tssrc/types/dashboard/aiReport.tssrc/types/dashboard/overview.tssrc/types/dashboard/platform.tssrc/types/dashboard/provider.ts
💤 Files with no reviewable changes (4)
- src/pages/dashboard/overview/mock/aiReport.mock.ts
- src/types/dashboard/aiReport.ts
- src/components/dashboard/ai-report/print/AiSummaryPrintReport.tsx
- src/components/landing/GuidePlatform.tsx
🚨 관련 이슈
#228
✨ 변경사항
✏️ 작업 내용
AI 요약 API 연동
/api/ai/organizations/{orgId}/analysis요청 → accessToken 발급/api/ai/reports/{accessToken}폴링으로 PENDING/SUCCESS/FAILED 처리AI 요약 UI/UX 개선
분석 기간
PDF 저장/인쇄
플랫폼 타입/표기 통일
provider.ts로 통일(TProviderType, TAiAnalysisProvider, PROVIDER_TYPES)파일구조
😅 미완성 작업
N/A
📢 논의 사항 및 참고 사항
PATCH /api/ai/reports/{accessToken}/share)는 기능 범위에서 제외Summary by CodeRabbit
릴리스 노트
New Features
Improvements
Refactor