Skip to content

How do I dependency inject Sentry? #3047

Answered by adinauer
ajacques asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @ajacques how about injecting IHub instances into your classes? You could use HubAdapter to forward to Sentry static method calls in case this is just for making your application more easily testable and mocking Sentry.

Are you planning on using multiple Sentry projects / DSNs to send data to from a single app? If no, there should be no need to deal with clients directly.

the docs recommend to use ISentryClient when you only need to report events and pass IHub when you need to configure the client (add tags, etc.)

Can you please link the docs page?

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ajacques
Comment options

@adinauer
Comment options

Answer selected by ajacques
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants