gitlytics 0.1.5__tar.gz → 0.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gitlytics-0.1.5 → gitlytics-0.1.7}/LICENSE +19 -5
- {gitlytics-0.1.5 → gitlytics-0.1.7}/PKG-INFO +43 -23
- {gitlytics-0.1.5 → gitlytics-0.1.7}/README.md +42 -21
- {gitlytics-0.1.5 → gitlytics-0.1.7}/pyproject.toml +1 -2
- {gitlytics-0.1.5 → gitlytics-0.1.7}/src/gitlytics/__init__.py +43 -13
- gitlytics-0.1.7/src/gitlytics/api.py +234 -0
- {gitlytics-0.1.5 → gitlytics-0.1.7}/src/gitlytics/automation.py +18 -13
- {gitlytics-0.1.5 → gitlytics-0.1.7}/src/gitlytics/cli.py +7 -3
- gitlytics-0.1.7/src/gitlytics/core.py +514 -0
- gitlytics-0.1.7/src/gitlytics/process.py +270 -0
- gitlytics-0.1.7/src/gitlytics/static/android-chrome-192x192.png +0 -0
- gitlytics-0.1.7/src/gitlytics/static/android-chrome-512x512.png +0 -0
- gitlytics-0.1.7/src/gitlytics/static/apple-touch-icon.png +0 -0
- gitlytics-0.1.7/src/gitlytics/static/assets/html2canvas-pro.esm-C9_j7xg5.js +10 -0
- gitlytics-0.1.7/src/gitlytics/static/assets/html2canvas.esm-QH1iLAAe.js +22 -0
- gitlytics-0.1.7/src/gitlytics/static/assets/index-Aazi2GN9.css +1 -0
- gitlytics-0.1.7/src/gitlytics/static/assets/index-DC2yfovd.js +504 -0
- gitlytics-0.1.7/src/gitlytics/static/assets/index.es-DPqfsOIl.js +18 -0
- gitlytics-0.1.7/src/gitlytics/static/assets/jspdf.es.min-Ck4Jy8d6.js +170 -0
- gitlytics-0.1.7/src/gitlytics/static/assets/purify.es-Csrj9YNg.js +3 -0
- gitlytics-0.1.7/src/gitlytics/static/favicon-16x16.png +0 -0
- gitlytics-0.1.7/src/gitlytics/static/favicon-32x32.png +0 -0
- gitlytics-0.1.7/src/gitlytics/static/favicon-48x48.png +0 -0
- gitlytics-0.1.7/src/gitlytics/static/favicon.ico +0 -0
- gitlytics-0.1.7/src/gitlytics/static/gitlytics-logo.png +0 -0
- gitlytics-0.1.7/src/gitlytics/static/index.html +24 -0
- gitlytics-0.1.7/src/gitlytics/static/octocat.png +0 -0
- gitlytics-0.1.7/src/gitlytics/static/robots.txt +5 -0
- gitlytics-0.1.7/src/gitlytics/static/sitemap.xml +13 -0
- {gitlytics-0.1.5 → gitlytics-0.1.7}/src/gitlytics.egg-info/PKG-INFO +43 -23
- gitlytics-0.1.7/src/gitlytics.egg-info/SOURCES.txt +41 -0
- {gitlytics-0.1.5 → gitlytics-0.1.7}/src/gitlytics.egg-info/requires.txt +0 -1
- {gitlytics-0.1.5 → gitlytics-0.1.7}/tests/test_api.py +71 -3
- {gitlytics-0.1.5 → gitlytics-0.1.7}/tests/test_automation.py +23 -0
- {gitlytics-0.1.5 → gitlytics-0.1.7}/tests/test_core.py +1 -1
- {gitlytics-0.1.5 → gitlytics-0.1.7}/tests/test_process.py +34 -0
- gitlytics-0.1.7/tests/test_username.py +335 -0
- gitlytics-0.1.5/src/gitlytics/api.py +0 -177
- gitlytics-0.1.5/src/gitlytics/core.py +0 -288
- gitlytics-0.1.5/src/gitlytics/process.py +0 -237
- gitlytics-0.1.5/src/gitlytics/static/assets/index-CJlQrbYd.js +0 -44
- gitlytics-0.1.5/src/gitlytics/static/assets/index-Dpkz0yGK.css +0 -2
- gitlytics-0.1.5/src/gitlytics/static/index.html +0 -14
- gitlytics-0.1.5/src/gitlytics/static/logo.png +0 -0
- gitlytics-0.1.5/src/gitlytics.egg-info/SOURCES.txt +0 -25
- {gitlytics-0.1.5 → gitlytics-0.1.7}/setup.cfg +0 -0
- {gitlytics-0.1.5 → gitlytics-0.1.7}/src/gitlytics/__main__.py +0 -0
- {gitlytics-0.1.5 → gitlytics-0.1.7}/src/gitlytics.egg-info/dependency_links.txt +0 -0
- {gitlytics-0.1.5 → gitlytics-0.1.7}/src/gitlytics.egg-info/entry_points.txt +0 -0
- {gitlytics-0.1.5 → gitlytics-0.1.7}/src/gitlytics.egg-info/top_level.txt +0 -0
- {gitlytics-0.1.5 → gitlytics-0.1.7}/tests/test_cli.py +0 -0
|
@@ -194,8 +194,22 @@
|
|
|
194
194
|
|
|
195
195
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
203
|
+
-------------------------------------------------------------------------
|
|
204
|
+
|
|
205
|
+
"Commons Clause" License Condition v1.0
|
|
206
|
+
|
|
207
|
+
The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.
|
|
208
|
+
|
|
209
|
+
Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, the right to Sell the Software.
|
|
210
|
+
|
|
211
|
+
For purposes of the foregoing, "Sell" means practicing any or all of the rights granted to you under the License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software), a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Clause License Condition notice.
|
|
212
|
+
|
|
213
|
+
Software: Gitlytics
|
|
214
|
+
License: Apache 2.0
|
|
215
|
+
Licensor: Ameya Sanjay Chopade
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitlytics
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Summary: Monitor and automate your GitHub repository traffic analytics.
|
|
5
5
|
Author-email: Ameya Chopade <ameyaccod171@gmail.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -27,15 +27,14 @@ Provides-Extra: dev
|
|
|
27
27
|
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
28
28
|
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
|
|
29
29
|
Requires-Dist: httpx>=0.27.0; extra == "dev"
|
|
30
|
-
Requires-Dist: Faker>=20.0.0; extra == "dev"
|
|
31
30
|
Requires-Dist: anyio[trio]>=4.0.0; extra == "dev"
|
|
32
31
|
Dynamic: license-file
|
|
33
32
|
|
|
34
33
|
<div align="center">
|
|
35
34
|
|
|
36
|
-
<img src="
|
|
35
|
+
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/logo.png" alt="Gitlytics Logo" width="150" />
|
|
37
36
|
|
|
38
|
-
#
|
|
37
|
+
# Gitlytics
|
|
39
38
|
### GitHub Traffic Analytics & Automation
|
|
40
39
|
|
|
41
40
|
[](LICENSE)
|
|
@@ -48,6 +47,8 @@ Dynamic: license-file
|
|
|
48
47
|
[](https://dashboard.gitlytics.dev)
|
|
49
48
|
[](https://docs.gitlytics.dev)
|
|
50
49
|
|
|
50
|
+
<br/>Please consider giving this project a ⭐ if you find it helpful! <br/>
|
|
51
|
+
|
|
51
52
|
**Beautiful GitHub traffic analytics for all your repositories — public and private.** <br/> Track views, clones, referrers, and popular paths indefinitely.
|
|
52
53
|
|
|
53
54
|
✨ **[Try the live dashboard at dashboard.gitlytics.dev](https://dashboard.gitlytics.dev)** ✨
|
|
@@ -57,22 +58,16 @@ Dynamic: license-file
|
|
|
57
58
|
|
|
58
59
|
> **🐍 Native Python API**
|
|
59
60
|
>
|
|
60
|
-
> You can import Gitlytics natively into your own Python applications to
|
|
61
|
+
> You can import Gitlytics natively into your own Python applications to fetch live repository data like views, clones, stars, and referrers. Build custom integrations, run custom cron workflows, or serve the dashboard programmatically on your own cloud servers.
|
|
61
62
|
>
|
|
62
63
|
> 📚 **[Read the Full API Documentation](https://docs.gitlytics.dev)**
|
|
63
64
|
|
|
64
|
-
Please consider giving this project a ⭐ if you find it helpful!
|
|
65
|
-
|
|
66
65
|
</div>
|
|
67
66
|
|
|
68
67
|
---
|
|
69
68
|
|
|
70
69
|
<div align="center">
|
|
71
|
-
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/gitlytics_thumbnail_1.png" width="
|
|
72
|
-
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/gitlytics_thumbnail_2.png" width="49%" />
|
|
73
|
-
</div>
|
|
74
|
-
<div align="center">
|
|
75
|
-
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/gitlytics_thumbnail_3.png" width="98.5%" />
|
|
70
|
+
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/gitlytics_thumbnail_1.png" width="100%" />
|
|
76
71
|
</div>
|
|
77
72
|
|
|
78
73
|
---
|
|
@@ -101,7 +96,7 @@ Please consider giving this project a ⭐ if you find it helpful!
|
|
|
101
96
|
|
|
102
97
|
The full Gitlytics ecosystem spans across a few repositories. If you are looking for the live web dashboard or the automation cron job, check out the links below:
|
|
103
98
|
|
|
104
|
-
- **[
|
|
99
|
+
- **[Gitlytics Web Ecosystem](https://github.com/ameyac11/gitlytics-deployement)**: The production landing page, React Dashboard, and React Documentation site.
|
|
105
100
|
- ⚙️ **[Gitlytics Automation](https://github.com/ameyac11/gitlytics-github-traffic-automation)**: The GitHub Action companion tool that automates fetching and saving to defeat GitHub's 14-day traffic limit.
|
|
106
101
|
|
|
107
102
|
---
|
|
@@ -147,6 +142,9 @@ Gitlytics is powered by 3 massive command-line tools. You can run them anywhere
|
|
|
147
142
|
Fetch your live 14-day traffic and print a beautiful ASCII table directly in your console.
|
|
148
143
|
```bash
|
|
149
144
|
gitlytics fetch --token ghp_your_token_here --print-table
|
|
145
|
+
|
|
146
|
+
# Fetch specific metrics only (e.g., views and clones)
|
|
147
|
+
gitlytics fetch --token ghp_your_token_here --print-table --metrics views clones
|
|
150
148
|
```
|
|
151
149
|
|
|
152
150
|
### 2️⃣ `gitlytics sync` (Background Database Cron)
|
|
@@ -155,6 +153,9 @@ Tired of losing data? Use `sync` to permanently append today's traffic to a CSV
|
|
|
155
153
|
# Sync once
|
|
156
154
|
gitlytics sync --token ghp_your_token --data-dir ./data
|
|
157
155
|
|
|
156
|
+
# Sync specific metrics only
|
|
157
|
+
gitlytics sync --token ghp_your_token --data-dir ./data --metrics views clones
|
|
158
|
+
|
|
158
159
|
# Run permanently in the background as a cron job (runs at 11:00 PM every day)
|
|
159
160
|
gitlytics sync --token ghp_your_token --data-dir ./data --schedule-cron "0 23 * * *"
|
|
160
161
|
```
|
|
@@ -212,6 +213,7 @@ gitlytics.fetch_traffic(
|
|
|
212
213
|
| `print_table` | `bool` | `False` | If `True`, formats and prints a detailed ASCII traffic table to the console. |
|
|
213
214
|
| `return_format` | `str` | `"dataframe"` | The format of returned data: `"dataframe"` (Pandas DataFrame), `"timeseries"` (chart-ready nested dict), or `"summary"` (per-repo totals dict). |
|
|
214
215
|
| `save_file` | `str` | `None` | Optional. File path where the fetched data will be saved (CSV or JSON). |
|
|
216
|
+
| `metrics` | `list` | `None` | Optional. List of metrics to fetch (e.g., `["views", "clones"]`). |
|
|
215
217
|
|
|
216
218
|
---
|
|
217
219
|
|
|
@@ -248,6 +250,7 @@ gitlytics.sync(
|
|
|
248
250
|
| `schedule_cron` | `str` | `None` | Optional cron expression (e.g., `"*/15 * * * *"`). If set, runs an infinite scheduler loop. |
|
|
249
251
|
| `export_json` | `str` | `None` | Optional. Path to compile and export a consolidated history JSON for the frontend. |
|
|
250
252
|
| `export_public_only` | `bool` | `True` | Security firewall: if `True`, strips private repository data from the compiled `export_json`. |
|
|
253
|
+
| `metrics` | `list` | `None` | Optional. List of metrics to sync (e.g., `["views", "clones"]`). |
|
|
251
254
|
|
|
252
255
|
---
|
|
253
256
|
|
|
@@ -279,16 +282,33 @@ gitlytics.serve_dashboard(
|
|
|
279
282
|
|
|
280
283
|
## 📊 CSV Output Columns
|
|
281
284
|
|
|
282
|
-
When you sync data, the local CSV databases track
|
|
283
|
-
|
|
284
|
-
| Column |
|
|
285
|
-
|
|
286
|
-
| `
|
|
287
|
-
| `
|
|
288
|
-
| `
|
|
289
|
-
| `
|
|
290
|
-
| `
|
|
291
|
-
| `
|
|
285
|
+
When you sync data, the local CSV databases track 23 detailed metrics by default. If you customize the metrics using the `--metrics` CLI flag or `metrics` Python parameter, the CSV columns will dynamically include only the columns corresponding to your selection (along with the default `date`, `repository`, and `is_private` identification columns).
|
|
286
|
+
|
|
287
|
+
| Column | Type | Description |
|
|
288
|
+
|---|---|---|
|
|
289
|
+
| `date` | `str` | ISO date (`YYYY-MM-DD`) for this day's traffic snapshot. |
|
|
290
|
+
| `repository` | `str` | Full GitHub repository name (`owner/repo`). |
|
|
291
|
+
| `is_private` | `bool` | `True` if repository is private, `False` otherwise. |
|
|
292
|
+
| `views` | `int` | Total page views on this day. |
|
|
293
|
+
| `unique_visitors` | `int` | Unique visitors on this day. |
|
|
294
|
+
| `clones` | `int` | Total git clone operations on this day. |
|
|
295
|
+
| `unique_cloners` | `int` | Unique clone clients on this day. |
|
|
296
|
+
| `stars` | `int` | Current total star count snapshot. |
|
|
297
|
+
| `forks` | `int` | Current total fork count snapshot. |
|
|
298
|
+
| `language` | `str` | Primary programming language of the repository. |
|
|
299
|
+
| `topics` | `str` | JSON array containing repository tags/topics. |
|
|
300
|
+
| `watchers_count` | `int` | Total watchers of the repository. |
|
|
301
|
+
| `pushed_at` | `str` | Last push ISO timestamp. |
|
|
302
|
+
| `created_at` | `str` | Repository creation ISO timestamp. |
|
|
303
|
+
| `open_issues_count` | `int` | Total number of open issues. |
|
|
304
|
+
| `top_referrer` | `str` | Top external traffic referral source (14-day rolling window). |
|
|
305
|
+
| `top_referrer_views` | `int` | Views sent by the top referrer. |
|
|
306
|
+
| `top_referrer_uniques` | `int` | Uniques sent by the top referrer. |
|
|
307
|
+
| `_raw_referrers` | `str` | Raw JSON array of all referral sources. |
|
|
308
|
+
| `top_path` | `str` | Most visited repository file path (14-day rolling window). |
|
|
309
|
+
| `top_path_views` | `int` | Views for the top path. |
|
|
310
|
+
| `top_path_uniques` | `int` | Uniques for the top path. |
|
|
311
|
+
| `_raw_paths` | `str` | Raw JSON array of all popular paths. |
|
|
292
312
|
|
|
293
313
|
---
|
|
294
314
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<img src="
|
|
3
|
+
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/logo.png" alt="Gitlytics Logo" width="150" />
|
|
4
4
|
|
|
5
|
-
#
|
|
5
|
+
# Gitlytics
|
|
6
6
|
### GitHub Traffic Analytics & Automation
|
|
7
7
|
|
|
8
8
|
[](LICENSE)
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
[](https://dashboard.gitlytics.dev)
|
|
16
16
|
[](https://docs.gitlytics.dev)
|
|
17
17
|
|
|
18
|
+
<br/>Please consider giving this project a ⭐ if you find it helpful! <br/>
|
|
19
|
+
|
|
18
20
|
**Beautiful GitHub traffic analytics for all your repositories — public and private.** <br/> Track views, clones, referrers, and popular paths indefinitely.
|
|
19
21
|
|
|
20
22
|
✨ **[Try the live dashboard at dashboard.gitlytics.dev](https://dashboard.gitlytics.dev)** ✨
|
|
@@ -24,22 +26,16 @@
|
|
|
24
26
|
|
|
25
27
|
> **🐍 Native Python API**
|
|
26
28
|
>
|
|
27
|
-
> You can import Gitlytics natively into your own Python applications to
|
|
29
|
+
> You can import Gitlytics natively into your own Python applications to fetch live repository data like views, clones, stars, and referrers. Build custom integrations, run custom cron workflows, or serve the dashboard programmatically on your own cloud servers.
|
|
28
30
|
>
|
|
29
31
|
> 📚 **[Read the Full API Documentation](https://docs.gitlytics.dev)**
|
|
30
32
|
|
|
31
|
-
Please consider giving this project a ⭐ if you find it helpful!
|
|
32
|
-
|
|
33
33
|
</div>
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
37
|
<div align="center">
|
|
38
|
-
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/gitlytics_thumbnail_1.png" width="
|
|
39
|
-
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/gitlytics_thumbnail_2.png" width="49%" />
|
|
40
|
-
</div>
|
|
41
|
-
<div align="center">
|
|
42
|
-
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/gitlytics_thumbnail_3.png" width="98.5%" />
|
|
38
|
+
<img src="https://raw.githubusercontent.com/ameyac11/gitlytics/main/assets/gitlytics_thumbnail_1.png" width="100%" />
|
|
43
39
|
</div>
|
|
44
40
|
|
|
45
41
|
---
|
|
@@ -68,7 +64,7 @@ Please consider giving this project a ⭐ if you find it helpful!
|
|
|
68
64
|
|
|
69
65
|
The full Gitlytics ecosystem spans across a few repositories. If you are looking for the live web dashboard or the automation cron job, check out the links below:
|
|
70
66
|
|
|
71
|
-
- **[
|
|
67
|
+
- **[Gitlytics Web Ecosystem](https://github.com/ameyac11/gitlytics-deployement)**: The production landing page, React Dashboard, and React Documentation site.
|
|
72
68
|
- ⚙️ **[Gitlytics Automation](https://github.com/ameyac11/gitlytics-github-traffic-automation)**: The GitHub Action companion tool that automates fetching and saving to defeat GitHub's 14-day traffic limit.
|
|
73
69
|
|
|
74
70
|
---
|
|
@@ -114,6 +110,9 @@ Gitlytics is powered by 3 massive command-line tools. You can run them anywhere
|
|
|
114
110
|
Fetch your live 14-day traffic and print a beautiful ASCII table directly in your console.
|
|
115
111
|
```bash
|
|
116
112
|
gitlytics fetch --token ghp_your_token_here --print-table
|
|
113
|
+
|
|
114
|
+
# Fetch specific metrics only (e.g., views and clones)
|
|
115
|
+
gitlytics fetch --token ghp_your_token_here --print-table --metrics views clones
|
|
117
116
|
```
|
|
118
117
|
|
|
119
118
|
### 2️⃣ `gitlytics sync` (Background Database Cron)
|
|
@@ -122,6 +121,9 @@ Tired of losing data? Use `sync` to permanently append today's traffic to a CSV
|
|
|
122
121
|
# Sync once
|
|
123
122
|
gitlytics sync --token ghp_your_token --data-dir ./data
|
|
124
123
|
|
|
124
|
+
# Sync specific metrics only
|
|
125
|
+
gitlytics sync --token ghp_your_token --data-dir ./data --metrics views clones
|
|
126
|
+
|
|
125
127
|
# Run permanently in the background as a cron job (runs at 11:00 PM every day)
|
|
126
128
|
gitlytics sync --token ghp_your_token --data-dir ./data --schedule-cron "0 23 * * *"
|
|
127
129
|
```
|
|
@@ -179,6 +181,7 @@ gitlytics.fetch_traffic(
|
|
|
179
181
|
| `print_table` | `bool` | `False` | If `True`, formats and prints a detailed ASCII traffic table to the console. |
|
|
180
182
|
| `return_format` | `str` | `"dataframe"` | The format of returned data: `"dataframe"` (Pandas DataFrame), `"timeseries"` (chart-ready nested dict), or `"summary"` (per-repo totals dict). |
|
|
181
183
|
| `save_file` | `str` | `None` | Optional. File path where the fetched data will be saved (CSV or JSON). |
|
|
184
|
+
| `metrics` | `list` | `None` | Optional. List of metrics to fetch (e.g., `["views", "clones"]`). |
|
|
182
185
|
|
|
183
186
|
---
|
|
184
187
|
|
|
@@ -215,6 +218,7 @@ gitlytics.sync(
|
|
|
215
218
|
| `schedule_cron` | `str` | `None` | Optional cron expression (e.g., `"*/15 * * * *"`). If set, runs an infinite scheduler loop. |
|
|
216
219
|
| `export_json` | `str` | `None` | Optional. Path to compile and export a consolidated history JSON for the frontend. |
|
|
217
220
|
| `export_public_only` | `bool` | `True` | Security firewall: if `True`, strips private repository data from the compiled `export_json`. |
|
|
221
|
+
| `metrics` | `list` | `None` | Optional. List of metrics to sync (e.g., `["views", "clones"]`). |
|
|
218
222
|
|
|
219
223
|
---
|
|
220
224
|
|
|
@@ -246,16 +250,33 @@ gitlytics.serve_dashboard(
|
|
|
246
250
|
|
|
247
251
|
## 📊 CSV Output Columns
|
|
248
252
|
|
|
249
|
-
When you sync data, the local CSV databases track
|
|
250
|
-
|
|
251
|
-
| Column |
|
|
252
|
-
|
|
253
|
-
| `
|
|
254
|
-
| `
|
|
255
|
-
| `
|
|
256
|
-
| `
|
|
257
|
-
| `
|
|
258
|
-
| `
|
|
253
|
+
When you sync data, the local CSV databases track 23 detailed metrics by default. If you customize the metrics using the `--metrics` CLI flag or `metrics` Python parameter, the CSV columns will dynamically include only the columns corresponding to your selection (along with the default `date`, `repository`, and `is_private` identification columns).
|
|
254
|
+
|
|
255
|
+
| Column | Type | Description |
|
|
256
|
+
|---|---|---|
|
|
257
|
+
| `date` | `str` | ISO date (`YYYY-MM-DD`) for this day's traffic snapshot. |
|
|
258
|
+
| `repository` | `str` | Full GitHub repository name (`owner/repo`). |
|
|
259
|
+
| `is_private` | `bool` | `True` if repository is private, `False` otherwise. |
|
|
260
|
+
| `views` | `int` | Total page views on this day. |
|
|
261
|
+
| `unique_visitors` | `int` | Unique visitors on this day. |
|
|
262
|
+
| `clones` | `int` | Total git clone operations on this day. |
|
|
263
|
+
| `unique_cloners` | `int` | Unique clone clients on this day. |
|
|
264
|
+
| `stars` | `int` | Current total star count snapshot. |
|
|
265
|
+
| `forks` | `int` | Current total fork count snapshot. |
|
|
266
|
+
| `language` | `str` | Primary programming language of the repository. |
|
|
267
|
+
| `topics` | `str` | JSON array containing repository tags/topics. |
|
|
268
|
+
| `watchers_count` | `int` | Total watchers of the repository. |
|
|
269
|
+
| `pushed_at` | `str` | Last push ISO timestamp. |
|
|
270
|
+
| `created_at` | `str` | Repository creation ISO timestamp. |
|
|
271
|
+
| `open_issues_count` | `int` | Total number of open issues. |
|
|
272
|
+
| `top_referrer` | `str` | Top external traffic referral source (14-day rolling window). |
|
|
273
|
+
| `top_referrer_views` | `int` | Views sent by the top referrer. |
|
|
274
|
+
| `top_referrer_uniques` | `int` | Uniques sent by the top referrer. |
|
|
275
|
+
| `_raw_referrers` | `str` | Raw JSON array of all referral sources. |
|
|
276
|
+
| `top_path` | `str` | Most visited repository file path (14-day rolling window). |
|
|
277
|
+
| `top_path_views` | `int` | Views for the top path. |
|
|
278
|
+
| `top_path_uniques` | `int` | Uniques for the top path. |
|
|
279
|
+
| `_raw_paths` | `str` | Raw JSON array of all popular paths. |
|
|
259
280
|
|
|
260
281
|
---
|
|
261
282
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gitlytics"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.7"
|
|
8
8
|
description = "Monitor and automate your GitHub repository traffic analytics."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -51,7 +51,6 @@ dev = [
|
|
|
51
51
|
"pytest>=8.0.0",
|
|
52
52
|
"pytest-cov>=5.0.0",
|
|
53
53
|
"httpx>=0.27.0", # required by FastAPI TestClient (used in test_api.py)
|
|
54
|
-
"Faker>=20.0.0", # used by pytest-faker plugin for generating test data
|
|
55
54
|
"anyio[trio]>=4.0.0" # async test support
|
|
56
55
|
]
|
|
57
56
|
|
|
@@ -8,7 +8,9 @@ import json
|
|
|
8
8
|
|
|
9
9
|
# Single source of truth for the package version.
|
|
10
10
|
# Mirrors the version in pyproject.toml — keep them in sync.
|
|
11
|
-
__version__ = "0.1.
|
|
11
|
+
__version__ = "0.1.7"
|
|
12
|
+
|
|
13
|
+
__all__ = ["fetch_traffic", "sync", "serve_dashboard", "__version__"]
|
|
12
14
|
|
|
13
15
|
# Import the internal building blocks — users never call these directly
|
|
14
16
|
from .core import fetch_traffic_data, print_repo_table
|
|
@@ -20,7 +22,7 @@ logger = logging.getLogger(__name__)
|
|
|
20
22
|
logger.addHandler(logging.NullHandler())
|
|
21
23
|
|
|
22
24
|
|
|
23
|
-
def fetch_traffic(token: str, repo_name=None, print_table: bool = False, return_format: str = "dataframe", save_file: str = None):
|
|
25
|
+
def fetch_traffic(token: str, repo_name=None, print_table: bool = False, return_format: str = "dataframe", save_file: str = None, metrics: list = None):
|
|
24
26
|
"""
|
|
25
27
|
Fetches the last 14 days of traffic data for one or all repositories.
|
|
26
28
|
|
|
@@ -35,13 +37,14 @@ def fetch_traffic(token: str, repo_name=None, print_table: bool = False, return_
|
|
|
35
37
|
``"summary"`` — returns a per-repo totals dict.
|
|
36
38
|
save_file: Optional path to save the output. Extension determines
|
|
37
39
|
format: ``.json`` writes JSON, anything else writes CSV.
|
|
40
|
+
metrics: Optional list of metrics to fetch (e.g., ``["views", "clones"]``).
|
|
38
41
|
|
|
39
42
|
Returns:
|
|
40
43
|
A ``pandas.DataFrame`` when ``return_format="dataframe"``, otherwise
|
|
41
44
|
a ``dict`` matching the requested format.
|
|
42
45
|
"""
|
|
43
46
|
# Hit the GitHub API and get back a tidy DataFrame (one row per day per repo)
|
|
44
|
-
df = fetch_traffic_data(token, repo_name)
|
|
47
|
+
df = fetch_traffic_data(token, repo_name, metrics)
|
|
45
48
|
|
|
46
49
|
# Print the ASCII table to the console if the user asked for it
|
|
47
50
|
if print_table:
|
|
@@ -79,7 +82,7 @@ def fetch_traffic(token: str, repo_name=None, print_table: bool = False, return_
|
|
|
79
82
|
return payload
|
|
80
83
|
|
|
81
84
|
|
|
82
|
-
def sync(token: str, repo_name=None, data_dir: str = "./data", output_mode: str = "monthly", schedule_cron: str = None, export_json: str = None, export_public_only: bool = True):
|
|
85
|
+
def sync(token: str, repo_name=None, data_dir: str = "./data", output_mode: str = "monthly", schedule_cron: str = None, export_json: str = None, export_public_only: bool = True, metrics: list = None):
|
|
83
86
|
"""
|
|
84
87
|
Fetches data and appends it to a local CSV database, optionally running as a permanent background daemon.
|
|
85
88
|
|
|
@@ -93,7 +96,13 @@ def sync(token: str, repo_name=None, data_dir: str = "./data", output_mode: str
|
|
|
93
96
|
export_json: Path to export the merged historical database as a JSON file.
|
|
94
97
|
export_public_only: If ``True`` (default), strips private repos from the
|
|
95
98
|
exported JSON — acts as a security firewall.
|
|
99
|
+
metrics: Optional list of metrics to fetch (e.g., ``["views", "clones"]``).
|
|
96
100
|
"""
|
|
101
|
+
if data_dir and not os.path.isabs(data_dir) and not os.path.exists(data_dir):
|
|
102
|
+
parent_dir = os.path.join("..", data_dir)
|
|
103
|
+
if os.path.exists(parent_dir):
|
|
104
|
+
data_dir = parent_dir
|
|
105
|
+
|
|
97
106
|
# Hand off to the automation engine — it handles deduplication and schema migration
|
|
98
107
|
run_sync(
|
|
99
108
|
token=token,
|
|
@@ -102,7 +111,8 @@ def sync(token: str, repo_name=None, data_dir: str = "./data", output_mode: str
|
|
|
102
111
|
output_mode=output_mode,
|
|
103
112
|
schedule_cron=schedule_cron,
|
|
104
113
|
export_json=export_json,
|
|
105
|
-
export_public_only=export_public_only
|
|
114
|
+
export_public_only=export_public_only,
|
|
115
|
+
metrics=metrics
|
|
106
116
|
)
|
|
107
117
|
|
|
108
118
|
|
|
@@ -130,11 +140,31 @@ def serve_dashboard(host: str = "127.0.0.1", port: int = 8000, token: str = None
|
|
|
130
140
|
"Install them with: pip install \"gitlytics[dashboard]\""
|
|
131
141
|
)
|
|
132
142
|
|
|
133
|
-
#
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
# M-7: save original values so they are restored when the server stops
|
|
144
|
+
_orig_token = os.environ.get("GITLYTICS_TOKEN")
|
|
145
|
+
_orig_data_dir = os.environ.get("GITLYTICS_DATA_DIR")
|
|
146
|
+
try:
|
|
147
|
+
if token:
|
|
148
|
+
os.environ["GITLYTICS_TOKEN"] = token
|
|
149
|
+
if data_dir:
|
|
150
|
+
from pathlib import Path
|
|
151
|
+
abs_data_dir = os.path.abspath(data_dir)
|
|
152
|
+
if not os.path.exists(abs_data_dir) and not os.path.isabs(data_dir):
|
|
153
|
+
parent_dir = os.path.abspath(os.path.join("..", data_dir))
|
|
154
|
+
if os.path.exists(parent_dir):
|
|
155
|
+
abs_data_dir = parent_dir
|
|
156
|
+
if not os.path.exists(abs_data_dir):
|
|
157
|
+
print(f"⚠️ Warning: The specified data directory '{data_dir}' (resolved to '{abs_data_dir}') does not exist.")
|
|
158
|
+
elif not any(Path(abs_data_dir).glob("traffic_*.csv")):
|
|
159
|
+
print(f"⚠️ Warning: No traffic_*.csv database files found in '{data_dir}' (resolved to '{abs_data_dir}').")
|
|
160
|
+
os.environ["GITLYTICS_DATA_DIR"] = abs_data_dir
|
|
161
|
+
uvicorn.run("gitlytics.api:app", host=host, port=port, reload=False)
|
|
162
|
+
finally:
|
|
163
|
+
if _orig_token is None:
|
|
164
|
+
os.environ.pop("GITLYTICS_TOKEN", None)
|
|
165
|
+
else:
|
|
166
|
+
os.environ["GITLYTICS_TOKEN"] = _orig_token
|
|
167
|
+
if _orig_data_dir is None:
|
|
168
|
+
os.environ.pop("GITLYTICS_DATA_DIR", None)
|
|
169
|
+
else:
|
|
170
|
+
os.environ["GITLYTICS_DATA_DIR"] = _orig_data_dir
|