Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Support for CaptureFailedRequests on iOS #2826

Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Changelog

Check failure on line 1 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / danger / danger

Please consider adding a changelog entry for the next release.

Check notice on line 1 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / danger / danger

### Instructions and example for changelog Please add an entry to `CHANGELOG.md` to the "Unreleased" section. Make sure the entry includes this PR's number. Example: ```markdown ## Unreleased - Support for CaptureFailedRequests on iOS ([#2826](https://github.com/getsentry/sentry-dotnet/pull/2826)) ``` If none of the above apply, you can opt out of this check by adding `#skip-changelog` to the PR description.

## Unreleased

Expand All @@ -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;
}
}
Loading