Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Removes `SentryIntegrationProtocol` from the API. This is not used after the removal of the `integrations` property (#6660)
- Removes deprecated SentryDebugImageProvider class (#5598)
- Properties on SentryOptions that had no effect on the WithoutUIKit variant are now removed from the API (#6644)
- Removes the SentryOptions.inAppExclude property because it had no effect (#6646)
- Removes segment property on SentryUser, SentryBaggage, and SentryTraceContext (#5638)
- Removes deprecated TraceContext initializers (#6348)
- Removes deprecated user feedback API, this is replaced with the new feedback API (#5591)
Expand Down
16 changes: 0 additions & 16 deletions Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,6 @@ NS_SWIFT_NAME(Options)

/**
* A list of string prefixes of framework names that belong to the app.
* @note This option takes precedence over @c inAppExcludes.
* @note By default, this contains @c CFBundleExecutable to mark it as "in-app".
*/
@property (nonatomic, readonly, copy) NSArray<NSString *> *inAppIncludes;
Expand All @@ -463,21 +462,6 @@ NS_SWIFT_NAME(Options)
*/
- (void)addInAppInclude:(NSString *)inAppInclude;

/**
* A list of string prefixes of framework names that do not belong to the app, but rather to
* third-party frameworks.
* @note By default, frameworks considered not part of the app will be hidden from stack
* traces.
* @note This option can be overridden using @c inAppIncludes.
*/
@property (nonatomic, readonly, copy) NSArray<NSString *> *inAppExcludes;

/**
* Adds an item to the list of @c inAppExcludes.
* @param inAppExclude The prefix of the frameworks name.
*/
- (void)addInAppExclude:(NSString *)inAppExclude;

/**
* Set as delegate on the @c NSURLSession used for all network data-transfer tasks performed by
* Sentry.
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/SentryCrashIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ - (void)startCrashHandler:(NSString *)cacheDirectory
BOOL canSendReports = NO;
if (installation == nil) {
SentryInAppLogic *inAppLogic =
[[SentryInAppLogic alloc] initWithInAppIncludes:self.options.inAppIncludes
inAppExcludes:self.options.inAppExcludes];
[[SentryInAppLogic alloc] initWithInAppIncludes:self.options.inAppIncludes];

installation = [[SentryCrashInstallationReporter alloc]
initWithInAppLogic:inAppLogic
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/SentryDefaultThreadInspector.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ - (id)initWithStacktraceBuilder:(SentryStacktraceBuilder *)stacktraceBuilder
- (instancetype)initWithOptions:(SentryOptions *_Nullable)options
{
SentryInAppLogic *inAppLogic =
[[SentryInAppLogic alloc] initWithInAppIncludes:options.inAppIncludes ?: @[]
inAppExcludes:options.inAppExcludes ?: @[]];
[[SentryInAppLogic alloc] initWithInAppIncludes:options.inAppIncludes ?: @[]];
SentryCrashStackEntryMapper *crashStackEntryMapper =
[[SentryCrashStackEntryMapper alloc] initWithInAppLogic:inAppLogic];
SentryStacktraceBuilder *stacktraceBuilder =
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/SentryMetricKitIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ - (BOOL)installWithOptions:(SentryOptions *)options
self.measurementFormatter = [[NSMeasurementFormatter alloc] init];
self.measurementFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
self.measurementFormatter.unitOptions = NSMeasurementFormatterUnitOptionsProvidedUnit;
self.inAppLogic = [[SentryInAppLogic alloc] initWithInAppIncludes:options.inAppIncludes
inAppExcludes:options.inAppExcludes];
self.inAppLogic = [[SentryInAppLogic alloc] initWithInAppIncludes:options.inAppIncludes];
self.attachDiagnosticAsAttachment = options.enableMetricKitRawPayload;

return YES;
Expand Down
7 changes: 0 additions & 7 deletions Sources/Sentry/SentryOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ - (instancetype)init
_inAppIncludes = @[ bundleExecutable ];
}

_inAppExcludes = [NSArray new];

// Set default release name
if (infoDict != nil) {
self.releaseName =
Expand Down Expand Up @@ -216,11 +214,6 @@ - (void)addInAppInclude:(NSString *)inAppInclude
_inAppIncludes = [self.inAppIncludes arrayByAddingObject:inAppInclude];
}

- (void)addInAppExclude:(NSString *)inAppExclude
{
_inAppExcludes = [self.inAppExcludes arrayByAddingObject:inAppExclude];
}

- (void)setSampleRate:(NSNumber *)sampleRate
{
if (sampleRate == nil) {
Expand Down
8 changes: 0 additions & 8 deletions Sources/Sentry/SentryOptionsInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,6 @@ + (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
}
}

if ([options[@"inAppExcludes"] isKindOfClass:[NSArray class]]) {
NSArray<NSString *> *inAppExcludes =
[options[@"inAppExcludes"] filteredArrayUsingPredicate:isNSString];
for (NSString *exclude in inAppExcludes) {
[sentryOptions addInAppExclude:exclude];
}
}

if ([options[@"urlSession"] isKindOfClass:[NSURLSession class]]) {
sentryOptions.urlSession = options[@"urlSession"];
}
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/SentryUIViewControllerSwizzling.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ - (instancetype)initWithOptions:(SentryOptions *)options
{
if (self = [super init]) {
self.options = options;
self.inAppLogic = [[SentryInAppLogic alloc] initWithInAppIncludes:options.inAppIncludes
inAppExcludes:options.inAppExcludes];
self.inAppLogic = [[SentryInAppLogic alloc] initWithInAppIncludes:options.inAppIncludes];
self.dispatchQueue = dispatchQueue;
self.objcRuntimeWrapper = objcRuntimeWrapper;
self.subClassFinder = subClassFinder;
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/SentryUseNSExceptionCallstackWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ - (SentryCrashStackEntryMapper *)buildCrashStackToEntryMapper
SentryOptions *options = SentrySDKInternal.options;

SentryInAppLogic *inAppLogic =
[[SentryInAppLogic alloc] initWithInAppIncludes:options.inAppIncludes
inAppExcludes:options.inAppExcludes];
[[SentryInAppLogic alloc] initWithInAppIncludes:options.inAppIncludes];
SentryCrashStackEntryMapper *crashStackEntryMapper =
[[SentryCrashStackEntryMapper alloc] initWithInAppLogic:inAppLogic];

Expand Down
25 changes: 6 additions & 19 deletions Sources/Swift/Core/Helper/SentryInAppLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,30 @@ import ObjectiveC
@objc @_spi(Private) public class SentryInAppLogic: NSObject {

@objc public let inAppIncludes: [String]
private let inAppExcludes: [String]

/**
* Initializes @c SentryInAppLogic with @c inAppIncludes and @c inAppExcludes.
* Initializes @c SentryInAppLogic with @c inAppIncludes.
*
* To work properly for Apple applications the @c inAppIncludes should contain the
* @c CFBundleExecutable, which is the name of the bundle's executable file.
*
* @param inAppIncludes A list of string prefixes of framework names that belong to the app. This
* option takes precedence over @c inAppExcludes.
* @param inAppExcludes A list of string prefixes of framework names that do not belong to the app,
* but rather to third-party packages. Modules considered not part of the app will be hidden from
* stack traces by default.
* @param inAppIncludes A list of string prefixes of framework names that belong to the app.
*/
@objc(initWithInAppIncludes:inAppExcludes:) public init(inAppIncludes: [String], inAppExcludes: [String]) {
@objc(initWithInAppIncludes:) public init(inAppIncludes: [String]) {
self.inAppIncludes = inAppIncludes.map { $0.lowercased() }
self.inAppExcludes = inAppExcludes.map { $0.lowercased() }
super.init()
}

/**
* Determines if the framework belongs to the app by using @c inAppIncludes and @c inAppExcludes.
* Determines if the framework belongs to the app by using @c inAppIncludes.
* Before checking this method lowercases the strings and uses only the @c lastPathComponent of the
* @c imagePath.
*
* @param imagePath the full path of the binary image.
*
* @return @c YES if the framework located at the @c imagePath starts with a prefix of
* @c inAppIncludes. @c NO if the framework located at the @c imagePath doesn't start with a prefix of
* @c inAppIncludes or start with a prefix of @c inAppExcludes.
* @c inAppIncludes.
*/
@objc public func `is`(inApp imagePath: String?) -> Bool {
guard let imagePath else {
Expand All @@ -72,12 +66,6 @@ import ObjectiveC
}
}

for inAppExclude in inAppExcludes {
if imageNameLastPathComponent.hasPrefix(inAppExclude) {
return false
}
}

return false
}

Expand All @@ -88,8 +76,7 @@ import ObjectiveC
* @param targetClass the class to check.
*
* @return @c YES if the @c targetClass belongs to a framework included in @c inAppIncludes.
* @c NO if targetClass does not belong to a framework in @c inAppIncludes or belongs to a framework in
* @c inAppExcludes.
* @c NO if targetClass does not belong to a framework in @c inAppIncludes.
*/
@objc public func isClassInApp(_ targetClass: AnyClass) -> Bool {
guard let imageName = class_getImageName(targetClass) else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import UIKit

override init() {
let options = SentrySDKInternal.options
inAppLogic = SentryInAppLogic(inAppIncludes: options?.inAppIncludes ?? [], inAppExcludes: options?.inAppExcludes ?? [])
inAppLogic = SentryInAppLogic(inAppIncludes: options?.inAppIncludes ?? [])
helper = SentryDefaultUIViewControllerPerformanceTracker(tracker: SentryPerformanceTracker.shared)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SentryUIViewControllerPerformanceTrackerTests: XCTestCase {
var viewControllerName: String!

var inAppLogic: SentryInAppLogic {
return SentryInAppLogic(inAppIncludes: options.inAppIncludes, inAppExcludes: [])
return SentryInAppLogic(inAppIncludes: options.inAppIncludes)
}

init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class SentryCrashInstallationReporterTests: XCTestCase {
let hub = SentryHubInternal(client: testClient, andScope: nil)
SentrySDKInternal.setCurrentHub(hub)

sut = SentryCrashInstallationReporter(inAppLogic: SentryInAppLogic(inAppIncludes: [], inAppExcludes: []), crashWrapper: TestSentryCrashWrapper(processInfoWrapper: ProcessInfo.processInfo), dispatchQueue: TestSentryDispatchQueueWrapper())
sut = SentryCrashInstallationReporter(inAppLogic: SentryInAppLogic(inAppIncludes: []), crashWrapper: TestSentryCrashWrapper(processInfoWrapper: ProcessInfo.processInfo), dispatchQueue: TestSentryDispatchQueueWrapper())
sut.install(options.cacheDirectoryPath)
// Works only if SentryCrash is installed
sentrycrash_deleteAllReports()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SentryCrashReportSinkTests: SentrySDKIntegrationTestsBase {
let dispatchQueue = TestSentryDispatchQueueWrapper()

var sut: SentryCrashReportSink {
return SentryCrashReportSink(inAppLogic: SentryInAppLogic(inAppIncludes: [], inAppExcludes: []), crashWrapper: crashWrapper, dispatchQueue: dispatchQueue)
return SentryCrashReportSink(inAppLogic: SentryInAppLogic(inAppIncludes: []), crashWrapper: crashWrapper, dispatchQueue: dispatchQueue)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SentryCrashStackEntryMapperTests: XCTestCase {

override func setUp() {
super.setUp()
sut = SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [bundleExecutable], inAppExcludes: []))
sut = SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [bundleExecutable]))
}

override func tearDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class SentryDefaultThreadInspectorTests: XCTestCase {

private class Fixture {
var testMachineContextWrapper = TestMachineContextWrapper()
var stacktraceBuilder = TestSentryStacktraceBuilder(crashStackEntryMapper: SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [], inAppExcludes: [])))
var stacktraceBuilder = TestSentryStacktraceBuilder(crashStackEntryMapper: SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [])))
var keepThreadAlive = true

func getSut(testWithRealMachineContextWrapper: Bool = false, symbolicate: Bool = true) -> SentryDefaultThreadInspector {

let machineContextWrapper = testWithRealMachineContextWrapper ? SentryCrashDefaultMachineContextWrapper() : testMachineContextWrapper as SentryCrashMachineContextWrapper
let stacktraceBuilder = testWithRealMachineContextWrapper ? SentryStacktraceBuilder(crashStackEntryMapper: SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [], inAppExcludes: []))) : self.stacktraceBuilder
let stacktraceBuilder = testWithRealMachineContextWrapper ? SentryStacktraceBuilder(crashStackEntryMapper: SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: []))) : self.stacktraceBuilder

stacktraceBuilder.symbolicate = symbolicate

Expand Down
22 changes: 7 additions & 15 deletions Tests/SentryTests/SentryCrash/SentryInAppLogicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ class SentryInAppLogicTests: XCTestCase {

private class Fixture {

func getSut(inAppIncludes: [String] = [], inAppExcludes: [String] = [] ) -> SentryInAppLogic {
func getSut(inAppIncludes: [String] = [] ) -> SentryInAppLogic {

return SentryInAppLogic(
inAppIncludes: inAppIncludes,
inAppExcludes: inAppExcludes
inAppIncludes: inAppIncludes
)
}
}
Expand Down Expand Up @@ -50,28 +49,21 @@ class SentryInAppLogicTests: XCTestCase {

func testInAppExclude_WithSpecifiedFramework() {
XCTAssertFalse(
fixture.getSut(inAppExcludes: ["iOS-Swift"])
.is(inApp: "/private/var/containers/Bundle/Application/D987FC7A-629E-41DD-A043-5097EB29E2F4/iOS-Swift.app/iOS-Swift")
)
}

func testInAppExclude_WithLowercasePrefix() {
XCTAssertFalse(
fixture.getSut(inAppExcludes: ["i"])
fixture.getSut()
.is(inApp: "/private/var/containers/Bundle/Application/D987FC7A-629E-41DD-A043-5097EB29E2F4/iOS-Swift.app/iOS-Swift")
)
}

func testInAppIncludeTakesPrecedence() {
XCTAssertTrue(
fixture.getSut(inAppIncludes: ["libdyld.dylib"], inAppExcludes: ["libdyld.dylib"])
fixture.getSut(inAppIncludes: ["libdyld.dylib"])
.is(inApp: "/usr/lib/system/libdyld.dylib")
)
}

func testInApp_WithNotMatchingIncludeButMatchingExclude() {
XCTAssertFalse(
fixture.getSut(inAppIncludes: ["iOS-Swifta"], inAppExcludes: ["iOS-Swift"])
fixture.getSut(inAppIncludes: ["iOS-Swifta"])
.is(inApp: "/private/var/containers/Bundle/Application/D987FC7A-629E-41DD-A043-5097EB29E2F4/iOS-Swift.app/iOS-Swift")
)
}
Expand Down Expand Up @@ -177,8 +169,8 @@ class SentryInAppLogicTests: XCTestCase {
testWithImages(images: images, inAppIncludes: ["watchOS-Swift WatchKit Extension"])
}

private func testWithImages(images: Images, inAppIncludes: [String], inAppExcludes: [String] = []) {
let sut = fixture.getSut(inAppIncludes: inAppIncludes, inAppExcludes: inAppExcludes)
private func testWithImages(images: Images, inAppIncludes: [String]) {
let sut = fixture.getSut(inAppIncludes: inAppIncludes)
XCTAssertTrue(sut.is(inApp: images.bundleExecutable))
images.privateFrameworks.forEach {
XCTAssertTrue(sut.is(inApp: $0))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SentryStacktraceBuilderTests: XCTestCase {

var sut: SentryStacktraceBuilder {
SentryDependencyContainer.sharedInstance().reachability = TestSentryReachability()
let res = SentryStacktraceBuilder(crashStackEntryMapper: SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [], inAppExcludes: [])))
let res = SentryStacktraceBuilder(crashStackEntryMapper: SentryCrashStackEntryMapper(inAppLogic: SentryInAppLogic(inAppIncludes: [])))
res.symbolicate = true
return res
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/SentryCrash/TestThreadInspector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class TestDefaultThreadInspector: SentryDefaultThreadInspector {

static var instance: TestDefaultThreadInspector {
// We need something to pass to the super initializer, because the empty initializer has been marked unavailable.
let inAppLogic = SentryInAppLogic(inAppIncludes: [], inAppExcludes: [])
let inAppLogic = SentryInAppLogic(inAppIncludes: [])
let crashStackEntryMapper = SentryCrashStackEntryMapper(inAppLogic: inAppLogic)
let stacktraceBuilder = SentryStacktraceBuilder(crashStackEntryMapper: crashStackEntryMapper)
return TestDefaultThreadInspector(stacktraceBuilder: stacktraceBuilder, andMachineContextWrapper: SentryCrashDefaultMachineContextWrapper(), symbolicate: false)
Expand Down
2 changes: 1 addition & 1 deletion Tests/SentryTests/SentryCrashReportConverterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ @implementation SentryCrashReportConverterTests
- (void)setUp
{
[super setUp];
self.inAppLogic = [[SentryInAppLogic alloc] initWithInAppIncludes:@[] inAppExcludes:@[]];
self.inAppLogic = [[SentryInAppLogic alloc] initWithInAppIncludes:@[]];
}

- (void)tearDown
Expand Down
25 changes: 0 additions & 25 deletions Tests/SentryTests/SentryOptionsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,6 @@ - (void)testNSNull_SetsDefaultValue
@"profilesSampler" : [NSNull null],
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
@"inAppIncludes" : [NSNull null],
@"inAppExcludes" : [NSNull null],
@"urlSessionDelegate" : [NSNull null],
@"enableSwizzling" : [NSNull null],
@"swizzleClassNameExcludes" : [NSNull null],
Expand Down Expand Up @@ -707,7 +706,6 @@ - (void)assertDefaultValues:(SentryOptions *)options
XCTAssertNil(options.tracesSampleRate);
XCTAssertNil(options.tracesSampler);
XCTAssertEqualObjects([self getDefaultInAppIncludes], options.inAppIncludes);
XCTAssertEqual(@[], options.inAppExcludes);
XCTAssertNil(options.urlSessionDelegate);
XCTAssertNil(options.urlSession);
XCTAssertEqual(YES, options.enableSwizzling);
Expand Down Expand Up @@ -1106,29 +1104,6 @@ - (void)testDefaultInAppIncludes
XCTAssertEqualObjects([self getDefaultInAppIncludes], options.inAppIncludes);
}

- (void)testInAppExcludes
{
NSArray<NSString *> *expected = @[ @"Sentry" ];
NSArray *inAppExcludes = @[ @"Sentry", @2 ];

SentryOptions *options = [self getValidOptions:@{ @"inAppExcludes" : inAppExcludes }];

XCTAssertEqualObjects(expected, options.inAppExcludes);
}

- (void)testAddInAppExcludes
{
SentryOptions *options = [self getValidOptions:@{}];
[options addInAppExclude:@"App"];
XCTAssertEqualObjects(@[ @"App" ], options.inAppExcludes);
}

- (void)testDefaultInAppExcludes
{
SentryOptions *options = [self getValidOptions:@{}];
XCTAssertEqualObjects(@[], options.inAppExcludes);
}

- (void)testDefaultInitialScope
{
SentryOptions *options = [self getValidOptions:@{}];
Expand Down
Loading
Loading