danielgek / nativescript-sentry

Sentry java/cocoa for nativescript
Apache License 2.0
27 stars 30 forks source link

Support beforeSend #42

Open mm-spiio opened 4 years ago

mm-spiio commented 4 years ago

Is there a way to support the beforeSend option? I don't want to log things when developing locally... Something like this:

Sentry.init(
    { dsn: "DSN", beforeSend: (event, hint) => { 
        if (IS_DEBUG) { 
            console.error(hint.originalException || hint.syntheticException || event); 
            return null; 
        } 
        return event; 
    }
}); 
TemaSM commented 4 years ago

@mm-spiio you can transform your Sentry.init() to something like this:

!IS_DEBUG && Sentry.init(/* your options */)
mm-spiio commented 4 years ago

@TemaSM I don't think so. That just does not initialize Sentry if DEBUG is true. But then in the code all the "log" statements are still there and then it'd try to log them on a not-initialized sentry object.