Skip to content

Commit

Permalink
Merge 7b81bc5 into 8607e67
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Oct 24, 2022
2 parents 8607e67 + 7b81bc5 commit c9f8158
Show file tree
Hide file tree
Showing 32 changed files with 421 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Offline caching improvements (#2263)
- Report usage of stitchAsyncCode (#2281)
- HTTP Client errors (#2308)

### Fixes

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 1 addition & 0 deletions Samples/iOS-ObjectiveC/iOS-ObjectiveC/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ - (BOOL)application:(UIApplication *)application
if ([NSProcessInfo.processInfo.arguments containsObject:@"--io.sentry.profiling.enable"]) {
options.profilesSampleRate = @1;
}
options.enableCaptureFailedRequests = YES;
}];

return YES;
Expand Down
4 changes: 2 additions & 2 deletions Samples/iOS-ObjectiveC/iOS-ObjectiveC/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ - (void)viewDidLoad
// Load an image just for HTTP swizzling
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
NSURL *url = [[NSURL alloc]
initWithString:@"https://sentry-brand.storage.googleapis.com/sentry-logo-black.png"];
NSURL *url = [[NSURL alloc] initWithString:@"https://sentry-brand.storage.googleapis.com/test/"
@"sentry-logo-black.png?myQuery=test#myFragment"];
NSURLSessionDataTask *task = [session dataTaskWithURL:url];
[task resume];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 1 addition & 0 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// because we run CPU for 15 seconds at full throttle, we trigger ANR issues being sent. disable such during benchmarks.
options.enableAppHangTracking = !isBenchmarking
options.appHangTimeoutInterval = 2
options.enableCaptureFailedRequests = true
}

if #available(iOS 14.0, *) {
Expand Down
2 changes: 1 addition & 1 deletion Samples/iOS-Swift/iOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ViewController: UIViewController {
_ = FileManager.default.contents(atPath: path)
}
}

