-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Session Replay): ReplayEvent, ReplayRecording and Envelope handling
- Loading branch information
Showing
23 changed files
with
503 additions
and
8 deletions.
There are no files selected for viewing
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,35 @@ | ||
#import "SentryReplayEnvelopeItemHeader.h" | ||
#import "SentryEnvelopeItemType.h" | ||
|
||
@implementation SentryReplayEnvelopeItemHeader | ||
|
||
- (instancetype)initWithType:(NSString *)type | ||
segmentId:(NSInteger)segmentId | ||
length:(NSUInteger)length | ||
{ | ||
if (self = [super initWithType:type length:length]) { | ||
self.segmentId = segmentId; | ||
} | ||
return self; | ||
} | ||
|
||
+ (instancetype)replayRecordingHeaderWithSegmentId:(NSInteger)segmentId length:(NSUInteger)length | ||
{ | ||
return [[self alloc] initWithType:SentryEnvelopeItemTypeReplayRecording | ||
segmentId:segmentId | ||
length:length]; | ||
} | ||
|
||
+ (instancetype)replayVideoHeaderWithSegmentId:(NSInteger)segmentId length:(NSUInteger)length | ||
{ | ||
return [[self alloc] initWithType:SentryEnvelopeItemTypeReplayVideo | ||
segmentId:segmentId | ||
length:length]; | ||
} | ||
|
||
- (NSDictionary *)serialize | ||
{ | ||
return @{ @"type" : self.type, @"length" : @(self.length), @"segment_id" : @(self.segmentId) }; | ||
} | ||
|
||
@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,28 @@ | ||
#import "SentryReplayEvent.h" | ||
#import "SentryDateUtil.h" | ||
#import "SentryId.h" | ||
|
||
@implementation SentryReplayEvent | ||
|
||
- (NSDictionary *)serialize | ||
{ | ||
NSMutableDictionary *result = [[super serialize] mutableCopy]; | ||
|
||
NSMutableArray *trace_ids = [NSMutableArray array]; | ||
|
||
for (SentryId *traceId in self.traceIds) { | ||
[trace_ids addObject:traceId.sentryIdString]; | ||
} | ||
|
||
result[@"urls"] = self.urls; | ||
result[@"replay_start_timestamp"] = | ||
@([SentryDateUtil javascriptDate:self.replayStartTimestamp]); | ||
result[@"trace_ids"] = trace_ids; | ||
result[@"replay_id"] = self.replayId.sentryIdString; | ||
result[@"segment_id"] = @(self.segmentId); | ||
result[@"replay_type"] = @"buffer"; | ||
|
||
return result; | ||
} | ||
|
||
@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,64 @@ | ||
#import "SentryReplayRecording.h" | ||
#import "SentryDateUtil.h" | ||
|
||
@implementation SentryReplayRecording | ||
|
||
- (instancetype)initWithSegmentId:(NSInteger)segmentId | ||
size:(NSInteger)size | ||
start:(NSDate *)start | ||
duration:(NSTimeInterval)duration | ||
frameCount:(NSInteger)frameCount | ||
frameRate:(NSInteger)frameRate | ||
height:(NSInteger)height | ||
width:(NSInteger)width | ||
{ | ||
if (self = [super init]) { | ||
self.segmentId = segmentId; | ||
self.size = size; | ||
self.start = start; | ||
self.duration = duration; | ||
self.frameCount = frameCount; | ||
self.frameRate = frameRate; | ||
self.height = height; | ||
self.width = width; | ||
} | ||
return self; | ||
} | ||
|
||
- (nonnull NSArray<NSDictionary<NSString *, id> *> *)serialize | ||
{ | ||
|
||
long timestamp = [SentryDateUtil javascriptDate:self.start]; | ||
|
||
NSDictionary *metaInfo = @{ | ||
@"type" : @4, | ||
@"timestamp" : @(timestamp), | ||
@"data" : @ { @"href" : @"", @"height" : @(self.height), @"width" : @(self.width) } | ||
}; | ||
|
||
NSDictionary *recordingInfo = @{ | ||
@"type" : @5, | ||
@"timestamp" : @(timestamp), | ||
@"data" : @ { | ||
@"tag" : @"video", | ||
@"payload" : @ { | ||
@"segmentId" : @(self.segmentId), | ||
@"size" : @(self.size), | ||
@"duration" : @(self.duration), | ||
@"encoding" : @"h264", | ||
@"container" : @"mp4", | ||
@"height" : @(self.height), | ||
@"width" : @(self.width), | ||
@"frameCount" : @(self.frameCount), | ||
@"frameRateType" : @"constant", | ||
@"frameRate" : @(self.frameRate), | ||
@"left" : @0, | ||
@"top" : @0, | ||
} | ||
} | ||
}; | ||
|
||
return @[ metaInfo, recordingInfo ]; | ||
} | ||
|
||
@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
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,20 @@ | ||
#import "SentryEnvelopeItemHeader.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface SentryReplayEnvelopeItemHeader : SentryEnvelopeItemHeader | ||
|
||
@property (nonatomic) NSInteger segmentId; | ||
|
||
- (instancetype)initWithType:(NSString *)type | ||
segmentId:(NSInteger)segmentId | ||
length:(NSUInteger)length; | ||
|
||
+ (instancetype)replayRecordingHeaderWithSegmentId:(NSInteger)segmentId length:(NSUInteger)length; | ||
|
||
+ (instancetype)replayVideoHeaderWithSegmentId:(NSInteger)segmentId length:(NSUInteger)length; | ||
|
||
@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,39 @@ | ||
#import "SentryEvent.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@class SentryId; | ||
|
||
@interface SentryReplayEvent : SentryEvent | ||
|
||
/** | ||
* Start time of the replay segment | ||
*/ | ||
@property (nonatomic, strong) NSDate *replayStartTimestamp; | ||
|
||
/** | ||
* Number of the segment in the replay. | ||
* This is an incremental number | ||
*/ | ||
@property (nonatomic) NSInteger segmentId; | ||
|
||
/** | ||
* This will be used to store the name of the screens | ||
* that appear during the duration of the replay segment. | ||
*/ | ||
@property (nonatomic, strong) NSArray<NSString *> *urls; | ||
|
||
/** | ||
* Trace ids happening during the duration of the replay segment. | ||
*/ | ||
@property (nonatomic, strong) NSArray<SentryId *> *traceIds; | ||
|
||
/** | ||
* The replay id to which this segment belongs to. | ||
*/ | ||
@property (nonatomic, strong) SentryId *replayId; | ||
|
||
@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,42 @@ | ||
#import "SentrySerializable.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@class SentryId; | ||
|
||
@interface SentryReplayRecording : NSObject | ||
|
||
@property (nonatomic) NSInteger segmentId; | ||
|
||
/** | ||
* Video file size | ||
*/ | ||
@property (nonatomic) NSInteger size; | ||
|
||
@property (nonatomic, strong) NSDate *start; | ||
|
||
@property (nonatomic) NSTimeInterval duration; | ||
|
||
@property (nonatomic) NSInteger frameCount; | ||
|
||
@property (nonatomic) NSInteger frameRate; | ||
|
||
@property (nonatomic) NSInteger height; | ||
|
||
@property (nonatomic) NSInteger width; | ||
|
||
- (instancetype)initWithSegmentId:(NSInteger)segmentId | ||
size:(NSInteger)size | ||
start:(NSDate *)start | ||
duration:(NSTimeInterval)duration | ||
frameCount:(NSInteger)frameCount | ||
frameRate:(NSInteger)frameRate | ||
height:(NSInteger)height | ||
width:(NSInteger)width; | ||
|
||
- (nonnull NSArray<NSDictionary<NSString *, id> *> *)serialize; | ||
|
||
@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
Oops, something went wrong.