Skip to content

Capturing user in Flask #769

@kam193

Description

@kam193

tl;dr: What is the recommended way to capture user in Flask, in case when there is no flask-login?

First try is to configure scope, so maybe decorate view with push_scope? Nope - it looks nice, but it is not enough if you want to have user info during e.g. error handling, which could be outside view method.

So we have configure_scope, what tell us the Sentry doc? Great, but only before #758 - before this PR, FlaskIntegration cleared the scope on every app context change (so typically for every request). Now information set global can be shared during requests - not the best option for user info.

And the last try, we have before_send hook, what is currently probably the only way to capture user. Ok, but it's like totally different use as designed for it (stripping sensitive data), and this way is undocumented neither in general Sentry doc, nor in Flask-specific page (as an option for capturing user).

I think we should have a recommended way for capturing user in Flask: by scope (similar like other platforms), hook (which works now) or a special one (like new hook in FlaskIntegration instead of hard coded support for flask-login only).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions