Skip to content

ref(replay): Log warning if trying to flush initial segment without checkout #8748

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 2 commits into from
Aug 8, 2023

Conversation

mydea
Copy link
Member

@mydea mydea commented Aug 7, 2023

We keep track of the eventBuffer contains a checkout, and if not, log a warning when trying to flush the initial segment.

If this turns out to be happening, we may think about aborting flushing or similar in this case. But for now, we can gather data.

…heckout

We keep track of the eventBuffer contains a checkout, and if not, log a warning when trying to flush the initial segment.

If this turns out to be happening, we may think about aborting flushing or similar in this case. But for now, we can gather data.
@mydea mydea added the Package: replay Issues related to the Sentry Replay SDK label Aug 7, 2023
@mydea mydea requested a review from billyvg August 7, 2023 15:17
@mydea mydea self-assigned this Aug 7, 2023

sessionStorage.clear();
clearSession(replay);
replay['_loadAndCheckSession']();
// No-op _loadAndCheckSession to avoid us resetting the session for this test
Copy link
Member Author

Choose a reason for hiding this comment

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

actually noticed this test was incorrect before, it just worked because we never reset minReplayDuration above 😬 oops...

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 74.96 KB (+0.14% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.11 KB (0%)
@sentry/browser - Webpack (gzipped) 21.81 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 69.58 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 28.15 KB (+0.01% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 20.18 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 219.29 KB (+0.11% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 84.67 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 59.83 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 31.02 KB (+0.01% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 65.16 KB (+0.16% 🔺)
@sentry/react - Webpack (gzipped) 21.84 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 92.75 KB (+0.11% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 50.61 KB (0%)

@@ -1151,6 +1151,12 @@ export class ReplayContainer implements ReplayContainerInterface {
return;
}

const eventBuffer = this.eventBuffer;
if (eventBuffer && this.session.segmentId === 0 && !eventBuffer.hasCheckout) {
Copy link
Member

Choose a reason for hiding this comment

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

Hmm won't this log for session based replays?

Copy link
Member Author

Choose a reason for hiding this comment

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

there should still always be a checkout in the initial segment, right?

* Log a message, and add a breadcrumb in the next tick.
* This is necessary when the breadcrumb may be added before the replay is initialized.
*/
export function logInfoNextTick(message: string, shouldAddBreadcrumb?: boolean): void {
Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up splitting this into two methods logInfo and logInfoNextTick, as while the log in next tick change fixed some cases, but "broke" others (when logging right before a flush). So now we only explicitly log in the next tick in cases that could be logged before the replay is started.

@mydea mydea merged commit 5044e6b into develop Aug 8, 2023
@mydea mydea deleted the fn/guard-no-checkout branch August 8, 2023 09:26
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