From 878b10ebe2b48da7815c6163dc5cfb077e013ba3 Mon Sep 17 00:00:00 2001 From: Ioannis J Date: Mon, 2 Dec 2024 14:13:44 +0200 Subject: [PATCH 1/8] fix: deprecate maskPhotoLibraryImages --- PostHog/Replay/PostHogReplayIntegration.swift | 27 +++---------------- .../Replay/PostHogSessionReplayConfig.swift | 3 +++ 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/PostHog/Replay/PostHogReplayIntegration.swift b/PostHog/Replay/PostHogReplayIntegration.swift index de028626d..c1455d24f 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,12 @@ 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 } - // 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..40ef574ba 100644 --- a/PostHog/Replay/PostHogSessionReplayConfig.swift +++ b/PostHog/Replay/PostHogSessionReplayConfig.swift @@ -27,6 +27,9 @@ /// Enable masking of images that likely originated from user's photo library /// Experimental support (UIKit only) /// Default: true + /// + /// - Note: Deprecated + @available(*, deprecated, message: "This property has no effect and will be removed in the next major release. To manually mask user photos, use the `ph-no-capture` attribute or appropriate view modifiers in your app.") @objc public var maskPhotoLibraryImages: Bool = true /// Enable capturing network telemetry From 3e0144102e63ecbf3160be6bc2b6812e415c9ade Mon Sep 17 00:00:00 2001 From: Ioannis J Date: Mon, 2 Dec 2024 14:18:06 +0200 Subject: [PATCH 2/8] chore: update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d0dcc78c..44b345841 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Next +- fix: deprecated now unused configuration maskPhotoLibraryImages. ([#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)) From 7d4102e48b9dd92f32f0338d8e5b7a70382fd4f2 Mon Sep 17 00:00:00 2001 From: Ioannis J Date: Mon, 2 Dec 2024 14:21:24 +0200 Subject: [PATCH 3/8] fix: deprecation message --- PostHog/Replay/PostHogSessionReplayConfig.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PostHog/Replay/PostHogSessionReplayConfig.swift b/PostHog/Replay/PostHogSessionReplayConfig.swift index 40ef574ba..c780cf570 100644 --- a/PostHog/Replay/PostHogSessionReplayConfig.swift +++ b/PostHog/Replay/PostHogSessionReplayConfig.swift @@ -29,7 +29,7 @@ /// Default: true /// /// - Note: Deprecated - @available(*, deprecated, message: "This property has no effect and will be removed in the next major release. To manually mask user photos, use the `ph-no-capture` attribute or appropriate view modifiers in your app.") + @available(*, deprecated, message: "This property has no effect and will be removed in the next major release. To manually mask user photos, use `ph-no-capture` accessibility label or an appropriate view modifier in your app.") @objc public var maskPhotoLibraryImages: Bool = true /// Enable capturing network telemetry From 6f6c05d9502d2c190790203ef8450f3e68b98c4d Mon Sep 17 00:00:00 2001 From: Ioannis J Date: Mon, 2 Dec 2024 14:36:11 +0200 Subject: [PATCH 4/8] fix: update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44b345841..8492afc80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## Next -- fix: deprecated now unused configuration maskPhotoLibraryImages. ([#268](https://github.com/PostHog/posthog-ios/pull/268)) +- fix: deprecate `maskPhotoLibraryImages` due to unintended masking issues ([#268](https://github.com/PostHog/posthog-ios/pull/268)) ## 3.15.9 - 2024-11-28 From 6b858ef012166c1f2a584ffc9774b04f5fb9cf0d Mon Sep 17 00:00:00 2001 From: Ioannis J Date: Mon, 2 Dec 2024 15:11:27 +0200 Subject: [PATCH 5/8] feat: add symbol check --- PostHog/Replay/PostHogReplayIntegration.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PostHog/Replay/PostHogReplayIntegration.swift b/PostHog/Replay/PostHogReplayIntegration.swift index c1455d24f..87a696859 100644 --- a/PostHog/Replay/PostHogReplayIntegration.swift +++ b/PostHog/Replay/PostHogReplayIntegration.swift @@ -467,6 +467,11 @@ if isAssetsImage(image) { return false } + + // symbols are probably not sensitive + if image.isSymbolImage { + return false + } return config.sessionReplayConfig.maskAllImages } From ac4e1b0a24016dcec24f46e3ca3990b744f28feb Mon Sep 17 00:00:00 2001 From: Ioannis J Date: Mon, 2 Dec 2024 15:11:51 +0200 Subject: [PATCH 6/8] fix: update deprecation message --- PostHog/Replay/PostHogSessionReplayConfig.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PostHog/Replay/PostHogSessionReplayConfig.swift b/PostHog/Replay/PostHogSessionReplayConfig.swift index c780cf570..bec70af45 100644 --- a/PostHog/Replay/PostHogSessionReplayConfig.swift +++ b/PostHog/Replay/PostHogSessionReplayConfig.swift @@ -29,7 +29,7 @@ /// Default: true /// /// - Note: Deprecated - @available(*, deprecated, message: "This property has no effect and will be removed in the next major release. To manually mask user photos, use `ph-no-capture` accessibility label or an appropriate view modifier in your app.") + @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 = true /// Enable capturing network telemetry From f29f14224a80724ecd170951431f141bab09c828 Mon Sep 17 00:00:00 2001 From: Ioannis J Date: Mon, 2 Dec 2024 16:01:28 +0200 Subject: [PATCH 7/8] fix: lint --- .swiftlint.yml | 6 +++++- PostHog/Replay/PostHogReplayIntegration.swift | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) 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/PostHog/Replay/PostHogReplayIntegration.swift b/PostHog/Replay/PostHogReplayIntegration.swift index 87a696859..ec1284e08 100644 --- a/PostHog/Replay/PostHogReplayIntegration.swift +++ b/PostHog/Replay/PostHogReplayIntegration.swift @@ -467,7 +467,7 @@ if isAssetsImage(image) { return false } - + // symbols are probably not sensitive if image.isSymbolImage { return false From c041827e2496511242fbd1fc61cedc25c4314957 Mon Sep 17 00:00:00 2001 From: Ioannis J Date: Mon, 2 Dec 2024 18:50:20 +0200 Subject: [PATCH 8/8] fix: set default to false --- PostHog/Replay/PostHogSessionReplayConfig.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PostHog/Replay/PostHogSessionReplayConfig.swift b/PostHog/Replay/PostHogSessionReplayConfig.swift index bec70af45..ce1ac073f 100644 --- a/PostHog/Replay/PostHogSessionReplayConfig.swift +++ b/PostHog/Replay/PostHogSessionReplayConfig.swift @@ -26,11 +26,11 @@ /// Enable masking of images that likely originated from user's photo library /// Experimental support (UIKit only) - /// Default: 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 = true + @objc public var maskPhotoLibraryImages: Bool = false /// Enable capturing network telemetry /// Experimental support