Skip to content

Commit 42e542e

Browse files
JonasBaAbhiPrasad
andauthored
feat(core): emit beforeEnvelope hook (#7448)
Co-authored-by: Abhijeet Prasad <[email protected]>
1 parent a34dab6 commit 42e542e

File tree

1 file changed

+6
-1
lines changed
  • packages/core/src/transports

1 file changed

+6
-1
lines changed

packages/core/src/transports/base.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import {
2424
updateRateLimits,
2525
} from '@sentry/utils';
2626

27+
import { getCurrentHub } from '../hub';
28+
2729
export const DEFAULT_TRANSPORT_BUFFER_SIZE = 30;
2830

2931
/**
@@ -40,11 +42,14 @@ export function createTransport(
4042
),
4143
): Transport {
4244
let rateLimits: RateLimits = {};
43-
4445
const flush = (timeout?: number): PromiseLike<boolean> => buffer.drain(timeout);
46+
const client = getCurrentHub().getClient();
4547

4648
function send(envelope: Envelope): PromiseLike<void | TransportMakeRequestResponse> {
4749
const filteredEnvelopeItems: EnvelopeItem[] = [];
50+
if (client && client.emit) {
51+
client.emit('beforeEnvelope', envelope);
52+
}
4853

4954
// Drop rate limited items from envelope
5055
forEachEnvelopeItem(envelope, (item, type) => {

0 commit comments

Comments
 (0)