Skip to main content

Python errors Catcher module for Hawk.

Project description

Hawk Python Catcher

Python errors Catcher module for Hawk.so.

Usage

Register an account and get a new project token.

If you want to connect specific frameworks see Flask integration, FastAPI integration.

Install module

Install hawk-python-sdk from PyPI.

$ pip install hawk-python-sdk

Import Catcher module to your project.

from hawk_python_sdk import Hawk
from hawk_python_sdk import Hawk

Then enable Hawk Catcher with your token and domain.

hawk = Hawk(
    "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwcm9qZWN0SWQiOiI1ZTZmNWM3NzAzOWI0MDAwMjNmZDViODAiLCJpYXQiOjE1ODQzNTY0NzF9.t-5Gelx3MgHVBrxTsoMyPQAdQ6ufVbPsts9zZLW3gM8")

Now all global errors would be sent to Hawk.

Try-except

If you want to catch errors in try-except blocks then use hawk.catch() in except:

try:
    ...
except:
    hawk.send()

Manual sending

You can also pass event to the hawk.send() call, for example:

try:
    ...
except:
    hawk.send(ValueError("error description"))

Event context

It is possible to pass additional event context for debugging purposes:

try:
    ...
except:
    hawk.send(ValueError("error description"), {"params": "value"})

Affected user

You can also pass user, who affected with specific error:

try:
    ...
except:
    hawk.send(ValueError("error description"), {"params": "value"}, {"id": 123})

Init params

To init Hawk Catcher just pass a project token.

hawk = Hawk('1234567-abcd-8901-efgh-123456789012')

Additional params

If you need to use custom Hawk server then pass a dictionary with params.

hawk = Hawk({
    'token': '1234567-abcd-8901-efgh-123456789012',
    'collector_endpoint': 'https://<id>.k1.hawk.so',
})

Parameters:

name type required description
token str required Your project's Integration Token
release str optional Release name for Suspected Commits feature
collector_endpoint string optional Collector endpoint for sending event to
context dict optional Additional context to be send with every event
before_send Callable[[dict], None] optional This Method allows you to filter any data you don't want sending to Hawk

Requirements

  • Python >= 3.10
  • requests

Links

Repository: https://github.com/codex-team/hawk.python

Report a bug: https://github.com/codex-team/hawk.python/issues

PyPI Package: https://pypi.python.org/pypi/hawk-python-sdk

CodeX Team: https://codex.so/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hawk_python_sdk-3.5.2.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hawk_python_sdk-3.5.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file hawk_python_sdk-3.5.2.tar.gz.

File metadata

  • Download URL: hawk_python_sdk-3.5.2.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.4

File hashes

Hashes for hawk_python_sdk-3.5.2.tar.gz
Algorithm Hash digest
SHA256 9a1d3a071afef31ae0ac4383cd0cee9849fff97b49eb9902207fd92643bb9469
MD5 90939e94a0d8070fa9a7b863019201ea
BLAKE2b-256 647256ccabe737913cdd274cafe3d9b15975b3e3c7e728dc6a88b43711fd5133

See more details on using hashes here.

File details

Details for the file hawk_python_sdk-3.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for hawk_python_sdk-3.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b7e9c2b3ddc764aaf76254f6d0038b855bf3f5f3fcb7e136f0d544168c9a5b9d
MD5 d8418b2d48e82685779a78b087f15c62
BLAKE2b-256 457c605460fef255a6df8e9f6523ae49cfaf4272285ec2acdb6c52e472b7fd4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page