ga4-cli 0.1.1__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.
Files changed (37) hide show
  1. ga4_cli-0.1.1/LICENSE +21 -0
  2. ga4_cli-0.1.1/PKG-INFO +308 -0
  3. ga4_cli-0.1.1/README.md +265 -0
  4. ga4_cli-0.1.1/ga4_cli.egg-info/PKG-INFO +308 -0
  5. ga4_cli-0.1.1/ga4_cli.egg-info/SOURCES.txt +35 -0
  6. ga4_cli-0.1.1/ga4_cli.egg-info/dependency_links.txt +1 -0
  7. ga4_cli-0.1.1/ga4_cli.egg-info/entry_points.txt +2 -0
  8. ga4_cli-0.1.1/ga4_cli.egg-info/requires.txt +5 -0
  9. ga4_cli-0.1.1/ga4_cli.egg-info/top_level.txt +2 -0
  10. ga4_cli-0.1.1/ga_cli/__init__.py +3 -0
  11. ga4_cli-0.1.1/ga_cli/auth.py +59 -0
  12. ga4_cli-0.1.1/ga_cli/cli.py +35 -0
  13. ga4_cli-0.1.1/ga_cli/commands/__init__.py +0 -0
  14. ga4_cli-0.1.1/ga_cli/commands/accounts.py +81 -0
  15. ga4_cli-0.1.1/ga_cli/commands/config.py +65 -0
  16. ga4_cli-0.1.1/ga_cli/commands/datastreams.py +146 -0
  17. ga4_cli-0.1.1/ga_cli/commands/properties.py +151 -0
  18. ga4_cli-0.1.1/ga_cli/config.py +95 -0
  19. ga4_cli-0.1.1/ga_cli/decorators.py +90 -0
  20. ga4_cli-0.1.1/ga_cli/errors.py +35 -0
  21. ga4_cli-0.1.1/ga_cli/formatters/__init__.py +0 -0
  22. ga4_cli-0.1.1/ga_cli/formatters/json.py +9 -0
  23. ga4_cli-0.1.1/ga_cli/formatters/table.py +23 -0
  24. ga4_cli-0.1.1/ga_cli/logging_config.py +44 -0
  25. ga4_cli-0.1.1/ga_cli/output.py +59 -0
  26. ga4_cli-0.1.1/ga_cli/retry.py +40 -0
  27. ga4_cli-0.1.1/ga_cli/validators.py +52 -0
  28. ga4_cli-0.1.1/setup.cfg +4 -0
  29. ga4_cli-0.1.1/setup.py +50 -0
  30. ga4_cli-0.1.1/tests/__init__.py +0 -0
  31. ga4_cli-0.1.1/tests/conftest.py +89 -0
  32. ga4_cli-0.1.1/tests/test_accounts.py +49 -0
  33. ga4_cli-0.1.1/tests/test_auth.py +74 -0
  34. ga4_cli-0.1.1/tests/test_cli.py +52 -0
  35. ga4_cli-0.1.1/tests/test_config.py +140 -0
  36. ga4_cli-0.1.1/tests/test_errors.py +73 -0
  37. ga4_cli-0.1.1/tests/test_validators.py +146 -0
