Skip to content

feat(replay): Capture replay mutation breadcrumbs & add experiment #7568

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
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PR feedback
  • Loading branch information
mydea committed Mar 24, 2023
commit bef15368da03d7525a1c7b3450cf1f773c9d7704
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ window.Replay = new Sentry.Replay({
flushMinDelay: 200,
flushMaxDelay: 200,
_experiments: {
fullSnapshotOnMutationsOver: 250,
mutationLimit: 250,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentryTest } from '../../../../utils/fixtures';
import { getReplayRecordingContent, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers';

sentryTest(
'handles large mutations with _experiments.fullSnapshotOnMutationsOver configured',
'handles large mutations with _experiments.mutationLimit configured',
async ({ getLocalTestPath, page, forceFlushReplay }) => {
if (shouldSkipReplayTest()) {
sentryTest.skip();
Expand Down
8 changes: 5 additions & 3 deletions packages/replay/src/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,13 @@ export class ReplayContainer implements ReplayContainerInterface {
private _onMutationHandler = (mutations: unknown[]): boolean => {
const count = mutations.length;

const fullSnapshotOnMutationsOver = this._options._experiments.fullSnapshotOnMutationsOver || 0;
const mutationLimit = this._options._experiments.mutationLimit || 0;
const mutationBreadcrumbLimit = this._options._experiments.mutationBreadcrumbLimit || 1000;
const overMutationLimit = mutationLimit && count > mutationLimit;

// Create a breadcrumb if a lot of mutations happen at the same time
// We can show this in the UI as an information with potential performance improvements
if (count > 500 || (fullSnapshotOnMutationsOver && count > fullSnapshotOnMutationsOver)) {
if (count > mutationBreadcrumbLimit || overMutationLimit) {
const breadcrumb = createBreadcrumb({
category: 'replay.mutations',
data: {
Expand All @@ -842,7 +844,7 @@ export class ReplayContainer implements ReplayContainerInterface {
this._createCustomBreadcrumb(breadcrumb);
}

if (fullSnapshotOnMutationsOver && count > fullSnapshotOnMutationsOver) {
if (overMutationLimit) {
// We want to skip doing an incremental snapshot if there are too many mutations
// Instead, we do a full snapshot
this._triggerFullSnapshot(false);
Expand Down
3 changes: 2 additions & 1 deletion packages/replay/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export interface ReplayPluginOptions extends SessionOptions {
_experiments: Partial<{
captureExceptions: boolean;
traceInternals: boolean;
fullSnapshotOnMutationsOver: number;
mutationLimit: number;
mutationBreadcrumbLimit: number;
}>;
}

Expand Down