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

feat: Do not flush immediately on checkout#109

Merged
billyvg merged 5 commits intomainfrom
feat/do-not-flush-checkout-immediately
Jul 18, 2022
Merged

feat: Do not flush immediately on checkout#109
billyvg merged 5 commits intomainfrom
feat/do-not-flush-checkout-immediately

Conversation

@billyvg
Copy link
Copy Markdown
Member

@billyvg billyvg commented Jul 15, 2022

Change the logic for when to flush after a full snapshot checkout. Add
option initialFlushDelay to control when to flush.

Do NOT flush on checkout after a session has expired. It will need to
wait for additional user actions before recording the new sessions
replay.

billyvg added 2 commits July 15, 2022 18:00
Change the logic for when to flush after a full snapshot checkout. Add
option `initialFlushDelay` to control when to flush.

Do NOT flush on checkout after a session has expired. It will need to
wait for additional user actions before recording the new sessions
replay.
Comment on lines +122 to +123
flushMinDelay = 5000,
flushMaxDelay = 15000,
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.

Went ahead and renamed this as well.

}

if (session.id !== this.session?.id) {
session.previousSessionId = this.session?.id;
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.

Wonder if it'd be useful to have this in our replay events to allow users to paginate through sessions or something cc @JoshFerge

logger.error(
new Error('Attempting to finish replay event after session expired.')
);
return;
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.

Added this as we should not continue to flush if session is expired.

{
data: { isCheckout },
timestamp: BASE_TIMESTAMP,
timestamp: new Date().getTime(),
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.

This is more accurate, as we want the current mocked time.

@billyvg billyvg marked this pull request as ready for review July 15, 2022 22:09
@billyvg billyvg requested a review from a team July 15, 2022 22:09
src/index.ts Outdated
Comment on lines 257 to 262
const result = cb?.();

if (typeof result === 'function') {
result();
return;
}
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.

It seems weird to optionally return a function and then stop processing after calling the function.

Would it work if the cb just exec whatever extra statements (the timeout), without the extra function, and return something to control whether we stop processing or not?
The return value could be a Symbol or something to tell it to stop processing, that'd save from having to update all callsites, and would be readable.

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.

🤨 you're right, I think this was my brain flip flopping around about how I wanted this to work - thanks!

return Promise.resolve();
});
advanceTimers(5000);
await advanceTimers(5000);
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.

oops. will watch more closely next time

i wonder if sentry repo catches these... it should be able to

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.

Yeah there's a lint rule for this

@billyvg billyvg merged commit b42bccf into main Jul 18, 2022
@billyvg billyvg deleted the feat/do-not-flush-checkout-immediately branch July 18, 2022 23:05
mydea pushed a commit to getsentry/sentry-javascript that referenced this pull request Nov 23, 2022
Change the logic for when to flush after a full snapshot checkout. Add
option `initialFlushDelay` to control when to flush.

Do NOT flush on checkout after a session has expired. It will need to
wait for additional user actions before recording the new sessions
replay.
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.

2 participants