Skip to content

SDK lifecycle hooks #7262

Closed
Closed
@AbhiPrasad

Description

@AbhiPrasad

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

Metadata

Metadata

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions