Skip to content

Commit c887b99

Browse files
committed
squashed changes
1 parent 3da30a9 commit c887b99

18 files changed

+1220
-27
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@
749749
A8F17B2E2901765900990B25 /* SentryRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B2D2901765900990B25 /* SentryRequest.m */; };
750750
A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */; };
751751
D4009EB22D771BC20007AF30 /* SentryFileIOTrackerSwiftHelpersTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4009EB12D771BB90007AF30 /* SentryFileIOTrackerSwiftHelpersTests.swift */; };
752+
D40A826B2EAA62E900843F37 /* SentryAccessibilityEnabler.swift in Sources */ = {isa = PBXBuildFile; fileRef = D40A82652EAA62E600843F37 /* SentryAccessibilityEnabler.swift */; };
752753
D41415A72DEEE532003B14D5 /* SentryRedactViewHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D41415A62DEEE532003B14D5 /* SentryRedactViewHelper.swift */; };
753754
D4291A6D2DD62ACE00772088 /* SentryDispatchFactoryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D4291A6C2DD62AC800772088 /* SentryDispatchFactoryTests.m */; };
754755
D42ADEEF2E9CF43200753166 /* SentrySessionReplayEnvironmentChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = D42ADEE92E9CF42800753166 /* SentrySessionReplayEnvironmentChecker.swift */; };
@@ -771,6 +772,7 @@
771772
D4411DD52E02B74900EA4987 /* ArrayAccessesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4411DD42E02B74100EA4987 /* ArrayAccessesTests.swift */; };
772773
D44311312EB22812006CABE4 /* SentryUIRedactBuilderTests+ReactNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AF7D212E93FFCA004F0F59 /* SentryUIRedactBuilderTests+ReactNative.swift */; };
773774
D44B16722DE464AD006DBDB3 /* TestDispatchFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D44B16712DE464A9006DBDB3 /* TestDispatchFactoryTests.swift */; };
775+
D450A8672EB4CDC9002DB0B4 /* SentryAccessibilityRedactBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D450A8662EB4CDC9002DB0B4 /* SentryAccessibilityRedactBuilder.swift */; };
774776
D451ED5D2D92ECD200C9BEA8 /* SentryOnDemandReplayError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D451ED5C2D92ECD200C9BEA8 /* SentryOnDemandReplayError.swift */; };
775777
D451ED5F2D92ECDE00C9BEA8 /* SentryReplayFrame.swift in Sources */ = {isa = PBXBuildFile; fileRef = D451ED5E2D92ECDE00C9BEA8 /* SentryReplayFrame.swift */; };
776778
D452FC592DDB4B1700AFF56F /* SentryWatchdogTerminationBreadcrumbProcessor.m in Sources */ = {isa = PBXBuildFile; fileRef = D452FC572DDB4B1700AFF56F /* SentryWatchdogTerminationBreadcrumbProcessor.m */; };
@@ -816,6 +818,9 @@
816818
D4AF00232D2E931000F5F3D7 /* SentryNSFileManagerSwizzling.h in Headers */ = {isa = PBXBuildFile; fileRef = D4AF00222D2E931000F5F3D7 /* SentryNSFileManagerSwizzling.h */; };
817819
D4AF00252D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AF00242D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m */; };
818820
D4AF7D2A2E940493004F0F59 /* SentryUIRedactBuilderTests+Common.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AF7D292E940492004F0F59 /* SentryUIRedactBuilderTests+Common.swift */; };
821+
D4AF7E7D2E9537FD004F0F59 /* SentryUIRedactBuilderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AF7E772E9537F5004F0F59 /* SentryUIRedactBuilderProtocol.swift */; };
822+
D4AF7E7F2E953B43004F0F59 /* SentryMLRedactBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4AF7E7E2E953B3E004F0F59 /* SentryMLRedactBuilder.swift */; };
823+
D4AF7E812E953D10004F0F59 /* SentryMaskingModel.mlpackage in Sources */ = {isa = PBXBuildFile; fileRef = D4AF7E802E953D10004F0F59 /* SentryMaskingModel.mlpackage */; };
819824
D4B0DC7F2DA9257A00DE61B6 /* SentryRenderVideoResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4B0DC7E2DA9257200DE61B6 /* SentryRenderVideoResult.swift */; };
820825
D4B339F92EA7823000359F3A /* SentryTestUtilsDynamic.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D84DAD4D2B17428D003CF120 /* SentryTestUtilsDynamic.framework */; };
821826
D4B339FA2EA7823000359F3A /* SentryTestUtilsDynamic.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D84DAD4D2B17428D003CF120 /* SentryTestUtilsDynamic.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -2108,6 +2113,7 @@
21082113
A8F17B2D2901765900990B25 /* SentryRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryRequest.m; sourceTree = "<group>"; };
21092114
A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryHttpStatusCodeRange.m; sourceTree = "<group>"; };
21102115
D4009EB12D771BB90007AF30 /* SentryFileIOTrackerSwiftHelpersTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryFileIOTrackerSwiftHelpersTests.swift; sourceTree = "<group>"; };
2116+
D40A82652EAA62E600843F37 /* SentryAccessibilityEnabler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryAccessibilityEnabler.swift; sourceTree = "<group>"; };
21112117
D41415A62DEEE532003B14D5 /* SentryRedactViewHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRedactViewHelper.swift; sourceTree = "<group>"; };
21122118
D41909922D48FFF6002B83D0 /* SentryNSDictionarySanitize+Tests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryNSDictionarySanitize+Tests.h"; sourceTree = "<group>"; };
21132119
D41909942D490006002B83D0 /* SentryNSDictionarySanitize+Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentryNSDictionarySanitize+Tests.m"; sourceTree = "<group>"; };
@@ -2130,6 +2136,7 @@
21302136
D43B26D92D70A60E007747FD /* SentrySpanDataKey.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySpanDataKey.m; sourceTree = "<group>"; };
21312137
D4411DD42E02B74100EA4987 /* ArrayAccessesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrayAccessesTests.swift; sourceTree = "<group>"; };
21322138
D44B16712DE464A9006DBDB3 /* TestDispatchFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestDispatchFactoryTests.swift; sourceTree = "<group>"; };
2139+
D450A8662EB4CDC9002DB0B4 /* SentryAccessibilityRedactBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryAccessibilityRedactBuilder.swift; sourceTree = "<group>"; };
21332140
D451ED5C2D92ECD200C9BEA8 /* SentryOnDemandReplayError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryOnDemandReplayError.swift; sourceTree = "<group>"; };
21342141
D451ED5E2D92ECDE00C9BEA8 /* SentryReplayFrame.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryReplayFrame.swift; sourceTree = "<group>"; };
21352142
D452FC562DDB4B1700AFF56F /* SentryWatchdogTerminationBreadcrumbProcessor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryWatchdogTerminationBreadcrumbProcessor.h; path = ../include/SentryWatchdogTerminationBreadcrumbProcessor.h; sourceTree = "<group>"; };
@@ -2181,6 +2188,9 @@
21812188
D4AF00242D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSFileManagerSwizzlingTests.m; sourceTree = "<group>"; };
21822189
D4AF7D212E93FFCA004F0F59 /* SentryUIRedactBuilderTests+ReactNative.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryUIRedactBuilderTests+ReactNative.swift"; sourceTree = "<group>"; };
21832190
D4AF7D292E940492004F0F59 /* SentryUIRedactBuilderTests+Common.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryUIRedactBuilderTests+Common.swift"; sourceTree = "<group>"; };
2191+
D4AF7E772E9537F5004F0F59 /* SentryUIRedactBuilderProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIRedactBuilderProtocol.swift; sourceTree = "<group>"; };
2192+
D4AF7E7E2E953B3E004F0F59 /* SentryMLRedactBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMLRedactBuilder.swift; sourceTree = "<group>"; };
2193+
D4AF7E802E953D10004F0F59 /* SentryMaskingModel.mlpackage */ = {isa = PBXFileReference; lastKnownFileType = folder.mlpackage; path = SentryMaskingModel.mlpackage; sourceTree = "<group>"; };
21842194
D4B0DC7E2DA9257200DE61B6 /* SentryRenderVideoResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRenderVideoResult.swift; sourceTree = "<group>"; };
21852195
D4BCA0C22DA93C25009E49AB /* SentrySessionReplayIntegration+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentrySessionReplayIntegration+Test.h"; sourceTree = "<group>"; };
21862196
D4C5F5992D4249E0002A9BF6 /* DataSentryTracingIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataSentryTracingIntegrationTests.swift; sourceTree = "<group>"; };
@@ -4956,11 +4966,16 @@
49564966
children = (
49574967
D4CD2A7C2DE9F91900DA9F59 /* SentryRedactRegion.swift */,
49584968
D4CD2A7D2DE9F91900DA9F59 /* SentryRedactRegionType.swift */,
4969+
D40A82652EAA62E600843F37 /* SentryAccessibilityEnabler.swift */,
4970+
D450A8662EB4CDC9002DB0B4 /* SentryAccessibilityRedactBuilder.swift */,
49594971
FA67DCDF2DDBD4EA00896B02 /* SentryDefaultMaskRenderer.swift */,
49604972
FA67DCE02DDBD4EA00896B02 /* SentryDefaultViewRenderer.swift */,
49614973
FA67DCE12DDBD4EA00896B02 /* SentryGraphicsImageRenderer.swift */,
49624974
FA67DCE22DDBD4EA00896B02 /* SentryMaskRenderer.swift */,
49634975
FA67DCE32DDBD4EA00896B02 /* SentryMaskRendererV2.swift */,
4976+
D4AF7E7E2E953B3E004F0F59 /* SentryMLRedactBuilder.swift */,
4977+
D4AF7E802E953D10004F0F59 /* SentryMaskingModel.mlpackage */,
4978+
D4AF7E772E9537F5004F0F59 /* SentryUIRedactBuilderProtocol.swift */,
49644979
FA67DCE42DDBD4EA00896B02 /* SentryViewPhotographer.swift */,
49654980
FA67DCE52DDBD4EA00896B02 /* SentryViewRenderer.swift */,
49664981
FA67DCE62DDBD4EA00896B02 /* SentryViewRendererV2.swift */,
@@ -5757,6 +5772,7 @@
57575772
623FD9042D3FA92700803EDA /* NSNumberDecodableWrapper.swift in Sources */,
57585773
63FE718D20DA4C1100CDBAE8 /* SentryCrashReportStore.c in Sources */,
57595774
7BA0C0482805600A003E0326 /* SentryTransportAdapter.m in Sources */,
5775+
D4AF7E812E953D10004F0F59 /* SentryMaskingModel.mlpackage in Sources */,
57605776
63FE712920DA4C1000CDBAE8 /* SentryCrashCPU_arm.c in Sources */,
57615777
03F84D3427DD4191008FE43F /* SentryThreadMetadataCache.cpp in Sources */,
57625778
62862B1E2B1DDC35009B16E3 /* SentryDelayedFrame.m in Sources */,
@@ -5782,6 +5798,7 @@
57825798
8E133FA225E72DEF00ABD0BF /* SentrySamplingContext.m in Sources */,
57835799
F451FAA62E0B304E0050ACF2 /* LoadValidator.swift in Sources */,
57845800
D81988C02BEBFFF70020E36C /* SentryReplayRecording.swift in Sources */,
5801+
D4AF7E7D2E9537FD004F0F59 /* SentryUIRedactBuilderProtocol.swift in Sources */,
57855802
7B6C5F8726034395007F7DFF /* SentryWatchdogTerminationLogic.m in Sources */,
57865803
63FE708D20DA4C1000CDBAE8 /* SentryCrashReportFilterBasic.m in Sources */,
57875804
F40E42352EA1887000E53876 /* SentryFramesTracker.swift in Sources */,
@@ -5958,12 +5975,14 @@
59585975
849B8F9C2C6E906900148E1F /* SentryUserFeedbackThemeConfiguration.swift in Sources */,
59595976
F452437E2DE60B71003E8F50 /* SentryUseNSExceptionCallstackWrapper.m in Sources */,
59605977
63FE70D320DA4C1000CDBAE8 /* SentryCrashMonitor_AppState.c in Sources */,
5978+
D4AF7E7F2E953B43004F0F59 /* SentryMLRedactBuilder.swift in Sources */,
59615979
FA1841832E4B457F005DEDC7 /* SentryApplication.swift in Sources */,
59625980
849B8F9D2C6E906900148E1F /* SentryUserFeedbackWidgetConfiguration.swift in Sources */,
59635981
620467AC2D3FFD230025F06C /* SentryNSErrorCodable.swift in Sources */,
59645982
639FCFA51EBC809A00778193 /* SentryStacktrace.m in Sources */,
59655983
D84D2CC32C29AD120011AF8A /* SentrySessionReplay.swift in Sources */,
59665984
F4FE9DFD2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift in Sources */,
5985+
D40A826B2EAA62E900843F37 /* SentryAccessibilityEnabler.swift in Sources */,
59675986
F4FE9DFE2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift in Sources */,
59685987
84A898542E163072009A551E /* SentryProfileConfiguration.m in Sources */,
59695988
849B8F9B2C6E906900148E1F /* SentryUserFeedbackIntegrationDriver.swift in Sources */,
@@ -6013,6 +6032,7 @@
60136032
63FE713120DA4C1100CDBAE8 /* SentryCrashDynamicLinker.c in Sources */,
60146033
03F84D3527DD4191008FE43F /* SentryThreadHandle.cpp in Sources */,
60156034
0A2D8DA9289BC905008720F6 /* SentryViewHierarchyProviderHelper.m in Sources */,
6035+
D450A8672EB4CDC9002DB0B4 /* SentryAccessibilityRedactBuilder.swift in Sources */,
60166036
D84D2CDD2C2BF7370011AF8A /* SentryReplayEvent.swift in Sources */,
60176037
D8BC28CC2BFF78220054DA4D /* SentryRRWebTouchEvent.swift in Sources */,
60186038
D452FC592DDB4B1700AFF56F /* SentryWatchdogTerminationBreadcrumbProcessor.m in Sources */,

Sources/Sentry/SentrySessionReplayIntegration.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,14 @@ - (void)setupWith:(SentryReplayOptions *)replayOptions
127127
viewRenderer = [[SentryDefaultViewRenderer alloc] init];
128128
}
129129

130+
// id<SentryUIRedactBuilderProtocol> redactBuilder = [[SentryUIRedactBuilder alloc] initWithOptions:replayOptions];
131+
// id<SentryUIRedactBuilderProtocol> redactBuilder = [[SentryAccessibilityRedactBuilder alloc] initWithOptions:replayOptions];
132+
id<SentryUIRedactBuilderProtocol> redactBuilder = [[SentryMLRedactBuilder alloc] initWithOptions:replayOptions];
133+
130134
// We are using the flag for the view renderer V2 also for the mask renderer V2, as it would
131135
// just introduce another option without affecting the SDK user experience.
132136
_viewPhotographer = [[SentryViewPhotographer alloc] initWithRenderer:viewRenderer
133-
redactOptions:replayOptions
137+
redactBuilder:redactBuilder
134138
enableMaskRendererV2:enableViewRendererV2];
135139

136140
if (touchTracker) {
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
//
2+
// SentryAccessibilityEnabler.swift
3+
// Sentry
4+
//
5+
// Enables accessibility temporarily for redaction purposes.
6+
// Based on ASAccessibilityEnabler from AccessibilitySnapshot.
7+
//
8+
9+
import Foundation
10+
import Darwin
11+
12+
@objcMembers
13+
public final class SentryAccessibilityEnabler: NSObject {
14+
private typealias AXSAutomationEnabled = @convention(c) () -> Int32
15+
private typealias AXSSetAutomationEnabled = @convention(c) (Int32) -> Void
16+
17+
private var getAutomationEnabled: AXSAutomationEnabled?
18+
private var setAutomationEnabled: AXSSetAutomationEnabled?
19+
private var previousValue: Int32 = 0
20+
private var handle: UnsafeMutableRawPointer?
21+
22+
public override init() {
23+
self.getAutomationEnabled = nil
24+
self.setAutomationEnabled = nil
25+
self.previousValue = 0
26+
self.handle = nil
27+
super.init()
28+
}
29+
30+
/// Enables accessibility automation by calling the private _AXSSetAutomationEnabled API.
31+
/// - Returns: true if accessibility was successfully enabled, false otherwise.
32+
public func enable() -> Bool {
33+
if handle != nil {
34+
// Already loaded
35+
return true
36+
}
37+
38+
// Load the private accessibility dylib
39+
guard let h = loadDylib(path: "/usr/lib/libAccessibility.dylib") else {
40+
NSLog("[Sentry] Failed to load libAccessibility.dylib")
41+
return false
42+
}
43+
handle = h
44+
45+
// Resolve function pointers to private APIs
46+
guard let symEnabled = dlsym(h, "_AXSAutomationEnabled"),
47+
let symSetEnabled = dlsym(h, "_AXSSetAutomationEnabled") else {
48+
NSLog("[Sentry] Failed to find accessibility automation functions")
49+
dlclose(h)
50+
handle = nil
51+
return false
52+
}
53+
54+
getAutomationEnabled = unsafeBitCast(symEnabled, to: AXSAutomationEnabled.self)
55+
setAutomationEnabled = unsafeBitCast(symSetEnabled, to: AXSSetAutomationEnabled.self)
56+
57+
// Save current state and enable accessibility
58+
previousValue = getAutomationEnabled?() ?? 0
59+
setAutomationEnabled?(1)
60+
61+
return true
62+
}
63+
64+
/// Disables accessibility automation and restores the previous state.
65+
public func disable() {
66+
guard let handle else {
67+
// Not enabled
68+
return
69+
}
70+
71+
// Restore previous state
72+
if let setAutomationEnabled {
73+
setAutomationEnabled(previousValue)
74+
}
75+
76+
// Clean up
77+
dlclose(handle)
78+
self.handle = nil
79+
self.getAutomationEnabled = nil
80+
self.setAutomationEnabled = nil
81+
}
82+
83+
private func loadDylib(path: String) -> UnsafeMutableRawPointer? {
84+
// Handle simulator vs device paths
85+
let environment = ProcessInfo.processInfo.environment
86+
if let simulatorRoot = environment["IPHONE_SIMULATOR_ROOT"] {
87+
let fullPath = simulatorRoot + path
88+
return dlopen((fullPath as NSString).fileSystemRepresentation, RTLD_LOCAL)
89+
} else {
90+
return dlopen((path as NSString).fileSystemRepresentation, RTLD_LOCAL)
91+
}
92+
}
93+
94+
deinit {
95+
disable()
96+
}
97+
}

0 commit comments

Comments
 (0)