google-analytics-cli 0.1.0rc1__py3-none-any.whl

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.
Files changed (49) hide show
  1. ga_cli/__init__.py +8 -0
  2. ga_cli/api/__init__.py +0 -0
  3. ga_cli/api/client.py +142 -0
  4. ga_cli/auth/__init__.py +35 -0
  5. ga_cli/auth/credentials.py +126 -0
  6. ga_cli/auth/oauth.py +322 -0
  7. ga_cli/auth/service_account.py +155 -0
  8. ga_cli/commands/__init__.py +0 -0
  9. ga_cli/commands/access_bindings.py +254 -0
  10. ga_cli/commands/access_reports.py +201 -0
  11. ga_cli/commands/account_summaries.py +68 -0
  12. ga_cli/commands/accounts.py +297 -0
  13. ga_cli/commands/agent_cmd.py +776 -0
  14. ga_cli/commands/annotations.py +264 -0
  15. ga_cli/commands/audiences.py +223 -0
  16. ga_cli/commands/auth_cmd.py +205 -0
  17. ga_cli/commands/bigquery_links.py +309 -0
  18. ga_cli/commands/calculated_metrics.py +312 -0
  19. ga_cli/commands/channel_groups.py +223 -0
  20. ga_cli/commands/completions_cmd.py +55 -0
  21. ga_cli/commands/config_cmd.py +113 -0
  22. ga_cli/commands/custom_dimensions.py +272 -0
  23. ga_cli/commands/custom_metrics.py +305 -0
  24. ga_cli/commands/data_retention.py +153 -0
  25. ga_cli/commands/data_streams.py +277 -0
  26. ga_cli/commands/event_create_rules.py +250 -0
  27. ga_cli/commands/event_edit_rules.py +292 -0
  28. ga_cli/commands/firebase_links.py +142 -0
  29. ga_cli/commands/google_ads_links.py +225 -0
  30. ga_cli/commands/key_events.py +269 -0
  31. ga_cli/commands/mp_secrets.py +265 -0
  32. ga_cli/commands/properties.py +330 -0
  33. ga_cli/commands/property_settings.py +287 -0
  34. ga_cli/commands/reports.py +726 -0
  35. ga_cli/commands/upgrade_cmd.py +148 -0
  36. ga_cli/config/__init__.py +0 -0
  37. ga_cli/config/constants.py +61 -0
  38. ga_cli/config/store.py +115 -0
  39. ga_cli/main.py +110 -0
  40. ga_cli/utils/__init__.py +20 -0
  41. ga_cli/utils/describe.py +129 -0
  42. ga_cli/utils/dry_run.py +40 -0
  43. ga_cli/utils/errors.py +150 -0
  44. ga_cli/utils/output.py +209 -0
  45. ga_cli/utils/pagination.py +93 -0
  46. google_analytics_cli-0.1.0rc1.dist-info/METADATA +269 -0
  47. google_analytics_cli-0.1.0rc1.dist-info/RECORD +49 -0
  48. google_analytics_cli-0.1.0rc1.dist-info/WHEEL +4 -0
  49. google_analytics_cli-0.1.0rc1.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,269 @@
