This commit is contained in:
1 parent
02dc3c155f
commit
cfa8128aa4
2 files changed
+7
-5
No files matched your search
@@ -175,7 +175,7 @@ export async function fetchAnalytics(
|
||||
fetchTraffic(token, zoneId, '博客', env?.CF_DOMAIN, now),
|
||||
fetchTraffic(token, env?.CF_ASSETS_ZONE_ID || zoneId, 'R2 附件', assetsDomain, now)
|
||||
]);
|
||||
|
||||
|
||||
let audiencePromise: Promise<AnalyticsData['audience']> = Promise.resolve(undefined);
|
||||
if (accountId && webAnalyticsToken) {
|
||||
audiencePromise = fetchAudience(token, accountId, webAnalyticsToken, now);
|
||||
@@ -281,7 +281,7 @@ async function fetchAudience(
|
||||
viewer {
|
||||
accounts(filter: { accountTag: $account }) {
|
||||
rumPagesAdaptiveGroups(
|
||||
limit: 30,
|
||||
limit: 30
|
||||
filter: { siteTag: $site, datetime_geq: $date }
|
||||
orderBy: [date_ASC]
|
||||
) {
|
||||
@@ -304,7 +304,8 @@ async function fetchAudience(
|
||||
}
|
||||
);
|
||||
const rows = data.viewer.accounts[0]?.rumPagesAdaptiveGroups;
|
||||
if (!rows) throw new Error('未返回数据,请检查 Token、Account ID 和 Site Tag 是否正确并具有权限');
|
||||
if (!rows)
|
||||
throw new Error('未返回数据,请检查 Token、Account ID 和 Site Tag 是否正确并具有权限');
|
||||
|
||||
let totalPageViews = 0;
|
||||
let totalUniqueVisitors = 0;
|
||||
@@ -318,7 +319,7 @@ async function fetchAudience(
|
||||
const row = dailyMap.get(date);
|
||||
const pv = row ? row.count : 0;
|
||||
const uv = row ? row.sum.visits : 0;
|
||||
|
||||
|
||||
totalPageViews += pv;
|
||||
totalUniqueVisitors += uv;
|
||||
if (date >= sevenDaysAgoStr) {
|
||||
|
||||
@@ -364,7 +364,8 @@
|
||||
<div class="settings-card full-width" style="margin-bottom: 25px;">
|
||||
<h3>Web Analytics (流量统计)</h3>
|
||||
<p class="desc">
|
||||
配置 Cloudflare Web Analytics 站点 Token。配置后博客将自动采集 PV、UV。如果您通过 Cloudflare Pages 部署并在后台一键开启了统计,只需在这里填写对应生成的 Site Tag 即可拉取数据展示。
|
||||
配置 Cloudflare Web Analytics 站点 Token。配置后博客将自动采集 PV、UV。如果您通过 Cloudflare
|
||||
Pages 部署并在后台一键开启了统计,只需在这里填写对应生成的 Site Tag 即可拉取数据展示。
|
||||
</p>
|
||||
<form
|
||||
method="POST"
|
||||
|
||||
Reference in new issue
Block a user