feat(logs): 支持用量日志显示 IP 列#5644
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
✅ Files skipped from review due to trivial changes (5)
🚧 Files skipped from review as they are similar to previous changes (8)
WalkthroughAdds a ChangesShow IP in Usage Logs
Sequence Diagram(s)sequenceDiagram
participant User
participant NotificationTab
participant API
participant useAuthStore
participant UsageLogsTable
participant useCommonLogsColumns
User->>NotificationTab: toggles "Show IP in Usage Logs"
NotificationTab->>API: PATCH /user/setting {show_ip_in_logs: true}
API-->>NotificationTab: 200 OK
NotificationTab->>useAuthStore: setUser with merged show_ip_in_logs=true
UsageLogsTable->>useAuthStore: reads user.setting
UsageLogsTable->>UsageLogsTable: getShowIpInLogsSetting → showIpInLogs=true
UsageLogsTable->>useCommonLogsColumns: useColumnsByCategory(..., showIpInLogs=true)
useCommonLogsColumns-->>UsageLogsTable: columns including IP Address column
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@controller/user.go`:
- Line 1210: The ShowIpInLogs field at line 1210 is defined as a non-pointer
bool, which causes JSON unmarshalling to default omitted fields to false instead
of nil. This causes the update logic at line 1313 to overwrite existing true
values with false when clients don't include this field. Change the ShowIpInLogs
field definition from bool to *bool (pointer to bool) so that omitted JSON
values remain nil, allowing the update logic to preserve previously stored
values when the field is not provided by the client.
In
`@web/default/src/features/usage-logs/components/columns/common-logs-columns.tsx`:
- Around line 813-835: The IP column definition is not respecting the
sensitiveVisible masking flag that other sensitive columns use in this file. Add
a check in the cell function of the IP column to conditionally mask the IP value
when sensitiveVisible is false, similar to how other sensitive data columns
handle masking. When sensitive mode is off, display a masked representation
(like asterisks or dashes) instead of the actual IP address in the StatusBadge
component.
In `@web/default/src/features/usage-logs/lib/columns.ts`:
- Around line 32-38: In the useColumnsByCategory function signature, replace the
return type ColumnDef<any>[] with ColumnDef<Record<string, unknown>>[] to
eliminate the explicit any type. This change provides better type safety while
maintaining the necessary flexibility for the function to return column
definitions for different log types (UsageLog, MidjourneyLog, and TaskLog)
without relying on the any type escape hatch.
🪄 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: 643cfed9-77c9-47ae-abf0-d7a37bffd4bf
📒 Files selected for processing (14)
controller/user.godto/user_settings.goweb/default/src/features/profile/components/tabs/notification-tab.tsxweb/default/src/features/profile/types.tsweb/default/src/features/usage-logs/components/columns/common-logs-columns.tsxweb/default/src/features/usage-logs/components/usage-logs-mobile-card.tsxweb/default/src/features/usage-logs/components/usage-logs-table.tsxweb/default/src/features/usage-logs/lib/columns.tsweb/default/src/i18n/locales/en.jsonweb/default/src/i18n/locales/fr.jsonweb/default/src/i18n/locales/ja.jsonweb/default/src/i18n/locales/ru.jsonweb/default/src/i18n/locales/vi.jsonweb/default/src/i18n/locales/zh.json
c8a3a25 to
89ffde6
Compare
Important
📝 变更描述 / Description
本 PR 为用量日志增加可选的 IP 列展示能力,虽然IP信息已经在使用日志的详情列里有了,但每次都要点开,这里直接通过开关控制将IP显示在列表上,更直观。
主要变更:
该功能默认不改变现有日志表格展示,只有开启对应设置后才显示 IP 列。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
📸 运行证明 / Proof of Work
本地验证命令:

个人资料 - 设置与偏好 - 在使用日志中显示 IP

使用日志 列表 显示IP地址

该功能默认不改变现有日志表格展示,只有开启对应设置后才显示 IP 列。
补充说明:本 PR 与 #5055 都涉及用量日志中的 IP 展示,但实现目标不同。本 PR 范围更聚焦,新增用户偏好开关
show_ip_in_logs,默认不改变现有表格展示,只有用户显式开启后才显示 IP 列;#5055 则是更完整的日志表格增强,包含管理员 IP 列、用户信息和移动端可见性调整等内容。本 PR 由 AI 辅助完成,并已由提交者人工检查和整理。
This PR was AI-assisted and manually reviewed by the submitter.
Summary by CodeRabbit