This repository has been archived by the owner on Aug 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 226
feat(replay): Add documentation about replay event types #1197
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
820669b
feat(replay): Add documentation about replay event types
billyvg 5339750
Add replays to sidebar
billyvg 87d55c2
extra `
billyvg 0ba86d2
replay_event
billyvg 96b5d08
formatting
billyvg cb8e7f7
formatting
billyvg 3dfaede
fix link
billyvg f3dd82a
add replay recording
billyvg 1933f91
add mobile events
billyvg a6b2b64
add example json
billyvg 873730b
add id description
billyvg bd5af02
error_ids is deprecated
billyvg 21cb328
quick fixes
billyvg 50d8d6d
remove semi
billyvg c018e03
Update src/docs/sdk/replays.mdx
billyvg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,206 @@ | ||
--- | ||
title: Replay Recordings | ||
--- | ||
|
||
A replay recording consists of a list of instructions for the replayer to play back for the viewer. This page aims to document the custom events that are used on top of the events provided by [rrweb](https://github.com/rrweb-io/rrweb), the recording library that powers Session Replay. | ||
|
||
The recording event is an object with the following required properties: | ||
|
||
`type` | ||
|
||
: **EventTypeEnum** The `type` describes what type of event it is. See the enum below. | ||
|
||
``` | ||
EventTypeEnum { | ||
DomContentLoaded, | ||
Load, | ||
FullSnapshot, | ||
IncrementalSnapshot, | ||
Meta, | ||
Custom, | ||
Plugin, | ||
} | ||
``` | ||
|
||
`timestamp` | ||
|
||
: **float** The timestamp (in milliseconds) at which the event occurs | ||
|
||
`data` | ||
|
||
: **unknown** `data` schema is dependent on the `type`. View the [base types](https://github.com/rrweb-io/rrweb/blob/master/packages/types/src/index.ts) or Sentry's [custom types](https://github.com/getsentry/sentry-javascript/blob/master/packages/replay-internal/src/types/replayFrame.ts). | ||
|
||
## Custom Events | ||
|
||
Sentry custom events augment the replay with additional context in order to help the user debug issues. Custom events have the following format for the `data` property of the event: | ||
|
||
`tag` | ||
|
||
: **string** The tag is used to describe the "type" of custom event. This will determine how the event gets used in the UI. | ||
|
||
`payload` | ||
|
||
: **object** The `payload` is similar to the upper level `data` attribute, whose schema is dependent on the `tag`. | ||
|
||
In addition to the TypeScript references linked above, the following sections will describe the expected `payload` for custom events. | ||
|
||
### options | ||
|
||
This recording event is used to record the SDK configuration options. This should only be sent on the first segment as we do not expect the options to change throughout the lifecycle of a replay. See [this issue](https://github.com/getsentry/sentry-javascript/issues/7140) for more context around the decision to send this as a recording event rather than part of the `"replay_event"`. Note that these options are generally used internally to debug rather than a customer-facing feature (e.g. there is no way to query/filter replays using these options). | ||
|
||
The payload for `"options"` is a record of configuration name -> configuration value. There is no defined schema as options can vary by SDKs. | ||
|
||
```json | ||
{ | ||
"type": 5, | ||
"timestamp": 1709218280301, | ||
"data": { | ||
"tag": "options", | ||
"payload": { | ||
"shouldRecordCanvas": false, | ||
"sessionSampleRate": 1, | ||
"errorSampleRate": 1, | ||
"useCompressionOption": true, | ||
"blockAllMedia": false, | ||
"maskAllText": false, | ||
"maskAllInputs": false, | ||
"useCompression": false, | ||
"networkDetailHasUrls": false, | ||
"networkCaptureBodies": true, | ||
"networkRequestHasHeaders": true, | ||
"networkResponseHasHeaders": true | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### breadcrumb | ||
|
||
Breadcrumbs are named as such because they are intercepted from the web SDK and forwarded as a custom recording event. They have the same structure as describe in <Link to="/sdk/event-payloads/breadcrumbs/">breadcrumbs interface</Link>. | ||
|
||
```json | ||
{ | ||
"type": 5, | ||
"timestamp": 1710853999781, | ||
"data": { | ||
"tag": "breadcrumb", | ||
"payload": { | ||
"timestamp": 1710853999.781, | ||
"type": "default", | ||
"category": "navigation", | ||
"data": { | ||
"from": "/issues/4893218638/", | ||
"to": "/performance/trace/b6e75da452bf40ee8330af41c5989545/" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### performanceSpan | ||
|
||
Similar to breadcrumbs, `"performanceSpan"` has a similar interface to Spans. The following is an example of a network request made in the browser. We have additional instrumentation to capture request and response payloads when configured to do so. | ||
|
||
```json | ||
{ | ||
"type": 5, | ||
"timestamp": 1710854008431, | ||
"data": { | ||
"tag": "performanceSpan", | ||
"payload": { | ||
"op": "resource.fetch", | ||
"description": "https://us.sentry.io/api/0/projects/foo/javascript/events/eea92bc02315448591e159d8138ef3e8/owners/", | ||
"startTimestamp": 1710854008.431, | ||
"endTimestamp": 1710854009.234, | ||
"data": { | ||
"method": "GET", | ||
"statusCode": 200, | ||
"request": { | ||
"headers": { | ||
"content-type": "application/json", | ||
"accept": "application/json; charset=utf-8", | ||
"sentry-trace": "b07d0e356aa1477bb279d9fe5680fcd0-83881f299ca64b4f-1" | ||
} | ||
}, | ||
"response": { | ||
"headers": { | ||
"content-length": "36", | ||
"content-type": "application/json" | ||
}, | ||
"size": 36, | ||
"body": { | ||
"owners": [], | ||
"rule": null, | ||
"rules": [] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
|
||
``` | ||
|
||
## Mobile Replay Events | ||
|
||
Mobile replays are captured as video rather than a series of mutations. In order to support mobile replays, the following custom event is required: | ||
|
||
| property | type | description | | ||
| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------ | | ||
| type | `5` | Custom event | | ||
| data.tag | `"video"` | The string `"video"` | | ||
| data.payload.duration | integer | The video duration in milliseconds | | ||
| data.payload.segmentId | integer | The segment id. This should be the same as the replay segment id. This will be used by the UI to fetch the video from the Sentry API | | ||
|
||
```json | ||
{ | ||
"type": 5, | ||
"timestamp": 1710854008431, | ||
"data": { | ||
"tag": "video", | ||
"payload": { | ||
"duration": 5000, | ||
"segmentId": 0 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Additional Events | ||
|
||
Mobile replays follow the same rrweb protocol, but because mobile replays are captured by video, a majority of the rrweb events do not apply. Outlined below are the ones that do. | ||
|
||
#### Meta Event | ||
|
||
This should be emitted at the start of a replay (i.e. on the first segment) and when the user's viewport dimensions change. | ||
|
||
| property | type | description | | ||
| ----------- | ------- | ---------------------------------- | | ||
| type | `4` | "Meta" event | | ||
| data.href | string | The current URI | | ||
| data.width | integer | The width of the current viewport | | ||
| data.height | integer | The height of the current viewport | | ||
|
||
```json | ||
{ | ||
"type": 4, | ||
"timestamp": 1710854008431, | ||
"data": { | ||
"href": "file://screen", | ||
"width": 360, | ||
"height": 800 | ||
} | ||
} | ||
``` | ||
|
||
#### Touch Interactions | ||
|
||
| property | type | description | | ||
| ---------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| type | `3` | "Incremental mutation" event | | ||
| data.source | `2` | "Mouse Interaction" | | ||
| data.type | integer | [MouseInteraction](https://github.com/getsentry/rrweb/blob/0722035e75a9aeedd716107cbcc949eba6da2a6a/packages/types/src/index.ts#L361-L373) enum. TouchStart = 7, TouchMove_Departed = 8, TouchEnd = 9, TouchCancel = 10 | | ||
| data.id | integer | Unique id of the event | | ||
| data.x | integer | The x-coordinate of the touch event | | ||
| data.y | integer | The y-coordinate of the touch event | | ||
| data.pointerType | `2` | [PointerTypes](https://github.com/getsentry/rrweb/blob/0722035e75a9aeedd716107cbcc949eba6da2a6a/packages/types/src/index.ts#L375-L379) enum. Touch = 2 | |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe
length
is required.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for
replay_event
though right? onlyreplay_recording
which is belowThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each envelope item needs a length header because a new line character could be present in the item's payload.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm we currently do not send a length header for js sdk