-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: Add attachments API #5004
Conversation
I like this idea. I think that it should be client defined, and we pass it into the transport as an option. We did something similar with @lforst's work on client reports. See: #5008 // core/src/baseclient.ts
this._transport = options.transport({
serializeEnvelope: mySpecificSerializeEnvelopeImpl,
...options.transportOptions,
url,
});
The changes in #5008 should mean that we respect rate limits per envelope items. See: sentry-javascript/packages/core/src/transports/base.ts Lines 46 to 54 in 1c5bff0
Awesome ❤️ This was a quick first pass - I'll come back and do another review tomorrow when I get some time :) |
We don't just need |
35fd7ea
to
2788c6c
Compare
This comment was marked as resolved.
This comment was marked as resolved.
@AbhiPrasad I think this is ready for a 2nd pass. It definitely still needs some tests to cover the changes around mutable hints + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were we able to test if babel will polyfill TextEncoder if they set the according browserslist?
@@ -86,7 +86,7 @@ export function getNativeFetchImplementation(): FetchImpl { | |||
* @param url report endpoint | |||
* @param body report payload | |||
*/ | |||
export function sendReport(url: string, body: string): void { | |||
export function sendReport(url: string, body: string | Uint8Array): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing the func signature here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serializeEnvelope
now returns string | Uint8Array
. In this case it will never actually be a Uint8Array
because there's no attachment but both sendBeacon
and fetch
take body: string | Uint8Array
so it seemed the best thing to do.
It looks like babel now just expects you to import |
Awesome, I think after the transport changes get extracted, we should be good to go to merge this in! |
That is done already! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good starting point for us - @getsentry/team-web-sdk-frontend I would appreciate another set of eyes to confirm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thank you Tim!
How quickly can we get this into a release so I can test it all in this PR 😆 |
I think we can merge tommorow, so get it out in a release by end of this week! |
- Adds `Attachment` interface and extends `AttachmentItemHeaders` with required fields - Adds `addAttachment`, `getAttachments` and `clearAttachments` to `Scope` - Adds `attachments: Attachment[]` to `EventHint` - In the private capture/process/prepare/send methods in the `BaseClient`, the `EventHint` argument has moved as it's no longer optional - We can't mutate the hint if it's undefined! - Copies attachments from the scope to the hint in `_prepareEvent` - Adds optional `textEncoder` to `InternalBaseTransportOptions` and overrides this in the node client to support node 8-10 - Manually pass `new TextEncoder()` in many of the tests so they pass on node.js 8-10 - Adds binary serialisation support for envelopes - `serializeEnvelope` returns `string | Uint8Array` which all transports supported without modification - Defaults to concatenating strings when no attachments are found. String concatenation is about 10x faster than the binary serialisation - Rewrites `parseEnvelope` in `testutils.ts` so that it can parse binary envelopes
After upgrading sentry to v7 getting below error. I am using sentry with node express project - @timfish @AbhiPrasad
|
Closes #4996
This PR:
Attachment
interface and extendsAttachmentItemHeaders
with required fieldsaddAttachment
,getAttachments
andclearAttachments
toScope
attachments: Attachment[]
toEventHint
BaseClient
, theEventHint
argument has moved as it's no longer optional_prepareEvent
textEncoder
toInternalBaseTransportOptions
and overrides this in the node client to support node 8-10new TextEncoder()
in many of the tests so they pass on node.js 8-10serializeEnvelope
returnsstring | Uint8Array
which all transports supported without modificationparseEnvelope
intestutils.ts
so that it can parse binary envelopesBonus