Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an afterInitProcessor handler that will be called after Sentry is initialized #11942

Closed
alSergey opened this issue May 7, 2024 · 2 comments

Comments

@alSergey
Copy link

alSergey commented May 7, 2024

Problem Statement

There is currently no way to subscribe to Sentry's initialization event and execute arbitrary code. This may be necessary if the project uses some custom subscriptions that depend on Sentry and they must be executed after Sentry is initialized.

Solution Brainstorm

Add a new hook that will receive a callback that will be called after Sentry is initialized. It should work similarly to addEventProcessor (it accepts a callback and calls it after initialization).

@Lms24
Copy link
Member

Lms24 commented May 10, 2024

Hey @alSergey thanks for writing in!

I'm curious about your use case:

This may be necessary if the project uses some custom subscriptions that depend on Sentry and they must be executed after Sentry is initialized

Can you elaborate on that? This is the first time we're hearing about this and I'm curious :)

Generally, initializing the SDK via Sentry.init is synchronous, so I'd argue you can emit an event yourself simply after the init call if that makes sense:

Sentry.init({});
notifyListenersThatSentryIsInitialized(); // #namingishard

Let me know if this works for you

@alSergey
Copy link
Author

@Lms24 Thank you very much for the advice, I hadn't thought of that. Everything worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants