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
Changes from 1 commit
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
Next Next commit
fix: deprecate maskPhotoLibraryImages
ioannisj committed Dec 2, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 878b10ebe2b48da7815c6163dc5cfb077e013ba3
27 changes: 4 additions & 23 deletions PostHog/Replay/PostHogReplayIntegration.swift
Original file line number Diff line number Diff line change
@@ -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? {
3 changes: 3 additions & 0 deletions PostHog/Replay/PostHogSessionReplayConfig.swift
Original file line number Diff line number Diff line change
@@ -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