Skip to content

Commit 2350bdb

Browse files
committed
make hook methods optional
1 parent 712feb2 commit 2350bdb

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

packages/core/test/lib/base.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,11 +1742,11 @@ describe('BaseClient', () => {
17421742
traceId: '86f39e84263a4de99c326acab3bfe3bd',
17431743
} as Transaction;
17441744

1745-
client.on('startTransaction', (transaction: Transaction) => {
1745+
client?.on('startTransaction', (transaction: Transaction) => {
17461746
expect(transaction).toEqual(mockTransaction);
17471747
});
17481748

1749-
client.emit('startTransaction', mockTransaction);
1749+
client?.emit('startTransaction', mockTransaction);
17501750
});
17511751
});
17521752
});

packages/types/src/client.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,27 @@ export interface Client<O extends ClientOptions = ClientOptions> {
150150
recordDroppedEvent(reason: EventDropReason, dataCategory: DataCategory, event?: Event): void;
151151

152152
// HOOKS
153+
// TODO(v8): Make the hooks non-optional.
153154

154155
/**
155156
* Register a callback for transaction start and finish.
156157
*/
157-
on(hook: TransactionHookName, callback: TransactionHookCallback): void;
158+
on?(hook: TransactionHookName, callback: TransactionHookCallback): void;
158159

159160
/**
160161
* Register a callback for envelope creation and sending.
161162
*/
162-
on(hook: EnvelopeHookName, callback: EnvelopeHookCallback): void;
163+
on?(hook: EnvelopeHookName, callback: EnvelopeHookCallback): void;
163164

164165
/**
165166
* Fire a hook event for transaction start and finish. Expects to be given a transaction as the
166167
* second argument.
167168
*/
168-
emit(hook: TransactionHookName, ...params: Parameters<TransactionHookCallback>): void;
169+
emit?(hook: TransactionHookName, ...params: Parameters<TransactionHookCallback>): void;
169170

170171
/*
171172
* Fire a hook event for envelope creation and sending. Expects to be given an envelope as the
172173
* second argument.
173174
*/
174-
emit(hook: EnvelopeHookName, ...params: Parameters<EnvelopeHookCallback>): void;
175+
emit?(hook: EnvelopeHookName, ...params: Parameters<EnvelopeHookCallback>): void;
175176
}

0 commit comments

Comments
 (0)