Skip to content

Commit 813957d

Browse files
committed
feat(core): Add lifecycle hooks
1 parent f8b56b0 commit 813957d

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

packages/core/src/baseclient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
9797
/** Holds flushable */
9898
private _outcomes: { [key: string]: number } = {};
9999

100+
private _hooks: Record<> = {};
101+
100102
/**
101103
* Initializes this client instance.
102104
*
@@ -351,6 +353,8 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
351353
}
352354
}
353355

356+
public on(): () => void {}
357+
354358
/** Updates existing session based on the provided event */
355359
protected _updateSessionFromEvent(session: Session, event: Event): void {
356360
let crashed = false;

packages/types/src/client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { Scope } from './scope';
88
import type { SdkMetadata } from './sdkmetadata';
99
import type { Session, SessionAggregates } from './session';
1010
import type { Severity, SeverityLevel } from './severity';
11+
import type { Transaction } from './transaction';
1112
import type { Transport } from './transport';
1213

1314
/**
@@ -147,4 +148,13 @@ export interface Client<O extends ClientOptions = ClientOptions> {
147148
* @param event The dropped event.
148149
*/
149150
recordDroppedEvent(reason: EventDropReason, dataCategory: DataCategory, event?: Event): void;
151+
152+
// HOOKS
153+
154+
on(
155+
hook: 'startTransaction' | 'transactionFinish',
156+
callback: (transaction: Transaction) => Transaction | null,
157+
): () => void;
158+
159+
emit(hook: Hooks, ...params: unknown[]): void;
150160
}

packages/types/src/hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type Hooks = 'startTransaction' | 'transactionFinish';

packages/types/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,4 @@ export type { WrappedFunction } from './wrappedfunction';
9696
export type { Instrumenter } from './instrumenter';
9797

9898
export type { BrowserClientReplayOptions } from './browseroptions';
99+
export type { Hooks } from './hooks';

0 commit comments

Comments
 (0)