Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enabled flag #2313

Open
danilofuchs opened this issue Sep 26, 2024 · 9 comments
Open

enabled flag #2313

danilofuchs opened this issue Sep 26, 2024 · 9 comments

Comments

@danilofuchs
Copy link

danilofuchs commented Sep 26, 2024

Problem Statement

I want to enable Sentry only in production builds
In other Sentry SDKs there is an enabled option

Solution Brainstorm

No response

Are you willing to submit a PR?

None

@buenaflor
Copy link
Contributor

It's a workaround but you can do this for now

await SentryFlutter.init((options) {
  options.beforeSend = (event, hint) async {
    if (kDebugMode) {
        return null;
    }
    return event;
  };
});

Let's see if we can do this more cleanly and easier

@buenaflor
Copy link
Contributor

buenaflor commented Sep 26, 2024

which enable option do you refer to in other SDKs?

@danilofuchs
Copy link
Author

In JS SDK there's an enabled flag:

Image

@buenaflor
Copy link
Contributor

Gotcha, I will discuss this internally

@danilofuchs danilofuchs changed the title enable flag enabled flag Sep 30, 2024
@buenaflor
Copy link
Contributor

What exactly are you trying to accomplish / expecting, just not send the event in debug builds?

@danilofuchs
Copy link
Author

What exactly are you trying to accomplish / expecting, just not send the event in debug builds?

Exactly! When developing, I will inevitably develop some runtime errors, and I don't want Sentry to be populated with these events, as they can become noise when debugging actual production issues.

For instance, we are notified in Slack for each new issue.

@buenaflor
Copy link
Contributor

In that case I'd use the snippet that I posted above with beforeSend which will achieve exactly what you're trying to do.

We don't have the enabled option in other mobile sdks as well and I want to keep the feature set similar. So I don't think we should add this option now.

@kuhnroyal
Copy link
Contributor

Only setting the DSN in production should do the trick?

@buenaflor
Copy link
Contributor

either setting dsn in prod or using beforeSend, both work - whatever you prefer

if you want to minimize the overhead in general you could conditionally use SentryFlutter.init only on prod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Status: Needs Discussion
Development

No branches or pull requests

3 participants