Skip to content

Commit

Permalink
fix(types): Add AttachmentType and use for envelope `attachment_typ…
Browse files Browse the repository at this point in the history
…e` property (#10946)

`Attachment.attachmentType` was changed to use a string union. The
`attachment_type` header property should match so I added an extra type
for this.
  • Loading branch information
timfish authored and AbhiPrasad committed Mar 7, 2024
1 parent 9144a86 commit 9b4c855
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/test/lib/transports/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ATTACHMENT_ENVELOPE = createEnvelope<EventEnvelope>(
length: 20,
filename: 'test-file.txt',
content_type: 'text/plain',
attachment_type: 'text',
attachment_type: 'event.attachment',
},
'attachment content',
] as AttachmentItem,
Expand Down
19 changes: 18 additions & 1 deletion packages/types/src/attachment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
export type AttachmentType =
| 'event.attachment'
| 'event.minidump'
| 'event.applecrashreport'
| 'unreal.context'
| 'unreal.logs';

/**
* An attachment to an event. This is used to upload arbitrary data to Sentry.
*
* Please take care to not add sensitive information in attachments.
*
* https://develop.sentry.dev/sdk/envelopes/#attachment
*/
export interface Attachment {
data: string | Uint8Array;
filename: string;
contentType?: string;
attachmentType?: string;
/**
* The type of the attachment. Defaults to `event.attachment` if not specified.
*/
attachmentType?: AttachmentType;
}
3 changes: 2 additions & 1 deletion packages/types/src/envelope.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { AttachmentType } from './attachment';
import type { SerializedCheckIn } from './checkin';
import type { ClientReport } from './clientreport';
import type { DsnComponents } from './dsn';
Expand Down Expand Up @@ -72,7 +73,7 @@ type AttachmentItemHeaders = {
length: number;
filename: string;
content_type?: string;
attachment_type?: string;
attachment_type?: AttachmentType;
};
type UserFeedbackItemHeaders = { type: 'user_report' };
type FeedbackItemHeaders = { type: 'feedback' };
Expand Down

0 comments on commit 9b4c855

Please sign in to comment.