guard let imgUrl = URL(string: "https://sentry-brand.storage.googleapis.com/sentry-logo-black.png") else {
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1310"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
18 changes: 17 additions & 1 deletion Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,10 @@
A811D867248E2770008A41EA /* SentrySystemEventBreadcrumbsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = A811D866248E2770008A41EA /* SentrySystemEventBreadcrumbsTest.swift */; };
A839D89824864B80003B7AFD /* SentrySystemEventBreadcrumbs.h in Headers */ = {isa = PBXBuildFile; fileRef = A839D89724864B80003B7AFD /* SentrySystemEventBreadcrumbs.h */; };
A839D89A24864BA8003B7AFD /* SentrySystemEventBreadcrumbs.m in Sources */ = {isa = PBXBuildFile; fileRef = A839D89924864BA8003B7AFD /* SentrySystemEventBreadcrumbs.m */; };
A8AFFCCD29069C3E00967CD7 /* SentryHttpStatusCodeRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A8AFFCCC29069C3E00967CD7 /* SentryHttpStatusCodeRange.h */; settings = {ATTRIBUTES = (Public, ); }; };
A8F17B2C29016BD100990B25 /* SentryRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = A8F17B2B29016BD100990B25 /* SentryRequest.h */; };
A8F17B2E2901765900990B25 /* SentryRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B2D2901765900990B25 /* SentryRequest.m */; };
A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */; };
D8019910286B089000C277F0 /* SentryCrashReportSinkTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = D801990F286B089000C277F0 /* SentryCrashReportSinkTest.swift */; };
D808FB88281AB33C009A2A33 /* SentryUIEventTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D808FB86281AB31D009A2A33 /* SentryUIEventTrackerTests.swift */; };
D808FB8B281BCE96009A2A33 /* TestSentrySwizzleWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D808FB89281BCE46009A2A33 /* TestSentrySwizzleWrapper.swift */; };
Expand Down Expand Up @@ -1444,6 +1448,10 @@
A811D866248E2770008A41EA /* SentrySystemEventBreadcrumbsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySystemEventBreadcrumbsTest.swift; sourceTree = "<group>"; };
A839D89724864B80003B7AFD /* SentrySystemEventBreadcrumbs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySystemEventBreadcrumbs.h; path = include/SentrySystemEventBreadcrumbs.h; sourceTree = "<group>"; };
A839D89924864BA8003B7AFD /* SentrySystemEventBreadcrumbs.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySystemEventBreadcrumbs.m; sourceTree = "<group>"; };
A8AFFCCC29069C3E00967CD7 /* SentryHttpStatusCodeRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryHttpStatusCodeRange.h; path = Public/SentryHttpStatusCodeRange.h; sourceTree = "<group>"; };
A8F17B2B29016BD100990B25 /* SentryRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryRequest.h; sourceTree = "<group>"; };
A8F17B2D2901765900990B25 /* SentryRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryRequest.m; sourceTree = "<group>"; };
A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryHttpStatusCodeRange.m; sourceTree = "<group>"; };
D801990F286B089000C277F0 /* SentryCrashReportSinkTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashReportSinkTest.swift; sourceTree = "<group>"; };
D808FB86281AB31D009A2A33 /* SentryUIEventTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIEventTrackerTests.swift; sourceTree = "<group>"; };
D808FB89281BCE46009A2A33 /* TestSentrySwizzleWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentrySwizzleWrapper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1640,6 +1648,8 @@
7BD4BD4827EB2A5D0071F4FF /* SentryDiscardedEvent.m */,
7BC9A20128F41350001E7C4C /* SentryMeasurementUnit.h */,
7BC9A20528F41781001E7C4C /* SentryMeasurementUnit.m */,
A8F17B2B29016BD100990B25 /* SentryRequest.h */,
A8F17B2D2901765900990B25 /* SentryRequest.m */,
);
name = Protocol;
sourceTree = "<group>";
Expand Down Expand Up @@ -2569,6 +2579,8 @@
8E564AE7267AF22600FE117D /* SentryNetworkTracker.m */,
D8370B6B273DF20F00F66E2D /* SentryNSURLSessionTaskSearch.h */,
D8370B68273DF1E900F66E2D /* SentryNSURLSessionTaskSearch.m */,
A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */,
A8AFFCCC29069C3E00967CD7 /* SentryHttpStatusCodeRange.h */,
);
name = Network;
sourceTree = "<group>";
Expand Down Expand Up @@ -2992,6 +3004,7 @@
8EA1ED0D2669028C00E62B98 /* SentryUIViewControllerSwizzling.h in Headers */,
7B98D7E425FB7A7200C5A389 /* SentryAppState.h in Headers */,
7BDEAA022632A4580001EA25 /* SentryOptions+Private.h in Headers */,
A8AFFCCD29069C3E00967CD7 /* SentryHttpStatusCodeRange.h in Headers */,
15E0A8EA240F2C9000F044E3 /* SentrySerialization.h in Headers */,
63FE70EF20DA4C1000CDBAE8 /* SentryCrashMonitor_AppState.h in Headers */,
635B3F381EBC6E2500A6176D /* SentryAsynchronousOperation.h in Headers */,
Expand All @@ -3008,6 +3021,7 @@
63FE711F20DA4C1000CDBAE8 /* SentryCrashObjC.h in Headers */,
7BC3936825B1AB3E004F03D3 /* SentryLevelMapper.h in Headers */,
8E4E7C6E25DAAAFE006AB9E2 /* SentrySpan.h in Headers */,
A8F17B2C29016BD100990B25 /* SentryRequest.h in Headers */,
D8ACE3CE2762187D00F5A213 /* SentryNSDataTracker.h in Headers */,
03F84D2427DD414C008FE43F /* SentryCompiler.h in Headers */,
631E6D331EBC679C00712345 /* SentryQueueableRequestManager.h in Headers */,
Expand Down Expand Up @@ -3215,7 +3229,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1250;
LastUpgradeCheck = 1200;
LastUpgradeCheck = 1400;
ORGANIZATIONNAME = Sentry;
TargetAttributes = {
63AA759A1EB8AEF500D153DE = {
Expand Down Expand Up @@ -3299,6 +3313,7 @@
7BE3C77D2446112C00A38442 /* SentryRateLimitParser.m in Sources */,
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.m in Sources */,
03BCC38C27E1C01A003232C7 /* SentryTime.mm in Sources */,
A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */,
03F84D3727DD4191008FE43F /* SentrySamplingProfiler.cpp in Sources */,
8453421628BE8A9500C22EEC /* SentrySpanStatus.m in Sources */,
7B9657262683104C00C66E25 /* NSData+Sentry.m in Sources */,
Expand Down Expand Up @@ -3392,6 +3407,7 @@
6344DDBA1EC3115C00D9160D /* SentryCrashReportConverter.m in Sources */,
63FE70FD20DA4C1000CDBAE8 /* SentryCrashCachedData.c in Sources */,
8EE32518261FE27B00DC3FF2 /* SentryUIViewControllerSanitizer.m in Sources */,
A8F17B2E2901765900990B25 /* SentryRequest.m in Sources */,
7BE1E33424F7E3CB009D3AD0 /* SentryMigrateSessionInit.m in Sources */,
15E0A8F22411A45A00F044E3 /* SentrySession.m in Sources */,
7B6D1261265F784000C9BE4B /* PrivateSentrySDKOnly.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1400"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/Public/Sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[];
#import "SentryEvent.h"
#import "SentryException.h"
#import "SentryFrame.h"
#import "SentryHttpStatusCodeRange.h"
#import "SentryHub.h"
#import "SentryId.h"
#import "SentryIntegrationProtocol.h"
Expand Down
7 changes: 6 additions & 1 deletion Sources/Sentry/Public/SentryEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NS_ASSUME_NONNULL_BEGIN

@class SentryThread, SentryException, SentryStacktrace, SentryUser, SentryDebugMeta, SentryContext,
SentryBreadcrumb, SentryId, SentryMessage;
SentryBreadcrumb, SentryId, SentryMessage, SentryRequest;

NS_SWIFT_NAME(Event)
@interface SentryEvent : NSObject <SentrySerializable>
Expand Down Expand Up @@ -159,6 +159,11 @@ NS_SWIFT_NAME(Event)
*/
@property (nonatomic, strong) NSArray<SentryBreadcrumb *> *_Nullable breadcrumbs;

/**
* Set the Http request information.
*/
@property (nonatomic, strong, nullable) SentryRequest *request;

/**
* Init an SentryEvent will set all needed fields by default
* @return SentryEvent
Expand Down
27 changes: 27 additions & 0 deletions Sources/Sentry/Public/SentryHttpStatusCodeRange.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#import "SentryDefines.h"

NS_ASSUME_NONNULL_BEGIN

/**
* The Http status code range. Example for a range: 400 to 499, 500 to 599, 400 to 599 The range is
* inclusive so the min and max is considered part of the range.
*
* Example for a single status code 400, 500
*/
NS_SWIFT_NAME(HttpStatusCodeRange)
@interface SentryHttpStatusCodeRange : NSObject
SENTRY_NO_INIT

@property (nonatomic, readonly) NSInteger min;

@property (nonatomic, readonly) NSInteger max;

- (instancetype)initWithMin:(NSInteger)min max:(NSInteger)max;

- (instancetype)initWithStatusCode:(NSInteger)statusCode;

- (BOOL)isInRange:(NSInteger)statusCode;

@end

NS_ASSUME_NONNULL_END
26 changes: 25 additions & 1 deletion Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

NS_ASSUME_NONNULL_BEGIN

@class SentryDsn, SentrySdkInfo, SentryMeasurementValue;
@class SentryDsn, SentrySdkInfo, SentryMeasurementValue, SentryHttpStatusCodeRange;

NS_SWIFT_NAME(Options)
@interface SentryOptions : NSObject
Expand Down Expand Up @@ -414,6 +414,30 @@ NS_SWIFT_NAME(Options)
*/
@property (nonatomic, retain) NSArray *tracePropagationTargets;

/**
* When enabled, the SDK captures HTTP Client errors. Default value is NO.
*/
@property (nonatomic, assign) BOOL enableCaptureFailedRequests;

/**
* The SDK will only capture HTTP Client errors if the HTTP Response status code is within the
* defined range.
*
* Defaults to 500 - 599.
*/
@property (nonatomic, strong) NSArray<SentryHttpStatusCodeRange *> *failedRequestStatusCodes;

/**
* An array of hosts or regexes that determines if HTTP Client errors will be automatically
* captured.
*
* This array can contain instances of NSString which should match the URL (using `contains`),
* and instances of NSRegularExpression, which will be used to check the whole URL.
*
* The default value automatically captures HTTP Client errors of all outgoing requests.
*/
@property (nonatomic, strong) NSArray *failedRequestTargets;

@end

NS_ASSUME_NONNULL_END
5 changes: 5 additions & 0 deletions Sources/Sentry/Public/SentryStacktrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ SENTRY_NO_INIT
*/
@property (nonatomic, strong) NSDictionary<NSString *, NSString *> *registers;

/**
* Indicates that this stack trace is a snapshot triggered by an external signal.
*/
@property (nonatomic, copy, nullable) NSNumber *snapshot;

/**
* Initialize a SentryStacktrace with frames and registers
* @param frames NSArray
Expand Down
5 changes: 5 additions & 0 deletions Sources/Sentry/SentryEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "SentryLevelMapper.h"
#import "SentryMessage.h"
#import "SentryMeta.h"
#import "SentryRequest.h"
#import "SentryStacktrace.h"
#import "SentryThread.h"
#import "SentryUser.h"
Expand Down Expand Up @@ -157,6 +158,10 @@ - (void)addSimpleProperties:(NSMutableDictionary *)serializedData
forKey:@"start_timestamp"];
}
}

if (nil != self.request) {
[serializedData setValue:[self.request serialize] forKey:@"request"];
}
}

- (NSArray *_Nullable)serializeBreadcrumbs
Expand Down
32 changes: 32 additions & 0 deletions Sources/Sentry/SentryHttpStatusCodeRange.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#import "SentryHttpStatusCodeRange.h"

NS_ASSUME_NONNULL_BEGIN

@implementation SentryHttpStatusCodeRange

- (instancetype)initWithMin:(NSInteger)min max:(NSInteger)max
{
if (self = [super init]) {
_min = min;
_max = max;
}
return self;
}

- (instancetype)initWithStatusCode:(NSInteger)statusCode
{
if (self = [super init]) {
_min = statusCode;
_max = statusCode;
}
return self;
}

- (BOOL)isInRange:(NSInteger)statusCode
{
return statusCode >= _min && statusCode <= _max;
}

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit c9f8158

Please sign in to comment.