Skip to content

feat: add pageview#306

Merged
PaiJi merged 2 commits intomainfrom
feat/add-pageview
May 4, 2026
Merged

feat: add pageview#306
PaiJi merged 2 commits intomainfrom
feat/add-pageview

Conversation

@PaiJi
Copy link
Copy Markdown
Member

@PaiJi PaiJi commented May 4, 2026

Summary by CodeRabbit

新功能

  • 事件详情和组织详情页面现已显示页面浏览计数,并配有可视化指示器。

国际化

  • 添加英文、俄文、简体中文和繁体中文翻译,支持页面浏览相关内容的多语言显示。

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@PaiJi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e6dcb3ca-93ad-411f-ae14-d9f1bd71f851

📥 Commits

Reviewing files that changed from the base of the PR and between 27a9954 and a0262fb.

📒 Files selected for processing (2)
  • src/pages/[organization]/[slug].tsx
  • src/pages/[organization]/index.tsx
📝 Walkthrough

Walkthrough

本PR为应用添加了多语言页面浏览计数统计功能。涵盖四种语言的国际化文案、一个新的基础设施API层、一个页面浏览计数UI组件,以及在事件详情页和组织详情页上的集成。

Changes

页面浏览计数功能

Layer / File(s) Summary
国际化文案
public/locales/en/common.json, public/locales/ru/common.json, public/locales/zh-Hans/common.json, public/locales/zh-Hant/common.json
在英文、俄文、简体中文和繁体中文四个语言文件中各添加 pageview.label(标签显示文本)和 pageview.aria(无障碍屏幕阅读器文本)两组翻译键。
API数据层
src/api/infra.ts
新增 InfraAPI 类,定义了 PageviewMetricsPageviewReportGetPageviewResponse 类型,实现 getPageview(path) 方法通过 HTTP GET 请求从 internal/infra/pageview 端点获取指定路径的浏览统计数据。
UI组件
src/components/PageviewHeatTag/index.tsx
新增 PageviewTag 组件,使用本地化 Intl.NumberFormat 格式化浏览计数(≥10,000时使用紧凑记号),配合火焰图标渲染;支持按语言环境调整数字格式,且当计数为 null 时返回空。
事件详情页集成
src/pages/[organization]/[slug].tsx
getServerSideProps 中并发获取事件详情和页面浏览数据,添加 PageviewTag 到事件标题区域;改进错误处理逻辑,仅对404响应返回 notFound,其他错误则重新抛出;使用 formatLocale() 统一处理语言环境。
组织详情页集成
src/pages/[organization]/index.tsx
扩展 OrganizationDetail 组件 props 以接收 pageviewCount,在 getServerSideProps 中并发获取组织数据和页面浏览统计,将 PageviewTag 渲染在组织头部导航区;改进语言环境处理为使用 formatLocale() 统一方案。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🔥 页面浏览量来敲门,
兔子欢喜把数字记,
四语种翻译齐整齐,
火焰图标闪闪烁,
组织与事件都绽放,
统计分析悄悄进行。 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题'feat: add pageview'清晰地概括了本次变更的核心内容——添加页面浏览量功能,准确反映了多个文件中新增的pageview相关功能。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-pageview

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 49 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

📦 Next.js Bundle Analysis for furrycons-site

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 358.72 KB (🟡 +399 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Two Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/[organization] 8.92 KB 367.63 KB 105.04% (🟡 +0.07%)
/[organization]/[slug] 12.84 KB 371.56 KB 106.16% (🟡 +0.07%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/PageviewHeatTag/index.tsx`:
- Around line 6-10: The locale mapping for number formatting is too broad:
intlLocale currently maps any non-"en"/"zh-Hant" to "zh-Hans", causing languages
like "ru" to be formatted with Chinese rules; update the intlLocale logic (the
locale variable and intlLocale constant used with new Intl.NumberFormat) to only
map explicit known overrides (e.g., map "en" -> "en-US", "zh-Hant" -> "zh-Hant",
"zh-Hans" -> "zh-Hans") and otherwise pass through the incoming locale (or a
safe fallback like "en-US") so Russian ("ru") and other locales use their
correct formatting.

In `@src/pages/`[organization]/[slug].tsx:
- Around line 197-200: The pageview call (InfraAPI.getPageview) is currently
awaited alongside EventsAPI.getEventDetail and any failure/404 from getPageview
causes the whole page to be treated as missing; change this so pageview is
optional by isolating its error handling—either use Promise.allSettled for the
pair or wrap InfraAPI.getPageview in a try/catch and set pv to null/undefined on
error (while still throwing or handling errors from EventsAPI.getEventDetail
normally). Apply the same change to the second occurrence around the 240–245
block so that event retrieval (EventsAPI.getEventDetail) controls 404 behavior
but pageview failures degrade silently.

In `@src/pages/`[organization]/index.tsx:
- Around line 318-321: The pageview fetch (InfraAPI.getPageview) is currently
combined with the organization detail fetch via Promise.all so any pageview
failure can trigger the shared 404/abort logic; change this so
OrganizationsAPI.getOrganizationDetail(reqParamsParseResult.organization) is
awaited and validated independently, then call
InfraAPI.getPageview(pageviewPath) in a separate try/catch (or fire-and-forget
with error handling) so its errors are caught and logged but do not cause the
organization detail path (and 404 handling) to run; apply the same decoupling
change where the same pattern occurs around the block that currently spans lines
395-400.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 005c129e-7ac3-4bcf-b743-5d21a77f1493

📥 Commits

Reviewing files that changed from the base of the PR and between fc7c11a and 27a9954.

📒 Files selected for processing (8)
  • public/locales/en/common.json
  • public/locales/ru/common.json
  • public/locales/zh-Hans/common.json
  • public/locales/zh-Hant/common.json
  • src/api/infra.ts
  • src/components/PageviewHeatTag/index.tsx
  • src/pages/[organization]/[slug].tsx
  • src/pages/[organization]/index.tsx

Comment on lines +6 to +10
const intlLocale = locale === "en" ? "en-US" : locale === "zh-Hant" ? "zh-Hant" : "zh-Hans";
return new Intl.NumberFormat(intlLocale, {
notation: count >= 10_000 ? "compact" : "standard",
maximumFractionDigits: 1,
}).format(count);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

修复 locale 映射默认分支,避免俄语页面被格式化成中文数字样式。

当前分支把所有非 en/zh-Hant 语言都强制映射到 zh-Hans;新增 ru 后会出现错误本地化展示。

💡 建议修改
 function formatCount(count: number, locale: string): string {
-  const intlLocale = locale === "en" ? "en-US" : locale === "zh-Hant" ? "zh-Hant" : "zh-Hans";
+  const intlLocaleMap: Record<string, string> = {
+    en: "en-US",
+    "zh-Hant": "zh-Hant",
+    "zh-Hans": "zh-Hans",
+    ru: "ru-RU",
+  };
+  const intlLocale = intlLocaleMap[locale] ?? locale;
   return new Intl.NumberFormat(intlLocale, {
     notation: count >= 10_000 ? "compact" : "standard",
     maximumFractionDigits: 1,
   }).format(count);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/PageviewHeatTag/index.tsx` around lines 6 - 10, The locale
mapping for number formatting is too broad: intlLocale currently maps any
non-"en"/"zh-Hant" to "zh-Hans", causing languages like "ru" to be formatted
with Chinese rules; update the intlLocale logic (the locale variable and
intlLocale constant used with new Intl.NumberFormat) to only map explicit known
overrides (e.g., map "en" -> "en-US", "zh-Hant" -> "zh-Hant", "zh-Hans" ->
"zh-Hans") and otherwise pass through the incoming locale (or a safe fallback
like "en-US") so Russian ("ru") and other locales use their correct formatting.

Comment thread src/pages/[organization]/[slug].tsx
Comment thread src/pages/[organization]/index.tsx
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

📦 Next.js Bundle Analysis for furrycons-site

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 358.72 KB (🟡 +403 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Two Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/[organization] 8.92 KB 367.64 KB 105.04% (🟡 +0.07%)
/[organization]/[slug] 12.84 KB 371.57 KB 106.16% (🟡 +0.07%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@PaiJi
Copy link
Copy Markdown
Member Author

PaiJi commented May 4, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@PaiJi
Copy link
Copy Markdown
Member Author

PaiJi commented May 4, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@PaiJi PaiJi merged commit efb6927 into main May 4, 2026
9 checks passed
@PaiJi PaiJi deleted the feat/add-pageview branch May 4, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant