Skip to content

Commit

Permalink
ref: functions to convert to/from enum cases (getsentry#2108)
Browse files Browse the repository at this point in the history
* ref: add function to return level name from enum constant

- remove duplicate tests
- add tests for going from name->level
- use C functions instead of ObjC methods
- deduplicated method that parses data categories for rate limits with one mod, which is inlined at the call site
- add tests and add degenerate cases for converting an unexpected string/numeric value to enum case
  • Loading branch information
armcknight authored Sep 9, 2022
1 parent 45ed684 commit 10a83a9
Show file tree
Hide file tree
Showing 36 changed files with 438 additions and 261 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let package = Package(
platforms: [.iOS(.v9), .macOS(.v10_10), .tvOS(.v9), .watchOS(.v2)],
products: [
.library(name: "Sentry", targets: ["Sentry"]),
.library(name: "Sentry-Dynamic", type: .dynamic, targets: ["Sentry"]),
.library(name: "Sentry-Dynamic", type: .dynamic, targets: ["Sentry"])
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion Samples/SPM-Dynamic/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "SPM-Dynamic",
products: [
.library(name: "SPM-Dynamic", type: .dynamic, targets: ["SPM-Dynamic"]),
.library(name: "SPM-Dynamic", type: .dynamic, targets: ["SPM-Dynamic"])
],
dependencies: [
// branch is replaced in CI to the current sha
Expand Down
12 changes: 8 additions & 4 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@
7BBD18BB24530D2600427C76 /* SentryFileManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BBD18BA24530D2600427C76 /* SentryFileManagerTests.swift */; };
7BC3936825B1AB3E004F03D3 /* SentryLevelMapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BC3936725B1AB3E004F03D3 /* SentryLevelMapper.h */; };
7BC3936E25B1AB72004F03D3 /* SentryLevelMapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BC3936D25B1AB72004F03D3 /* SentryLevelMapper.m */; };
7BC3937425B1ACB7004F03D3 /* SentryLevelMapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BC3937325B1ACB7004F03D3 /* SentryLevelMapperTests.swift */; };
7BC63F0828081242009D9E37 /* SentrySwizzleWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BC63F0728081242009D9E37 /* SentrySwizzleWrapper.h */; };
7BC63F0A28081288009D9E37 /* SentrySwizzleWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BC63F0928081288009D9E37 /* SentrySwizzleWrapper.m */; };
7BC6EBF4255C044A0059822A /* SentryEventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BC6EBF3255C044A0059822A /* SentryEventTests.swift */; };
Expand Down Expand Up @@ -573,6 +572,8 @@
7DC83100239826280043DD9A /* SentryIntegrationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DC830FF239826280043DD9A /* SentryIntegrationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
7DC8310A2398283C0043DD9A /* SentryCrashIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DC831082398283C0043DD9A /* SentryCrashIntegration.h */; };
7DC8310C2398283C0043DD9A /* SentryCrashIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC831092398283C0043DD9A /* SentryCrashIntegration.m */; };
8453421228BE855D00C22EEC /* SentrySampleDecision.m in Sources */ = {isa = PBXBuildFile; fileRef = 8453421128BE855D00C22EEC /* SentrySampleDecision.m */; };
8453421628BE8A9500C22EEC /* SentrySpanStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 8453421528BE8A9500C22EEC /* SentrySpanStatus.m */; };
861265F92404EC1500C4AFDE /* NSArray+SentrySanitize.h in Headers */ = {isa = PBXBuildFile; fileRef = 861265F72404EC1500C4AFDE /* NSArray+SentrySanitize.h */; };
861265FA2404EC1500C4AFDE /* NSArray+SentrySanitize.m in Sources */ = {isa = PBXBuildFile; fileRef = 861265F82404EC1500C4AFDE /* NSArray+SentrySanitize.m */; };
8E0551E026A7A63C00400526 /* TestProtocolClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E0551DF26A7A63C00400526 /* TestProtocolClient.swift */; };
Expand Down Expand Up @@ -1182,7 +1183,6 @@
7BBEB16026AEE5EF00C06C03 /* SentryTracer+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryTracer+Test.h"; sourceTree = "<group>"; };
7BC3936725B1AB3E004F03D3 /* SentryLevelMapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryLevelMapper.h; path = include/SentryLevelMapper.h; sourceTree = "<group>"; };
7BC3936D25B1AB72004F03D3 /* SentryLevelMapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryLevelMapper.m; sourceTree = "<group>"; };
7BC3937325B1ACB7004F03D3 /* SentryLevelMapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryLevelMapperTests.swift; sourceTree = "<group>"; };
7BC63F0728081242009D9E37 /* SentrySwizzleWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySwizzleWrapper.h; path = include/SentrySwizzleWrapper.h; sourceTree = "<group>"; };
7BC63F0928081288009D9E37 /* SentrySwizzleWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySwizzleWrapper.m; sourceTree = "<group>"; };
7BC6EBF3255C044A0059822A /* SentryEventTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEventTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1328,6 +1328,8 @@
844DA81D28246DAE00E6B62E /* develop-docs */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "develop-docs"; sourceTree = "<group>"; };
844DA81E28246DB900E6B62E /* fastlane */ = {isa = PBXFileReference; lastKnownFileType = folder; path = fastlane; sourceTree = "<group>"; };
844DA81F28246DE300E6B62E /* scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = scripts; sourceTree = "<group>"; };
8453421128BE855D00C22EEC /* SentrySampleDecision.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySampleDecision.m; sourceTree = "<group>"; };
8453421528BE8A9500C22EEC /* SentrySpanStatus.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySpanStatus.m; sourceTree = "<group>"; };
861265F72404EC1500C4AFDE /* NSArray+SentrySanitize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "NSArray+SentrySanitize.h"; path = "include/NSArray+SentrySanitize.h"; sourceTree = "<group>"; };
861265F82404EC1500C4AFDE /* NSArray+SentrySanitize.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSArray+SentrySanitize.m"; sourceTree = "<group>"; };
8E0551DF26A7A63C00400526 /* TestProtocolClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestProtocolClient.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2363,7 +2365,6 @@
7BD729992463EA4A00EA3610 /* SentryDateUtilTests.swift */,
7B85BD8D24C5C3A6000A4225 /* SentryFileManagerTestExtension.swift */,
7B4C817124D1BC2B0076ACE4 /* SentryFileManager+TestProperties.h */,
7BC3937325B1ACB7004F03D3 /* SentryLevelMapperTests.swift */,
7B98D7EB25FB7C4900C5A389 /* SentryAppStateTests.swift */,
69BEE6F62620729E006DF9DF /* UrlSessionDelegateSpy.swift */,
7BD86ECA264A6DB5005439DB /* TestSysctl.swift */,
Expand Down Expand Up @@ -2721,13 +2722,15 @@
8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */,
0A56DA5E28ABA01B00C400D5 /* SentryTransactionContext+Private.h */,
8EC4CF4725C38CAF0093DEE9 /* SentrySpanStatus.h */,
8453421528BE8A9500C22EEC /* SentrySpanStatus.m */,
8E133FA525E72EB400ABD0BF /* SentrySamplingContext.h */,
8E133FA025E72DEF00ABD0BF /* SentrySamplingContext.m */,
8E4E7C7B25DAB287006AB9E2 /* SentryTracer.h */,
8E4E7C8125DAB2A5006AB9E2 /* SentryTracer.m */,
8E8C57A525EEFC42001CEEFA /* SentryTracesSampler.h */,
8E8C57A025EEFC07001CEEFA /* SentryTracesSampler.m */,
8E4A037725F6F52100000D77 /* SentrySampleDecision.h */,
8453421128BE855D00C22EEC /* SentrySampleDecision.m */,
8E7C98302693E1CC00E6336C /* SentryTraceHeader.h */,
8E7C982D2693D56000E6336C /* SentryTraceHeader.m */,
D88817D926D72AB800BF2251 /* SentryTraceContext.h */,
Expand Down Expand Up @@ -3218,6 +3221,7 @@
8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.m in Sources */,
03BCC38C27E1C01A003232C7 /* SentryTime.mm in Sources */,
03F84D3727DD4191008FE43F /* SentrySamplingProfiler.cpp in Sources */,
8453421628BE8A9500C22EEC /* SentrySpanStatus.m in Sources */,
7B9657262683104C00C66E25 /* NSData+Sentry.m in Sources */,
7B63459B280EB9E200CFA05A /* SentryUIEventTrackingIntegration.m in Sources */,
15E0A8ED240F2CB000F044E3 /* SentrySerialization.m in Sources */,
Expand Down Expand Up @@ -3372,6 +3376,7 @@
7BD86EC7264A641D005439DB /* SentrySysctl.m in Sources */,
D859697327BECDD20036A46E /* SentryCoreDataSwizzling.m in Sources */,
639889BD1EDED18400EA7442 /* SentrySwizzle.m in Sources */,
8453421228BE855D00C22EEC /* SentrySampleDecision.m in Sources */,
7B7D872E2486482600D2ECFF /* SentryStacktraceBuilder.m in Sources */,
861265FA2404EC1500C4AFDE /* NSArray+SentrySanitize.m in Sources */,
D8603DD6284F8497000E1227 /* SentryBaggage.m in Sources */,
Expand Down Expand Up @@ -3419,7 +3424,6 @@
7B869EBC249B91D8004F4FDB /* SentryDebugMetaEquality.swift in Sources */,
7B01CE3D271993AC00B5AF31 /* SentryTransportFactoryTests.swift in Sources */,
7B30B68026527C3C006B2752 /* SentryFramesTrackerTests.swift in Sources */,
7BC3937425B1ACB7004F03D3 /* SentryLevelMapperTests.swift in Sources */,
63FE720E20DA66EC00CDBAE8 /* SentryCrashCString_Tests.m in Sources */,
0A9BF4EB28A127120068D266 /* SentryViewHierarchyIntegrationTests.swift in Sources */,
631501BB1EE6F30B00512C5B /* SentrySwizzleTests.m in Sources */,
Expand Down
18 changes: 10 additions & 8 deletions Sources/Sentry/Public/SentryDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ typedef NS_ENUM(NSInteger, SentryPermissionStatus) {
/**
* Static internal helper to convert enum to string
*/
static NSString *_Nonnull const SentryLevelNames[] = {
@"none",
@"debug",
@"info",
@"warning",
@"error",
@"fatal",
};
static DEPRECATED_MSG_ATTRIBUTE(
"Use nameForSentryLevel() instead.") NSString *_Nonnull const SentryLevelNames[]
= {
@"none",
@"debug",
@"info",
@"warning",
@"error",
@"fatal",
};

static NSUInteger const defaultMaxBreadcrumbs = 100;

Expand Down
15 changes: 14 additions & 1 deletion Sources/Sentry/Public/SentrySampleDecision.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import <Foundation/Foundation.h>

/**
* Trace sample decision flag.
*/
Expand All @@ -19,4 +20,16 @@ typedef NS_ENUM(NSUInteger, SentrySampleDecision) {
kSentrySampleDecisionNo
};

static NSString *_Nonnull const SentrySampleDecisionNames[] = { @"undecided", @"true", @"false" };
static DEPRECATED_MSG_ATTRIBUTE("Use nameForSentrySampleDecision() instead.")
NSString *_Nonnull const SentrySampleDecisionNames[]
= { @"undecided", @"true", @"false" };

NS_ASSUME_NONNULL_BEGIN

FOUNDATION_EXPORT NSString *const kSentrySampleDecisionNameUndecided;
FOUNDATION_EXPORT NSString *const kSentrySampleDecisionNameYes;
FOUNDATION_EXPORT NSString *const kSentrySampleDecisionNameNo;

NSString *nameForSentrySampleDecision(SentrySampleDecision decision);

NS_ASSUME_NONNULL_END
28 changes: 27 additions & 1 deletion Sources/Sentry/Public/SentrySpanStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,34 @@ typedef NS_ENUM(NSUInteger, SentrySpanStatus) {
kSentrySpanStatusDataLoss,
};

static NSString *_Nonnull const SentrySpanStatusNames[]
static DEPRECATED_MSG_ATTRIBUTE(
"Use nameForSentrySpanStatus() instead.") NSString *_Nonnull const SentrySpanStatusNames[]
= { @"undefined", @"ok", @"deadline_exceeded", @"unauthenticated", @"permission_denied",
@"not_found", @"resource_exhausted", @"invalid_argument", @"unimplemented",
@"unavailable", @"internal_error", @"unknown_error", @"cancelled", @"already_exists",
@"failed_precondition", @"aborted", @"out_of_range", @"data_loss" };

NS_ASSUME_NONNULL_BEGIN

FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameUndefined;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameOk;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameDeadlineExceeded;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameUnauthenticated;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNamePermissionDenied;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameNotFound;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameResourceExhausted;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameInvalidArgument;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameUnimplemented;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameUnavailable;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameInternalError;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameUnknownError;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameCancelled;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameAlreadyExists;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameFailedPrecondition;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameAborted;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameOutOfRange;
FOUNDATION_EXPORT NSString *const kSentrySpanStatusNameDataLoss;

NSString *nameForSentrySpanStatus(SentrySpanStatus status);

NS_ASSUME_NONNULL_END
3 changes: 2 additions & 1 deletion Sources/Sentry/SentryBreadcrumb.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#import "SentryBreadcrumb.h"
#import "NSDate+SentryExtras.h"
#import "NSDictionary+SentrySanitize.h"
#import "SentryLevelMapper.h"

@implementation SentryBreadcrumb

Expand All @@ -24,7 +25,7 @@ - (instancetype)init
{
NSMutableDictionary *serializedData = [NSMutableDictionary new];

[serializedData setValue:SentryLevelNames[self.level] forKey:@"level"];
[serializedData setValue:nameForSentryLevel(self.level) forKey:@"level"];
[serializedData setValue:[self.timestamp sentry_toIso8601String] forKey:@"timestamp"];
[serializedData setValue:self.category forKey:@"category"];
[serializedData setValue:self.type forKey:@"type"];
Expand Down
3 changes: 2 additions & 1 deletion Sources/Sentry/SentryCrashScopeObserver.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import "SentryLevelMapper.h"
#import <Foundation/Foundation.h>
#import <NSData+Sentry.h>
#import <SentryBreadcrumb.h>
Expand Down Expand Up @@ -83,7 +84,7 @@ - (void)setLevel:(enum SentryLevel)level
return;
}

NSString *levelAsString = SentryLevelNames[level];
NSString *levelAsString = nameForSentryLevel(level);
NSData *json = [self toJSONEncodedCString:levelAsString];

sentrycrash_scopesync_setLevel([json bytes]);
Expand Down
124 changes: 70 additions & 54 deletions Sources/Sentry/SentryDataCategoryMapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,91 +3,107 @@
#import "SentryEnvelopeItemType.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface
SentryDataCategoryMapper ()

@end

@implementation SentryDataCategoryMapper
NSString *const kSentryDataCategoryNameAll = @"";
NSString *const kSentryDataCategoryNameDefault = @"default";
NSString *const kSentryDataCategoryNameError = @"error";
NSString *const kSentryDataCategoryNameSession = @"session";
NSString *const kSentryDataCategoryNameTransaction = @"transaction";
NSString *const kSentryDataCategoryNameAttachment = @"attachment";
NSString *const kSentryDataCategoryNameUserFeedback = @"user_report";
NSString *const kSentryDataCategoryNameProfile = @"profile";
NSString *const kSentryDataCategoryNameUnknown = @"unknown";

+ (SentryDataCategory)mapEventTypeToCategory:(NSString *)eventType
{
// Currently we classify every event type as error.
// This is going to change in the future.
return kSentryDataCategoryError;
}
NS_ASSUME_NONNULL_BEGIN

+ (SentryDataCategory)mapEnvelopeItemTypeToCategory:(NSString *)itemType
SentryDataCategory
sentryDataCategoryForEnvelopItemType(NSString *itemType)
{
SentryDataCategory category = kSentryDataCategoryDefault;
if ([itemType isEqualToString:SentryEnvelopeItemTypeEvent]) {
category = kSentryDataCategoryError;
return kSentryDataCategoryError;
}
if ([itemType isEqualToString:SentryEnvelopeItemTypeSession]) {
category = kSentryDataCategorySession;
return kSentryDataCategorySession;
}
if ([itemType isEqualToString:SentryEnvelopeItemTypeTransaction]) {
category = kSentryDataCategoryTransaction;
return kSentryDataCategoryTransaction;
}
if ([itemType isEqualToString:SentryEnvelopeItemTypeAttachment]) {
category = kSentryDataCategoryAttachment;
return kSentryDataCategoryAttachment;
}
if ([itemType isEqualToString:SentryEnvelopeItemTypeProfile]) {
category = kSentryDataCategoryProfile;
return kSentryDataCategoryProfile;
}
return category;
return kSentryDataCategoryDefault;
}

+ (SentryDataCategory)mapIntegerToCategory:(NSUInteger)value
SentryDataCategory
sentryDataCategoryForNSUInteger(NSUInteger value)
{
SentryDataCategory category = kSentryDataCategoryUnknown;

if (value == kSentryDataCategoryAll) {
category = kSentryDataCategoryAll;
if (value < 0 || value > kSentryDataCategoryUnknown) {
return kSentryDataCategoryUnknown;
}
if (value == kSentryDataCategoryDefault) {
category = kSentryDataCategoryDefault;

return (SentryDataCategory)value;
}

SentryDataCategory
sentryDataCategoryForString(NSString *value)
{
if ([value isEqualToString:kSentryDataCategoryNameAll]) {
return kSentryDataCategoryAll;
}
if (value == kSentryDataCategoryError) {
category = kSentryDataCategoryError;
if ([value isEqualToString:kSentryDataCategoryNameDefault]) {
return kSentryDataCategoryDefault;
}
if (value == kSentryDataCategorySession) {
category = kSentryDataCategorySession;
if ([value isEqualToString:kSentryDataCategoryNameError]) {
return kSentryDataCategoryError;
}
if (value == kSentryDataCategoryTransaction) {
category = kSentryDataCategoryTransaction;
if ([value isEqualToString:kSentryDataCategoryNameSession]) {
return kSentryDataCategorySession;
}
if (value == kSentryDataCategoryAttachment) {
category = kSentryDataCategoryAttachment;
if ([value isEqualToString:kSentryDataCategoryNameTransaction]) {
return kSentryDataCategoryTransaction;
}
if (value == kSentryDataCategoryUserFeedback) {
category = kSentryDataCategoryUserFeedback;
if ([value isEqualToString:kSentryDataCategoryNameAttachment]) {
return kSentryDataCategoryAttachment;
}
if (value == kSentryDataCategoryProfile) {
category = kSentryDataCategoryProfile;
if ([value isEqualToString:kSentryDataCategoryNameUserFeedback]) {
return kSentryDataCategoryUserFeedback;
}
if (value == kSentryDataCategoryUnknown) {
category = kSentryDataCategoryUnknown;
if ([value isEqualToString:kSentryDataCategoryNameProfile]) {
return kSentryDataCategoryProfile;
}

return category;
return kSentryDataCategoryUnknown;
}

+ (SentryDataCategory)mapStringToCategory:(NSString *)value
NSString *
nameForSentryDataCategory(SentryDataCategory category)
{
SentryDataCategory category = kSentryDataCategoryUnknown;

for (int i = 0; i <= kSentryDataCategoryUnknown; i++) {
if ([value isEqualToString:SentryDataCategoryNames[i]]) {
return [SentryDataCategoryMapper mapIntegerToCategory:i];
}
if (category < kSentryDataCategoryAll && category > kSentryDataCategoryUnknown) {
return kSentryDataCategoryNameUnknown;
}

return category;
switch (category) {
case kSentryDataCategoryAll:
return kSentryDataCategoryNameAll;
case kSentryDataCategoryDefault:
return kSentryDataCategoryNameDefault;
case kSentryDataCategoryError:
return kSentryDataCategoryNameError;
case kSentryDataCategorySession:
return kSentryDataCategoryNameSession;
case kSentryDataCategoryTransaction:
return kSentryDataCategoryNameTransaction;
case kSentryDataCategoryAttachment:
return kSentryDataCategoryNameAttachment;
case kSentryDataCategoryUserFeedback:
return kSentryDataCategoryNameUserFeedback;
case kSentryDataCategoryProfile:
return kSentryDataCategoryNameProfile;
case kSentryDataCategoryUnknown:
return kSentryDataCategoryNameUnknown;
}
}

@end

NS_ASSUME_NONNULL_END
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryDefaultRateLimits.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ - (void)update:(NSHTTPURLResponse *)response
NSDictionary<NSNumber *, NSDate *> *limits = [self.rateLimitParser parse:rateLimitsHeader];

for (NSNumber *categoryAsNumber in limits.allKeys) {
SentryDataCategory category = [SentryDataCategoryMapper
mapIntegerToCategory:(NSUInteger)[categoryAsNumber integerValue]];
SentryDataCategory category
= sentryDataCategoryForNSUInteger(categoryAsNumber.unsignedIntegerValue);

[self updateRateLimit:category withDate:limits[categoryAsNumber]];
}
Expand Down
Loading

0 comments on commit 10a83a9

Please sign in to comment.