Skip to content

Commit caafeee

Browse files
fix: Support for CaptureFailedRequests on iOS (#2826)
1 parent 4eefeca commit caafeee

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2213)
1212
- [diff](https://github.com/getsentry/sentry-cli/compare/2.21.2...2.21.3)
1313

14+
### Fixes
15+
16+
- Fixed CaptureFailedRequests and FailedRequestStatusCodes not affecting the Cocoa layer ([#2744](https://github.com/getsentry/sentry-dotnet/issues/2744))
17+
18+
1419
## 3.41.0
1520

1621
- Speed up SDK init ([#2784](https://github.com/getsentry/sentry-dotnet/pull/2784))

src/Sentry/Platforms/iOS/SentrySdk.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ private static void InitSentryCocoaSdk(SentryOptions options)
2727
cocoaOptions.DiagnosticLevel = options.DiagnosticLevel.ToCocoaSentryLevel();
2828
cocoaOptions.Dsn = options.Dsn;
2929
cocoaOptions.EnableAutoSessionTracking = options.AutoSessionTracking;
30+
cocoaOptions.EnableCaptureFailedRequests = options.CaptureFailedRequests;
31+
cocoaOptions.FailedRequestStatusCodes = GetFailedRequestStatusCodes(options.FailedRequestStatusCodes);
3032
cocoaOptions.MaxAttachmentSize = (nuint) options.MaxAttachmentSize;
3133
cocoaOptions.MaxBreadcrumbs = (nuint) options.MaxBreadcrumbs;
3234
cocoaOptions.MaxCacheItems = (nuint) options.MaxCacheItems;
@@ -201,4 +203,16 @@ private static string GetDefaultReleaseString()
201203
private static string GetDefaultDistributionString() => GetBundleValue("CFBundleVersion");
202204

203205
private static string GetBundleValue(string key) => NSBundle.MainBundle.ObjectForInfoDictionary(key).ToString();
206+
207+
private static CocoaSdk.SentryHttpStatusCodeRange[] GetFailedRequestStatusCodes(IList<HttpStatusCodeRange> httpStatusCodeRanges)
208+
{
209+
var nativeRanges = new CocoaSdk.SentryHttpStatusCodeRange[httpStatusCodeRanges.Count];
210+
for (var i = 0; i < httpStatusCodeRanges.Count; i++)
211+
{
212+
var range = httpStatusCodeRanges[i];
213+
nativeRanges[i] = new CocoaSdk.SentryHttpStatusCodeRange(range.Start, range.End);
214+
}
215+
216+
return nativeRanges;
217+
}
204218
}

0 commit comments

Comments
 (0)