Skip to content

Latest commit

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Flask-Sentry

Sentry and Spotlight integration for Flask.

  • Configure and initialize Sentry SDK for Flask and the browser
  • Spotlight integration
  • Properly handle debug mode

Installation

pip install flask-sentry

Usage

fromflaskimportappfromflask_sentryimportSentryapp=Flask(__name__)
Sentry(app, dsn="http://DSN")

Use init_sentry() in your template:

<!DOCTYPE html>
<html>
<head>
{{ init_sentry() }}
</head>
</html>

Using spotlight

Install spotlight:

npm install @spotlightjs/spotlight

Run spotlight before starting your app:

flask spotlight

Include the spotlight init script in your template, either using init_sentry() or only spotlight using init_spotlight().

<!DOCTYPE html>
<html>
<head>
{{ init_spotlight() }}
</head>
</html>

Will only render something if spotlight is enabled.

Spotlight is automatically enabled in debug mode when a spotlight server is detected. Otherwise, spotlight is disabled.

Configuration

Config keyExtension argument DescriptionDefault
SENTRY_DSNdsnSentry DSN
SENTRY_***kwargsAny options available in the sentry_sdk.init() function
SENTRY_DEBUG_ENABLEDdebug_enabledWhether to enable sending to the dsn in debugFalse
SPOTLIGHT_URLspotlight_urlTrue or a spotlight url to enable spotlightTrue
SPOTLIGHT_DETECTdetect_spotlightWhether to detect if the spotlight sidecar is running before enabling spotlightTrue
SPOTLIGHT_CMDspotlight_cmdThe spotlight cmd to launch the sidecarnpx @spotlightjs/spotlight
SPOTLIGHT_SCRIPTspotlight_scriptThe spotlight script in the browserCurrently recommended url
SENTRY_BROWSERbrowserWhether to enable sentry sdk in the browserTrue
SENTRY_BROWSER_OPTIONSbrowser_optionsOptions for the browser sdk{}
SENTRY_BROWSER_TRACINGbrowser_tracingWhether to enable tracing in the browserTrue
SENTRY_BROWSER_REPLAYbrowser_replayWhether to enable session replay in the browserTrue
SENTRY_BROWSER_SCRIPTbrowser_scriptSentry sdk script url (do not load script if None)Currently recommended url
SENTRY_BROWSER_SCRIPT_INTEGRITYbrowser_script_integrityIntegrity hash for the sdk scriptHash for currently recommended url

About

Sentry and Spotlight integration for Flask

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages