Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
brustolin committed Sep 24, 2024
1 parent 73bc265 commit 745e53b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
29 changes: 29 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,9 @@
D84F833E2A1CC401005828E0 /* SentrySwiftAsyncIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = D84F833C2A1CC401005828E0 /* SentrySwiftAsyncIntegration.m */; };
D851527F2C9971020070F669 /* SentryStringUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = D851527E2C9971020070F669 /* SentryStringUtils.h */; };
D85152832C997A280070F669 /* SentryStringUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D85152822C997A1F0070F669 /* SentryStringUtils.swift */; };
D85153002CA2B5F60070F669 /* SentrySwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8199DAA29376E9B0074249E /* SentrySwiftUI.framework */; };
D85153012CA2B5F60070F669 /* SentrySwiftUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D8199DAA29376E9B0074249E /* SentrySwiftUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D851530C2CA2B7B00070F669 /* SentryRedactModifierTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D851530B2CA2B7A30070F669 /* SentryRedactModifierTests.swift */; };
D85596F3280580F10041FF8B /* SentryScreenshotIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = D85596F1280580F10041FF8B /* SentryScreenshotIntegration.m */; };
D855AD62286ED6A4002573E1 /* SentryCrashTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D855AD61286ED6A4002573E1 /* SentryCrashTests.m */; };
D855B3E827D652AF00BCED76 /* SentryCoreDataTrackingIntegrationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D855B3E727D652AF00BCED76 /* SentryCoreDataTrackingIntegrationTest.swift */; };
Expand Down Expand Up @@ -983,6 +986,13 @@
remoteGlobalIDString = D84DAD4C2B17428D003CF120;
remoteInfo = SentryTestUtilsDynamic;
};
D85153022CA2B5F60070F669 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 6327C5CA1EB8A783004E799B /* Project object */;
proxyType = 1;
remoteGlobalIDString = D8199DA929376E9B0074249E;
remoteInfo = SentrySwiftUI;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -993,6 +1003,7 @@
dstSubfolderSpec = 10;
files = (
D84DAD5A2B1742C1003CF120 /* SentryTestUtilsDynamic.framework in Embed Frameworks */,
D85153012CA2B5F60070F669 /* SentrySwiftUI.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1917,6 +1928,7 @@
D8511F722BAC8F750015E6FD /* Sentry.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = Sentry.modulemap; sourceTree = "<group>"; };
D851527E2C9971020070F669 /* SentryStringUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryStringUtils.h; sourceTree = "<group>"; };
D85152822C997A1F0070F669 /* SentryStringUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryStringUtils.swift; sourceTree = "<group>"; };
D851530B2CA2B7A30070F669 /* SentryRedactModifierTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRedactModifierTests.swift; sourceTree = "<group>"; };
D85596F1280580F10041FF8B /* SentryScreenshotIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryScreenshotIntegration.m; sourceTree = "<group>"; };
D855AD61286ED6A4002573E1 /* SentryCrashTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashTests.m; sourceTree = "<group>"; };
D855B3E727D652AF00BCED76 /* SentryCoreDataTrackingIntegrationTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCoreDataTrackingIntegrationTest.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2056,6 +2068,7 @@
8431F01C29B2854200D8DC56 /* libSentryTestUtils.a in Frameworks */,
D84DAD592B1742C1003CF120 /* SentryTestUtilsDynamic.framework in Frameworks */,
63AA766A1EB8CB2F00D153DE /* Sentry.framework in Frameworks */,
D85153002CA2B5F60070F669 /* SentrySwiftUI.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -2590,6 +2603,7 @@
7BF536D224BEF240004FA6A2 /* TestUtils */,
D81FDF0F280E9FEC0045E0E4 /* Tools */,
7B6C5ED4264E62B60010D138 /* Transaction */,
D851530A2CA2B7960070F669 /* SwiftUI */,
);
path = SentryTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -3773,6 +3787,14 @@
path = SentryTestUtilsDynamic;
sourceTree = "<group>";
};
D851530A2CA2B7960070F669 /* SwiftUI */ = {
isa = PBXGroup;
children = (
D851530B2CA2B7A30070F669 /* SentryRedactModifierTests.swift */,
);
path = SwiftUI;
sourceTree = "<group>";
};
D85596EF280580BE0041FF8B /* Screenshot */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4373,6 +4395,7 @@
dependencies = (
63AA766C1EB8CB2F00D153DE /* PBXTargetDependency */,
D84DAD5C2B1742C1003CF120 /* PBXTargetDependency */,
D85153032CA2B5F60070F669 /* PBXTargetDependency */,
);
name = SentryTests;
packageProductDependencies = (
Expand Down Expand Up @@ -5086,6 +5109,7 @@
D8AE48C12C57B1550092A2A6 /* SentryLevelTests.swift in Sources */,
63FE721820DA66EC00CDBAE8 /* TestThread.m in Sources */,
7B4D308A26FC616B00C94DE9 /* SentryHttpTransportTests.swift in Sources */,
D851530C2CA2B7B00070F669 /* SentryRedactModifierTests.swift in Sources */,
7B4E23B6251A07BD00060D68 /* SentryDispatchQueueWrapperTests.swift in Sources */,
63FE720720DA66EC00CDBAE8 /* SentryCrashReportFilter_Tests.m in Sources */,
8F73BC312B02B87E00C3CEF4 /* SentryInstallationTests.swift in Sources */,
Expand Down Expand Up @@ -5252,6 +5276,11 @@
target = D84DAD4C2B17428D003CF120 /* SentryTestUtilsDynamic */;
targetProxy = D84DAD5B2B1742C1003CF120 /* PBXContainerItemProxy */;
};
D85153032CA2B5F60070F669 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D8199DA929376E9B0074249E /* SentrySwiftUI */;
targetProxy = D85153022CA2B5F60070F669 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
Expand Down
4 changes: 2 additions & 2 deletions Sources/SentrySwiftUI/SentryInternal/SentryInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ typedef NS_ENUM(NSUInteger, SentrySpanStatus);

@property (nonatomic, class, readonly) SentryPerformanceTracker *shared;

- (SentrySpanId *)startSpanWithName:(NSString *)name operation:(NSString *)operation;

- (SentrySpanId *)startSpanWithName:(NSString *)name
nameSource:(SentryTransactionNameSource)source
operation:(NSString *)operation
Expand All @@ -30,11 +28,13 @@ typedef NS_ENUM(NSUInteger, SentrySpanStatus);
- (void)activateSpan:(SentrySpanId *)spanId duringBlock:(void (^)(void))block;

- (void)measureSpanWithDescription:(NSString *)description
nameSource:(SentryTransactionNameSource)source
operation:(NSString *)operation
origin:(NSString *)origin
inBlock:(void (^)(void))block;

- (void)measureSpanWithDescription:(NSString *)description
nameSource:(SentryTransactionNameSource)source
operation:(NSString *)operation
origin:(NSString *)origin
parentSpanId:(SentrySpanId *)parentSpanId
Expand Down
9 changes: 7 additions & 2 deletions Sources/SentrySwiftUI/SentryReplayView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(SwiftUI) && canImport(UIKit)
#if SENTRY_NO_UIKIT
import SentryWithoutUIKit
#else
Expand All @@ -8,8 +9,11 @@ import UIKit

@available(iOS 13, macOS 10.15, tvOS 13, *)
struct SentryReplayView: UIViewRepresentable {
class SentryRedactView: UIView {
}

func makeUIView(context: Context) -> UIView {
let result = UIView()
let result = SentryRedactView()
result.sentryReplayRedact()
return result

Check warning on line 18 in Sources/SentrySwiftUI/SentryReplayView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/SentrySwiftUI/SentryReplayView.swift#L15-L18

Added lines #L15 - L18 were not covered by tests
}
Expand All @@ -36,8 +40,9 @@ public extension View {
/// data or confidential information that shouldn't be visible when the replay is reviewed.
///
/// - Returns: A modifier that redacts sensitive information during session replays.
///
/// - Experiment: This is an experimental feature and may still have bugs.
func sentryReplayRedact() -> some View {
modifier(SentryReplayModifier())
}
}
#endif
2 changes: 2 additions & 0 deletions Sources/SentrySwiftUI/SentryTracedView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(SwiftUI) && canImport(UIKit)
import Foundation
#if SENTRY_NO_UIKIT
import SentryWithoutUIKit
Expand Down Expand Up @@ -104,3 +105,4 @@ public extension View {
}
}
}
#endif
18 changes: 18 additions & 0 deletions Tests/SentryTests/SwiftUI/SentryRedactModifierTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#if canImport(UIKit) && canImport(SwiftUI)
@testable import Sentry
@testable import SentrySwiftUI
import SwiftUI
import XCTest

class SentryRedactModifierTests: XCTestCase {

func testViewRedate() throws {
let text = Text("Hello, World!")
let redactedText = text.sentryReplayRedact()

XCTAssertTrue(redactedText is ModifiedContent<Text, SentryReplayModifier>)
}

}

#endif

0 comments on commit 745e53b

Please sign in to comment.