ga4-cli 0.1.0__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.0/LICENSE +21 -0
  2. ga4_cli-0.1.0/PKG-INFO +253 -0
  3. ga4_cli-0.1.0/README.md +210 -0
  4. ga4_cli-0.1.0/ga4_cli.egg-info/PKG-INFO +253 -0
  5. ga4_cli-0.1.0/ga4_cli.egg-info/SOURCES.txt +35 -0
  6. ga4_cli-0.1.0/ga4_cli.egg-info/dependency_links.txt +1 -0
  7. ga4_cli-0.1.0/ga4_cli.egg-info/entry_points.txt +2 -0
  8. ga4_cli-0.1.0/ga4_cli.egg-info/requires.txt +5 -0
  9. ga4_cli-0.1.0/ga4_cli.egg-info/top_level.txt +2 -0
  10. ga4_cli-0.1.0/ga_cli/__init__.py +3 -0
  11. ga4_cli-0.1.0/ga_cli/auth.py +59 -0
  12. ga4_cli-0.1.0/ga_cli/cli.py +35 -0
  13. ga4_cli-0.1.0/ga_cli/commands/__init__.py +0 -0
  14. ga4_cli-0.1.0/ga_cli/commands/accounts.py +81 -0
  15. ga4_cli-0.1.0/ga_cli/commands/config.py +65 -0
  16. ga4_cli-0.1.0/ga_cli/commands/datastreams.py +146 -0
  17. ga4_cli-0.1.0/ga_cli/commands/properties.py +151 -0
  18. ga4_cli-0.1.0/ga_cli/config.py +95 -0
  19. ga4_cli-0.1.0/ga_cli/decorators.py +90 -0
  20. ga4_cli-0.1.0/ga_cli/errors.py +35 -0
  21. ga4_cli-0.1.0/ga_cli/formatters/__init__.py +0 -0
  22. ga4_cli-0.1.0/ga_cli/formatters/json.py +9 -0
  23. ga4_cli-0.1.0/ga_cli/formatters/table.py +23 -0
  24. ga4_cli-0.1.0/ga_cli/logging_config.py +44 -0
  25. ga4_cli-0.1.0/ga_cli/output.py +59 -0
  26. ga4_cli-0.1.0/ga_cli/retry.py +40 -0
  27. ga4_cli-0.1.0/ga_cli/validators.py +52 -0
  28. ga4_cli-0.1.0/setup.cfg +4 -0
  29. ga4_cli-0.1.0/setup.py +50 -0
  30. ga4_cli-0.1.0/tests/__init__.py +0 -0
  31. ga4_cli-0.1.0/tests/conftest.py +89 -0
  32. ga4_cli-0.1.0/tests/test_accounts.py +49 -0
  33. ga4_cli-0.1.0/tests/test_auth.py +74 -0
  34. ga4_cli-0.1.0/tests/test_cli.py +52 -0
  35. ga4_cli-0.1.0/tests/test_config.py +140 -0
  36. ga4_cli-0.1.0/tests/test_errors.py +73 -0
  37. ga4_cli-0.1.0/tests/test_validators.py +146 -0
