Skip to content

Commit aa61cd8

Browse files
authored
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 82c356d commit aa61cd8

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-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
@@ -22,7 +22,7 @@ const ATTACHMENT_ENVELOPE = createEnvelope<EventEnvelope>(
2222
length: 20,
2323
filename: 'test-file.txt',
2424
content_type: 'text/plain',
25-
attachment_type: 'text',
25+
attachment_type: 'event.attachment',
2626
},
2727
'attachment content',
2828
] as AttachmentItem,

packages/types/src/attachment.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
export type AttachmentType =
2+
| 'event.attachment'
3+
| 'event.minidump'
4+
| 'event.applecrashreport'
5+
| 'unreal.context'
6+
| 'unreal.logs';
7+
18
/**
29
* An attachment to an event. This is used to upload arbitrary data to Sentry.
310
*
@@ -23,5 +30,5 @@ export interface Attachment {
2330
/**
2431
* The type of the attachment. Defaults to `event.attachment` if not specified.
2532
*/
26-
attachmentType?: 'event.attachment' | 'event.minidump' | 'event.applecrashreport' | 'unreal.context' | 'unreal.logs';
33+
attachmentType?: AttachmentType;
2734
}

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';
@@ -66,7 +67,7 @@ type AttachmentItemHeaders = {
6667
length: number;
6768
filename: string;
6869
content_type?: string;
69-
attachment_type?: string;
70+
attachment_type?: AttachmentType;
7071
};
7172
type UserFeedbackItemHeaders = { type: 'user_report' };
7273
type FeedbackItemHeaders = { type: 'feedback' };

0 commit comments

Comments
 (0)