Skip to content

Commit 99f440c

Browse files
authored
fix: deprecate maskPhotoLibraryImages (#268)
* fix: deprecate maskPhotoLibraryImages * chore: update CHANGELOG * fix: deprecation message * fix: update CHANGELOG * feat: add symbol check * fix: update deprecation message * fix: lint * fix: set default to false
1 parent 6eae78c commit 99f440c

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

.swiftlint.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ disabled_rules:
1515
- trailing_comma
1616
- opening_brace
1717

18-
line_length:
18+
line_length:
1919
warning: 160
2020
ignores_comments: true
21+
excluded_lines_patterns: [
22+
# long deprecation messages
23+
\@available(.*/*deprecated.*)
24+
]
2125

2226
file_length:
2327
warning: 1000

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Next
22

3+
- fix: deprecate `maskPhotoLibraryImages` due to unintended masking issues ([#268](https://github.com/PostHog/posthog-ios/pull/268))
4+
35
## 3.15.9 - 2024-11-28
46

57
- fix: skip capturing a snapshot during view controller transitions ([#265](https://github.com/PostHog/posthog-ios/pull/265))

PostHog/Replay/PostHogReplayIntegration.swift

+9-23
Original file line numberDiff line numberDiff line change
@@ -406,24 +406,6 @@
406406
image.imageAsset?.value(forKey: "_containingBundle") != nil
407407
}
408408

409-
// Photo library images have a UUID identifier as _assetName (e.g 64EF5A48-2E96-4AB2-A79B-AAB7E9116E3D)
410-
// SF symbol and bundle images have the actual symbol name as _assetName (e.g chevron.backward)
411-
private func isPhotoLibraryImage(_ image: UIImage) -> Bool {
412-
guard config.sessionReplayConfig.maskPhotoLibraryImages else {
413-
return false
414-
}
415-
416-
guard let assetName = image.imageAsset?.value(forKey: "_assetName") as? String else {
417-
return false
418-
}
419-
420-
if assetName.isEmpty { return false }
421-
if image.isSymbolImage { return false }
422-
if isAssetsImage(image) { return false }
423-
424-
return true
425-
}
426-
427409
private func isAnyInputSensitive(_ view: UIView) -> Bool {
428410
isTextInputSensitive(view) || config.sessionReplayConfig.maskAllImages
429411
}
@@ -481,13 +463,17 @@
481463
return true
482464
}
483465

484-
if config.sessionReplayConfig.maskAllImages {
485-
// asset images are probably not sensitive
486-
return !isAssetsImage(image)
466+
// asset images are probably not sensitive
467+
if isAssetsImage(image) {
468+
return false
469+
}
470+
471+
// symbols are probably not sensitive
472+
if image.isSymbolImage {
473+
return false
487474
}
488475

489-
// try to detect user photo images
490-
return isPhotoLibraryImage(image)
476+
return config.sessionReplayConfig.maskAllImages
491477
}
492478

493479
private func toWireframe(_ view: UIView) -> RRWireframe? {

PostHog/Replay/PostHogSessionReplayConfig.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626

2727
/// Enable masking of images that likely originated from user's photo library
2828
/// Experimental support (UIKit only)
29-
/// Default: true
30-
@objc public var maskPhotoLibraryImages: Bool = true
29+
/// Default: false
30+
///
31+
/// - Note: Deprecated
32+
@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")
33+
@objc public var maskPhotoLibraryImages: Bool = false
3134

3235
/// Enable capturing network telemetry
3336
/// Experimental support

0 commit comments

Comments
 (0)