diff --git a/.swiftlint.yml b/.swiftlint.yml index 519c6e3ae..fae5d675c 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -15,9 +15,13 @@ disabled_rules: - trailing_comma - opening_brace -line_length: +line_length: warning: 160 ignores_comments: true + excluded_lines_patterns: [ + # long deprecation messages + \@available(.*/*deprecated.*) + ] file_length: warning: 1000 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d0dcc78c..8492afc80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Next +- fix: deprecate `maskPhotoLibraryImages` due to unintended masking issues ([#268](https://github.com/PostHog/posthog-ios/pull/268)) + ## 3.15.9 - 2024-11-28 - fix: skip capturing a snapshot during view controller transitions ([#265](https://github.com/PostHog/posthog-ios/pull/265)) diff --git a/PostHog/Replay/PostHogReplayIntegration.swift b/PostHog/Replay/PostHogReplayIntegration.swift index de028626d..ec1284e08 100644 --- a/PostHog/Replay/PostHogReplayIntegration.swift +++ b/PostHog/Replay/PostHogReplayIntegration.swift @@ -406,24 +406,6 @@ image.imageAsset?.value(forKey: "_containingBundle") != nil } - // Photo library images have a UUID identifier as _assetName (e.g 64EF5A48-2E96-4AB2-A79B-AAB7E9116E3D) - // SF symbol and bundle images have the actual symbol name as _assetName (e.g chevron.backward) - private func isPhotoLibraryImage(_ image: UIImage) -> Bool { - guard config.sessionReplayConfig.maskPhotoLibraryImages else { - return false - } - - guard let assetName = image.imageAsset?.value(forKey: "_assetName") as? String else { - return false - } - - if assetName.isEmpty { return false } - if image.isSymbolImage { return false } - if isAssetsImage(image) { return false } - - return true - } - private func isAnyInputSensitive(_ view: UIView) -> Bool { isTextInputSensitive(view) || config.sessionReplayConfig.maskAllImages } @@ -481,13 +463,17 @@ return true } - if config.sessionReplayConfig.maskAllImages { - // asset images are probably not sensitive - return !isAssetsImage(image) + // asset images are probably not sensitive + if isAssetsImage(image) { + return false + } + + // symbols are probably not sensitive + if image.isSymbolImage { + return false } - // try to detect user photo images - return isPhotoLibraryImage(image) + return config.sessionReplayConfig.maskAllImages } private func toWireframe(_ view: UIView) -> RRWireframe? { diff --git a/PostHog/Replay/PostHogSessionReplayConfig.swift b/PostHog/Replay/PostHogSessionReplayConfig.swift index b9b29f92a..ce1ac073f 100644 --- a/PostHog/Replay/PostHogSessionReplayConfig.swift +++ b/PostHog/Replay/PostHogSessionReplayConfig.swift @@ -26,8 +26,11 @@ /// Enable masking of images that likely originated from user's photo library /// Experimental support (UIKit only) - /// Default: true - @objc public var maskPhotoLibraryImages: Bool = true + /// Default: false + /// + /// - Note: Deprecated + @available(*, deprecated, message: "This property has no effect and will be removed in the next major release. To learn how to manually mask user photos please see our Privacy controls documentation: https://posthog.com/docs/session-replay/privacy?tab=iOS") + @objc public var maskPhotoLibraryImages: Bool = false /// Enable capturing network telemetry /// Experimental support