py2adobe-reporting 0.0.15__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.
- py2adobe_reporting-0.0.15/.gitignore +207 -0
- py2adobe_reporting-0.0.15/.vscode/settings.json +7 -0
- py2adobe_reporting-0.0.15/LICENSE +21 -0
- py2adobe_reporting-0.0.15/PKG-INFO +205 -0
- py2adobe_reporting-0.0.15/README.md +179 -0
- py2adobe_reporting-0.0.15/docs/reporting_management.md +86 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/__init__.py +8 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/__version__.py +2 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/auth.py +114 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/cja_functions/reporting_management.py +548 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/http_client.py +108 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/json_extractor.py +260 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/reporting_api.py +103 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/static/script.js +279 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/static/style.css +194 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/templates/jsonExtractionUi.html +49 -0
- py2adobe_reporting-0.0.15/py2adobe_reporting/utils.py +215 -0
- py2adobe_reporting-0.0.15/pyproject.toml +41 -0
- py2adobe_reporting-0.0.15/requirements.txt +8 -0
- py2adobe_reporting-0.0.15/test/exceptions_test.py +84 -0
- py2adobe_reporting-0.0.15/test/reporting_management_test.py +370 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 James Mitchell
|
|
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.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: py2adobe_reporting
|
|
3
|
+
Version: 0.0.15
|
|
4
|
+
Summary: Data Engineering tool for accessing Adobe CJA Reporting API
|
|
5
|
+
Project-URL: Homepage, https://github.com/jaytmii/py2adobe_reporting_package
|
|
6
|
+
Project-URL: Repository, https://github.com/jaytmii/py2adobe_reporting_package
|
|
7
|
+
Project-URL: Issues, https://github.com/jaytmii/py2adobe_reporting_package/issues
|
|
8
|
+
Author-email: James Mitchell <jaytmii@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Requires-Dist: numpy>=2.2.4
|
|
18
|
+
Requires-Dist: pandas>=2.2.3
|
|
19
|
+
Requires-Dist: plotly>=6.5.0
|
|
20
|
+
Requires-Dist: pytz>=2024.1
|
|
21
|
+
Requires-Dist: requests>=2.32.3
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pylint>=4.0.4; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8.2.2; extra == 'dev'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# py2adobe_reporting
|
|
28
|
+
|
|
29
|
+
A Python wrapper for Adobe Customer Journey Analytics (CJA) Reporting API that enables analysts to easily extract and analyze data programmatically.
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- **Time Series Reports** - Daily and monthly aggregated metrics
|
|
34
|
+
- **Multi-Metric Analysis** - Pull up to 5 metrics in a single report
|
|
35
|
+
- **Dimension Breakdowns** - Break down metrics by multiple dimensions
|
|
36
|
+
- **Top Items Analysis** - Get top 10 dimension items with optional search
|
|
37
|
+
- **Pagination Support** - Handle large datasets with automatic pagination (up to 50,000 rows per page)
|
|
38
|
+
- **Server-to-Server Authentication** - Secure OAuth 2.0 authentication
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install py2adobe_reporting
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or install from source:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone https://github.com/jaytmii/py2adobe_reporting_package.git
|
|
50
|
+
cd py2adobe_reporting_package
|
|
51
|
+
pip install -e .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Requirements
|
|
55
|
+
|
|
56
|
+
- Python >= 3.10
|
|
57
|
+
- Adobe CJA API credentials (OAuth 2.0 Server-to-Server)
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
|
|
61
|
+
### 1. Set Up Authentication
|
|
62
|
+
|
|
63
|
+
Create a JSON configuration file with your Adobe credentials:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"client_secret": "your-client-secret",
|
|
68
|
+
"defaultHeaders": {
|
|
69
|
+
"x-api-key": "your-api-key",
|
|
70
|
+
"x-gw-ims-org-id": "your-org-id"
|
|
71
|
+
},
|
|
72
|
+
"company_id": "your-company-id",
|
|
73
|
+
"scopes": "api_scopes",
|
|
74
|
+
"ims_host": "ims",
|
|
75
|
+
"token_url": "token_url"
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 2. Authenticate
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from py2adobe_reporting.auth import s2s_auth
|
|
83
|
+
|
|
84
|
+
# Authenticate and get environment object
|
|
85
|
+
env = s2s_auth("path/to/config.json")
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 3. Generate Headers
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from py2Adobe_reporting.auth import cja_oauth_headers
|
|
92
|
+
|
|
93
|
+
# Create headers for API calls
|
|
94
|
+
headers = cja_oauth_headers("path/to/config.json", env.token)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 4. Pull a Report
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from py2adobe_reporting.cja_functions.reporting_management import Reporting
|
|
101
|
+
|
|
102
|
+
# Initialize reporting class
|
|
103
|
+
reporting = Reporting()
|
|
104
|
+
|
|
105
|
+
# Get daily time series report
|
|
106
|
+
df = reporting.daily_time_series_report(
|
|
107
|
+
headers=headers,
|
|
108
|
+
data_view_id="your-data-view-id",
|
|
109
|
+
start_date="2024-01-01",
|
|
110
|
+
end_date="2024-01-31",
|
|
111
|
+
metric="metrics/visits"
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
print(df.head())
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Available Functions
|
|
118
|
+
|
|
119
|
+
### Time Series Reports
|
|
120
|
+
- `monthly_time_series_report()` - Month-level aggregated metrics
|
|
121
|
+
- `daily_time_series_report()` - Day-level aggregated metrics
|
|
122
|
+
|
|
123
|
+
### Multi-Dimensional Reports
|
|
124
|
+
- `five_metrics_report()` - Pull 5 metrics with a dimension
|
|
125
|
+
- `breakdown_report()` - Break down a metric by two dimensions
|
|
126
|
+
- `get_all_rows_report()` - Get all rows for custom request body
|
|
127
|
+
|
|
128
|
+
### Utility Functions
|
|
129
|
+
- `get_single_call_report()` - Single API call with custom body
|
|
130
|
+
- `get_total_table_rows()` - Get row count for a table
|
|
131
|
+
- `get_total_table_pages()` - Calculate total pages needed
|
|
132
|
+
- `get_top_ten_dimension_items()` - Get top 10 items for a dimension
|
|
133
|
+
|
|
134
|
+
## Documentation
|
|
135
|
+
|
|
136
|
+
For detailed function parameters and examples, see:
|
|
137
|
+
- [Reporting Management Documentation](docs/reporting_management.md)
|
|
138
|
+
|
|
139
|
+
## Example Use Cases
|
|
140
|
+
|
|
141
|
+
### Get Daily Visits
|
|
142
|
+
```python
|
|
143
|
+
df = reporting.daily_time_series_report(
|
|
144
|
+
headers=headers,
|
|
145
|
+
data_view_id="your-data-view-id",
|
|
146
|
+
start_date="2024-01-01",
|
|
147
|
+
end_date="2024-01-31",
|
|
148
|
+
metric="metrics/visits"
|
|
149
|
+
)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Get Monthly Visits
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
df = reporting.monthly_time_series_report(
|
|
156
|
+
headers=headers,
|
|
157
|
+
data_view_id="dv_123",
|
|
158
|
+
start_date="2024-01-01",
|
|
159
|
+
end_date="2024-12-31",
|
|
160
|
+
metric="metrics/visits"
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Breakdown by Multiple Dimensions
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
df = reporting.breakdown_report(
|
|
168
|
+
headers=headers,
|
|
169
|
+
data_view_id="dv_123",
|
|
170
|
+
start_date="2024-01-01",
|
|
171
|
+
end_date="2024-01-31",
|
|
172
|
+
dimension="variables/page",
|
|
173
|
+
metric="metrics/visits",
|
|
174
|
+
dim_rows_per_page=50,
|
|
175
|
+
breakdown_dim="variables/browser",
|
|
176
|
+
breakdown_rows_per_page=50
|
|
177
|
+
)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Search for Dimension Items
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
df = reporting.get_top_ten_dimension_items(
|
|
184
|
+
headers=headers,
|
|
185
|
+
data_view_id="dv_123",
|
|
186
|
+
start_date="2024-01-01",
|
|
187
|
+
end_date="2024-01-31",
|
|
188
|
+
dimension="variables/page",
|
|
189
|
+
search_type="contains",
|
|
190
|
+
contains_term="( CONTAINS 'product' )"
|
|
191
|
+
)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Contributing
|
|
195
|
+
|
|
196
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
201
|
+
|
|
202
|
+
## Author
|
|
203
|
+
|
|
204
|
+
James Mitchell - jaytmii@gmail.com
|
|
205
|
+
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# py2adobe_reporting
|
|
2
|
+
|
|
3
|
+
A Python wrapper for Adobe Customer Journey Analytics (CJA) Reporting API that enables analysts to easily extract and analyze data programmatically.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Time Series Reports** - Daily and monthly aggregated metrics
|
|
8
|
+
- **Multi-Metric Analysis** - Pull up to 5 metrics in a single report
|
|
9
|
+
- **Dimension Breakdowns** - Break down metrics by multiple dimensions
|
|
10
|
+
- **Top Items Analysis** - Get top 10 dimension items with optional search
|
|
11
|
+
- **Pagination Support** - Handle large datasets with automatic pagination (up to 50,000 rows per page)
|
|
12
|
+
- **Server-to-Server Authentication** - Secure OAuth 2.0 authentication
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install py2adobe_reporting
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or install from source:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git clone https://github.com/jaytmii/py2adobe_reporting_package.git
|
|
24
|
+
cd py2adobe_reporting_package
|
|
25
|
+
pip install -e .
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Requirements
|
|
29
|
+
|
|
30
|
+
- Python >= 3.10
|
|
31
|
+
- Adobe CJA API credentials (OAuth 2.0 Server-to-Server)
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
### 1. Set Up Authentication
|
|
36
|
+
|
|
37
|
+
Create a JSON configuration file with your Adobe credentials:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"client_secret": "your-client-secret",
|
|
42
|
+
"defaultHeaders": {
|
|
43
|
+
"x-api-key": "your-api-key",
|
|
44
|
+
"x-gw-ims-org-id": "your-org-id"
|
|
45
|
+
},
|
|
46
|
+
"company_id": "your-company-id",
|
|
47
|
+
"scopes": "api_scopes",
|
|
48
|
+
"ims_host": "ims",
|
|
49
|
+
"token_url": "token_url"
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Authenticate
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from py2adobe_reporting.auth import s2s_auth
|
|
57
|
+
|
|
58
|
+
# Authenticate and get environment object
|
|
59
|
+
env = s2s_auth("path/to/config.json")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 3. Generate Headers
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from py2Adobe_reporting.auth import cja_oauth_headers
|
|
66
|
+
|
|
67
|
+
# Create headers for API calls
|
|
68
|
+
headers = cja_oauth_headers("path/to/config.json", env.token)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 4. Pull a Report
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from py2adobe_reporting.cja_functions.reporting_management import Reporting
|
|
75
|
+
|
|
76
|
+
# Initialize reporting class
|
|
77
|
+
reporting = Reporting()
|
|
78
|
+
|
|
79
|
+
# Get daily time series report
|
|
80
|
+
df = reporting.daily_time_series_report(
|
|
81
|
+
headers=headers,
|
|
82
|
+
data_view_id="your-data-view-id",
|
|
83
|
+
start_date="2024-01-01",
|
|
84
|
+
end_date="2024-01-31",
|
|
85
|
+
metric="metrics/visits"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
print(df.head())
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Available Functions
|
|
92
|
+
|
|
93
|
+
### Time Series Reports
|
|
94
|
+
- `monthly_time_series_report()` - Month-level aggregated metrics
|
|
95
|
+
- `daily_time_series_report()` - Day-level aggregated metrics
|
|
96
|
+
|
|
97
|
+
### Multi-Dimensional Reports
|
|
98
|
+
- `five_metrics_report()` - Pull 5 metrics with a dimension
|
|
99
|
+
- `breakdown_report()` - Break down a metric by two dimensions
|
|
100
|
+
- `get_all_rows_report()` - Get all rows for custom request body
|
|
101
|
+
|
|
102
|
+
### Utility Functions
|
|
103
|
+
- `get_single_call_report()` - Single API call with custom body
|
|
104
|
+
- `get_total_table_rows()` - Get row count for a table
|
|
105
|
+
- `get_total_table_pages()` - Calculate total pages needed
|
|
106
|
+
- `get_top_ten_dimension_items()` - Get top 10 items for a dimension
|
|
107
|
+
|
|
108
|
+
## Documentation
|
|
109
|
+
|
|
110
|
+
For detailed function parameters and examples, see:
|
|
111
|
+
- [Reporting Management Documentation](docs/reporting_management.md)
|
|
112
|
+
|
|
113
|
+
## Example Use Cases
|
|
114
|
+
|
|
115
|
+
### Get Daily Visits
|
|
116
|
+
```python
|
|
117
|
+
df = reporting.daily_time_series_report(
|
|
118
|
+
headers=headers,
|
|
119
|
+
data_view_id="your-data-view-id",
|
|
120
|
+
start_date="2024-01-01",
|
|
121
|
+
end_date="2024-01-31",
|
|
122
|
+
metric="metrics/visits"
|
|
123
|
+
)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Get Monthly Visits
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
df = reporting.monthly_time_series_report(
|
|
130
|
+
headers=headers,
|
|
131
|
+
data_view_id="dv_123",
|
|
132
|
+
start_date="2024-01-01",
|
|
133
|
+
end_date="2024-12-31",
|
|
134
|
+
metric="metrics/visits"
|
|
135
|
+
)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Breakdown by Multiple Dimensions
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
df = reporting.breakdown_report(
|
|
142
|
+
headers=headers,
|
|
143
|
+
data_view_id="dv_123",
|
|
144
|
+
start_date="2024-01-01",
|
|
145
|
+
end_date="2024-01-31",
|
|
146
|
+
dimension="variables/page",
|
|
147
|
+
metric="metrics/visits",
|
|
148
|
+
dim_rows_per_page=50,
|
|
149
|
+
breakdown_dim="variables/browser",
|
|
150
|
+
breakdown_rows_per_page=50
|
|
151
|
+
)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Search for Dimension Items
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
df = reporting.get_top_ten_dimension_items(
|
|
158
|
+
headers=headers,
|
|
159
|
+
data_view_id="dv_123",
|
|
160
|
+
start_date="2024-01-01",
|
|
161
|
+
end_date="2024-01-31",
|
|
162
|
+
dimension="variables/page",
|
|
163
|
+
search_type="contains",
|
|
164
|
+
contains_term="( CONTAINS 'product' )"
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Contributing
|
|
169
|
+
|
|
170
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
175
|
+
|
|
176
|
+
## Author
|
|
177
|
+
|
|
178
|
+
James Mitchell - jaytmii@gmail.com
|
|
179
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# reporting_management
|
|
2
|
+
-----------------------
|
|
3
|
+
This module is used by the CJA Reporting API and provides significant value for extracting data
|
|
4
|
+
|
|
5
|
+
## Functionality
|
|
6
|
+
* Get Single Call Report
|
|
7
|
+
* Get Total Table Rows
|
|
8
|
+
* Get Total Table Pages
|
|
9
|
+
* Get All Rows Report
|
|
10
|
+
* Monthly Time Series Report
|
|
11
|
+
* Daily Time Series Report
|
|
12
|
+
* Five Metrics Report
|
|
13
|
+
* Breakdown Report
|
|
14
|
+
* Get Top Ten Dimension Items
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Dependencies
|
|
18
|
+
* pandas
|
|
19
|
+
* requests
|
|
20
|
+
* numpy
|
|
21
|
+
* plotly
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Common Input Parameters
|
|
25
|
+
* headers are generated using the auth file and are required for all calls
|
|
26
|
+
* req_num is an optional parameter that can be used to set the number of retries
|
|
27
|
+
* data_view_id is the unique identifier of the dataView
|
|
28
|
+
* start_date this is formatted in the standard `YYYY-MM-DD` format
|
|
29
|
+
* end_date this is formatted in the standard `YYYY-MM-DD` format
|
|
30
|
+
* metric this is the schema location for a single metric
|
|
31
|
+
* metrics this is a list of metrics, it must contain five separate entries in list format
|
|
32
|
+
* rows_per_page allows you to set the number of rows per page of pull, can accept a max of int 50000
|
|
33
|
+
* limit this is differentiated as an input name, but is functionally the same as rows_per_page
|
|
34
|
+
|
|
35
|
+
## Get Single Call Report
|
|
36
|
+
```python
|
|
37
|
+
get_single_call_report(headers=dict, body=dict, req_num=int)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Get Total Table Rows
|
|
41
|
+
```python
|
|
42
|
+
get_total_table_rows(headers=dict, body=dict, req_num=int)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Get Total Table Pages
|
|
46
|
+
```python
|
|
47
|
+
get_total_table_pages(headers=dict, body=dict, req_num=int)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Get All Rows Report
|
|
51
|
+
```python
|
|
52
|
+
get_all_rows_report(headers=dict, body=dict, rows_per_page=int, req_num=int)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Monthly Time Series Report
|
|
56
|
+
```python
|
|
57
|
+
monthly_time_series_report(headers=dict, data_view_id=str, start_date=str, end_date=str, metric=str, req_num=int, limit=int)
|
|
58
|
+
```
|
|
59
|
+
* This will get a month based report for a single metric
|
|
60
|
+
|
|
61
|
+
## Daily Time Series Report
|
|
62
|
+
```python
|
|
63
|
+
daily_time_series_report(headers=dict, data_view_id=str, start_date=str, end_date=str, metric=str, req_num=int, limit=int)
|
|
64
|
+
```
|
|
65
|
+
* This will get a day's based report for a single metric
|
|
66
|
+
|
|
67
|
+
## Five Metrics Report
|
|
68
|
+
```python
|
|
69
|
+
five_metrics_report(headers=dict, data_view_id=str, start_date=str, end_date=str, metrics=list, dimension=str, rows_per_page=int, req_num=int, limit=int)
|
|
70
|
+
```
|
|
71
|
+
* You must include five metrics in the entry for this to work and in a list format
|
|
72
|
+
|
|
73
|
+
## Breakdown Report
|
|
74
|
+
```python
|
|
75
|
+
breakdown_report(headers=dict, data_view_id=str, start_date=str, end_date=str, dimension=str, metric=str, dim_rows_per_page=int, breakdown_dim=str, breakdown_rows_per_page=int, req_num=int, limit=int)
|
|
76
|
+
```
|
|
77
|
+
* This will breakdown a single metric by two dimensions, rows_per_page will set the rows per page for each dimension
|
|
78
|
+
|
|
79
|
+
## Get Top Ten Dimension Items
|
|
80
|
+
```python
|
|
81
|
+
get_top_ten_dimension_items(headers=dict, data_view_id=str, start_date=str, end_date=str, dimension=str, search_type=str, contains_term=str, req_num=int)
|
|
82
|
+
```
|
|
83
|
+
* dimension uses the full schema path
|
|
84
|
+
* search_type currently should be set to `contain` to access search functionality
|
|
85
|
+
* contains_term must use the following formatting "( CONTAINS 'click' )"
|
|
86
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""Setting package imports"""
|
|
2
|
+
from py2adobe_reporting import http_client
|
|
3
|
+
from py2adobe_reporting import auth
|
|
4
|
+
from py2adobe_reporting.cja_functions import reporting_management
|
|
5
|
+
from py2adobe_reporting import reporting_api
|
|
6
|
+
from py2adobe_reporting import utils
|
|
7
|
+
from py2adobe_reporting import json_extractor
|
|
8
|
+
from .__version__ import __version__
|