Skip to content

Commit

Permalink
fix: Support for CaptureFailedRequests on iOS (#2826)
Browse files Browse the repository at this point in the history
  • Loading branch information
carmichaelalonso authored Nov 13, 2023
1 parent 4eefeca commit caafeee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2213)
- [diff](https://github.com/getsentry/sentry-cli/compare/2.21.2...2.21.3)

### Fixes

- Fixed CaptureFailedRequests and FailedRequestStatusCodes not affecting the Cocoa layer ([#2744](https://github.com/getsentry/sentry-dotnet/issues/2744))


## 3.41.0

- Speed up SDK init ([#2784](https://github.com/getsentry/sentry-dotnet/pull/2784))
Expand Down
14 changes: 14 additions & 0 deletions src/Sentry/Platforms/iOS/SentrySdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ private static void InitSentryCocoaSdk(SentryOptions options)
cocoaOptions.DiagnosticLevel = options.DiagnosticLevel.ToCocoaSentryLevel();
cocoaOptions.Dsn = options.Dsn;
cocoaOptions.EnableAutoSessionTracking = options.AutoSessionTracking;
cocoaOptions.EnableCaptureFailedRequests = options.CaptureFailedRequests;
cocoaOptions.FailedRequestStatusCodes = GetFailedRequestStatusCodes(options.FailedRequestStatusCodes);
cocoaOptions.MaxAttachmentSize = (nuint) options.MaxAttachmentSize;
cocoaOptions.MaxBreadcrumbs = (nuint) options.MaxBreadcrumbs;
cocoaOptions.MaxCacheItems = (nuint) options.MaxCacheItems;
Expand Down Expand Up @@ -201,4 +203,16 @@ private static string GetDefaultReleaseString()
private static string GetDefaultDistributionString() => GetBundleValue("CFBundleVersion");

private static string GetBundleValue(string key) => NSBundle.MainBundle.ObjectForInfoDictionary(key).ToString();

private static CocoaSdk.SentryHttpStatusCodeRange[] GetFailedRequestStatusCodes(IList<HttpStatusCodeRange> httpStatusCodeRanges)
{
var nativeRanges = new CocoaSdk.SentryHttpStatusCodeRange[httpStatusCodeRanges.Count];
for (var i = 0; i < httpStatusCodeRanges.Count; i++)
{
var range = httpStatusCodeRanges[i];
nativeRanges[i] = new CocoaSdk.SentryHttpStatusCodeRange(range.Start, range.End);
}

return nativeRanges;
}
}

0 comments on commit caafeee

Please sign in to comment.