Skip to content

Commit 9b4c855

Browse files
timfishAbhiPrasad
authored andcommitted
fix(types): Add AttachmentType and use for envelope attachment_type 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.
1 parent 9144a86 commit 9b4c855

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

packages/core/test/lib/transports/base.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ATTACHMENT_ENVELOPE = createEnvelope<EventEnvelope>(
2323
length: 20,
2424
filename: 'test-file.txt',
2525
content_type: 'text/plain',
26-
attachment_type: 'text',
26+
attachment_type: 'event.attachment',
2727
},
2828
'attachment content',
2929
] as AttachmentItem,

packages/types/src/attachment.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1+
export type AttachmentType =
2+
| 'event.attachment'
3+
| 'event.minidump'
4+
| 'event.applecrashreport'
5+
| 'unreal.context'
6+
| 'unreal.logs';
7+
8+
/**
9+
* An attachment to an event. This is used to upload arbitrary data to Sentry.
10+
*
11+
* Please take care to not add sensitive information in attachments.
12+
*
13+
* https://develop.sentry.dev/sdk/envelopes/#attachment
14+
*/
115
export interface Attachment {
216
data: string | Uint8Array;
317
filename: string;
418
contentType?: string;
5-
attachmentType?: string;
19+
/**
20+
* The type of the attachment. Defaults to `event.attachment` if not specified.
21+
*/
22+
attachmentType?: AttachmentType;
623
}

packages/types/src/envelope.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { AttachmentType } from './attachment';
12
import type { SerializedCheckIn } from './checkin';
23
import type { ClientReport } from './clientreport';
34
import type { DsnComponents } from './dsn';
@@ -72,7 +73,7 @@ type AttachmentItemHeaders = {
7273
length: number;
7374
filename: string;
7475
content_type?: string;
75-
attachment_type?: string;
76+
attachment_type?: AttachmentType;
7677
};
7778
type UserFeedbackItemHeaders = { type: 'user_report' };
7879
type FeedbackItemHeaders = { type: 'feedback' };

0 commit comments

Comments
 (0)