diff --git a/CHANGELOG.md b/CHANGELOG.md index d33fb216b9e..1da8bdfac33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Sources/Sentry/Public/SentryAttachment.h b/Sources/Sentry/Public/SentryAttachment.h index 8b0e904fe46..5e6cb0092e3 100644 --- a/Sources/Sentry/Public/SentryAttachment.h +++ b/Sources/Sentry/Public/SentryAttachment.h @@ -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. */ @@ -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. */ @@ -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 diff --git a/Sources/Sentry/include/SentryAttachment+Private.h b/Sources/Sentry/include/SentryAttachment+Private.h index 32c012e9324..f44435f3e80 100644 --- a/Sources/Sentry/include/SentryAttachment+Private.h +++ b/Sources/Sentry/include/SentryAttachment+Private.h @@ -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 diff --git a/sdk_api.json b/sdk_api.json index b6908bb4328..8e623dc50b8 100644 --- a/sdk_api.json +++ b/sdk_api.json @@ -621,6 +621,114 @@ ], "init_kind": "Designated" }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init(data:filename:contentType:attachmentType:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Attachment", + "printedName": "Sentry.Attachment", + "usr": "c:objc(cs)SentryAttachment" + }, + { + "kind": "TypeNominal", + "name": "Data", + "printedName": "Foundation.Data", + "usr": "s:10Foundation4DataV" + }, + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "SentryAttachmentType", + "printedName": "Sentry.SentryAttachmentType", + "usr": "c:@E@SentryAttachmentType" + } + ], + "declKind": "Constructor", + "usr": "c:objc(cs)SentryAttachment(im)initWithData:filename:contentType:attachmentType:", + "moduleName": "Sentry", + "objc_name": "initWithData:filename:contentType:attachmentType:", + "declAttributes": [ + "ObjC", + "Dynamic" + ], + "init_kind": "Designated" + }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init(path:filename:contentType:attachmentType:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Attachment", + "printedName": "Sentry.Attachment", + "usr": "c:objc(cs)SentryAttachment" + }, + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + }, + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + }, + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Swift.String?", + "children": [ + { + "kind": "TypeNominal", + "name": "String", + "printedName": "Swift.String", + "usr": "s:SS" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "SentryAttachmentType", + "printedName": "Sentry.SentryAttachmentType", + "usr": "c:@E@SentryAttachmentType" + } + ], + "declKind": "Constructor", + "usr": "c:objc(cs)SentryAttachment(im)initWithPath:filename:contentType:attachmentType:", + "moduleName": "Sentry", + "objc_name": "initWithPath:filename:contentType:attachmentType:", + "declAttributes": [ + "ObjC", + "Dynamic" + ], + "init_kind": "Designated" + }, { "kind": "Var", "name": "data", @@ -860,6 +968,54 @@ "accessorKind": "get" } ] + }, + { + "kind": "Var", + "name": "attachmentType", + "printedName": "attachmentType", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryAttachmentType", + "printedName": "Sentry.SentryAttachmentType", + "usr": "c:@E@SentryAttachmentType" + } + ], + "declKind": "Var", + "usr": "c:objc(cs)SentryAttachment(py)attachmentType", + "moduleName": "Sentry", + "isOpen": true, + "objc_name": "attachmentType", + "declAttributes": [ + "ObjC", + "Dynamic" + ], + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryAttachmentType", + "printedName": "Sentry.SentryAttachmentType", + "usr": "c:@E@SentryAttachmentType" + } + ], + "declKind": "Accessor", + "usr": "c:objc(cs)SentryAttachment(im)attachmentType", + "moduleName": "Sentry", + "isOpen": true, + "objc_name": "attachmentType", + "declAttributes": [ + "DiscardableResult", + "ObjC", + "Dynamic" + ], + "accessorKind": "get" + } + ] } ], "declKind": "Class", @@ -23767,6 +23923,259 @@ } ] }, + { + "kind": "TypeDecl", + "name": "SentryAttachmentType", + "printedName": "SentryAttachmentType", + "children": [ + { + "kind": "Constructor", + "name": "init", + "printedName": "init(rawValue:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Sentry.SentryAttachmentType?", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryAttachmentType", + "printedName": "Sentry.SentryAttachmentType", + "usr": "c:@E@SentryAttachmentType" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "Int", + "printedName": "Swift.Int", + "usr": "s:Si" + } + ], + "declKind": "Constructor", + "usr": "s:So20SentryAttachmentTypeV8rawValueABSgSi_tcfc", + "mangledName": "$sSo20SentryAttachmentTypeV8rawValueABSgSi_tcfc", + "moduleName": "Sentry", + "implicit": true, + "init_kind": "Designated" + }, + { + "kind": "Var", + "name": "rawValue", + "printedName": "rawValue", + "children": [ + { + "kind": "TypeNominal", + "name": "Int", + "printedName": "Swift.Int", + "usr": "s:Si" + } + ], + "declKind": "Var", + "usr": "s:So20SentryAttachmentTypeV8rawValueSivp", + "mangledName": "$sSo20SentryAttachmentTypeV8rawValueSivp", + "moduleName": "Sentry", + "implicit": true, + "accessors": [ + { + "kind": "Accessor", + "name": "Get", + "printedName": "Get()", + "children": [ + { + "kind": "TypeNominal", + "name": "Int", + "printedName": "Swift.Int", + "usr": "s:Si" + } + ], + "declKind": "Accessor", + "usr": "s:So20SentryAttachmentTypeV8rawValueSivg", + "mangledName": "$sSo20SentryAttachmentTypeV8rawValueSivg", + "moduleName": "Sentry", + "implicit": true, + "accessorKind": "get" + } + ] + }, + { + "kind": "TypeAlias", + "name": "RawValue", + "printedName": "RawValue", + "children": [ + { + "kind": "TypeNominal", + "name": "Int", + "printedName": "Swift.Int", + "usr": "s:Si" + } + ], + "declKind": "TypeAlias", + "usr": "s:So20SentryAttachmentTypeV8RawValuea", + "mangledName": "$sSo20SentryAttachmentTypeV8RawValuea", + "moduleName": "Sentry", + "implicit": true + }, + { + "kind": "Var", + "name": "eventAttachment", + "printedName": "eventAttachment", + "children": [ + { + "kind": "TypeFunc", + "name": "Function", + "printedName": "(Sentry.SentryAttachmentType.Type) -> Sentry.SentryAttachmentType", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryAttachmentType", + "printedName": "Sentry.SentryAttachmentType", + "usr": "c:@E@SentryAttachmentType" + }, + { + "kind": "TypeNominal", + "name": "Metatype", + "printedName": "Sentry.SentryAttachmentType.Type", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryAttachmentType", + "printedName": "Sentry.SentryAttachmentType", + "usr": "c:@E@SentryAttachmentType" + } + ] + } + ] + } + ], + "declKind": "EnumElement", + "usr": "c:@E@SentryAttachmentType@kSentryAttachmentTypeEventAttachment", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ] + }, + { + "kind": "Var", + "name": "viewHierarchy", + "printedName": "viewHierarchy", + "children": [ + { + "kind": "TypeFunc", + "name": "Function", + "printedName": "(Sentry.SentryAttachmentType.Type) -> Sentry.SentryAttachmentType", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryAttachmentType", + "printedName": "Sentry.SentryAttachmentType", + "usr": "c:@E@SentryAttachmentType" + }, + { + "kind": "TypeNominal", + "name": "Metatype", + "printedName": "Sentry.SentryAttachmentType.Type", + "children": [ + { + "kind": "TypeNominal", + "name": "SentryAttachmentType", + "printedName": "Sentry.SentryAttachmentType", + "usr": "c:@E@SentryAttachmentType" + } + ] + } + ] + } + ], + "declKind": "EnumElement", + "usr": "c:@E@SentryAttachmentType@kSentryAttachmentTypeViewHierarchy", + "moduleName": "Sentry", + "declAttributes": [ + "ObjC" + ] + } + ], + "declKind": "Enum", + "usr": "c:@E@SentryAttachmentType", + "moduleName": "Sentry", + "objc_name": "SentryAttachmentType", + "declAttributes": [ + "SynthesizedProtocol", + "ObjC", + "SynthesizedProtocol", + "Sendable", + "Dynamic" + ], + "enumRawTypeName": "Int", + "conformances": [ + { + "kind": "Conformance", + "name": "Copyable", + "printedName": "Copyable", + "usr": "s:s8CopyableP", + "mangledName": "$ss8CopyableP" + }, + { + "kind": "Conformance", + "name": "Escapable", + "printedName": "Escapable", + "usr": "s:s9EscapableP", + "mangledName": "$ss9EscapableP" + }, + { + "kind": "Conformance", + "name": "RawRepresentable", + "printedName": "RawRepresentable", + "children": [ + { + "kind": "TypeWitness", + "name": "RawValue", + "printedName": "RawValue", + "children": [ + { + "kind": "TypeNameAlias", + "name": "RawValue", + "printedName": "Sentry.SentryAttachmentType.RawValue", + "children": [ + { + "kind": "TypeNominal", + "name": "Int", + "printedName": "Swift.Int", + "usr": "s:Si" + } + ] + } + ] + } + ], + "usr": "s:SY", + "mangledName": "$sSY" + }, + { + "kind": "Conformance", + "name": "Sendable", + "printedName": "Sendable", + "usr": "s:s8SendableP", + "mangledName": "$ss8SendableP" + }, + { + "kind": "Conformance", + "name": "Equatable", + "printedName": "Equatable", + "usr": "s:SQ", + "mangledName": "$sSQ" + }, + { + "kind": "Conformance", + "name": "Hashable", + "printedName": "Hashable", + "usr": "s:SH", + "mangledName": "$sSH" + } + ] + }, { "kind": "TypeAlias", "name": "SentryBeforeBreadcrumbCallback",