sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Disable SDK if initialized without a [valid] DSN

Open armcknight opened this issue 3 years ago • 2 comments

Description

If the SDK is initialized with out a DSN, or an invalid one, then it will never be able to upload data for use by customers. But, as of today, it will still gather that data by installing its various runtime mechanisms. This incurs a performance cost with no benefit.

We will even state in a log message that the SDK failed to initialize here: https://github.com/getsentry/sentry-cocoa/blob/63f740dc5141fc10b864f36e13eedd3d8bff79dd/Sources/Sentry/SentryOptions.m#L164

Which isn't quite accurate because methods like startTransaction and swizzleInstanceMethod will still operate, which I wouldn't expect with an uninitialized SDK. For those and other top-level methods, we should check whether the SDK was successfully initialized before proceeding.

That log method should also explicitly state that, if not provided a valid DSN, the SDK will do no further work.

armcknight avatar Feb 21 '23 20:02 armcknight

The benefit of this fix is that the running code doesn't pollute the logs. If you pass in a wrong DSN, the SDK should only print one error message that it couldn't parse the DSN, so users don't miss it.

philipphofmann avatar Mar 01 '23 13:03 philipphofmann

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

github-actions[bot] avatar Mar 23 '23 00:03 github-actions[bot]