Skip to content

feat(transport): Add client report hook to makeTransport #5008

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
Apr 28, 2022

Conversation

lforst
Copy link
Contributor

@lforst lforst commented Apr 28, 2022

This PR introduces an internal option to inject a hook/callback into the transports, that is responsible for collecting client reports within the transport itself.

We are now also dropping individual envelope items that are rate limited, just like we do in the python SDK.

For more context: #5002

Ref: getsentry.atlassian.net/browse/WEB-775

@github-actions
Copy link
Contributor

github-actions bot commented Apr 28, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 18.33 KB (-8.99% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 57.46 KB (-11.08% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.09 KB (-9.37% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 51.66 KB (-10.89% 🔽)
@sentry/browser - Webpack (gzipped + minified) 19.03 KB (-18.12% 🔽)
@sentry/browser - Webpack (minified) 61.54 KB (-24.69% 🔽)
@sentry/react - Webpack (gzipped + minified) 19.05 KB (-18.16% 🔽)
@sentry/nextjs Client - Webpack (gzipped + minified) 42.74 KB (-11.07% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 24.1 KB (-7.58% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 22.62 KB (-7.63% 🔽)

@lforst lforst closed this Apr 28, 2022
@lforst lforst force-pushed the lforst-make-transport-client-report-hook branch from ebf0996 to ebc938a Compare April 28, 2022 11:39
@lforst lforst reopened this Apr 28, 2022
@lforst lforst marked this pull request as ready for review April 28, 2022 12:42
@lforst lforst requested a review from AbhiPrasad April 28, 2022 12:42
Comment on lines 63 to 71
const map = {
session: 'session',
sessions: 'session',
attachment: 'attachment',
transaction: 'transaction',
event: 'error',
client_report: 'internal',
user_report: 'default',
} as const;
Copy link
Member

Choose a reason for hiding this comment

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

nit: Let's extract this out to a top level constant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you replace the entire function with the top level constant or would you just move it in outer scope?

Copy link
Member

Choose a reason for hiding this comment

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

Either works for me - your call here.

@@ -22,11 +22,18 @@ export function addItemToEnvelope<E extends Envelope>(envelope: E, newItem: E[1]
}

/**
* Get the type of the envelope. Grabs the type from the first envelope item.
* Convenience function to loop through the items and item types of an envelope.
* (This function was mostly created because working with envelope types is painful at the moment)
Copy link
Member

Choose a reason for hiding this comment

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

on purpose because they are tuple types :P - but very fair

Introducing something like forEachEnvelopeItem is actually good behaviour because we intentionally want to treat the envelope data structure as a void pointer (only allow functions to access and mutate it).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. Did not know that - thanks for bringing it up!

@@ -14,7 +16,9 @@ export type TransportMakeRequestResponse = {

export interface InternalBaseTransportOptions {
bufferSize?: number;
recordDroppedEvent?: (reason: EventDropReason, dataCategory: DataCategory) => void;
Copy link
Member

Choose a reason for hiding this comment

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

Should we just make this required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed: yeah we should as clients should always pass this in

@AbhiPrasad AbhiPrasad added this to the 7.0.0 milestone Apr 28, 2022
@lforst lforst requested a review from AbhiPrasad April 28, 2022 13:40
@lforst lforst merged commit de2822b into 7.x Apr 28, 2022
@lforst lforst deleted the lforst-make-transport-client-report-hook branch April 28, 2022 14:03
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.

2 participants