feat: add rrweb plugin#762
Conversation
| ], | ||
| allowCookies: true, | ||
| enableXRay: true, | ||
| enableXRay: false, |
There was a problem hiding this comment.
why are we disabling this?
There was a problem hiding this comment.
just for demo purposes. it was polluting the logs
| export const TIME_TO_INTERACTIVE_EVENT_TYPE = `${RUM_AMZ_PREFIX}.time_to_interactive_event`; | ||
|
|
||
| // RRWeb session recording event | ||
| export const RRWEB_EVENT_TYPE = `${RUM_AMZ_PREFIX}.rrweb`; |
There was a problem hiding this comment.
is it conventional to name this event rrweb as opposed to something like session_replay_event?
There was a problem hiding this comment.
i found this to be the best practice in case we want to migrate from rrweb someday
There was a problem hiding this comment.
I am a bit confused. The RUM event schema seems to say session_replay_event but we are planning to make the event type com.amazon.rum.rrweb?
There was a problem hiding this comment.
should be rrweb. fixed
| "type": "number", | ||
| "description": "rrweb event type." | ||
| }, | ||
| "timestamp": { |
There was a problem hiding this comment.
question: Would events get recorded into a batch here in chronology? Or would backend need to use the timestamp to figure out the ordering
There was a problem hiding this comment.
it's insertion order, which should also be chronological. backend will use rum event timestamp for pagination
|
|
||
| /** Configuration options for {@link RRWebPlugin}. */ | ||
| export type RRWebPluginConfig = { | ||
| /** Probability (0–1) of recording replay for a session, applied on top of sessionSampleRate. */ |
There was a problem hiding this comment.
nit: Add docs how this + sessionSample would work together
There was a problem hiding this comment.
updated the jsdoc. i'm not updating public docs at this time because this is still in pre-release state.
| }; | ||
|
|
||
| /** Development defaults — privacy masking disabled for easier debugging. */ | ||
| export const RRWEB_CONFIG_DEV: RRWebPluginConfig = { |
There was a problem hiding this comment.
comment: I think we should be careful about enabling privacy masking even in the dev config.
Users should have to explicitly enable that and we should not hide it under dev. Additionally storage concerns that exist in prod might be applicable here as well
There was a problem hiding this comment.
this is disabling privacy masking, not enabling. but sure i can just remove dev config
| export const TIME_TO_INTERACTIVE_EVENT_TYPE = `${RUM_AMZ_PREFIX}.time_to_interactive_event`; | ||
|
|
||
| // RRWeb session recording event | ||
| export const RRWEB_EVENT_TYPE = `${RUM_AMZ_PREFIX}.rrweb`; |
There was a problem hiding this comment.
I am a bit confused. The RUM event schema seems to say session_replay_event but we are planning to make the event type com.amazon.rum.rrweb?
Summary
Add RRWebPlugin to main branch in pre-release mode. This does not get bundled into the CDN release, and is not exposed to top level configuration. RUM users may manually import this module if they would like to try it out, but there is no native support at this time.
Implementation
Add RRWebPlugin, which collects RRWeb events in batches and converts them into RUM SessionReplayEvent batches. On visibilitychange event, we will also flush these events before preparing the final batch before exiting the page.
SessionReplayEvents are not compressed separately via the native packer method. Instead, it is recommended to compress at payload level via #759
Schema
{ "$id": "com.amazon.rum.session_replay_event", "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "SessionReplayEvent", "type": "object", "properties": { "version": { "const": "1.0.0", "type": "string", "description": "Schema version." }, "events": { "type": "array", "description": "Batch of rrweb recording events.", "items": { "type": "object", "properties": { "type": { "type": "number", "description": "rrweb event type." }, "timestamp": { "type": "number", "description": "Unix timestamp in milliseconds." }, "data": { "description": "rrweb event payload." } }, "required": ["type", "timestamp", "data"] } }, "eventCount": { "type": "number", "description": "Number of events in this batch." } }, "additionalProperties": false, "required": ["version", "events", "eventCount"] }Default settings
Future
Bundle Size
156 KB parsed
Testing
Added unit and integration tests. See spa-react-demo for manual testing with compression enabled.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.