Skip to content

feat(replay): Remove replayType from tags and into replay_event #6658

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
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions packages/replay/src/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ export class ReplayContainer implements ReplayContainerInterface {
urls,
replay_id: replayId,
segment_id,
replay_type: this.session?.sampled,
};

const replayEvent = await getReplayEvent({ scope, client, event: baseEvent });
Expand All @@ -951,7 +952,6 @@ export class ReplayContainer implements ReplayContainerInterface {
...replayEvent.tags,
sessionSampleRate: this._options.sessionSampleRate,
errorSampleRate: this._options.errorSampleRate,
replayType: this.session?.sampled,
};

/*
Expand All @@ -970,6 +970,7 @@ export class ReplayContainer implements ReplayContainerInterface {
],
"replay_id": "eventId",
"segment_id": 3,
"replay_type": "error",
"platform": "javascript",
"event_id": "generated-uuid",
"environment": "production",
Expand All @@ -985,7 +986,6 @@ export class ReplayContainer implements ReplayContainerInterface {
"tags": {
"sessionSampleRate": 1,
"errorSampleRate": 0,
"replayType": "error"
}
}
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/replay/test/unit/index-errorSampleRate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ describe('Replay (errorSampleRate)', () => {
expect(replay).toHaveSentReplay({
recordingPayloadHeader: { segment_id: 0 },
replayEventPayload: expect.objectContaining({
replay_type: 'error',
Comment on lines 62 to +63
Copy link
Member

Choose a reason for hiding this comment

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

Just as a side note: I'm not too happy about assertions like expect.objectContaining because they don't catch certain kinds of changes to the object under test. In this example, when we add a field, we need to specifically look up these tests and add them to cover the new field. Also, if we "accidentally" add a field, this assertion wouldn't catch it. If we just use "hard" comparisons, I think we could increase the robustness of these tests, as they would fail automatically. It's not something we have to change right now but I think, we should keep it in mind going forward.

tags: expect.objectContaining({
errorSampleRate: 1,
replayType: 'error',
sessionSampleRate: 0,
}),
}),
Expand Down Expand Up @@ -90,9 +90,9 @@ describe('Replay (errorSampleRate)', () => {
expect(replay).toHaveLastSentReplay({
recordingPayloadHeader: { segment_id: 1 },
replayEventPayload: expect.objectContaining({
replay_type: 'error',
tags: expect.objectContaining({
errorSampleRate: 1,
replayType: 'error',
sessionSampleRate: 0,
}),
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/replay/test/unit/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,9 @@ describe('Replay', () => {
replayEventPayload: expect.objectContaining({
replay_start_timestamp: (BASE_TIMESTAMP - 10000) / 1000,
urls: ['http://localhost/'], // this doesn't truly test if we are capturing the right URL as we don't change URLs, but good enough
replay_type: 'session',
tags: expect.objectContaining({
errorSampleRate: 0,
replayType: 'session',
sessionSampleRate: 1,
}),
}),
Expand Down
8 changes: 5 additions & 3 deletions packages/replay/test/unit/util/createReplayEnvelope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ describe('createReplayEnvelope', () => {
name: 'sentry.javascript.browser',
version: '7.25.0',
},
replay_type: 'error',
tags: {
sessionSampleRate: 1,
errorSampleRate: 0,
replayType: 'error',
},
};

Expand Down Expand Up @@ -59,9 +59,10 @@ describe('createReplayEnvelope', () => {
event_id: REPLAY_ID,
platform: 'javascript',
replay_id: REPLAY_ID,
replay_type: 'error',
sdk: { integrations: ['BrowserTracing', 'Replay'], name: 'sentry.javascript.browser', version: '7.25.0' },
segment_id: 3,
tags: { errorSampleRate: 0, replayType: 'error', sessionSampleRate: 1 },
tags: { errorSampleRate: 0, sessionSampleRate: 1 },
Copy link
Member

Choose a reason for hiding this comment

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

Also side note: I think eventually, we'll want to remove these tags as well, right? IMO they don't really add value for our users and SDKs shouldn't just add additional tags to events (unless there's a justified reason to do so ofc). That being said, I know that it's convenient for us to have this data so we might want to think about a similar approach for the sample rate tags. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep I have a follow-up here: #6659

timestamp: 1670837008.634,
trace_ids: ['traceId'],
type: 'replay_event',
Expand Down Expand Up @@ -94,7 +95,8 @@ describe('createReplayEnvelope', () => {
replay_id: REPLAY_ID,
sdk: { integrations: ['BrowserTracing', 'Replay'], name: 'sentry.javascript.browser', version: '7.25.0' },
segment_id: 3,
tags: { errorSampleRate: 0, replayType: 'error', sessionSampleRate: 1 },
replay_type: 'error',
tags: { errorSampleRate: 0, sessionSampleRate: 1 },
timestamp: 1670837008.634,
trace_ids: ['traceId'],
type: 'replay_event',
Expand Down