88
99NS_ASSUME_NONNULL_BEGIN
1010
11+ /* *
12+ * Attachment Type
13+ *
14+ * This enum specifies the type of attachment. The attachment type is primarily used by downstream
15+ * SDKs (such as sentry-godot) to distinguish between different attachment categories.
16+ * Most applications using the SDK directly do not need to specify this, as the default
17+ * @c kSentryAttachmentTypeEventAttachment is used for regular file attachments.
18+ *
19+ *
20+ * See also: https://develop.sentry.dev/sdk/data-model/envelope-items/#attachment
21+ */
22+ typedef NS_ENUM (NSInteger , SentryAttachmentType) {
23+ /* *
24+ * Standard event attachment. This is the default type for user-provided attachments.
25+ */
26+ kSentryAttachmentTypeEventAttachment ,
27+ /* *
28+ * View hierarchy attachment. Automatically set by the SDK when capturing view hierarchy data.
29+ * This type is primarily used by downstream SDKs.
30+ */
31+ kSentryAttachmentTypeViewHierarchy
32+ };
33+
1134/* *
1235 * You can use an attachment to store additional files alongside an event.
1336 */
@@ -62,6 +85,30 @@ SENTRY_NO_INIT
6285 filename:(NSString *)filename
6386 contentType:(nullable NSString *)contentType;
6487
88+ /* *
89+ * Initializes an attachment with data.
90+ * @param data The data for the attachment.
91+ * @param filename The name of the attachment to display in Sentry.
92+ * @param contentType The content type of the attachment. Default is @c "application/octet-stream".
93+ * @param attachmentType The type of the attachment. Default is @c "EventAttachment".
94+ */
95+ - (instancetype )initWithData:(NSData *)data
96+ filename:(NSString *)filename
97+ contentType:(nullable NSString *)contentType
98+ attachmentType:(SentryAttachmentType)attachmentType;
99+
100+ /* *
101+ * Initializes an attachment with data.
102+ * @param path The path of the file whose contents you want to upload to Sentry.
103+ * @param filename The name of the attachment to display in Sentry.
104+ * @param contentType The content type of the attachment. Default is @c "application/octet-stream".
105+ * @param attachmentType The type of the attachment. Default is@c "EventAttachment".
106+ */
107+ - (instancetype )initWithPath:(NSString *)path
108+ filename:(NSString *)filename
109+ contentType:(nullable NSString *)contentType
110+ attachmentType:(SentryAttachmentType)attachmentType;
111+
65112/* *
66113 * The data of the attachment.
67114 */
@@ -82,6 +129,11 @@ SENTRY_NO_INIT
82129 */
83130@property (readonly, nonatomic, copy, nullable) NSString *contentType;
84131
132+ /* *
133+ * The type of the attachment.
134+ */
135+ @property (readonly, nonatomic) SentryAttachmentType attachmentType;
136+
85137@end
86138
87139NS_ASSUME_NONNULL_END
0 commit comments