bugstack 1.0.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.
- bugstack-1.0.0/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
- bugstack-1.0.0/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- bugstack-1.0.0/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- bugstack-1.0.0/.github/workflows/ci.yml +36 -0
- bugstack-1.0.0/.github/workflows/publish.yml +32 -0
- bugstack-1.0.0/.gitignore +37 -0
- bugstack-1.0.0/CHANGELOG.md +19 -0
- bugstack-1.0.0/CONTRIBUTING.md +46 -0
- bugstack-1.0.0/LICENSE +21 -0
- bugstack-1.0.0/PKG-INFO +216 -0
- bugstack-1.0.0/README.md +171 -0
- bugstack-1.0.0/SECURITY.md +25 -0
- bugstack-1.0.0/examples/basic_usage.py +29 -0
- bugstack-1.0.0/examples/django_example/settings.py +15 -0
- bugstack-1.0.0/examples/fastapi_example/main.py +29 -0
- bugstack-1.0.0/examples/flask_example/main.py +29 -0
- bugstack-1.0.0/pyproject.toml +75 -0
- bugstack-1.0.0/src/bugstack/__init__.py +142 -0
- bugstack-1.0.0/src/bugstack/client.py +151 -0
- bugstack-1.0.0/src/bugstack/fingerprint.py +96 -0
- bugstack-1.0.0/src/bugstack/integrations/__init__.py +5 -0
- bugstack-1.0.0/src/bugstack/integrations/django.py +93 -0
- bugstack-1.0.0/src/bugstack/integrations/fastapi.py +94 -0
- bugstack-1.0.0/src/bugstack/integrations/flask.py +57 -0
- bugstack-1.0.0/src/bugstack/integrations/generic.py +71 -0
- bugstack-1.0.0/src/bugstack/py.typed +0 -0
- bugstack-1.0.0/src/bugstack/transport.py +171 -0
- bugstack-1.0.0/src/bugstack/types.py +108 -0
- bugstack-1.0.0/tests/conftest.py +37 -0
- bugstack-1.0.0/tests/helpers.py +9 -0
- bugstack-1.0.0/tests/integrations/django_settings.py +12 -0
- bugstack-1.0.0/tests/integrations/test_django.py +77 -0
- bugstack-1.0.0/tests/integrations/test_fastapi.py +74 -0
- bugstack-1.0.0/tests/integrations/test_flask.py +63 -0
- bugstack-1.0.0/tests/integrations/test_generic.py +73 -0
- bugstack-1.0.0/tests/test_client.py +187 -0
- bugstack-1.0.0/tests/test_fingerprint.py +137 -0
- bugstack-1.0.0/tests/test_init.py +106 -0
- bugstack-1.0.0/tests/test_transport.py +153 -0
- bugstack-1.0.0/tests/test_types.py +139 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug Report
|
|
3
|
+
about: Report a bug in the BugStack Python SDK
|
|
4
|
+
title: "[Bug] "
|
|
5
|
+
labels: bug
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
**Describe the bug**
|
|
9
|
+
A clear description of what the bug is.
|
|
10
|
+
|
|
11
|
+
**To Reproduce**
|
|
12
|
+
```python
|
|
13
|
+
# Minimal code to reproduce
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Expected behavior**
|
|
17
|
+
What you expected to happen.
|
|
18
|
+
|
|
19
|
+
**Environment**
|
|
20
|
+
- Python version:
|
|
21
|
+
- SDK version:
|
|
22
|
+
- Framework (if applicable):
|
|
23
|
+
- OS:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature Request
|
|
3
|
+
about: Suggest a feature for the BugStack Python SDK
|
|
4
|
+
title: "[Feature] "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
**Describe the feature**
|
|
9
|
+
A clear description of what you'd like.
|
|
10
|
+
|
|
11
|
+
**Use case**
|
|
12
|
+
Why is this feature useful? What problem does it solve?
|
|
13
|
+
|
|
14
|
+
**Proposed API**
|
|
15
|
+
```python
|
|
16
|
+
# How would you like to use this feature?
|
|
17
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install --upgrade pip
|
|
27
|
+
pip install -e ".[dev]"
|
|
28
|
+
|
|
29
|
+
- name: Lint
|
|
30
|
+
run: ruff check .
|
|
31
|
+
|
|
32
|
+
- name: Type check
|
|
33
|
+
run: mypy src/bugstack --ignore-missing-imports
|
|
34
|
+
|
|
35
|
+
- name: Test
|
|
36
|
+
run: pytest -v
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
id-token: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
environment: pypi
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python
|
|
19
|
+
uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
|
|
23
|
+
- name: Install build tools
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
pip install build
|
|
27
|
+
|
|
28
|
+
- name: Build package
|
|
29
|
+
run: python -m build
|
|
30
|
+
|
|
31
|
+
- name: Publish to PyPI
|
|
32
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.so
|
|
5
|
+
*.egg
|
|
6
|
+
*.egg-info/
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
.eggs/
|
|
10
|
+
*.whl
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
ENV/
|
|
17
|
+
|
|
18
|
+
# IDE
|
|
19
|
+
.idea/
|
|
20
|
+
.vscode/
|
|
21
|
+
*.swp
|
|
22
|
+
*.swo
|
|
23
|
+
|
|
24
|
+
# Testing
|
|
25
|
+
.pytest_cache/
|
|
26
|
+
.coverage
|
|
27
|
+
htmlcov/
|
|
28
|
+
.mypy_cache/
|
|
29
|
+
.ruff_cache/
|
|
30
|
+
|
|
31
|
+
# OS
|
|
32
|
+
.DS_Store
|
|
33
|
+
Thumbs.db
|
|
34
|
+
|
|
35
|
+
# Environment
|
|
36
|
+
.env
|
|
37
|
+
.env.local
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.0.0] - 2026-02-13
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Core SDK with `bugstack.init()` and `bugstack.capture_exception()`
|
|
10
|
+
- Background HTTP transport with retry and exponential backoff
|
|
11
|
+
- SHA-256 error fingerprinting and client-side deduplication
|
|
12
|
+
- `before_send` hook for event inspection/modification/filtering
|
|
13
|
+
- `ignored_errors` for skipping specific error types or messages
|
|
14
|
+
- `dry_run` mode for transparent debugging
|
|
15
|
+
- `enabled` kill switch
|
|
16
|
+
- FastAPI middleware integration
|
|
17
|
+
- Django middleware integration with auto-init from settings
|
|
18
|
+
- Flask integration via `init_app()`
|
|
19
|
+
- Generic integration via `sys.excepthook` and `threading.excepthook`
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Contributing to bugstack-python
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing!
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/MasonBachmann7/bugstack-python.git
|
|
9
|
+
cd bugstack-python
|
|
10
|
+
python -m venv .venv
|
|
11
|
+
source .venv/bin/activate # or .venv\Scripts\activate on Windows
|
|
12
|
+
pip install -e ".[dev]"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Running Tests
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pytest
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Code Style
|
|
22
|
+
|
|
23
|
+
We use [Ruff](https://docs.astral.sh/ruff/) for linting and formatting:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
ruff check .
|
|
27
|
+
ruff format .
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Type Checking
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
mypy src/bugstack
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Pull Requests
|
|
37
|
+
|
|
38
|
+
1. Fork the repo and create your branch from `main`
|
|
39
|
+
2. Add tests for any new functionality
|
|
40
|
+
3. Ensure all tests pass
|
|
41
|
+
4. Run the linter and type checker
|
|
42
|
+
5. Submit your PR
|
|
43
|
+
|
|
44
|
+
## Reporting Issues
|
|
45
|
+
|
|
46
|
+
Use [GitHub Issues](https://github.com/MasonBachmann7/bugstack-python/issues) to report bugs or request features.
|
bugstack-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BugStack
|
|
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.
|
bugstack-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bugstack
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official BugStack SDK for Python — capture, report, and auto-fix production errors.
|
|
5
|
+
Project-URL: Homepage, https://bugstack.dev
|
|
6
|
+
Project-URL: Documentation, https://docs.bugstack.dev/sdks/python
|
|
7
|
+
Project-URL: Repository, https://github.com/MasonBachmann7/bugstack-python
|
|
8
|
+
Project-URL: Issues, https://github.com/MasonBachmann7/bugstack-python/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/MasonBachmann7/bugstack-python/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: BugStack <team@bugstack.dev>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: auto-fix,bugstack,debugging,error-tracking,monitoring
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Software Development :: Bug Tracking
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Requires-Dist: httpx>=0.24.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: django>=3.2; extra == 'dev'
|
|
30
|
+
Requires-Dist: fastapi>=0.95; extra == 'dev'
|
|
31
|
+
Requires-Dist: flask>=2.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: httpx>=0.24; extra == 'dev'
|
|
33
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: respx>=0.20; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
38
|
+
Provides-Extra: django
|
|
39
|
+
Requires-Dist: django>=3.2; extra == 'django'
|
|
40
|
+
Provides-Extra: fastapi
|
|
41
|
+
Requires-Dist: fastapi>=0.95.0; extra == 'fastapi'
|
|
42
|
+
Provides-Extra: flask
|
|
43
|
+
Requires-Dist: flask>=2.0.0; extra == 'flask'
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
|
|
46
|
+
# bugstack-python
|
|
47
|
+
|
|
48
|
+
Official Python SDK for [BugStack](https://bugstack.dev) — capture, report, and auto-fix production errors.
|
|
49
|
+
|
|
50
|
+
[](https://pypi.org/project/bugstack/)
|
|
51
|
+
[](https://pypi.org/project/bugstack/)
|
|
52
|
+
[](LICENSE)
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install bugstack
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import bugstack
|
|
64
|
+
|
|
65
|
+
bugstack.init(api_key="bs_live_...")
|
|
66
|
+
|
|
67
|
+
try:
|
|
68
|
+
risky_operation()
|
|
69
|
+
except Exception as e:
|
|
70
|
+
bugstack.capture_exception(e)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Framework Integrations
|
|
74
|
+
|
|
75
|
+
### FastAPI
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from fastapi import FastAPI
|
|
79
|
+
from bugstack.integrations.fastapi import FastAPIMiddleware
|
|
80
|
+
|
|
81
|
+
app = FastAPI()
|
|
82
|
+
app.add_middleware(FastAPIMiddleware)
|
|
83
|
+
|
|
84
|
+
bugstack.init(api_key="bs_live_...")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Django
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
# settings.py
|
|
91
|
+
MIDDLEWARE = [
|
|
92
|
+
'bugstack.integrations.django.BugStackMiddleware',
|
|
93
|
+
# ... other middleware
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
BUGSTACK_API_KEY = "bs_live_..."
|
|
97
|
+
BUGSTACK_AUTO_FIX = True # optional
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Flask
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from flask import Flask
|
|
104
|
+
from bugstack.integrations.flask import init_app
|
|
105
|
+
|
|
106
|
+
app = Flask(__name__)
|
|
107
|
+
bugstack.init(api_key="bs_live_...")
|
|
108
|
+
init_app(app)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Generic (sys.excepthook)
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from bugstack.integrations.generic import install_hooks
|
|
115
|
+
|
|
116
|
+
bugstack.init(api_key="bs_live_...")
|
|
117
|
+
install_hooks()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Configuration
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
bugstack.init(
|
|
124
|
+
api_key="bs_live_...", # Required
|
|
125
|
+
environment="production", # Default: "production"
|
|
126
|
+
auto_fix=True, # Enable AI-powered auto-fix
|
|
127
|
+
debug=False, # Log SDK activity
|
|
128
|
+
dry_run=False, # Log without sending
|
|
129
|
+
enabled=True, # Kill switch
|
|
130
|
+
deduplication_window=300, # Seconds (default: 5 min)
|
|
131
|
+
timeout=5.0, # HTTP timeout in seconds
|
|
132
|
+
max_retries=3, # Retry attempts
|
|
133
|
+
ignored_errors=[ # Errors to skip
|
|
134
|
+
KeyboardInterrupt,
|
|
135
|
+
"expected error message",
|
|
136
|
+
],
|
|
137
|
+
before_send=my_hook, # Inspect/modify/drop events
|
|
138
|
+
redact_fields=["password"], # Fields to redact
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Data Transparency
|
|
143
|
+
|
|
144
|
+
### `before_send` Hook
|
|
145
|
+
|
|
146
|
+
Inspect, modify, or drop any event before it leaves your application:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
def before_send(event):
|
|
150
|
+
# Drop health check errors
|
|
151
|
+
if "health" in event.request.route:
|
|
152
|
+
return None
|
|
153
|
+
|
|
154
|
+
# Redact sensitive data
|
|
155
|
+
event.metadata.pop("secret", None)
|
|
156
|
+
|
|
157
|
+
return event
|
|
158
|
+
|
|
159
|
+
bugstack.init(api_key="bs_live_...", before_send=before_send)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### `ignored_errors`
|
|
163
|
+
|
|
164
|
+
Skip specific error types or messages:
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
bugstack.init(
|
|
168
|
+
api_key="bs_live_...",
|
|
169
|
+
ignored_errors=[
|
|
170
|
+
KeyboardInterrupt, # By type
|
|
171
|
+
SystemExit, # By type
|
|
172
|
+
"Connection reset", # By exact message
|
|
173
|
+
],
|
|
174
|
+
)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### `dry_run` Mode
|
|
178
|
+
|
|
179
|
+
See exactly what would be sent without making any network requests:
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
bugstack.init(api_key="bs_live_...", dry_run=True)
|
|
183
|
+
# Prints: [BugStack DryRun] Would send: { ... }
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## What Gets Sent
|
|
187
|
+
|
|
188
|
+
Every error event contains exactly this — nothing more:
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"apiKey": "bs_live_...",
|
|
193
|
+
"error": {
|
|
194
|
+
"message": "division by zero",
|
|
195
|
+
"stackTrace": "Traceback (most recent call last)...",
|
|
196
|
+
"file": "app/api/handler.py",
|
|
197
|
+
"function": "process_request",
|
|
198
|
+
"fingerprint": "a1b2c3d4e5f6g7h8"
|
|
199
|
+
},
|
|
200
|
+
"environment": {
|
|
201
|
+
"language": "python",
|
|
202
|
+
"languageVersion": "3.12.1",
|
|
203
|
+
"framework": "fastapi",
|
|
204
|
+
"frameworkVersion": "0.109.0",
|
|
205
|
+
"os": "linux",
|
|
206
|
+
"sdkVersion": "1.0.0"
|
|
207
|
+
},
|
|
208
|
+
"timestamp": "2026-01-15T08:30:00+00:00"
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
No cookies. No IP addresses. No user data. No request bodies (unless you explicitly include them).
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
MIT — see [LICENSE](LICENSE).
|
bugstack-1.0.0/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# bugstack-python
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [BugStack](https://bugstack.dev) — capture, report, and auto-fix production errors.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/bugstack/)
|
|
6
|
+
[](https://pypi.org/project/bugstack/)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install bugstack
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import bugstack
|
|
19
|
+
|
|
20
|
+
bugstack.init(api_key="bs_live_...")
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
risky_operation()
|
|
24
|
+
except Exception as e:
|
|
25
|
+
bugstack.capture_exception(e)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Framework Integrations
|
|
29
|
+
|
|
30
|
+
### FastAPI
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from fastapi import FastAPI
|
|
34
|
+
from bugstack.integrations.fastapi import FastAPIMiddleware
|
|
35
|
+
|
|
36
|
+
app = FastAPI()
|
|
37
|
+
app.add_middleware(FastAPIMiddleware)
|
|
38
|
+
|
|
39
|
+
bugstack.init(api_key="bs_live_...")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Django
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
# settings.py
|
|
46
|
+
MIDDLEWARE = [
|
|
47
|
+
'bugstack.integrations.django.BugStackMiddleware',
|
|
48
|
+
# ... other middleware
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
BUGSTACK_API_KEY = "bs_live_..."
|
|
52
|
+
BUGSTACK_AUTO_FIX = True # optional
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Flask
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from flask import Flask
|
|
59
|
+
from bugstack.integrations.flask import init_app
|
|
60
|
+
|
|
61
|
+
app = Flask(__name__)
|
|
62
|
+
bugstack.init(api_key="bs_live_...")
|
|
63
|
+
init_app(app)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Generic (sys.excepthook)
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from bugstack.integrations.generic import install_hooks
|
|
70
|
+
|
|
71
|
+
bugstack.init(api_key="bs_live_...")
|
|
72
|
+
install_hooks()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
bugstack.init(
|
|
79
|
+
api_key="bs_live_...", # Required
|
|
80
|
+
environment="production", # Default: "production"
|
|
81
|
+
auto_fix=True, # Enable AI-powered auto-fix
|
|
82
|
+
debug=False, # Log SDK activity
|
|
83
|
+
dry_run=False, # Log without sending
|
|
84
|
+
enabled=True, # Kill switch
|
|
85
|
+
deduplication_window=300, # Seconds (default: 5 min)
|
|
86
|
+
timeout=5.0, # HTTP timeout in seconds
|
|
87
|
+
max_retries=3, # Retry attempts
|
|
88
|
+
ignored_errors=[ # Errors to skip
|
|
89
|
+
KeyboardInterrupt,
|
|
90
|
+
"expected error message",
|
|
91
|
+
],
|
|
92
|
+
before_send=my_hook, # Inspect/modify/drop events
|
|
93
|
+
redact_fields=["password"], # Fields to redact
|
|
94
|
+
)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Data Transparency
|
|
98
|
+
|
|
99
|
+
### `before_send` Hook
|
|
100
|
+
|
|
101
|
+
Inspect, modify, or drop any event before it leaves your application:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
def before_send(event):
|
|
105
|
+
# Drop health check errors
|
|
106
|
+
if "health" in event.request.route:
|
|
107
|
+
return None
|
|
108
|
+
|
|
109
|
+
# Redact sensitive data
|
|
110
|
+
event.metadata.pop("secret", None)
|
|
111
|
+
|
|
112
|
+
return event
|
|
113
|
+
|
|
114
|
+
bugstack.init(api_key="bs_live_...", before_send=before_send)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### `ignored_errors`
|
|
118
|
+
|
|
119
|
+
Skip specific error types or messages:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
bugstack.init(
|
|
123
|
+
api_key="bs_live_...",
|
|
124
|
+
ignored_errors=[
|
|
125
|
+
KeyboardInterrupt, # By type
|
|
126
|
+
SystemExit, # By type
|
|
127
|
+
"Connection reset", # By exact message
|
|
128
|
+
],
|
|
129
|
+
)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### `dry_run` Mode
|
|
133
|
+
|
|
134
|
+
See exactly what would be sent without making any network requests:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
bugstack.init(api_key="bs_live_...", dry_run=True)
|
|
138
|
+
# Prints: [BugStack DryRun] Would send: { ... }
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## What Gets Sent
|
|
142
|
+
|
|
143
|
+
Every error event contains exactly this — nothing more:
|
|
144
|
+
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"apiKey": "bs_live_...",
|
|
148
|
+
"error": {
|
|
149
|
+
"message": "division by zero",
|
|
150
|
+
"stackTrace": "Traceback (most recent call last)...",
|
|
151
|
+
"file": "app/api/handler.py",
|
|
152
|
+
"function": "process_request",
|
|
153
|
+
"fingerprint": "a1b2c3d4e5f6g7h8"
|
|
154
|
+
},
|
|
155
|
+
"environment": {
|
|
156
|
+
"language": "python",
|
|
157
|
+
"languageVersion": "3.12.1",
|
|
158
|
+
"framework": "fastapi",
|
|
159
|
+
"frameworkVersion": "0.109.0",
|
|
160
|
+
"os": "linux",
|
|
161
|
+
"sdkVersion": "1.0.0"
|
|
162
|
+
},
|
|
163
|
+
"timestamp": "2026-01-15T08:30:00+00:00"
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
No cookies. No IP addresses. No user data. No request bodies (unless you explicitly include them).
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting a Vulnerability
|
|
4
|
+
|
|
5
|
+
If you discover a security vulnerability, please report it responsibly:
|
|
6
|
+
|
|
7
|
+
**Email:** security@bugstack.dev
|
|
8
|
+
|
|
9
|
+
Please do **not** open a public GitHub issue for security vulnerabilities.
|
|
10
|
+
|
|
11
|
+
We will respond within 48 hours and work with you to understand and address the issue.
|
|
12
|
+
|
|
13
|
+
## Supported Versions
|
|
14
|
+
|
|
15
|
+
| Version | Supported |
|
|
16
|
+
|---------|-----------|
|
|
17
|
+
| 1.x | Yes |
|
|
18
|
+
|
|
19
|
+
## Security Design
|
|
20
|
+
|
|
21
|
+
- The SDK never captures request bodies, headers, cookies, or IP addresses by default
|
|
22
|
+
- All data transmission uses HTTPS
|
|
23
|
+
- The `before_send` hook lets you inspect and filter every event before it leaves your application
|
|
24
|
+
- The `dry_run` mode lets you verify exactly what would be sent
|
|
25
|
+
- The SDK never throws exceptions — all errors are caught internally
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Basic BugStack SDK usage example."""
|
|
2
|
+
|
|
3
|
+
import bugstack
|
|
4
|
+
|
|
5
|
+
# Initialize the SDK
|
|
6
|
+
bugstack.init(
|
|
7
|
+
api_key="bs_live_your_api_key_here",
|
|
8
|
+
environment="production",
|
|
9
|
+
auto_fix=True,
|
|
10
|
+
debug=True, # See SDK activity in console
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
# Manual exception capture
|
|
14
|
+
try:
|
|
15
|
+
result = 1 / 0
|
|
16
|
+
except Exception as e:
|
|
17
|
+
bugstack.capture_exception(e)
|
|
18
|
+
|
|
19
|
+
# Capture from except block (auto-detects current exception)
|
|
20
|
+
try:
|
|
21
|
+
int("not a number")
|
|
22
|
+
except ValueError:
|
|
23
|
+
bugstack.capture_exception()
|
|
24
|
+
|
|
25
|
+
# With metadata
|
|
26
|
+
try:
|
|
27
|
+
raise RuntimeError("something went wrong")
|
|
28
|
+
except RuntimeError as e:
|
|
29
|
+
bugstack.capture_exception(e, metadata={"user_id": "42", "action": "checkout"})
|