diff --git a/.env.template b/.env.template index b0092ed..c0966a6 100644 --- a/.env.template +++ b/.env.template @@ -18,3 +18,6 @@ TFA_PASSWORD=gmail_pass # Example, note double $ for escaping # SAVE_MEDIA_TO='/records/$${Y}/$${m}/$${F}T$${t}_$${N}_$${SN}' + +# Monitor errors +# SENTRY_DSN=https://XXX.sentry.io/YYY diff --git a/arlo-downloader.py b/arlo-downloader.py index 2a52060..6c1f1ce 100644 --- a/arlo-downloader.py +++ b/arlo-downloader.py @@ -9,6 +9,25 @@ from config import Config +# Optionally, enable Sentry. Should be initialized as early as possible. +SENTRY_DSN = os.getenv("SENTRY_DSN", "_invalid") +if SENTRY_DSN != "_invalid": + import sentry_sdk + + sentry_sdk.init( + dsn=SENTRY_DSN, + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + traces_sample_rate=1.0, + # Set profiles_sample_rate to 1.0 to profile 100% + # of sampled transactions. + # We recommend adjusting this value in production. + profiles_sample_rate=1.0, + ) + print("Sentry enabled.") +else: + print("Sentry disabled.") + def parse_arguments(): diff --git a/compose.yml b/compose.yml index acd7fb7..f6e3cb8 100644 --- a/compose.yml +++ b/compose.yml @@ -16,3 +16,4 @@ services: DEBUG: ${DEBUG:-0} UID: ${UID:-999} GID: ${GID:-999} + SENTRY_DSN: ${SENTRY_DSN:-_invalid} diff --git a/requirements.txt b/requirements.txt index db445b4..05e1dfe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,6 @@ cloudscraper>=1.2.71 # TODO: switch to release when better errors is merged pyaarlo @ git+https://github.com/twrecked/pyaarlo@bb84163fc576c3756bf3a535b8cfe5a436bee8a1 + +# optional +sentry-sdk>=2.12.0