Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds recording discarded events and sending them with client reports to Sentry. Discarded events give insight into where the SDK drops certain events like, for example, beforeSend or rate limiting. Fixes GH-1655
- Loading branch information
1 parent
2e5882c
commit df77385
Showing
37 changed files
with
687 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#import "SentryClientReport.h" | ||
#import "SentryCurrentDate.h" | ||
#import <Foundation/Foundation.h> | ||
#import <SentryDiscardedEvent.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@implementation SentryClientReport | ||
|
||
- (instancetype)initWithDiscardedEvents:(NSArray<SentryDiscardedEvent *> *)discardedEvents | ||
{ | ||
if (self = [super init]) { | ||
_timestamp = [SentryCurrentDate date]; | ||
_discardedEvents = discardedEvents; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSDictionary<NSString *, id> *)serialize | ||
{ | ||
NSMutableArray<NSDictionary<NSString *, id> *> *events = | ||
[[NSMutableArray alloc] initWithCapacity:self.discardedEvents.count]; | ||
for (SentryDiscardedEvent *event in self.discardedEvents) { | ||
[events addObject:[event serialize]]; | ||
} | ||
|
||
return | ||
@{ @"timestamp" : @(self.timestamp.timeIntervalSince1970), @"discarded_events" : events }; | ||
} | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#import "SentryDiscardReasonMapper.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@implementation SentryDiscardReasonMapper | ||
|
||
+ (SentryDiscardReason)mapStringToReason:(NSString *)value | ||
{ | ||
SentryDiscardReason reason = kSentryDiscardReasonBeforeSend; | ||
|
||
for (int i = 0; i <= kSentryDiscardReasonRateLimitBackoff; i++) { | ||
if ([value isEqualToString:SentryDiscardReasonNames[i]]) { | ||
reason = [SentryDiscardReasonMapper mapIntegerToReason:i]; | ||
} | ||
} | ||
|
||
return reason; | ||
} | ||
|
||
+ (SentryDiscardReason)mapIntegerToReason:(NSUInteger)value | ||
{ | ||
SentryDiscardReason reason = kSentryDiscardReasonBeforeSend; | ||
|
||
if (value <= kSentryDiscardReasonRateLimitBackoff) { | ||
reason = (SentryDiscardReason)value; | ||
} | ||
|
||
return reason; | ||
} | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#import "SentryDiscardedEvent.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@implementation SentryDiscardedEvent | ||
|
||
- (instancetype)initWithReason:(SentryDiscardReason)reason | ||
category:(SentryDataCategory)category | ||
quantity:(NSUInteger)quantity | ||
{ | ||
if (self = [super init]) { | ||
_reason = reason; | ||
_category = category; | ||
_quantity = quantity; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSDictionary<NSString *, id> *)serialize | ||
{ | ||
return @{ | ||
@"reason" : SentryDiscardReasonNames[self.reason], | ||
@"category" : SentryDataCategoryNames[self.category], | ||
@"quantity" : @(self.quantity) | ||
}; | ||
} | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.