Skip to content

fix(replay): Generate uuids for replay events #6650

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 1 commit into from
Jan 4, 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 @@ -938,7 +938,7 @@ export class ReplayContainer implements ReplayContainerInterface {
segment_id,
};

const replayEvent = await getReplayEvent({ scope, client, replayId, event: baseEvent });
const replayEvent = await getReplayEvent({ scope, client, event: baseEvent });

if (!replayEvent) {
// Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions
Expand Down Expand Up @@ -971,7 +971,7 @@ export class ReplayContainer implements ReplayContainerInterface {
"replay_id": "eventId",
"segment_id": 3,
"platform": "javascript",
"event_id": "eventId",
"event_id": "generated-uuid",
"environment": "production",
"sdk": {
"integrations": [
Expand Down
4 changes: 1 addition & 3 deletions packages/replay/src/util/getReplayEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { Client, ReplayEvent } from '@sentry/types';
export async function getReplayEvent({
client,
scope,
replayId: event_id,
event,
}: {
client: Client;
scope: Scope;
replayId: string;
event: ReplayEvent;
}): Promise<ReplayEvent | null> {
const preparedEvent = (await prepareEvent(client.getOptions(), event, { event_id }, scope)) as ReplayEvent | null;
const preparedEvent = (await prepareEvent(client.getOptions(), event, {}, scope)) as ReplayEvent | null;

// If e.g. a global event processor returned null
if (!preparedEvent) {
Expand Down
6 changes: 3 additions & 3 deletions packages/replay/test/unit/util/getReplayEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ describe('getReplayEvent', () => {
trace_ids: ['trace-ID'],
urls: ['https://sentry.io/'],
replay_id: replayId,
event_id: replayId,
segment_id: 3,
};

const replayEvent = await getReplayEvent({ scope, client, replayId, event });
const replayEvent = await getReplayEvent({ scope, client, event });

expect(replayEvent).toEqual({
type: 'replay_event',
Expand All @@ -48,7 +47,8 @@ describe('getReplayEvent', () => {
replay_id: 'replay-ID',
segment_id: 3,
platform: 'javascript',
event_id: 'replay-ID',
// generated uuid with 32 chars
event_id: expect.stringMatching(/^\w{32}$/),
environment: 'production',
sdk: {
name: 'sentry.javascript.browser',
Expand Down