ga4_cli-0.1.0/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.0/PKG-INFO ADDED
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.4
2
+ Name: ga4-cli
3
+ Version: 0.1.0
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
+ ## Features
49
+
50
+ - List and manage Google Analytics accounts
51
+ - Create and manage GA4 properties
52
+ - Manage data streams and retrieve measurement IDs
53
+ - Beautiful table output with Rich
54
+ - JSON output support
55
+ - Authentication via service account credentials
56
+
57
+ ## Installation
58
+
59
+ ### From source
60
+
61
+ ```bash
62
+ cd ga-cli
63
+ pip install -e .
64
+ ```
65
+
66
+ ### Using pip (when published)
67
+
68
+ ```bash
69
+ pip install ga-cli
70
+ ```
71
+
72
+ ## Setup
73
+
74
+ ### 1. Get Google Service Account Credentials
75
+
76
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
77
+ 2. Create or select a project
78
+ 3. Enable the Google Analytics Admin API
79
+ 4. Create a service account with Analytics Admin permissions
80
+ 5. Download the JSON credentials file
81
+
82
+ ### 2. Initialize GA CLI
83
+
84
+ ```bash
85
+ ga-cli config init
86
+ ```
87
+
88
+ This will prompt you for the path to your service account JSON file and test the credentials.
89
+
90
+ Alternatively, set the environment variable:
91
+
92
+ ```bash
93
+ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
94
+ ```
95
+
96
+ ## Usage
97
+
98
+ ### Configuration
99
+
100
+ ```bash
101
+ # Initialize with credentials
102
+ ga-cli config init
103
+
104
+ # Show current configuration
105
+ ga-cli config show
106
+ ```
107
+
108
+ ### Accounts
109
+
110
+ ```bash
111
+ # List all accounts
112
+ ga-cli accounts list
113
+
114
+ # Get account details
115
+ ga-cli accounts get <account-id>
116
+
117
+ # Output as JSON
118
+ ga-cli accounts list --format json
119
+ ```
120
+
121
+ ### Properties
122
+
123
+ ```bash
124
+ # List properties for an account
125
+ ga-cli properties list <account-id>
126
+
127
+ # Get property details
128
+ ga-cli properties get <property-id>
129
+
130
+ # Create a new property
131
+ ga-cli properties create <account-id> --name "My Website" --timezone "America/New_York" --currency "USD"
132
+
133
+ # Delete a property
134
+ ga-cli properties delete <property-id>
135
+ ```
136
+
137
+ ### Data Streams
138
+
139
+ ```bash
140
+ # List data streams for a property
141
+ ga-cli datastreams list <property-id>
142
+
143
+ # Get data stream details (including measurement ID)
144
+ ga-cli datastreams get <property-id> <stream-id>
145
+
146
+ # Create a new web data stream
147
+ ga-cli datastreams create <property-id> --name "Main Website" --url "https://example.com"
148
+ ```
149
+
150
+ ## Examples
151
+
152
+ ### Quick workflow to create a new GA4 property
153
+
154
+ ```bash
155
+ # 1. List your accounts to get the account ID
156
+ ga-cli accounts list
157
+
158
+ # 2. Create a new property
159
+ ga-cli properties create 123456789 --name "BOTCHA" --timezone "Africa/Tripoli"
160
+
161
+ # 3. Create a web data stream
162
+ ga-cli datastreams create 987654321 --name "BOTCHA Website" --url "https://botcha.example.com"
163
+
164
+ # 4. Get the measurement ID
165
+ ga-cli datastreams get 987654321 111222333
166
+ ```
167
+
168
+ ### Get measurement ID quickly
169
+
170
+ ```bash
171
+ # If you know your property and stream IDs
172
+ ga-cli datastreams get <property-id> <stream-id> | grep "Measurement ID"
173
+ ```
174
+
175
+ ## Command Reference
176
+
177
+ ### Global Options
178
+
179
+ - `--credentials PATH` - Path to service account credentials file
180
+ - `--version` - Show version
181
+ - `--help` - Show help message
182
+
183
+ ### Output Formats
184
+
185
+ Most list and get commands support:
186
+ - `--format table` (default) - Beautiful table output
187
+ - `--format json` - JSON output
188
+
189
+ ## Development
190
+
191
+ ### Setup development environment
192
+
193
+ ```bash
194
+ # Clone the repository
195
+ git clone <repository-url>
196
+ cd ga-cli
197
+
198
+ # Create virtual environment
199
+ python -m venv venv
200
+ source venv/bin/activate # On Windows: venv\Scripts\activate
201
+
202
+ # Install in development mode
203
+ pip install -e .
204
+ ```
205
+
206
+ ### Run tests
207
+
208
+ ```bash
209
+ pytest tests/ -v
210
+ ```
211
+
212
+ ## Project Structure
213
+
214
+ ```
215
+ ga-cli/
216
+ ├── ga_cli/
217
+ │ ├── __init__.py
218
+ │ ├── cli.py # Main CLI entry point
219
+ │ ├── auth.py # Authentication manager
220
+ │ ├── config.py # Configuration manager
221
+ │ ├── commands/
222
+ │ │ ├── accounts.py # Account commands
223
+ │ │ ├── properties.py # Property commands
224
+ │ │ ├── datastreams.py # Data stream commands
225
+ │ │ └── config.py # Config commands
226
+ │ └── formatters/
227
+ │ ├── table.py # Table formatter
228
+ │ └── json.py # JSON formatter
229
+ ├── tests/
230
+ ├── setup.py
231
+ ├── requirements.txt
232
+ └── README.md
233
+ ```
234
+
235
+ ## Requirements
236
+
237
+ - Python 3.7+
238
+ - Click 8.0+
239
+ - google-analytics-admin 0.27.0+
240
+ - google-auth 2.0+
241
+ - rich 13.0+
242
+
243
+ ## License
244
+
245
+ MIT License
246
+
247
+ ## Contributing
248
+
249
+ Contributions are welcome! Please feel free to submit a Pull Request.
250
+
251
+ ## Support
252
+
253
+ For issues and questions, please open an issue on GitHub.
@@ -0,0 +1,210 @@
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
+ ## Features
6
+
7
+ - List and manage Google Analytics accounts
8
+ - Create and manage GA4 properties
9
+ - Manage data streams and retrieve measurement IDs
10
+ - Beautiful table output with Rich
11
+ - JSON output support
12
+ - Authentication via service account credentials
13
+
14
+ ## Installation
15
+
16
+ ### From source
17
+
18
+ ```bash
19
+ cd ga-cli
20
+ pip install -e .
21
+ ```
22
+
23
+ ### Using pip (when published)
24
+
25
+ ```bash
26
+ pip install ga-cli
27
+ ```
28
+
29
+ ## Setup
30
+
31
+ ### 1. Get Google Service Account Credentials
32
+
33
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
34
+ 2. Create or select a project
35
+ 3. Enable the Google Analytics Admin API
36
+ 4. Create a service account with Analytics Admin permissions
37
+ 5. Download the JSON credentials file
38
+
39
+ ### 2. Initialize GA CLI
40
+
41
+ ```bash
42
+ ga-cli config init
43
+ ```
44
+
45
+ This will prompt you for the path to your service account JSON file and test the credentials.
46
+
47
+ Alternatively, set the environment variable:
48
+
49
+ ```bash
50
+ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
51
+ ```
52
+
53
+ ## Usage
54
+
55
+ ### Configuration
56
+
57
+ ```bash
58
+ # Initialize with credentials
59
+ ga-cli config init
60
+
61
+ # Show current configuration
62
+ ga-cli config show
63
+ ```
64
+
65
+ ### Accounts
66
+
67
+ ```bash
68
+ # List all accounts
69
+ ga-cli accounts list
70
+
71
+ # Get account details
72
+ ga-cli accounts get <account-id>
73
+
74
+ # Output as JSON
75
+ ga-cli accounts list --format json
76
+ ```
77
+
78
+ ### Properties
79
+
80
+ ```bash
81
+ # List properties for an account
82
+ ga-cli properties list <account-id>
83
+
84
+ # Get property details
85
+ ga-cli properties get <property-id>
86
+
87
+ # Create a new property
88
+ ga-cli properties create <account-id> --name "My Website" --timezone "America/New_York" --currency "USD"
89
+
90
+ # Delete a property
91
+ ga-cli properties delete <property-id>
92
+ ```
93
+
94
+ ### Data Streams
95
+
96
+ ```bash
97
+ # List data streams for a property
98
+ ga-cli datastreams list <property-id>
99
+
100
+ # Get data stream details (including measurement ID)
101
+ ga-cli datastreams get <property-id> <stream-id>
102
+
103
+ # Create a new web data stream
104
+ ga-cli datastreams create <property-id> --name "Main Website" --url "https://example.com"
105
+ ```
106
+
107
+ ## Examples
108
+
109
+ ### Quick workflow to create a new GA4 property
110
+
111
+ ```bash
112
+ # 1. List your accounts to get the account ID
113
+ ga-cli accounts list
114
+
115
+ # 2. Create a new property
116
+ ga-cli properties create 123456789 --name "BOTCHA" --timezone "Africa/Tripoli"
117
+
118
+ # 3. Create a web data stream
119
+ ga-cli datastreams create 987654321 --name "BOTCHA Website" --url "https://botcha.example.com"
120
+
121
+ # 4. Get the measurement ID
122
+ ga-cli datastreams get 987654321 111222333
123
+ ```
124
+
125
+ ### Get measurement ID quickly
126
+
127
+ ```bash
128
+ # If you know your property and stream IDs
129
+ ga-cli datastreams get <property-id> <stream-id> | grep "Measurement ID"
130
+ ```
131
+
132
+ ## Command Reference
133
+
134
+ ### Global Options
135
+
136
+ - `--credentials PATH` - Path to service account credentials file
137
+ - `--version` - Show version
138
+ - `--help` - Show help message
139
+
140
+ ### Output Formats
141
+
142
+ Most list and get commands support:
143
+ - `--format table` (default) - Beautiful table output
144
+ - `--format json` - JSON output
145
+
146
+ ## Development
147
+
148
+ ### Setup development environment
149
+
150
+ ```bash
151
+ # Clone the repository
152
+ git clone <repository-url>
153
+ cd ga-cli
154
+
155
+ # Create virtual environment
156
+ python -m venv venv
157
+ source venv/bin/activate # On Windows: venv\Scripts\activate
158
+
159
+ # Install in development mode
160
+ pip install -e .
161
+ ```
162
+
163
+ ### Run tests
164
+
165
+ ```bash
166
+ pytest tests/ -v
167
+ ```
168
+
169
+ ## Project Structure
170
+
171
+ ```
172
+ ga-cli/
173
+ ├── ga_cli/
174
+ │ ├── __init__.py
175
+ │ ├── cli.py # Main CLI entry point
176
+ │ ├── auth.py # Authentication manager
177
+ │ ├── config.py # Configuration manager
178
+ │ ├── commands/
179
+ │ │ ├── accounts.py # Account commands
180
+ │ │ ├── properties.py # Property commands
181
+ │ │ ├── datastreams.py # Data stream commands
182
+ │ │ └── config.py # Config commands
183
+ │ └── formatters/
184
+ │ ├── table.py # Table formatter
185
+ │ └── json.py # JSON formatter
186
+ ├── tests/
187
+ ├── setup.py
188
+ ├── requirements.txt
189
+ └── README.md
190
+ ```
191
+
192
+ ## Requirements
193
+
194
+ - Python 3.7+
195
+ - Click 8.0+
196
+ - google-analytics-admin 0.27.0+
197
+ - google-auth 2.0+
198
+ - rich 13.0+
199
+
200
+ ## License
201
+
202
+ MIT License
203
+
204
+ ## Contributing
205
+
206
+ Contributions are welcome! Please feel free to submit a Pull Request.
207
+
208
+ ## Support
209
+
210
+ For issues and questions, please open an issue on GitHub.