Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecate maskPhotoLibraryImages #268

Merged
merged 8 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }
ioannisj marked this conversation as resolved.
Show resolved Hide resolved
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")
ioannisj marked this conversation as resolved.
Show resolved Hide resolved
@objc public var maskPhotoLibraryImages: Bool = false

/// Enable capturing network telemetry
/// Experimental support
Expand Down
Loading