Skip to content
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
### Improvements

- Replace deprecated SCNetworkReachability with NWPathMonitor (#6019)
- Expose attachment type on `SentryAttachment` for downstream SDKs (like sentry-godot) (#6521)
- Increase attachment max size to 100MB (#6537)

## 8.57.0
Expand Down
52 changes: 52 additions & 0 deletions Sources/Sentry/Public/SentryAttachment.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@

NS_ASSUME_NONNULL_BEGIN

/**
* Attachment Type
*
* This enum specifies the type of attachment. The attachment type is primarily used by downstream
* SDKs (such as sentry-godot) to distinguish between different attachment categories.
* Most applications using the SDK directly do not need to specify this, as the default
* @c kSentryAttachmentTypeEventAttachment is used for regular file attachments.
*
*
* See also: https://develop.sentry.dev/sdk/data-model/envelope-items/#attachment
*/
typedef NS_ENUM(NSInteger, SentryAttachmentType) {
/**
* Standard event attachment. This is the default type for user-provided attachments.
*/
kSentryAttachmentTypeEventAttachment,
/**
* View hierarchy attachment. Automatically set by the SDK when capturing view hierarchy data.
* This type is primarily used by downstream SDKs.
*/
kSentryAttachmentTypeViewHierarchy
};

/**
* You can use an attachment to store additional files alongside an event.
*/
Expand Down Expand Up @@ -62,6 +85,30 @@ SENTRY_NO_INIT
filename:(NSString *)filename
contentType:(nullable NSString *)contentType;

/**
* Initializes an attachment with data.
* @param data The data for the attachment.
* @param filename The name of the attachment to display in Sentry.
* @param contentType The content type of the attachment. Default is @c "application/octet-stream".
* @param attachmentType The type of the attachment. Default is @c "EventAttachment".
*/
- (instancetype)initWithData:(NSData *)data
filename:(NSString *)filename
contentType:(nullable NSString *)contentType
attachmentType:(SentryAttachmentType)attachmentType;

/**
* Initializes an attachment with data.
* @param path The path of the file whose contents you want to upload to Sentry.
* @param filename The name of the attachment to display in Sentry.
* @param contentType The content type of the attachment. Default is @c "application/octet-stream".
* @param attachmentType The type of the attachment. Default is@c "EventAttachment".
*/
- (instancetype)initWithPath:(NSString *)path
filename:(NSString *)filename
contentType:(nullable NSString *)contentType
attachmentType:(SentryAttachmentType)attachmentType;

/**
* The data of the attachment.
*/
Expand All @@ -82,6 +129,11 @@ SENTRY_NO_INIT
*/
@property (readonly, nonatomic, copy, nullable) NSString *contentType;

/**
* The type of the attachment.
*/
@property (readonly, nonatomic) SentryAttachmentType attachmentType;

@end

NS_ASSUME_NONNULL_END
42 changes: 0 additions & 42 deletions Sources/Sentry/include/SentryAttachment+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,8 @@ NS_ASSUME_NONNULL_BEGIN
FOUNDATION_EXPORT NSString *const kSentryAttachmentTypeNameEventAttachment;
FOUNDATION_EXPORT NSString *const kSentryAttachmentTypeNameViewHierarchy;

/**
* Attachment Type
*/
typedef NS_ENUM(NSInteger, SentryAttachmentType) {
kSentryAttachmentTypeEventAttachment,
kSentryAttachmentTypeViewHierarchy
};

NSString *nameForSentryAttachmentType(SentryAttachmentType attachmentType);

SentryAttachmentType typeForSentryAttachmentName(NSString *_Nullable name);

@interface SentryAttachment ()
SENTRY_NO_INIT

/**
* Initializes an attachment with data.
* @param data The data for the attachment.
* @param filename The name of the attachment to display in Sentry.
* @param contentType The content type of the attachment. Default is @c "application/octet-stream".
* @param attachmentType The type of the attachment. Default is @c "EventAttachment".
*/
- (instancetype)initWithData:(NSData *)data
filename:(NSString *)filename
contentType:(nullable NSString *)contentType
attachmentType:(SentryAttachmentType)attachmentType;

/**
* Initializes an attachment with data.
* @param path The path of the file whose contents you want to upload to Sentry.
* @param filename The name of the attachment to display in Sentry.
* @param contentType The content type of the attachment. Default is @c "application/octet-stream".
* @param attachmentType The type of the attachment. Default is@c "EventAttachment".
*/
- (instancetype)initWithPath:(NSString *)path
filename:(NSString *)filename
contentType:(nullable NSString *)contentType
attachmentType:(SentryAttachmentType)attachmentType;

/**
* The type of the attachment.
*/
@property (readonly, nonatomic) SentryAttachmentType attachmentType;

@end

NS_ASSUME_NONNULL_END
Loading
Loading