diff --git a/CHANGELOG.md b/CHANGELOG.md index e6ebb81de4..f984d85e9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ - Add `maskedViewClasses` and `unmaskedViewClasses` to SentryReplayOptions init via dict (#4492) - Add `quality` to SentryReplayOptions init via dict (#4495) +### Fixes + +- Masking text with transparent text color (#4499) + ## 8.39.0 ### Removal of Experimental API diff --git a/Sources/Swift/Tools/UIRedactBuilder.swift b/Sources/Swift/Tools/UIRedactBuilder.swift index cd3f0f3442..5e1bd3f985 100644 --- a/Sources/Swift/Tools/UIRedactBuilder.swift +++ b/Sources/Swift/Tools/UIRedactBuilder.swift @@ -261,7 +261,7 @@ class UIRedactBuilder { } private func color(for view: UIView) -> UIColor? { - return (view as? UILabel)?.textColor + return (view as? UILabel)?.textColor.withAlphaComponent(1) } /** diff --git a/Tests/SentryTests/UIRedactBuilderTests.swift b/Tests/SentryTests/UIRedactBuilderTests.swift index 0261485d7b..73cf5b888b 100644 --- a/Tests/SentryTests/UIRedactBuilderTests.swift +++ b/Tests/SentryTests/UIRedactBuilderTests.swift @@ -51,6 +51,16 @@ class UIRedactBuilderTests: XCTestCase { XCTAssertEqual(result.first?.transform, CGAffineTransform(a: 1, b: 0, c: 0, d: 1, tx: 20, ty: 20)) } + func testDontUseLabelTransparentColor() { + let sut = getSut() + let label = UILabel(frame: CGRect(x: 20, y: 20, width: 40, height: 40)) + label.textColor = .purple.withAlphaComponent(0.5) + rootView.addSubview(label) + + let result = sut.redactRegionsFor(view: rootView) + XCTAssertEqual(result.first?.color, .purple) + } + func testDontRedactALabelOptionDisabled() { let sut = getSut(RedactOptions(maskAllText: false)) let label = UILabel(frame: CGRect(x: 20, y: 20, width: 40, height: 40))