1
+ Metadata-Version: 2.4
2
+ Name: google-analytics-cli
3
+ Version: 0.1.0rc1
4
+ Summary: Command-line interface for Google Analytics 4
5
+ Project-URL: Homepage, https://github.com/daidalytics/google-analytics-cli
6
+ Project-URL: Repository, https://github.com/daidalytics/google-analytics-cli
7
+ Project-URL: Issues, https://github.com/daidalytics/google-analytics-cli/issues
8
+ Author: Gunnar Griese
9
+ License: MIT
10
+ Keywords: analytics,cli,ga4,google-analytics
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Internet :: WWW/HTTP
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: google-api-python-client>=2.0
23
+ Requires-Dist: google-auth-oauthlib>=1.0
24
+ Requires-Dist: google-auth>=2.0
25
+ Requires-Dist: packaging>=23.0
26
+ Requires-Dist: platformdirs>=4.0
27
+ Requires-Dist: questionary>=2.0
28
+ Requires-Dist: rich>=13.0
29
+ Requires-Dist: typer[all]>=0.9.0
30
+ Description-Content-Type: text/markdown
31
+
32
+ # GA CLI
33
+
34
+ Command-line interface for Google Analytics 4.
35
+
36
+ Manage GA4 accounts, properties, data streams, and run reports — all from your terminal.
37
+
38
+ ## Features
39
+
40
+ - **Authentication** — OAuth 2.0 (browser-based) and service account support
41
+ - **Account management** — List, inspect, and update GA4 accounts
42
+ - **Property management** — List, create, inspect, update, and delete GA4 properties
43
+ - **Data stream management** — List, create, inspect, update, and delete web, Android, and iOS data streams
44
+ - **Custom dimensions & metrics** — List, create, update, and archive custom definitions
45
+ - **Key events** — List, create, update, and delete key events (conversions)
46
+ - **Reporting** — Run custom reports, pivot reports, real-time reports with live polling, check compatibility, and build reports interactively
47
+ - **Flexible output** — Table (default), JSON, and compact output formats
48
+ - **Self-update** — Check for and install updates via `ga upgrade`
49
+ - **Schema introspection** — `ga --describe` outputs JSON Schema for all commands (agent/MCP-ready)
50
+ - **Shell completions** — Generate completion scripts for bash, zsh, and fish
51
+ - **Interactive setup** — Guided configuration wizard via `ga config setup`
52
+
53
+ ## Installation
54
+
55
+ ### From PyPI (recommended)
56
+
57
+ ```bash
58
+ # pipx (recommended for CLI tools — isolated env)
59
+ pipx install google-analytics-cli
60
+
61
+ # uv
62
+ uv tool install google-analytics-cli
63
+
64
+ # pip
65
+ pip install google-analytics-cli
66
+ ```
67
+
68
+ ### Quick install (script)
69
+
70
+ ```bash
71
+ curl -fsSL https://raw.githubusercontent.com/daidalytics/google-analytics-cli/master/install.sh | bash
72
+ ```
73
+
74
+ ### From GitHub
75
+
76
+ ```bash
77
+ # With uv
78
+ uv pip install git+https://github.com/daidalytics/google-analytics-cli.git
79
+
80
+ # With pip
81
+ pip install git+https://github.com/daidalytics/google-analytics-cli.git
82
+ ```
83
+
84
+ ### From source
85
+
86
+ ```bash
87
+ git clone https://github.com/daidalytics/google-analytics-cli.git
88
+ cd google-analytics-cli
89
+ uv sync
90
+ uv run ga --help
91
+ ```
92
+
93
+ ### One-off execution (no install)
94
+
95
+ ```bash
96
+ uvx --from git+https://github.com/daidalytics/google-analytics-cli.git ga --help
97
+ ```
98
+
99
+ ## Quick Start
100
+
101
+ ```bash
102
+ # 1. Authenticate
103
+ ga auth login
104
+
105
+ # 2. List your accounts
106
+ ga accounts list
107
+
108
+ # 3. List properties for an account
109
+ ga properties list --account-id 123456789
110
+
111
+ # 4. Run a report
112
+ ga reports run --property-id 987654321 \
113
+ --metrics sessions,totalUsers \
114
+ --dimensions date \
115
+ --start-date 7daysAgo
116
+ ```
117
+
118
+ ## Setup
119
+
120
+ ### 1. Create OAuth credentials
121
+
122
+ Create an OAuth 2.0 Client ID in the [Google Cloud Console](https://console.cloud.google.com/apis/credentials):
123
+
124
+ 1. Go to **APIs & Services > Credentials**
125
+ 2. Click **Create Credentials > OAuth client ID**
126
+ 3. Choose **Desktop app** as the application type
127
+ 4. Download the JSON file
128
+
129
+ Make sure the following APIs are enabled in your GCP project:
130
+ - Google Analytics Admin API
131
+ - Google Analytics Data API
132
+
133
+ ### 2. Configure client credentials
134
+
135
+ Copy the downloaded `client_secret.json` to the GA CLI config directory:
136
+
137
+ ```bash
138
+ mkdir -p ~/.config/ga-cli
139
+ cp /path/to/client_secret.json ~/.config/ga-cli/client_secret.json
140
+ ```
141
+
142
+ Alternatively, set environment variables:
143
+
144
+ ```bash
145
+ export GA_CLI_CLIENT_ID="your-client-id"
146
+ export GA_CLI_CLIENT_SECRET="your-client-secret"
147
+ ```
148
+
149
+ ### 3. Authenticate
150
+
151
+ ```bash
152
+ ga auth login
153
+ ```
154
+
155
+ This opens your browser for Google OAuth consent and stores the token locally at `~/.config/ga-cli/credentials.json`.
156
+
157
+ #### Service account (alternative)
158
+
159
+ ```bash
160
+ ga auth login --service-account /path/to/key.json
161
+ ```
162
+
163
+ Or set an environment variable:
164
+
165
+ ```bash
166
+ export GA_CLI_SERVICE_ACCOUNT="/path/to/key.json"
167
+ ```
168
+
169
+ ## Command Reference
170
+
171
+ | Command | Subcommands | Description |
172
+ |---------|-------------|-------------|
173
+ | `ga auth` | `login`, `logout`, `status` | Manage authentication |
174
+ | `ga config` | `setup`, `get`, `set`, `unset`, `path`, `reset` | Manage CLI configuration |
175
+ | `ga accounts` | `list`, `get`, `update` | List, inspect, and update GA4 accounts |
176
+ | `ga account-summaries` | `list` | Quick overview of all accounts and properties |
177
+ | `ga properties` | `list`, `get`, `create`, `update`, `delete` | Manage GA4 properties |
178
+ | `ga custom-dimensions` | `list`, `get`, `create`, `update`, `archive` | Manage custom dimensions |
179
+ | `ga custom-metrics` | `list`, `get`, `create`, `update`, `archive` | Manage custom metrics |
180
+ | `ga data-streams` | `list`, `get`, `create`, `update`, `delete` | Manage data streams |
181
+ | `ga key-events` | `list`, `get`, `create`, `update`, `delete` | Manage key events (conversions) |
182
+ | `ga reports` | `run`, `pivot`, `check-compatibility`, `metadata`, `realtime`, `build` | Run and build reports |
183
+ | `ga upgrade` | `--check`, `--force` | Check for and install updates |
184
+ | `ga completions` | `bash`, `zsh`, `fish` | Generate shell completion scripts |
185
+
186
+ Use `ga <command> --help` for detailed usage of any command, or `ga --describe` for the full CLI schema as JSON.
187
+
188
+ ### Output formats
189
+
190
+ All read commands support `--output` (`-o`) to control output format:
191
+
192
+ ```bash
193
+ ga accounts list --output json # JSON output
194
+ ga accounts list --output table # Table output (default)
195
+ ga accounts list --output compact # Minimal ID + name output
196
+ ```
197
+
198
+ ## Global Options
199
+
200
+ ```
201
+ --help, -h Show help
202
+ --version, -v Show version
203
+ --quiet, -q Suppress non-essential output
204
+ --no-color Disable colored output
205
+ --describe Show full CLI schema as JSON (for agents and tooling)
206
+ ```
207
+
208
+ ## Shell Completions
209
+
210
+ ```bash
211
+ ga completions bash > ~/.bash_completion.d/ga
212
+ ga completions zsh > ~/.zsh/completions/_ga
213
+ ga completions fish > ~/.config/fish/completions/ga.fish
214
+ ```
215
+
216
+ ## Environment Variables
217
+
218
+ | Variable | Description |
219
+ |----------|-------------|
220
+ | `GA_CLI_SERVICE_ACCOUNT` | Path to service account key file |
221
+ | `GOOGLE_APPLICATION_CREDENTIALS` | Standard GCP credential path (fallback) |
222
+ | `GA_CLI_CONFIG_DIR` | Override config directory |
223
+ | `GA_CLI_CLIENT_ID` | OAuth client ID (alternative to client_secret.json) |
224
+ | `GA_CLI_CLIENT_SECRET` | OAuth client secret (alternative to client_secret.json) |
225
+ | `NO_COLOR` | Disable colored output |
226
+
227
+ ## CI/CD Integration
228
+
229
+ ```yaml
230
+ jobs:
231
+ ga-report:
232
+ runs-on: ubuntu-latest
233
+ steps:
234
+ - name: Install GA CLI
235
+ run: pip install google-analytics-cli
236
+
237
+ - name: Export daily report
238
+ run: |
239
+ echo '${{ secrets.GA_SERVICE_ACCOUNT_KEY }}' > /tmp/sa-key.json
240
+ ga auth login --service-account /tmp/sa-key.json
241
+ ga reports run -p ${{ vars.GA_PROPERTY_ID }} \
242
+ --metrics sessions,users --dimensions date \
243
+ --start-date 7daysAgo -o json > report.json
244
+ rm /tmp/sa-key.json
245
+ ```
246
+
247
+ ## Privacy
248
+
249
+ GA CLI stores authentication credentials locally on your machine. No data is sent to any third party — all communication is directly between your machine and Google's APIs.
250
+
251
+ ## Development
252
+
253
+ ```bash
254
+ # Install with dev dependencies
255
+ uv sync
256
+
257
+ # Run the CLI
258
+ uv run ga --help
259
+
260
+ # Run tests
261
+ uv run pytest
262
+
263
+ # Lint
264
+ uv run ruff check src/ tests/
265
+ ```
266
+
267
+ ## License
268
+
269
+ MIT
@@ -0,0 +1,49 @@
1
+ ga_cli/__init__.py,sha256=u1fUfOShfVMGpKVw01qh843uLrdZ6cArcFt-6I99WK0,227
2
+ ga_cli/main.py,sha256=uksuGR7J3L5nSbLeoztM4Sij5efMJ5hIHq0JI477T70,4425
3
+ ga_cli/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ ga_cli/api/client.py,sha256=GM53azK0cT0a_T9AYGmJfQZdCPanlXTnLXhKXUfLkWA,4375
5
+ ga_cli/auth/__init__.py,sha256=PItt3BDK4o4wDLyUllWt1Q5IjYaz3l_mTywj4w7YxII,764
6
+ ga_cli/auth/credentials.py,sha256=gja3dm060CZBeNyS5W8CMgMbiW_8eZjHUHnjUqwCw-Y,3512
7
+ ga_cli/auth/oauth.py,sha256=KMKQmuFsvNFnTVFHIcGqsjBnKMaS-yDd6fwvrpc9m7g,10086
8
+ ga_cli/auth/service_account.py,sha256=k1UaAwi-8OtKewsdeAvrhFVhEM6NAeBAn5jELuVMW7A,4689
9
+ ga_cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ ga_cli/commands/access_bindings.py,sha256=fNUJFFA9-Xr83sPAPy38PnwZPBJu6pskQL4DoHzseIg,8600
11
+ ga_cli/commands/access_reports.py,sha256=Rdqfp3LE9ar6mpGXPz8ogIwLYbrnZGhLKkeuJAEhPVI,6846
12
+ ga_cli/commands/account_summaries.py,sha256=TWdzx55X3m_c6Ji_yCw3JfTYqLKOYnZnLe0qjp2RXH8,2263
13
+ ga_cli/commands/accounts.py,sha256=BOIMbusC4bP5ozU-QC3yt2dYyQ-vLoY_kQQvW_M2-3Q,9977
14
+ ga_cli/commands/agent_cmd.py,sha256=aHBjeOu78xGfLlTzg0D6UpCcvz-v948ONQAV5IuYUVw,34971
15
+ ga_cli/commands/annotations.py,sha256=5syML-sRiaeVCJXqR6ftfniyk20oySe4df282owJziY,8706
16
+ ga_cli/commands/audiences.py,sha256=RKNZB4RkHnpmI-efBi3g54Co_Ez2bR8MhDijRIxdSCs,7121
17
+ ga_cli/commands/auth_cmd.py,sha256=wQUOtieylMUGLHd7PAaxUtX4EmVYNMHbAqDsJPRfIgI,6554
18
+ ga_cli/commands/bigquery_links.py,sha256=sBmEhA1W2HWWK-KcH6wirtYA9TbAYoChEqWNK8cq04I,10987
19
+ ga_cli/commands/calculated_metrics.py,sha256=BvDZajhTjOZ4u9nZu2oYI8pM7wksUb1_VLQwTxEC1Js,10046
20
+ ga_cli/commands/channel_groups.py,sha256=3CTzttnQuyZiJ-PPNnuHlbyfNo8RR9xDh7vMavk8ijk,7259
21
+ ga_cli/commands/completions_cmd.py,sha256=01aBw0jNsR5mD3USQOACwDBreh2V3xaJN3wGxmeVGYw,1372
22
+ ga_cli/commands/config_cmd.py,sha256=knYM0DxbPiq-IqqspQzVVgOtPKxi5ljjoXOZCb-u0mw,3061
23
+ ga_cli/commands/custom_dimensions.py,sha256=0MAIxq6kEvlrQiGRJFZn5Y_SI9-wFTjZg_cy5UQ41rE,8997
24
+ ga_cli/commands/custom_metrics.py,sha256=i9p0LH2L4ES2kJkrxOihY4NLVw3hCLDr5xRemMnw3TE,9963
25
+ ga_cli/commands/data_retention.py,sha256=3dE1VbnFJ_KZazDeVZzy95WRQ2q8xLLg_Atr1fkclqs,4871
26
+ ga_cli/commands/data_streams.py,sha256=s8vyWz_znMWvlJ7jihXS4bhArwLaAmfr1JxylbB8_ns,8887
27
+ ga_cli/commands/event_create_rules.py,sha256=SfwVTq5cnSIZ4WvIBnUUB2p54VbjEy_lnN-KohlAQ_8,8133
28
+ ga_cli/commands/event_edit_rules.py,sha256=16celmbTD1LgYUrsjv1Eks9TRykIvas3je197nNByrQ,9443
29
+ ga_cli/commands/firebase_links.py,sha256=DKkwqdzKEQhc1nzscBNFRtHKLZhvnBXYCBXrn04SSyQ,4426
30
+ ga_cli/commands/google_ads_links.py,sha256=jSoLy26A0NX_3M0WPMtVCtk8CKLXywqBj-XS54eBqVA,7079
31
+ ga_cli/commands/key_events.py,sha256=4xRYXl8UU_rZJwhK4IESjFBirpNaMRsXIwpwriyfBP8,8571
32
+ ga_cli/commands/mp_secrets.py,sha256=fbK9F3jr8N68nSyAtKRT3a15n7sTfFH8hmBTl8337v8,8634
33
+ ga_cli/commands/properties.py,sha256=AAp3Aa7g7ZZt2vecG3RxBzi8NTRO6bIaIUmV-Pzrfjo,11584
34
+ ga_cli/commands/property_settings.py,sha256=Qlz2a-1ufPUwbN7CfY3XepW6mCv4UtMUj1aaMgSA9l8,10265
35
+ ga_cli/commands/reports.py,sha256=2Gw5Nd9fz0DKw8TUfgLThqzEz3swCKsbaUnf1oM2MYI,25960
36
+ ga_cli/commands/upgrade_cmd.py,sha256=LhRZ4cjXqAz9xx1CDYYgWeSp_xhkLiHdpOV3XflcahA,4726
37
+ ga_cli/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ ga_cli/config/constants.py,sha256=Oo_gg1R8WVNColi3wFLCKQkVH_DiCPL_07HQFt9HgL4,1651
39
+ ga_cli/config/store.py,sha256=fqB3AV3DcAz94sq2qXNEI8d6MBfXA945QFaYq25NraU,3294
40
+ ga_cli/utils/__init__.py,sha256=AWd3N-hbTXsY9sg_LYchPFlgfouq2KlEgU-ecL5cG34,908
41
+ ga_cli/utils/describe.py,sha256=QtCXB4Nm3DKb9BBxDEQbHv6UbDL3bo7WRYRucIEWaXs,3999
42
+ ga_cli/utils/dry_run.py,sha256=DD4Id-0Y6eSKC7KiknAtXDxKhyxQRuSekjgNOQF3EJA,1149
43
+ ga_cli/utils/errors.py,sha256=l0Iwjmj1QqzLU032QAiVUnIbfntkxoIAZqyQCfgACCE,4465
44
+ ga_cli/utils/output.py,sha256=0ihWQi7-kGSkNb-0OTFv_12ZmqVUjpZQLEGjvNrxUeE,6092
45
+ ga_cli/utils/pagination.py,sha256=w6_To6luCR54M04Uk_WFFydvProG2yGxN-CzkzSk9c4,2380
46
+ google_analytics_cli-0.1.0rc1.dist-info/METADATA,sha256=8EgBv0ux-hl2sO9o4Ci8nvtTUUM0XtME3ydVjhsDAZE,8193
47
+ google_analytics_cli-0.1.0rc1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
48
+ google_analytics_cli-0.1.0rc1.dist-info/entry_points.txt,sha256=J1Jvi1IZo4YujxqhyipvHz4NAepNhxZo7g_WyQIIOz0,39
49
+ google_analytics_cli-0.1.0rc1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ga = ga_cli.main:run