feat: add API Dashboard + filled icons + pipeline improvements
- Add /api-dashboard page with API connection status, env var checker, pipeline flow diagram, and cost estimator - Add 15 new filled SVG icons (Shield, Database, Server, Bolt, Eye, Copy, Check, Cross, Warning, Refresh, Flow, Coin, LinkExternal etc.) - Follow INFINITH design system: no emoji, no line icons, semantic status colors, diagonal shadows, brand gradients, font-serif headings - Improve Vision Analysis with base64 encoding fix - Add SectionErrorBoundary for graceful section-level error handling - Add Google Places API utility (prepared for future migration) - Fix Edge Function auth headers and report generation pipeline Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2ca9ec0306
commit
ec991057e6
20 files changed
+1397
-109
No files matched your search
@@ -134,14 +134,19 @@ ${JSON.stringify(scrapeData.branding || {}, null, 2).slice(0, 1000)}
|
||||
// ─── Post-processing: Inject Vision Analysis data directly ───
|
||||
// Perplexity may ignore Vision data in prompt, so we force-inject critical fields
|
||||
const vision = channelData.visionAnalysis as Record<string, unknown> | undefined;
|
||||
const isEstablishedMissing = (val: unknown): boolean => {
|
||||
if (!val) return true;
|
||||
const s = String(val).trim().toLowerCase();
|
||||
return s === '' || s === '데이터 없음' || s === '데이터없음' || s === 'n/a' || s === '확인불가' || s === '미확인' || s === '정보없음' || s === '정보 없음';
|
||||
};
|
||||
if (vision) {
|
||||
// Force-inject foundingYear if Vision found it but Perplexity didn't
|
||||
if (vision.foundingYear && (!report.clinicInfo?.established || report.clinicInfo.established === "데이터 없음")) {
|
||||
if (vision.foundingYear && isEstablishedMissing(report.clinicInfo?.established)) {
|
||||
report.clinicInfo = report.clinicInfo || {};
|
||||
report.clinicInfo.established = String(vision.foundingYear);
|
||||
console.log(`[report] Injected foundingYear from Vision: ${vision.foundingYear}`);
|
||||
}
|
||||
if (vision.operationYears && (!report.clinicInfo?.established || report.clinicInfo.established === "데이터 없음")) {
|
||||
if (vision.operationYears && isEstablishedMissing(report.clinicInfo?.established)) {
|
||||
const year = new Date().getFullYear() - Number(vision.operationYears);
|
||||
report.clinicInfo = report.clinicInfo || {};
|
||||
report.clinicInfo.established = String(year);
|
||||
@@ -202,6 +207,78 @@ ${JSON.stringify(scrapeData.branding || {}, null, 2).slice(0, 1000)}
|
||||
caption: ss.caption,
|
||||
sourceUrl: ss.sourceUrl,
|
||||
}));
|
||||
|
||||
// 채널별 스크린샷 그룹핑 (프론트엔드에서 각 채널 섹션에 증거 이미지 표시)
|
||||
report.channelScreenshots = screenshots.reduce((acc: Record<string, unknown[]>, ss: Record<string, unknown>) => {
|
||||
const channel = ss.channel as string || 'etc';
|
||||
if (!acc[channel]) acc[channel] = [];
|
||||
acc[channel].push({ url: ss.url, caption: ss.caption, id: ss.id, sourceUrl: ss.sourceUrl });
|
||||
return acc;
|
||||
}, {} as Record<string, unknown[]>);
|
||||
}
|
||||
|
||||
// Instagram Posts/Reels 분석 (engagement rate, 콘텐츠 성과)
|
||||
const igProfile = channelData.instagram as Record<string, unknown> | undefined;
|
||||
const igPosts = channelData.instagramPosts as Record<string, unknown> | undefined;
|
||||
const igReels = channelData.instagramReels as Record<string, unknown> | undefined;
|
||||
if (igProfile && (igPosts || igReels)) {
|
||||
const followers = (igProfile.followers as number) || 0;
|
||||
const avgLikes = (igPosts?.avgLikes as number) || 0;
|
||||
const avgComments = (igPosts?.avgComments as number) || 0;
|
||||
|
||||
// 해시태그 빈도 분석
|
||||
const hashtagCounts: Record<string, number> = {};
|
||||
const allPosts = [...((igPosts?.posts as Record<string, unknown>[]) || []), ...((igReels?.reels as Record<string, unknown>[]) || [])];
|
||||
for (const post of allPosts) {
|
||||
for (const tag of (post.hashtags as string[]) || []) {
|
||||
const lower = tag.toLowerCase();
|
||||
hashtagCounts[lower] = (hashtagCounts[lower] || 0) + 1;
|
||||
}
|
||||
}
|
||||
const topHashtags = Object.entries(hashtagCounts)
|
||||
.sort((a, b) => b[1] - a[1])
|
||||
.slice(0, 10)
|
||||
.map(([tag, count]) => ({ tag, count }));
|
||||
|
||||
// 게시 빈도 (최근 포스트 간 평균 간격)
|
||||
const postTimestamps = ((igPosts?.posts as Record<string, unknown>[]) || [])
|
||||
.map(p => new Date(p.timestamp as string).getTime())
|
||||
.filter(t => !isNaN(t))
|
||||
.sort((a, b) => b - a);
|
||||
let postFrequency = 'N/A';
|
||||
if (postTimestamps.length >= 2) {
|
||||
const spanDays = (postTimestamps[0] - postTimestamps[postTimestamps.length - 1]) / (1000 * 60 * 60 * 24);
|
||||
const postsPerWeek = spanDays > 0 ? (postTimestamps.length / spanDays * 7).toFixed(1) : 'N/A';
|
||||
postFrequency = `${postsPerWeek}회/주`;
|
||||
}
|
||||
|
||||
// 최고 성과 포스트
|
||||
const bestPost = ((igPosts?.posts as Record<string, unknown>[]) || [])
|
||||
.sort((a, b) => ((b.likesCount as number) || 0) - ((a.likesCount as number) || 0))[0] || null;
|
||||
|
||||
report.instagramAnalysis = {
|
||||
engagementRate: followers > 0 ? ((avgLikes + avgComments) / followers * 100).toFixed(2) + '%' : 'N/A',
|
||||
avgLikes,
|
||||
avgComments,
|
||||
topHashtags,
|
||||
postFrequency,
|
||||
bestPerformingPost: bestPost ? {
|
||||
url: bestPost.url,
|
||||
likes: bestPost.likesCount,
|
||||
comments: bestPost.commentsCount,
|
||||
caption: ((bestPost.caption as string) || '').slice(0, 200),
|
||||
} : null,
|
||||
reelsPerformance: igReels ? {
|
||||
totalReels: igReels.totalReels,
|
||||
avgViews: igReels.avgViews,
|
||||
avgPlays: igReels.avgPlays,
|
||||
viewToFollowerRatio: followers > 0
|
||||
? (((igReels.avgViews as number) || 0) / followers * 100).toFixed(1) + '%'
|
||||
: 'N/A',
|
||||
} : null,
|
||||
totalPostsAnalyzed: (igPosts?.totalPosts as number) || 0,
|
||||
totalReelsAnalyzed: (igReels?.totalReels as number) || 0,
|
||||
};
|
||||
}
|
||||
|
||||
// Embed verified handles
|
||||
|
||||
Reference in new issue
Block a user