Skip to content

Commit

Permalink
fix: deprecate maskPhotoLibraryImages (#268)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ioannisj authored Dec 3, 2024
1 parent 6eae78c commit 99f440c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
6 changes: 5 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
32 changes: 9 additions & 23 deletions PostHog/Replay/PostHogReplayIntegration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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? {
Expand Down
7 changes: 5 additions & 2 deletions PostHog/Replay/PostHogSessionReplayConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 99f440c

Please sign in to comment.