Skip to content

ref(replay): Extract sendReplay functionality into functions #6751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 13, 2023

Conversation

mydea
Copy link
Member

@mydea mydea commented Jan 12, 2023

This extracts this out into a more functional style.
In addition, it also changes the timestamp we put on the replay to always reflect the time we've added it, no matter if it was retried.

This also renames a few things for clarity (e.g. events that was often passed around is actually recordingData, so we may as well reflect that in order to be clear about recordingData vs. events).

Note: This depends on #6733, where I'll need to merge the changes once that is merged.

@mydea mydea added the Package: replay Issues related to the Sentry Replay SDK label Jan 12, 2023
@mydea mydea requested review from billyvg and Lms24 January 12, 2023 13:43
@mydea mydea self-assigned this Jan 12, 2023
@@ -414,14 +411,12 @@ describe('Integration | sendReplayEvent', () => {

await advanceTimers(30000);
expect(mockSendReplayRequest).toHaveBeenCalledTimes(4);
expect(spySendReplay).toHaveBeenCalledTimes(4);
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: We cannot spy on recursive calls of modules, it seems, so this is never incremented. IMHO this is well enough tested by ensure that sendReplayRequest is called X times, we don't really care that much about sendReplay does.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.84 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 61.46 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.62 KB (+0.02% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 55 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.38 KB (0%)
@sentry/browser - Webpack (minified) 66.55 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.4 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.63 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.82 KB (+0.02% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.25 KB (-0.01% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.34 KB (+0.19% 🔺)
@sentry/replay - Webpack (gzipped + minified) 38.57 KB (+0.19% 🔺)

@mydea mydea force-pushed the fn/send-replay-extract branch from bee9cf7 to f84854d Compare January 12, 2023 15:56
@mydea mydea force-pushed the fn/send-replay-extract branch from f84854d to caec2f7 Compare January 12, 2023 15:59
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Nice, looks like a great change to me.

@@ -34,7 +34,7 @@ type SentReplayExpected = {
replayEventPayload?: ReplayEventPayload;
recordingHeader?: RecordingHeader;
recordingPayloadHeader?: RecordingPayloadHeader;
events?: ReplayRecordingData;
recordingData?: ReplayRecordingData;
Copy link
Member

Choose a reason for hiding this comment

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

great change, "event" is overloaded enough already 😅

@@ -110,7 +110,7 @@ describe('Integration | stop', () => {
jest.runAllTimers();
await new Promise(process.nextTick);
expect(replay).toHaveLastSentReplay({
events: JSON.stringify([
recordingData: JSON.stringify([
Copy link
Member

Choose a reason for hiding this comment

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

Just to double check: This renaming doesn't change anything for the actual envelope content that is sent to Sentry, right? Just don't wanna risk some problem with Relay not finding the field it expects in the envelope

Copy link
Member Author

Choose a reason for hiding this comment

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

no, this basically reads the SendReplayData passed around!

@mydea mydea marked this pull request as ready for review January 12, 2023 16:38
@mydea mydea merged commit 93b8ec5 into master Jan 13, 2023
@mydea mydea deleted the fn/send-replay-extract branch January 13, 2023 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: replay Issues related to the Sentry Replay SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants