We often don't want to couple our code with a static class like
SentrySdk. Especially to allow our code to be testable.
If that's your case, you can use 2 abstractions:
ISentryClient exposes the
CaptureEvent method and its implementation
SentryClient is responsible for queueing the event to be sent to Sentry. It also abstracts away the internal transport.
IHub on the other hand, holds a client and the current scope. In fact, it extends
ISentryClient and is able to dispatch calls to the right client depending on the current scope.
In order to allow different events to hold different contextual data, you need to know in which scope you are in.
That's the job of the
Hub. It holds the scope management as well as a client.
If all you are doing is sending events, without modification/access to the current scope, then you depend on
ISentryClient. If on the other hand you would like to have access to the current scope by configuring it or binding a different client to it, you depend on
An example using
IHub for testability is SentryLogger and its unit tests SentryLoggerTests.
SentryLogger depends on
IHub because it does modify the scope (through
AddBreadcrumb). In case it only sent events, it should instead depend on