Skip to content

Return client from init methods #12495

@mydea

Description

@mydea

It is stated in develop docs that init should return something, e.g. a disposable or the client that was created.

Currently, we return void. We should align this with the Unified API, as that also has benefits for the user - today, you sometimes have to do this slightly weird thing:

Sentry.init();

const client = Sentry.getClient();
// Need to guard for this always :(
if (client) {
  client.addIntegration(...);
}

Which would be much nicer as:

const client = Sentry.init();

We already always create a client that could be returned (it may be disabled, but this is fine), so this should be easy to do.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions