arnoson/kirby-stats

为 Kirby CMS 提供简单且隐私友好的网站统计。

安装: 65

依赖: 0

建议者: 0

安全: 0

星星: 8

关注者: 5

分支: 0

开放问题: 8

类型:kirby-plugin

0.0.10 2024-01-12 15:39 UTC

This package is auto-updated.

Last update: 2024-09-12 17:00:27 UTC


README

⚠️ 此插件仍在 alpha 版本,许多功能尚未实现或未完成。

Kirby stats 是一个简单、隐私友好的 Kirby 3 插件,用于跟踪页面浏览量和访问量。

Kirby Stats Panel Screenshot

注意

我不是律师,不能就 GDPR 提供任何法律建议。我只能告诉你插件收集了哪些数据。对于每个页面浏览,都会在指定的时间间隔内增加各种计数器。例如,在第一个用户访问您的网站后,数据将如下:

  • path 是 URL 路径
  • unixtimestamp 是您选择的跟踪时间间隔的时间。例如,如果您按小时跟踪,则 unixtimestamp 将是当前小时的开始。
  • views 将在每次页面浏览时增加,但不是重新加载
  • visit 仅在用户从空白标签页或通过其他网站的链接访问您的网站时增加。为了确定请求是否计入访问量,会检查用户的引用者(但不会保存)。这也意味着这并不是像许多其他跟踪插件那样的唯一访问量。如果同一个人一天内两次访问您的网站,您将看到两个访问量。
  • 根据用户的浏览器(使用用户代理确定),FirefoxOperaMicrosoftEdgeInternetExplorerSafariChrome 将在每次访问时增加。
  • 根据用户的操作系统(使用用户代理确定),WindowsMacLinuxAndroidiOS 将在每次访问时增加。

就这些。此插件不会存储 IP 地址,也不会设置任何 cookie。而且也没有唯一请求,所有数据都按时间间隔分组。如果第二个用户在同一个小时内访问,计数器将相应增加。如果用户在下一个小时或之后访问,将创建表格中的一行新的计数器。

请查看源代码,并自行决定这将对您的隐私声明和 GDPR 意味着什么。

安装

composer require arnoson/kirby-stats

使用方法

还可以查看 /example 文件夹,文档仍在进行中。

该插件提供了一个端点 /kirby-stats/hit,它由一个小 脚本 调用。只需将脚本添加到您的网站并将它包含在模板中,如示例所示。

选项

// site/config.php
[
  'arnoson.kirby-stats' => [
    // Enable or disable tracking. This is useful to disable tracking in local
    // development by using Kirby's multi environment config setup:
    // https://getkirby.com/docs/guide/configuration#multi-environment-setup
    'enabled' => true,

    // The time interval in which to group the collected data. Use the default
    // 'hour' if you are interested in how your visits/views change during the
    // day, or something like 'week' if don't really care about the details.
    // Allowed values: 'hour', 'day', 'week', 'month', 'year'.
    'interval' => 'hour',

    // Where to (automatically) create the database. Default is
    // '/storage/stats.sqlite' for public folder setups or
    // '/site/storage/stats.sqlite' for normal setups.
    'sqlite' => dirname(__DIR__) . '/some-file-path.sqlite',
  ],
];

注意:如果您想使用 Kirby 的 roots 来定义数据库位置,请使用 Kirby 的 ready 回调

[
  'ready' => fn() => [
    'arnoson.kirby-stats.sqlite' => kirby()->root('site') . '/stats.sqlite',
  ],
];

鸣谢