Skip to content

feat(core): emit beforeEnvelope hook #7448

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

Merged
merged 5 commits into from
Mar 14, 2023
Merged

Conversation

JonasBa
Copy link
Member

@JonasBa JonasBa commented Mar 13, 2023

Emit beforeEnvelope event on the client when sending event.

@JonasBa JonasBa requested a review from AbhiPrasad March 13, 2023 20:25
@github-actions
Copy link
Contributor

github-actions bot commented Mar 13, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.41 KB (+0.07% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 63.3 KB (+0.05% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.99 KB (+0.06% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 56.21 KB (+0.06% 🔺)
@sentry/browser - Webpack (gzipped + minified) 20.65 KB (+0.07% 🔺)
@sentry/browser - Webpack (minified) 67.44 KB (+0.05% 🔺)
@sentry/react - Webpack (gzipped + minified) 20.68 KB (+0.07% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 52.09 KB (+7.29% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 33.66 KB (+21.78% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 26 KB (+0.38% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.17 KB (0%)
@sentry/replay - Webpack (gzipped + minified) 37.19 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.3 KB (+0.18% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 54.39 KB (+0.03% 🔺)


function send(envelope: Envelope): PromiseLike<void | TransportMakeRequestResponse> {
const filteredEnvelopeItems: EnvelopeItem[] = [];

// Drop rate limited items from envelope
forEachEnvelopeItem(envelope, (item, type) => {
if (client && client.emit) {
client.emit('beforeEnvelope', envelope);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be called above forEachEnvelopeItem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, idk why I placed it here but yes, it def should be. Do I even need to feature check here btw, can I just client.emit...?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emit may be unavailable when using a custom client, so until v8 we need to guard this, sadly!

@AbhiPrasad AbhiPrasad changed the title feat(sdk): emit beforeEnvelope feat(core): emit beforeEnvelope hook Mar 14, 2023
@JonasBa
Copy link
Member Author

JonasBa commented Mar 14, 2023

@AbhiPrasad @mydea
There seems to be a problem that is unrelated to my changes - I keep seeing this error in e2e tests

  > @sentry-internal/tracing:"build:tarball"
  
  $ ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm
  
  ERROR: Directory 'build/npm' does not exist in @sentry-internal/tracing.
  This script should only be executed after you've run `yarn build`.

@AbhiPrasad
Copy link
Member

Tests are too flaky 😭

@JonasBa
Copy link
Member Author

JonasBa commented Mar 14, 2023

hehe yeah, I have been restarting them 😅

@AbhiPrasad AbhiPrasad merged commit 42e542e into develop Mar 14, 2023
@AbhiPrasad AbhiPrasad deleted the feat/sdk/beforeenvelope branch March 14, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants