|
1 | 1 | #import <Foundation/Foundation.h> |
2 | 2 | #include <dlfcn.h> |
| 3 | +#include <objc/message.h> |
3 | 4 |
|
4 | 5 | static NSDateFormatter *_Nullable sentry_cachedISO8601Formatter(void) { |
5 | 6 | static NSDateFormatter *formatter = nil; |
|
45 | 46 | static Class SentryId; |
46 | 47 | static Class SentrySpanId; |
47 | 48 | static Class PrivateSentrySDKOnly; |
| 49 | +static Class SentryHttpStatusCodeRange; |
48 | 50 |
|
49 | 51 | #define LOAD_CLASS_OR_BREAK(name) \ |
50 | 52 | name = (__bridge Class)dlsym(dylib, "OBJC_CLASS_$_" #name); \ |
@@ -87,6 +89,7 @@ int SentryNativeBridgeLoadLibrary() |
87 | 89 | LOAD_CLASS_OR_BREAK(SentryId) |
88 | 90 | LOAD_CLASS_OR_BREAK(SentrySpanId) |
89 | 91 | LOAD_CLASS_OR_BREAK(PrivateSentrySDKOnly) |
| 92 | + LOAD_CLASS_OR_BREAK(SentryHttpStatusCodeRange) |
90 | 93 |
|
91 | 94 | // everything above passed - mark as successfully loaded |
92 | 95 | loadStatus = 1; |
@@ -118,6 +121,23 @@ void SentryNativeBridgeOptionsSetInt(const void *options, const char *name, int3 |
118 | 121 | dictOptions[[NSString stringWithUTF8String:name]] = [NSNumber numberWithInt:value]; |
119 | 122 | } |
120 | 123 |
|
| 124 | +void SentryNativeBridgeOptionsAddFailedRequestStatusCodeRange(const void *options, int32_t min, int32_t max) |
| 125 | +{ |
| 126 | + NSMutableDictionary *dictOptions = (__bridge NSMutableDictionary *)options; |
| 127 | + NSMutableArray *ranges = dictOptions[@"failedRequestStatusCodes"]; |
| 128 | + if (!ranges) { |
| 129 | + ranges = [[NSMutableArray alloc] init]; |
| 130 | + dictOptions[@"failedRequestStatusCodes"] = ranges; |
| 131 | + } |
| 132 | + id instance = [SentryHttpStatusCodeRange alloc]; |
| 133 | + // initWithMin:max: takes NSInteger args - use objc_msgSend directly |
| 134 | + id range = ((id (*)(id, SEL, NSInteger, NSInteger))objc_msgSend)( |
| 135 | + instance, @selector(initWithMin:max:), (NSInteger)min, (NSInteger)max); |
| 136 | + if (range) { |
| 137 | + [ranges addObject:range]; |
| 138 | + } |
| 139 | +} |
| 140 | + |
121 | 141 | int SentryNativeBridgeStartWithOptions(const void *options) |
122 | 142 | { |
123 | 143 | NSMutableDictionary *dictOptions = (__bridge_transfer NSMutableDictionary *)options; |
|
0 commit comments