Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

feat: Defer capturing root replay until upload#106

Merged
billyvg merged 8 commits intomainfrom
feat/defer-capturing-root-replay-until-recording-upload
Jul 15, 2022
Merged

feat: Defer capturing root replay until upload#106
billyvg merged 8 commits intomainfrom
feat/defer-capturing-root-replay-until-recording-upload

Conversation

@billyvg
Copy link
Copy Markdown
Member

@billyvg billyvg commented Jul 7, 2022

I suspect we have a lot of "empty" replays due to this issue where we are immediately creating the root replay event. This had the possibility of having a replay w/ no recording events. Unfortunately, after some testing, a lot of short replays still get through because we immediately flush updates after a full DOM checkout. However, this is still needed in order to implement #101.

@billyvg billyvg force-pushed the feat/defer-capturing-root-replay-until-recording-upload branch from 6332727 to aeed92f Compare July 7, 2022 12:20
@billyvg billyvg requested a review from a team July 7, 2022 12:33
@billyvg billyvg marked this pull request as ready for review July 7, 2022 14:07
@billyvg billyvg removed the request for review from a team July 7, 2022 14:08
@billyvg billyvg marked this pull request as draft July 7, 2022 14:08
@billyvg
Copy link
Copy Markdown
Member Author

billyvg commented Jul 7, 2022

Ah this isn't correct yet, we should only create the event if a session was newly created.

@billyvg billyvg marked this pull request as ready for review July 15, 2022 14:37
@billyvg billyvg force-pushed the feat/defer-capturing-root-replay-until-recording-upload branch from e1ae1e2 to 1b55f12 Compare July 15, 2022 14:37
@billyvg billyvg force-pushed the feat/defer-capturing-root-replay-until-recording-upload branch from 56ad54b to f7061df Compare July 15, 2022 15:29
@billyvg billyvg requested a review from a team July 15, 2022 15:31
src/index.ts Outdated
this.shouldCreateReplay = false;
}

// TEMP: keep sending a replay event just for the duration
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going forward we'll send replay events pretty frequently for things like url / transaction name, so not sure if this is just temp

src/index.ts Outdated
* event per session and it should only be created
* immediately before sending recording)
*/
private shouldCreateReplay = false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicky, but i'd prefer a name like:
private hasInitializedReplay = false
private didCaptureRootEvent = false

idk. i guess i'm thinking something more definitive sounding instead of 'should'

Alternatively it could be a property of the session, that's what is being passed into captureReplay and call captureReplay unconditionally, do the check and update the flag in there, and keep options private.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make it more affirmative sounding like needsCaptureReplay - the suggested names imply it can only be initialized once, but a session could expire and we would need to create a new root event.

re: property of Session - this does feel icky having it live in options (it's not really an option, and it will be a bit annoying having to sync its state). I may refactor this actually because what we need to know is if the session has been newly created, or if it was loaded from storage, which can be handled when calling getSession rather than have it live as a property on the Session.

billyvg and others added 2 commits July 15, 2022 14:01
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
…return if session was newly created or loaded from storage
@billyvg billyvg requested a review from ryan953 July 15, 2022 18:07
@billyvg billyvg merged commit eebfe29 into main Jul 15, 2022
@billyvg billyvg deleted the feat/defer-capturing-root-replay-until-recording-upload branch July 15, 2022 20:45
mydea pushed a commit to getsentry/sentry-javascript that referenced this pull request Nov 23, 2022
…ay#106)

I suspect we have a lot of "empty" replays due to this issue where we are immediately creating the root replay event. This had the possibility of having a replay w/ no recording events. Unfortunately, after some testing, a lot of short replays still get through because we immediately flush updates after a full DOM checkout. However, this is still needed in order to implement getsentry/sentry-replay#101.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Defer creation of the "root" replay event until we send the first set of recording data

3 participants