diff --git a/kDriveCore/Utils/PHAsset/PHAsset+Exension.swift b/kDriveCore/Utils/PHAsset/PHAsset+Exension.swift index 4d38843a2..f96959ceb 100644 --- a/kDriveCore/Utils/PHAsset/PHAsset+Exension.swift +++ b/kDriveCore/Utils/PHAsset/PHAsset+Exension.swift @@ -132,7 +132,7 @@ public extension PHAsset { shouldTransformIntoJPEG = true } - // Asset are copied when we start the Upload, thus guarantees the stability of the file + // Asset is copied when we start the Upload, thus guarantees the stability of the file @InjectService var fileImportHelper: FileImportHelper let targetURL = fileImportHelper.generateImportURL(for: resourceUTI) do { @@ -149,6 +149,7 @@ public extension PHAsset { return targetURL } catch { SentryDebug.addBreadcrumb(message: error.localizedDescription, category: SentryDebug.Category.PHAsset, level: .error) + SentryDebug.capturePHAssetResourceManagerError(error) } return nil } diff --git a/kDriveCore/Utils/PHAsset/PHAssetIdentifier.swift b/kDriveCore/Utils/PHAsset/PHAssetIdentifier.swift index cc3621c16..bec25044b 100644 --- a/kDriveCore/Utils/PHAsset/PHAssetIdentifier.swift +++ b/kDriveCore/Utils/PHAsset/PHAssetIdentifier.swift @@ -174,6 +174,7 @@ struct PHAssetIdentifier: PHAssetIdentifiable { // PHAssetResourceManager errors, possibly fetching an asset on iCloud failed if let resourceManagerError { + SentryDebug.capturePHAssetResourceManagerError(resourceManagerError) throw resourceManagerError } diff --git a/kDriveCore/Utils/Sentry/SentryDebug+Upload.swift b/kDriveCore/Utils/Sentry/SentryDebug+Upload.swift index 8f1a30cee..d3c6d6fbe 100644 --- a/kDriveCore/Utils/Sentry/SentryDebug+Upload.swift +++ b/kDriveCore/Utils/Sentry/SentryDebug+Upload.swift @@ -106,6 +106,15 @@ extension SentryDebug { SentryDebug.capture(message: EventNames.uploadCompletedSuccess, extras: metadata) } + static func capturePHAssetResourceManagerError(_ error: Error, function: StaticString = #function) { + let metadata: [String: Any] = [ + "func": function, + "error": error, + "localizedError": error.localizedDescription + ] + SentryDebug.capture(message: ErrorNames.assetResourceManagerError, context: metadata, level: .error) + } + // MARK: - Upload notifications static func uploadNotificationError(_ metadata: [String: Any]) { diff --git a/kDriveCore/Utils/Sentry/SentryDebug.swift b/kDriveCore/Utils/Sentry/SentryDebug.swift index d5ea45f63..cbe58fb94 100644 --- a/kDriveCore/Utils/Sentry/SentryDebug.swift +++ b/kDriveCore/Utils/Sentry/SentryDebug.swift @@ -52,6 +52,8 @@ public enum SentryDebug { static let uploadSessionErrorHandling = "UploadSessionErrorHandling" static let uploadErrorUserNotification = "UploadErrorUserNotification" static let viewModelNotConnectedToView = "ViewModelNotConnected" + /// An error was generated by an instance of `PHAssetResourceManager` + static let assetResourceManagerError = "PHAssetResourceManagerError" } static func logTokenMigration(newToken: ApiToken, oldToken: ApiToken) {