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

SDK lifecycle hooks #7262

Closed
2 tasks done
AbhiPrasad opened this issue Feb 23, 2023 · 2 comments · Fixed by #7387
Closed
2 tasks done

SDK lifecycle hooks #7262

AbhiPrasad opened this issue Feb 23, 2023 · 2 comments · Fixed by #7387
Assignees

Comments

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Feb 23, 2023

Problem Statement

In order to integrate with profiling, the SDK needs to expose a couple of new lifecycle hooks. Primarily we need hooks on startTransaction, and transaction.finish() so that profiling can start/end profiles.

Replay also needs something similar, but centered around [TBD FILL THIS IN]. For now we aim not to solve for the Replay case specifically, but we should keep it in mind.

Solution Brainstorm

Let's introduce hooks to the Sentry client. These live on the client and as stored as simple function pointers.

type Hook = Record<KnownHooks, Function[]>;

^ The type above prob needs to actually be a union or overload of some sort so we get better intellisense, but our TS version might hold us back from it 😭.

Whenever we need to add a hook, we access the client, and call `client.on('...');

Whenever a hook is called, we call client.emit('...'), which will iterate through the array of hooks and call them all one at a time.

This is special case - but we need this to unblock profiling so let's :shipit:. We keep these APIs completely internal, we can change it later on.

Stretch

Send profiling + transactions in the same envelope

  • profiling stops first when transaction is finished
  • we need some way to combine envelopes (createEnvelope) in transaction.finish
@AbhiPrasad
Copy link
Member Author

Based on whatever we do here - we can update getsentry/rfcs#34 accordingly, but let's try to solve this for JavaScript first, and then try to generalize. We can always fix inconsistencies with v8.

@mydea
Copy link
Member

mydea commented Feb 27, 2023

👍 For replay, we'd love to have something like:

  • onBeforeSend
  • and/or onAfterSend

We can add them as follow-up steps, should be straightforward once the general setup is there 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants