// Copyright 2026 tamakyi. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package user import ( "time" "github.com/tamakyi/TamaBox/internal/context" "github.com/tamakyi/TamaBox/internal/i18n" "github.com/tamakyi/TamaBox/internal/insights" ) // Insights 箱主自己的数据面板。 // // 与 /stats 的区别:那个是全站公开数据(任何人可看、不含单箱维度); // 这里只统计当前登录用户自己的箱,且只对本人可见 —— 所以数据里可以出现 // 「你的箱本周被看了多少次」这种带归属的指标。 // // 隐私边界:库里只存「每 访客×天×箱 的访问次数」,访客标识是带日盐的 IP HMAC, // 没有 IP、没有 UA、没有访问路径。因此面板能回答「多少人来了」, // 但回答不了「谁来过」——这是刻意的,箱主不需要也不应该拿到提问者与访客的身份。 func Insights(ctx context.Context) { page := insights.Build(ctx.Request().Context(), ctx.Lang(), ctx.User.ID, time.Now()) page.FormatInsights() ctx.SetTitle(i18n.T(ctx.Lang(), "insights.title")) ctx.Data["Insights"] = page ctx.Success("user/insights") }