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

ref(core): move beforeEnvelope to client #7527

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
*/
protected _sendEnvelope(envelope: Envelope): PromiseLike<void | TransportMakeRequestResponse> | void {
if (this._transport && this._dsn) {
this.emit('beforeEnvelope', envelope);

return this._transport.send(envelope).then(null, reason => {
__DEBUG_BUILD__ && logger.error('Error while sending event:', reason);
});
Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/transports/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import {
updateRateLimits,
} from '@sentry/utils';

import { getCurrentHub } from '../hub';

export const DEFAULT_TRANSPORT_BUFFER_SIZE = 30;

/**
Expand All @@ -43,13 +41,9 @@ export function createTransport(
): Transport {
let rateLimits: RateLimits = {};
const flush = (timeout?: number): PromiseLike<boolean> => buffer.drain(timeout);
const client = getCurrentHub().getClient();

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

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