ga4_cli-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GA CLI Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ga4_cli-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,308 @@
1
+ Metadata-Version: 2.4
2
+ Name: ga4-cli
3
+ Version: 0.1.1
4
+ Summary: Command-line interface for Google Analytics 4
5
+ Home-page: https://github.com/sulimanbenhalim/ga-cli
6
+ Author: Suliman Ben Halim
7
+ Author-email: suliman.benhalim@binary.ly
8
+ License: MIT
9
+ Project-URL: Bug Reports, https://github.com/sulimanbenhalim/ga-cli/issues
10
+ Project-URL: Source, https://github.com/sulimanbenhalim/ga-cli
11
+ Project-URL: Documentation, https://github.com/sulimanbenhalim/ga-cli#readme
12
+ Keywords: google-analytics ga4 cli command-line
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: click<9.0.0,>=8.0.0
26
+ Requires-Dist: google-analytics-admin<1.0.0,>=0.27.0
27
+ Requires-Dist: google-auth<3.0.0,>=2.0.0
28
+ Requires-Dist: rich<14.0.0,>=13.0.0
29
+ Requires-Dist: pytz>=2023.3
30
+ Dynamic: author
31
+ Dynamic: author-email
32
+ Dynamic: classifier
33
+ Dynamic: description
34
+ Dynamic: description-content-type
35
+ Dynamic: home-page
36
+ Dynamic: keywords
37
+ Dynamic: license
38
+ Dynamic: license-file
39
+ Dynamic: project-url
40
+ Dynamic: requires-dist
41
+ Dynamic: requires-python
42
+ Dynamic: summary
43
+
44
+ # GA CLI - Google Analytics Command Line Interface
45
+
46
+ A command-line interface tool for managing Google Analytics 4 properties, accounts, and data streams.
47
+
48
+ **Note**: The package is published as `ga4-cli` on PyPI, but the command is `ga-cli`.
49
+
50
+ ## Features
51
+
52
+ - List and manage Google Analytics accounts
53
+ - Create and manage GA4 properties
54
+ - Manage data streams and retrieve measurement IDs
55
+ - Beautiful table output with Rich
56
+ - JSON output support
57
+ - Authentication via service account credentials
58
+
59
+ ## Installation
60
+
61
+ ### Using pip
62
+
63
+ ```bash
64
+ pip install ga4-cli
65
+ ```
66
+
67
+ After installation, the command is available as `ga-cli`:
68
+
69
+ ```bash
70
+ ga-cli --version
71
+ ga-cli --help
72
+ ```
73
+
74
+ ### Using Homebrew (macOS/Linux)
75
+
76
+ ```bash
77
+ # Add the tap
78
+ brew tap sulimanbenhalim/ga-cli
79
+
80
+ # Install
81
+ brew install ga-cli
82
+
83
+ # Use it
84
+ ga-cli --version
85
+ ```
86
+
87
+ ### Using Docker
88
+
89
+ ```bash
90
+ # Pull from Docker Hub
91
+ docker pull sulimanbenhalim/ga-cli:latest
92
+
93
+ # Or build locally
94
+ docker build -t ga-cli .
95
+
96
+ # Run with credentials mounted
97
+ docker run -v /path/to/credentials.json:/credentials.json \
98
+ -v ~/.ga-cli:/root/.ga-cli \
99
+ ga-cli accounts list --credentials /credentials.json
100
+ ```
101
+
102
+ ### Download Binary (No Python Required)
103
+
104
+ Download standalone binaries from [GitHub Releases](https://github.com/sulimanbenhalim/ga-cli/releases):
105
+
106
+ **Linux/macOS:**
107
+ ```bash
108
+ # Download and extract
109
+ curl -L -o ga-cli.tar.gz https://github.com/sulimanbenhalim/ga-cli/releases/latest/download/ga-cli-linux-amd64.tar.gz
110
+ tar -xzf ga-cli.tar.gz
111
+ chmod +x ga-cli
112
+ sudo mv ga-cli /usr/local/bin/
113
+ ```
114
+
115
+ **Windows:**
116
+ Download `ga-cli-windows-amd64.exe.zip` from the releases page, extract, and run.
117
+
118
+ ### From source
119
+
120
+ ```bash
121
+ git clone https://github.com/sulimanbenhalim/ga-cli.git
122
+ cd ga-cli
123
+ pip install -e .
124
+ ```
125
+
126
+ ## Setup
127
+
128
+ ### 1. Get Google Service Account Credentials
129
+
130
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
131
+ 2. Create or select a project
132
+ 3. Enable the Google Analytics Admin API
133
+ 4. Create a service account with Analytics Admin permissions
134
+ 5. Download the JSON credentials file
135
+
136
+ ### 2. Initialize GA CLI
137
+
138
+ ```bash
139
+ ga-cli config init
140
+ ```
141
+
142
+ This will prompt you for the path to your service account JSON file and test the credentials.
143
+
144
+ Alternatively, set the environment variable:
145
+
146
+ ```bash
147
+ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
148
+ ```
149
+
150
+ ## Usage
151
+
152
+ ### Configuration
153
+
154
+ ```bash
155
+ # Initialize with credentials
156
+ ga-cli config init
157
+
158
+ # Show current configuration
159
+ ga-cli config show
160
+ ```
161
+
162
+ ### Accounts
163
+
164
+ ```bash
165
+ # List all accounts
166
+ ga-cli accounts list
167
+
168
+ # Get account details
169
+ ga-cli accounts get <account-id>
170
+
171
+ # Output as JSON
172
+ ga-cli accounts list --format json
173
+ ```
174
+
175
+ ### Properties
176
+
177
+ ```bash
178
+ # List properties for an account
179
+ ga-cli properties list <account-id>
180
+
181
+ # Get property details
182
+ ga-cli properties get <property-id>
183
+
184
+ # Create a new property
185
+ ga-cli properties create <account-id> --name "My Website" --timezone "America/New_York" --currency "USD"
186
+
187
+ # Delete a property
188
+ ga-cli properties delete <property-id>
189
+ ```
190
+
191
+ ### Data Streams
192
+
193
+ ```bash
194
+ # List data streams for a property
195
+ ga-cli datastreams list <property-id>
196
+
197
+ # Get data stream details (including measurement ID)
198
+ ga-cli datastreams get <property-id> <stream-id>
199
+
200
+ # Create a new web data stream
201
+ ga-cli datastreams create <property-id> --name "Main Website" --url "https://example.com"
202
+ ```
203
+
204
+ ## Examples
205
+
206
+ ### Quick workflow to create a new GA4 property
207
+
208
+ ```bash
209
+ # 1. List your accounts to get the account ID
210
+ ga-cli accounts list
211
+
212
+ # 2. Create a new property
213
+ ga-cli properties create 123456789 --name "BOTCHA" --timezone "Africa/Tripoli"
214
+
215
+ # 3. Create a web data stream
216
+ ga-cli datastreams create 987654321 --name "BOTCHA Website" --url "https://botcha.example.com"
217
+
218
+ # 4. Get the measurement ID
219
+ ga-cli datastreams get 987654321 111222333
220
+ ```
221
+
222
+ ### Get measurement ID quickly
223
+
224
+ ```bash
225
+ # If you know your property and stream IDs
226
+ ga-cli datastreams get <property-id> <stream-id> | grep "Measurement ID"
227
+ ```
228
+
229
+ ## Command Reference
230
+
231
+ ### Global Options
232
+
233
+ - `--credentials PATH` - Path to service account credentials file
234
+ - `--version` - Show version
235
+ - `--help` - Show help message
236
+
237
+ ### Output Formats
238
+
239
+ Most list and get commands support:
240
+ - `--format table` (default) - Beautiful table output
241
+ - `--format json` - JSON output
242
+
243
+ ## Development
244
+
245
+ ### Setup development environment
246
+
247
+ ```bash
248
+ # Clone the repository
249
+ git clone https://github.com/sulimanbenhalim/ga-cli.git
250
+ cd ga-cli
251
+
252
+ # Create virtual environment
253
+ python -m venv venv
254
+ source venv/bin/activate # On Windows: venv\Scripts\activate
255
+
256
+ # Install in development mode
257
+ pip install -e .
258
+ ```
259
+
260
+ ### Run tests
261
+
262
+ ```bash
263
+ pytest tests/ -v
264
+ ```
265
+
266
+ ## Project Structure
267
+
268
+ ```
269
+ ga-cli/
270
+ ├── ga_cli/
271
+ │ ├── __init__.py
272
+ │ ├── cli.py # Main CLI entry point
273
+ │ ├── auth.py # Authentication manager
274
+ │ ├── config.py # Configuration manager
275
+ │ ├── commands/
276
+ │ │ ├── accounts.py # Account commands
277
+ │ │ ├── properties.py # Property commands
278
+ │ │ ├── datastreams.py # Data stream commands
279
+ │ │ └── config.py # Config commands
280
+ │ └── formatters/
281
+ │ ├── table.py # Table formatter
282
+ │ └── json.py # JSON formatter
283
+ ├── tests/
284
+ ├── setup.py
285
+ ├── requirements.txt
286
+ └── README.md
287
+ ```
288
+
289
+ ## Requirements
290
+
291
+ - Python 3.8+
292
+ - Click 8.0+
293
+ - google-analytics-admin 0.27.0+
294
+ - google-auth 2.0+
295
+ - rich 13.0+
296
+ - pytz 2023.3+
297
+
298
+ ## License
299
+
300
+ MIT License
301
+
302
+ ## Contributing
303
+
304
+ Contributions are welcome! Please feel free to submit a Pull Request.
305
+
306
+ ## Support
307
+
308
+ For issues and questions, please open an issue on GitHub.
@@ -0,0 +1,265 @@
1
+ # GA CLI - Google Analytics Command Line Interface
2
+
3
+ A command-line interface tool for managing Google Analytics 4 properties, accounts, and data streams.
4
+
5
+ **Note**: The package is published as `ga4-cli` on PyPI, but the command is `ga-cli`.
6
+
7
+ ## Features
8
+
9
+ - List and manage Google Analytics accounts
10
+ - Create and manage GA4 properties
11
+ - Manage data streams and retrieve measurement IDs
12
+ - Beautiful table output with Rich
13
+ - JSON output support
14
+ - Authentication via service account credentials
15
+
16
+ ## Installation
17
+
18
+ ### Using pip
19
+
20
+ ```bash
21
+ pip install ga4-cli
22
+ ```
23
+
24
+ After installation, the command is available as `ga-cli`:
25
+
26
+ ```bash
27
+ ga-cli --version
28
+ ga-cli --help
29
+ ```
30
+
31
+ ### Using Homebrew (macOS/Linux)
32
+
33
+ ```bash
34
+ # Add the tap
35
+ brew tap sulimanbenhalim/ga-cli
36
+
37
+ # Install
38
+ brew install ga-cli
39
+
40
+ # Use it
41
+ ga-cli --version
42
+ ```
43
+
44
+ ### Using Docker
45
+
46
+ ```bash
47
+ # Pull from Docker Hub
48
+ docker pull sulimanbenhalim/ga-cli:latest
49
+
50
+ # Or build locally
51
+ docker build -t ga-cli .
52
+
53
+ # Run with credentials mounted
54
+ docker run -v /path/to/credentials.json:/credentials.json \
55
+ -v ~/.ga-cli:/root/.ga-cli \
56
+ ga-cli accounts list --credentials /credentials.json
57
+ ```
58
+
59
+ ### Download Binary (No Python Required)
60
+
61
+ Download standalone binaries from [GitHub Releases](https://github.com/sulimanbenhalim/ga-cli/releases):
62
+
63
+ **Linux/macOS:**
64
+ ```bash
65
+ # Download and extract
66
+ curl -L -o ga-cli.tar.gz https://github.com/sulimanbenhalim/ga-cli/releases/latest/download/ga-cli-linux-amd64.tar.gz
67
+ tar -xzf ga-cli.tar.gz
68
+ chmod +x ga-cli
69
+ sudo mv ga-cli /usr/local/bin/
70
+ ```
71
+
72
+ **Windows:**
73
+ Download `ga-cli-windows-amd64.exe.zip` from the releases page, extract, and run.
74
+
75
+ ### From source
76
+
77
+ ```bash
78
+ git clone https://github.com/sulimanbenhalim/ga-cli.git
79
+ cd ga-cli
80
+ pip install -e .
81
+ ```
82
+
83
+ ## Setup
84
+
85
+ ### 1. Get Google Service Account Credentials
86
+
87
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
88
+ 2. Create or select a project
89
+ 3. Enable the Google Analytics Admin API
90
+ 4. Create a service account with Analytics Admin permissions
91
+ 5. Download the JSON credentials file
92
+
93
+ ### 2. Initialize GA CLI
94
+
95
+ ```bash
96
+ ga-cli config init
97
+ ```
98
+
99
+ This will prompt you for the path to your service account JSON file and test the credentials.
100
+
101
+ Alternatively, set the environment variable:
102
+
103
+ ```bash
104
+ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
105
+ ```
106
+
107
+ ## Usage
108
+
109
+ ### Configuration
110
+
111
+ ```bash
112
+ # Initialize with credentials
113
+ ga-cli config init
114
+
115
+ # Show current configuration
116
+ ga-cli config show
117
+ ```
118
+
119
+ ### Accounts
120
+
121
+ ```bash
122
+ # List all accounts
123
+ ga-cli accounts list
124
+
125
+ # Get account details
126
+ ga-cli accounts get <account-id>
127
+
128
+ # Output as JSON
129
+ ga-cli accounts list --format json
130
+ ```
131
+
132
+ ### Properties
133
+
134
+ ```bash
135
+ # List properties for an account
136
+ ga-cli properties list <account-id>
137
+
138
+ # Get property details
139
+ ga-cli properties get <property-id>
140
+
141
+ # Create a new property
142
+ ga-cli properties create <account-id> --name "My Website" --timezone "America/New_York" --currency "USD"
143
+
144
+ # Delete a property
145
+ ga-cli properties delete <property-id>
146
+ ```
147
+
148
+ ### Data Streams
149
+
150
+ ```bash
151
+ # List data streams for a property
152
+ ga-cli datastreams list <property-id>
153
+
154
+ # Get data stream details (including measurement ID)
155
+ ga-cli datastreams get <property-id> <stream-id>
156
+
157
+ # Create a new web data stream
158
+ ga-cli datastreams create <property-id> --name "Main Website" --url "https://example.com"
159
+ ```
160
+
161
+ ## Examples
162
+
163
+ ### Quick workflow to create a new GA4 property
164
+
165
+ ```bash
166
+ # 1. List your accounts to get the account ID
167
+ ga-cli accounts list
168
+
169
+ # 2. Create a new property
170
+ ga-cli properties create 123456789 --name "BOTCHA" --timezone "Africa/Tripoli"
171
+
172
+ # 3. Create a web data stream
173
+ ga-cli datastreams create 987654321 --name "BOTCHA Website" --url "https://botcha.example.com"
174
+
175
+ # 4. Get the measurement ID
176
+ ga-cli datastreams get 987654321 111222333
177
+ ```
178
+
179
+ ### Get measurement ID quickly
180
+
181
+ ```bash
182
+ # If you know your property and stream IDs
183
+ ga-cli datastreams get <property-id> <stream-id> | grep "Measurement ID"
184
+ ```
185
+
186
+ ## Command Reference
187
+
188
+ ### Global Options
189
+
190
+ - `--credentials PATH` - Path to service account credentials file
191
+ - `--version` - Show version
192
+ - `--help` - Show help message
193
+
194
+ ### Output Formats
195
+
196
+ Most list and get commands support:
197
+ - `--format table` (default) - Beautiful table output
198
+ - `--format json` - JSON output
199
+
200
+ ## Development
201
+
202
+ ### Setup development environment
203
+
204
+ ```bash
205
+ # Clone the repository
206
+ git clone https://github.com/sulimanbenhalim/ga-cli.git
207
+ cd ga-cli
208
+
209
+ # Create virtual environment
210
+ python -m venv venv
211
+ source venv/bin/activate # On Windows: venv\Scripts\activate
212
+
213
+ # Install in development mode
214
+ pip install -e .
215
+ ```
216
+
217
+ ### Run tests
218
+
219
+ ```bash
220
+ pytest tests/ -v
221
+ ```
222
+
223
+ ## Project Structure
224
+
225
+ ```
226
+ ga-cli/
227
+ ├── ga_cli/
228
+ │ ├── __init__.py
229
+ │ ├── cli.py # Main CLI entry point
230
+ │ ├── auth.py # Authentication manager
231
+ │ ├── config.py # Configuration manager
232
+ │ ├── commands/
233
+ │ │ ├── accounts.py # Account commands
234
+ │ │ ├── properties.py # Property commands
235
+ │ │ ├── datastreams.py # Data stream commands
236
+ │ │ └── config.py # Config commands
237
+ │ └── formatters/
238
+ │ ├── table.py # Table formatter
239
+ │ └── json.py # JSON formatter
240
+ ├── tests/
241
+ ├── setup.py
242
+ ├── requirements.txt
243
+ └── README.md
244
+ ```
245
+
246
+ ## Requirements
247
+
248
+ - Python 3.8+
249
+ - Click 8.0+
250
+ - google-analytics-admin 0.27.0+
251
+ - google-auth 2.0+
252
+ - rich 13.0+
253
+ - pytz 2023.3+
254
+
255
+ ## License
256
+
257
+ MIT License
258
+
259
+ ## Contributing
260
+
261
+ Contributions are welcome! Please feel free to submit a Pull Request.
262
+
263
+ ## Support
264
+
265
+ For issues and questions, please open an issue on GitHub.