stacktrace-sdk-python
Python SDK for the Artim Stacktrace backend. This package provides basic error reporting and event capture utilities similar to the existing React SDK.
Usage
from bug_sdk_python import ArtimStacktrace
ArtimStacktrace.init(
api_key="your-api-key",
project_id="your-project-id",
)
ArtimStacktrace.capture_message("Something went wrong", level="warn")
try:
1 / 0
except Exception as error:
ArtimStacktrace.capture_exception(error)
ArtimStacktrace.set_user({"id": "123", "email": "user@example.com"})
# Or identify by callback
ArtimStacktrace.identify(lambda: {"id": "123", "email": "user@example.com"})
Features
initsets API key, project id, environment, release, and backend endpointcapture_exceptionsends exception details and stacktracecapture_messagesends simple event messagesset_userandidentifyattach user context to events- default backend endpoint:
https://stacktrace-backend.artim-industries.com/api/events
Using with FastAPI
add this to main.py
@app.middleware("http")
async def artim_middleware(request: Request, call_next):
try:
response = await call_next(request)
return response
except Exception as e:
capture_exception(e)
raise
Environment detection
One project holds several environments (development, staging, production,
plus any custom ones). environment and release are detected automatically and
only need to be passed to init() to override the detection.
Environment is resolved in this order:
environmentpassed toinit()ARTIM_ENV, thenENVIRONMENT,ENV,APP_ENV,STAGE,DJANGO_ENV,FLASK_ENV,RAILS_ENV- Debug flags —
ARTIM_DEBUG,DEBUG,FLASK_DEBUG,DJANGO_DEBUGset to a truthy value, or Django'ssettings.DEBUG→development - otherwise
production
Aliases are normalized: dev, local, debug → development; stage, stg,
preview → staging; prod, live → production. Any other value is kept as
a custom environment and registered on the project automatically.
Release detection
releasepassed toinit()ARTIM_RELEASE, thenAPP_VERSION,RELEASE,SOURCE_VERSION,HEROKU_SLUG_COMMIT,RAILWAY_GIT_COMMIT_SHA,FLY_MACHINE_VERSION,GIT_COMMIT,GITHUB_SHA- Installed package version, when
distributionnames your package:ArtimStacktrace.init(api_key="...", distribution="my-service")
versionfrompyproject.tomlin the working directory- Short git SHA of
HEAD "unknown"plus a warning
To check what the SDK resolved:
ArtimStacktrace.get_environment()
ArtimStacktrace.get_release()
Metadata
Release files for stacktrace-sdk-python 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| stacktrace_sdk_python-0.2.0.tar.gz | 7.1 kB | Without provenance | Details for stacktrace_sdk_python-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| stacktrace_sdk_python-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for stacktrace_sdk_python-0.2.0-py3-none-any.whl |
Total release size: 14.9 kB
Release files / stacktrace_sdk_python-0.2.0.tar.gz
| Download URL | stacktrace_sdk_python-0.2.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03956d121a603c5bbde3299d03401094a6ea2902c1fde3a6b1dd2d851c3e541b
|
|
BLAKE2b-256 checksum How to use checksums |
02f48f314f573fb07d7e31ea9941ff4f5634e9fe817cb1dbf24f656220de1f7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / stacktrace_sdk_python-0.2.0-py3-none-any.whl
| Download URL | stacktrace_sdk_python-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
843ca953f5250883be765d9ce6aa367b3e8fdde884a9e4fe1fb153e5043e8382
|
|
BLAKE2b-256 checksum How to use checksums |
f419d81906fcf916aadf6d7131f3ae1fb89bb292c9bfdf70cbed2664ccf4e0f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Security for stacktrace-sdk-python 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.