metrics - 📊 一个带有 30 多个插件和 200 多个选项的信息图表生成器,用于显示有关你的 GitHub 帐户的统计信息并将它们呈现为 SVG、Markdown、PDF 或 JSON!

Created at: 2020-09-09 00:01:43
Language: JavaScript
License: MIT

📊 指标

构建、测试、分析和发布 指标(示例)

生成可以嵌入到任何地方的指标,包括你的 GitHub 个人资料自述文件!它适用于用户和组织帐户,甚至适用于存储库!

⚠️这是v3.17 -beta

@master
分支)的文档,其中包含未发布的功能,请在此处查看v3.16
@latest
分支)的
文档。

对于用户帐户 对于组织帐户

你可以使用插件、模板和数百个选项对这些进行大量自定义!

🧩 36个插件
📅 等距提交日历 🈷️ 最常用的语言
全年等距日历
半年等距日历
深入分析(克隆和分析存储库)
最近使用(分析最近的活动事件)
默认算法
默认算法(有详细信息)
📌 已加星标的主题 🌟 最近加星标的存储库
带图标
带标签
📜 存储库许可证 💡 编码习惯
许可、限制和条件
许可证概述
近期活动图表
中等有趣的事实
🏅 存储库贡献者 🎟️ 跟进问题和拉取请求
按贡献类型
按投稿次数
深入分析
在用户的存储库上创建
由用户创建
🎭 评论 React 🧑‍🤝‍🧑 人物插件
与用户相关
与存储库相关
过去几周的观星者 🗂️ 活跃项目
当天的代码片段 📰 近期活动
🏆 成就 🎩 显着贡献
紧凑型显示器
详细展示
深入分析
仅在组织中的贡献
💬 讨论 💭 GitHub 社区支持
👨‍💻 代码行改变 🧮 存储库流量
📓 存储库 🎫 要点
🙋 介绍 💕 GitHub 赞助商
对于用户或组织
对于存储库
GitHub 赞助商卡
GitHub 赞助商完整介绍
🌇 GitHub Skyline 3D 日历 ⏱️ 网站表演
PageSpeed 得分
PageSpeed 分数与详细报告
PageSpeed 得分与网站截图
🎼 音乐插件 🐤 最新推文
播放列表中的随机曲目
最近听过
最新推文
带附件的最新推文
🌸 Anilist 观察列表和阅读列表 🗨️ Stackoverflow 插件
对于动漫观察者
对于漫画读者
收藏人物
✒️ 最近的帖子 🗼 RSS订阅
最新帖子
最新帖子宽度描述和封面图片
唤醒时间插件 💹 股票价格
📸 网站截图 💉 夜童子军
更多即将推出!
🖼️ 4+ 模板
📗 经典模板 📘 存储库模板
📙 终端模板 📒 降价模板
📕 社区模板
查看文档 🌍

🦑 有兴趣拥有自己的吗?

为了获得功能齐全的体验,你应该将指标用作GitHub 操作,但你现在也可以使用你的 GitHub 用户名在metrics.lecoq.io上尝试!

选择

📊 Metrics embed
是否要自定义 GitHub 配置文件并
✨ Metrics insights
快速概览 GitHub 统计信息:

📊 指标嵌入 指标洞察
Embed metrics images on your profile readme or blog!
Use GitHub actions for even more features!
Share your metrics with friends and on social medias!
No configuration needed!

🐙 Features

  • Create infographics from 36 plugins, 4 templates and 218 options
  • Support users, organizations and even repositories
  • Transparent by default so it'll blend well whether light or dark mode is used
  • Save your metrics as images (SVG, PNG or JPEG), markdown, PDF or JSON
    • Upload them to GitHub through commits, pull requests and gists, or handle renders yourself
  • Works either as GitHub action or as web instance

📜 How to use?

⚙️ Using GitHub Action on your profile repository (~5 min setup)

Setup a GitHub Action which runs periodically and pushes your generated metrics image to your repository. See all supported options in action.yml.

Assuming your username is

my-github-user
, you can then embed rendered metrics in your readme like below:

<!-- If you're using "master" as default branch -->
![Metrics](https://github.com/my-github-user/my-github-user/blob/master/github-metrics.svg)
<!-- If you're using "main" as default branch -->
![Metrics](https://github.com/my-github-user/my-github-user/blob/main/github-metrics.svg)
💬 How to setup? (click to expand)

0. Setup your personal repository

Create a repository with the same name as your GitHub login (if it's not already done).

设置个人存储库

Its

README.md
will be displayed on your user profile:

GitHub 个人资料示例

1. Create a GitHub personal token

From the

Developer settings
of your account settings, select
Personal access tokens
to create a new token.

No additional scopes are needed for basic metrics, but you may have to grant additional scope depending on what features you're planning to use:

  • public_repo
    scope for some plugins
  • read:org
    scope for all organizations related metrics
  • repo
    scope for all private repositories related metrics
    • read:user
      scope may also be required for some private repositories related metrics

设置 GitHub 个人令牌

A scope-less token can still display private contributions by enabling

Include private contributions on my profile
in your account settings:

启用“在我的个人资料中包含私有贡献`”

If a plugin has not enough scopes to operate (and

plugins_errors_fatal
isn't enabled), it'll be reported in the rendering like below:

插件错误示例

2. Put your GitHub personal token in your repository secrets

Go to the

Settings
of your repository to create a new secret and paste your freshly generated GitHub token there.

设置存储库机密

3. Create a GitHub Action workflow in your repository

Create a new workflow from the

Actions
tab of your repository and paste the following:

name: Metrics
on:
  # Schedule updates (each hour)
  schedule: [{cron: "0 * * * *"}]
  # Lines below let you run workflow manually and on each commit (optional)
  workflow_dispatch:
  push: {branches: ["master", "main"]}
jobs:
  github-metrics:
    runs-on: ubuntu-latest
    steps:
      # See action.yml for all options
      - uses: lowlighter/metrics@latest
        with:
          # Your GitHub token
          token: ${{ secrets.METRICS_TOKEN }}

See all supported options in action.yml.

Rendered metrics will be committed to your repository on each run.

动作更新示例

Choosing between
@latest
,
@master
or a fork

If you wish to use new features as they're being released, you can switch from

@latest
to
@master
. As the latter is used as a development branch, jobs may fail from time to time (although we try to mitigate this).

For convenience, it is possible to use

@main
instead of
@master
.

When using a token with additional permissions, it is advised to fork this repository and use it instead to minimize security risks:

      - uses: my-github-username/metrics@master
      # If you make changes on your fork, be sure not leave @latest as tag!

In this case, please consider watching new releases to stay up-to-date and enjoy latest features!

@latest
will be updated on each release. Metrics doesn't introduce breaking changes from an user point of view (i.e. your workflows will always be valid) so you can follow release cycles without worrying.

Examples workflows

Metrics displayed on this page are rendered from this workflow so you can check it out for some code examples about plugins usage.

You can also take a look at this user workflow if you want.

4. Embed link into your README.md

Update your README.md to embed your metrics:

<!-- If you're using "master" as default branch -->
![Metrics](https://github.com/my-github-user/my-github-user/blob/master/github-metrics.svg)
<!-- If you're using "main" as default branch -->
![Metrics](https://github.com/my-github-user/my-github-user/blob/main/github-metrics.svg)
<!-- If you're using the "columns" display mode -->
<img src="https://github.com/my-github-user/my-github-user/blob/master/github-metrics.svg" alt="Metrics" width="100%">

💕 Using the shared instance (~1 min setup, but with limitations)

For convenience, you can use the shared instance available at metrics.lecoq.io without any additional setup.

![Metrics](https://metrics.lecoq.io/my-github-user)

This is mostly intended for previews, to enjoy all features consider using GitHub Action instead. Availability is not guaranteed.

💬 Fair use (click to expand)

To ensure service availability, shared instance has a few limitations:

  • Images are cached for 1 hour
    • Rendered metrics won't be updated during this time window when queried
    • You can manually update rendering again your metrics on metrics.lecoq.io
  • A rate limiter is enabled to prevent denial of service (it doesn't affect already cached metrics)
  • Some plugins may not be available

Service is provided free of charge, so please be gentle with it 🙂

🏗️ Deploying your own web instance (~15 min setup, depending on your sysadmin knowledge)

Setup a metrics instance on your server if you don't want to use GitHub Actions and metrics.lecoq.io. See all supported options in settings.example.json.

Assuming your username is

my-github-user
, you can then embed rendered metrics in your readme like below:

![Metrics](https://my-personal-domain.com/my-github-user)
💬 How to setup? (click to expand)

0. Prepare your server

You'll need a server with a recent version NodeJS (see used version in Dockerfile).

1. Create a GitHub personal token

From the

Developer settings
of your account settings, select
Personal access tokens
to create a new token.

No additional scopes are needed.

设置 GitHub 个人令牌

2. Install dependencies

Clone repository, install dependencies and copy configuration example to

settings.json
:

git clone https://github.com/lowlighter/metrics.git
cd metrics/
npm install --only=prod
cp settings.example.json settings.json

3. Configure your instance and start it

Edit

settings.json
to configure your instance.

{
  //GitHub API token
    "token":"GITHUB_TOKEN",
  //Other options...
}

See all supported options in settings.example.json.

If you plan to make your web instance public, it is advised to restrict its access thanks to rate limiter and access list.

Once you've finished configuring metrics, start your instance:

npm start

Access your server with provided port in

setting.json
from your browser to ensure everything is working.

4. Embed link into your README.md

Edit your repository readme and add your metrics image from your server domain:

![Metrics](https://my-personal-domain.com/my-github-user)

6. (optional) Setup your instance as a service

To ensure that your instance will restart if it reboots or crashes, you should set it up as a service. This is described below for Linux-like systems which support systemd.

Create a new service file

/etc/systemd/system/github_metrics.service
and paste the following after editing paths inside:

[Unit]
Description=Metrics
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
WorkingDirectory=/path/to/metrics
ExecStart=/usr/bin/node /path/to/metrics/index.mjs

[Install]
WantedBy=multi-user.target

Reload services, enable it, start it and check if it is up and running:

systemctl daemon-reload
systemctl enable github_metrics
systemctl start github_metrics
systemctl status github_metrics
🔗 HTTP parameters (click to expand)

Most of options from action.yml are actually supported by web instance, though syntax is slightly different. All underscores (

_
) must be replaced by dots (
.
) and
plugin_
prefixes must be dropped.

For example, to configure pagespeed plugin you'd use the following:

https://my-personal-domain.com/my-github-user?pagespeed=1&pagespeed.detailed=1&pagespeed.url=https%3A%2F%2Fexample.com

Note that url parameters must be encoded.

As for

base
content, which is enabled by default, sections are available through "
base.<section>
".

For example, to display only

repositories
section, use:

https://my-personal-domain.com/my-github-user?base=0&base.repositories=1

📚 Documentation

🧰 Plugin compatibility matrix

Template/Plugin 🗃️ 📅 🈷️ 📌 🌟 📜 💡 🏅 🎟️ 🎭 🧑‍🤝‍🧑 🗂️ 📰 🏆 🎩 💬 💭 👨‍💻 🧮 📓 🎫 🙋 💕 🌇 ⏱️ 🎼 🐤 🌸 🗨️ ✒️ 🗼 💹 📸 💉
📗 Classic template ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
📘 Repository template ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
📙 Terminal template ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
📒 Markdown template ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Mode/Plugin 🗃️ 📅 🈷️ 📌 🌟 📜 💡 🏅 🎟️ 🎭 🧑‍🤝‍🧑 🗂️ 📰 🏆 🎩 💬 💭 👨‍💻 🧮 📓 🎫 🙋 💕 🌇 ⏱️ 🎼 🐤 🌸 🗨️ ✒️ 🗼 💹 📸 💉
👤 User ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
👥 Organization ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
📓 Repository ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️

注意:markdown 模板实际上可以使用函数渲染任何类型的 SVG 指标

embed

🖼️ 模板

模板可让你更改渲染指标的一般外观。有关如何设置它们的更多信息,请参阅它们各自的文档:

🧩 插件

插件是提供额外内容并允许你自定义渲染指标的功能。有关如何设置它们的更多信息,请参阅它们各自的文档:

🏦 组织指标

虽然指标主要针对用户帐户,但也可以呈现组织帐户的指标。

Metrics (organization account)

💬组织指标 (点击展开)

设置与用户帐户相同,但你需要添加

read:org
范围,无论你是否是目标组织的成员

Add read:org scope to personal token

你还需要

user
使用你的组织名称设置选项。

如果你遇到错误并且你的组织正在使用单点登录,请尝试授权你的个人令牌

用户帐户支持的大多数插件都可以与组织帐户一起使用,但请注意,组织的渲染指标会消耗更多 API 请求。

要支持私有存储库,请将完整

repo
范围添加到你的个人令牌中。

ℹ️ 示例工作流程

- uses: lowlighter/metrics@latest
  with:
    # ... other options
    token: ${{ secrets.METRICS_TOKEN }}          # A personal token from an user account with read:org scope
    user: organization-name                      # Organization name
💬用户帐户的组织成员资格 (单击以展开)

默认情况下,指标只能显示公共成员资格。你可以在

People
组织的选项卡中管理你的会员可见性:

发布组织成员资格

对于组织成员资格,将

read:org
范围添加到你的个人令牌。

将 read:org 范围添加到个人令牌

💪 定制和贡献

Metrics 可以轻松定制。Fork 这个存储库,将使用的操作从

lowlighter/metrics@latest
你的 fork切换到你的 fork 并开始编码!

有关代码结构的更多信息,请参见ARCHITECTURE.md

要报告错误,请填写描述它的问题。要建议新功能或请求帮助设置指标,请查看讨论

如果你想贡献,提交一个pull request。请务必阅读CONTRIBUTING.md以获取更多信息。

📜 授权协议

MIT License
Copyright (c) 2020-present lowlighter

许可证详情

LICENSE.md 中查看完整许可证

赞助商

贡献者

♥️ Become a sponsor

📖 有用的参考

灵感