Skip to content

Conversation

@cjy3458
Copy link

@cjy3458 cjy3458 commented Jan 9, 2026

DESCRIBE YOUR PR

This PR adds comprehensive documentation explaining how Sentry's Session Replay sampling mechanism works internally.

Problem: Many developers find it confusing how replaysSessionSampleRate and replaysOnErrorSampleRate work together, especially regarding the memory buffer system and when data is actually sent to Sentry.

Solution: Added detailed technical documentation that explains:

  • How the 60-second memory buffer (ring buffer) works
  • The sampling decision flow with clear user scenarios
  • What data format is stored (event logs, not video)
  • When and how data is transmitted to Sentry
  • Best practices for configuration

This documentation will help developers better understand the internal mechanisms and optimize their Session Replay configuration.

IS YOUR CHANGE URGENT?

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Requesting review from @getsentry/docs team
  • Happy to wait up to 1 week for review

PRE-MERGE CHECKLIST

  • Checked Vercel preview for correctness, including links
    (External contributor - waiting for team authorization)
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

NOTE FOR REVIEWERS

As an external contributor, I'm unable to access the Vercel preview until authorized. I've tested the markdown formatting and links locally using yarn dev. Please let me know if you spot any issues in the preview!

LEGAL BOILERPLATE

I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

…nism

- Explain memory buffer system
- Document sampling decision flow
- Add user scenario examples
- Include technical implementation details
@vercel
Copy link

vercel bot commented Jan 9, 2026

@cjy3458 is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

- Old events are automatically overwritten
- No memory leak concerns
- Stops recording after 60 minutes (hard limit)
- Pauses when internet connection is lost

This comment was marked as outdated.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @sentry bot for catching this! You're absolutely right - the pause-on-connection-loss feature is mobile-specific. I've removed that line to avoid confusion.

Fixed in 8890311

The pause-on-connection-loss feature is specific to mobile SDKs,
not web SDKs. Removed to avoid confusion.
@aldy505 aldy505 requested a review from bruno-garcia January 13, 2026 09:15
@rodolfoBee rodolfoBee requested a review from a team January 13, 2026 12:07
@cjy3458 cjy3458 marked this pull request as draft January 15, 2026 08:20
@cjy3458 cjy3458 marked this pull request as ready for review January 15, 2026 08:23
@cjy3458
Copy link
Author

cjy3458 commented Jan 15, 2026

Hi team! 👋

Friendly ping - all CI checks passed and this is ready for review whenever the team has time!

Let me know if you need any clarifications. Thanks! 🙏

Copy link
Member

@philprime philprime left a comment

Choose a reason for hiding this comment

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

Thanks for opening up this PR. We appreciate everyone contributing to Sentry. I left a couple of high-priority comments we need to address. Overall I currently do not see the clear benefit of this page, as it mentions a lot of information we already have on our platform-specific session-replay related documentation for Web, Android and iOS (I am one of the iOS maintainers).

I'll leave it to the @getsentry/product-owners-docs to decide on how to proceed with this contribution, but I do not believe we can merge it as it is right now.


### What Gets Stored

Contrary to what you might expect, Session Replay doesn't store actual video files in memory. Instead, it stores **event logs** in a structured format:
Copy link
Member

Choose a reason for hiding this comment

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

h: This applies to web, not to mobile. As this is a product page for a feature spanning all platforms we must either not mention this or make it clear that it's different and explain both applications.


### Buffer Duration and Size

- **Duration**: 60 seconds of the most recent activity
Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines 46 to 53
### Configuration Example
```javascript
Sentry.init({
dsn: 'YOUR_DSN',
replaysSessionSampleRate: 0.1, // 10% of users
replaysOnErrorSampleRate: 1.0, // 100% of error-encountering users
});
```
Copy link
Member

Choose a reason for hiding this comment

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

h: This can become outdated, let's reference the actual product page per platform instead using PlatformLink

Comment on lines 61 to 62
- If selected (10% chance): Full session recording starts immediately → sent to Sentry in real-time
- If not selected (90% chance): Recording starts but stays in memory buffer only
Copy link
Member

Choose a reason for hiding this comment

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

m: Let's not add percentages here, as they are configurable:

Suggested change
- If selected (10% chance): Full session recording starts immediately → sent to Sentry in real-time
- If not selected (90% chance): Recording starts but stays in memory buffer only
- If selected: Full session recording starts immediately → sent to Sentry in real-time
- If not selected: Recording starts but stays in memory buffer only


2. **Error Trigger**
- If an error occurs and `replaysOnErrorSampleRate` condition is met:
- The buffered 60 seconds *before* the error is captured
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- The buffered 60 seconds *before* the error is captured
- The buffered 60 seconds (or as configured) *before* the error is captured


### Memory Management

The 60-second buffer is managed as a **ring buffer**:
Copy link
Member

Choose a reason for hiding this comment

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

h: This is also different per platform. On mobile we take screenshots, mask them, then combine them into videos on-device after X seconds

Comment on lines 151 to 162
### Recommended Configuration
```javascript
Sentry.init({
dsn: 'YOUR_DSN',

// Capture 10% of sessions for general monitoring
replaysSessionSampleRate: 0.1,

// Capture 100% of sessions where errors occur
replaysOnErrorSampleRate: 1.0,
});
```
Copy link
Member

Choose a reason for hiding this comment

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

m: This does not match the recommendation we already have in place: https://docs.sentry.io/platforms/javascript/session-replay/#recommended-production-sample-rates

…dress review feedback

- Relocate from product-level to Web-specific location
  (docs/product/explore/session-replay/ → docs/platforms/javascript/common/session-replay/)
- Address all 7 review comments from @philiprime

Changes:
- Add Web-specific disclaimer and platform callouts (getsentry#1, getsentry#6)
- Change buffer duration to configurable with platform notes (getsentry#2)
- Replace config examples with PlatformLink references (getsentry#3)
- Remove hardcoded percentages from decision flow (getsentry#4)
- Add '(or as configured)' qualifiers (getsentry#5)
- Remove duplicate 'Recommended Configuration' section (getsentry#7)

The document now focuses on Web's internal mechanism (rrweb, DOM events,
ring buffer) while deferring configuration to official setup docs."
@cjy3458
Copy link
Author

cjy3458 commented Jan 15, 2026

@philprime

All 7 review comments addressed! 🙏

Main changes:

Structural:

  • Moved to docs/platforms/javascript/common/session-replay/understanding-sampling.mdx
  • Added Web-specific disclaimers and platform difference callouts

Content:

  • Made all technical sections Web-specific with mobile notes (event logs, ring buffer)
  • Changed hardcoded durations to "configurable" with platform notes
  • Replaced config examples with PlatformLink references
  • Removed hardcoded percentages from flow descriptions
  • Removed duplicate "Recommended Configuration" section entirely

Result: Document now focuses on Web's internal mechanism while linking to official docs for configuration.

Ready for re-review! 🚀

@cjy3458 cjy3458 requested a review from philprime January 15, 2026 15:26
@bruno-garcia bruno-garcia requested review from jas-kas and removed request for bruno-garcia January 19, 2026 14:25
@vercel
Copy link

vercel bot commented Jan 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sentry-docs Ready Ready Preview, Comment Jan 30, 2026 0:15am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
develop-docs Ignored Ignored Preview Jan 30, 2026 0:15am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants