-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(replay): Send SDK's name in replay event #6514
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import { Scope } from '@sentry/core'; | ||
import { Client, Event } from '@sentry/types'; | ||
|
||
import { REPLAY_SDK_INFO } from '../constants'; | ||
|
||
export async function getReplayEvent({ | ||
client, | ||
scope, | ||
|
@@ -18,9 +16,14 @@ export async function getReplayEvent({ | |
// @ts-ignore private api | ||
const preparedEvent: Event = await client._prepareEvent(event, { event_id }, scope); | ||
|
||
// extract the SDK name because `client._prepareEvent` doesn't add it to the event | ||
const metadata = client.getOptions() && client.getOptions()._metadata; | ||
const { name } = (metadata && metadata.sdk) || {}; | ||
|
||
preparedEvent.sdk = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l: IMHO we don't need to overwrite this like that, as it will never be set. I'd just do: preparedEvent.sdk = {
name,
version: 'xxx'
} Or, maybe export the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't use the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, we can use |
||
...preparedEvent.sdk, | ||
...REPLAY_SDK_INFO, | ||
version: __SENTRY_REPLAY_VERSION__, | ||
name, | ||
}; | ||
|
||
return preparedEvent; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Event } from '@sentry/types'; | ||
|
||
import { createReplayEnvelope } from '../../../src/util/createReplayEnvelope'; | ||
|
||
describe('createReplayEnvelope', () => { | ||
it('creates an envelope for a given Replay event', () => { | ||
const replayId = '1234'; | ||
const replayEvent = { | ||
type: 'replay_event', | ||
timestamp: 1670837008.634, | ||
error_ids: ['errorId'], | ||
trace_ids: ['traceId'], | ||
urls: ['https://example.com'], | ||
replay_id: 'eventId', | ||
segment_id: 3, | ||
platform: 'javascript', | ||
event_id: 'eventId', | ||
environment: 'production', | ||
sdk: { | ||
integrations: ['BrowserTracing', 'Replay'], | ||
name: 'sentry.javascript.browser', | ||
version: '7.25.0', | ||
billyvg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
tags: { | ||
sessionSampleRate: 1, | ||
errorSampleRate: 0, | ||
replayType: 'error', | ||
}, | ||
}; | ||
const payloadWithSequence = 'payload'; | ||
|
||
const envelope = createReplayEnvelope(replayId, replayEvent as Event, payloadWithSequence); | ||
|
||
expect(envelope).toEqual([ | ||
{ | ||
event_id: '1234', | ||
sdk: { name: 'sentry.javascript.browser', version: '7.25.0' }, | ||
sent_at: expect.any(String), | ||
}, | ||
[ | ||
[ | ||
{ type: 'replay_event' }, | ||
{ | ||
environment: 'production', | ||
error_ids: ['errorId'], | ||
event_id: 'eventId', | ||
platform: 'javascript', | ||
replay_id: 'eventId', | ||
sdk: { integrations: ['BrowserTracing', 'Replay'], name: 'sentry.javascript.browser', version: '7.25.0' }, | ||
segment_id: 3, | ||
tags: { errorSampleRate: 0, replayType: 'error', sessionSampleRate: 1 }, | ||
timestamp: 1670837008.634, | ||
trace_ids: ['traceId'], | ||
type: 'replay_event', | ||
urls: ['https://example.com'], | ||
}, | ||
], | ||
[{ length: 7, type: 'replay_recording' }, 'payload'], | ||
], | ||
]); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Should we maybe just pass
sdk: replayEvent.sdk
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For envelopes in the SDK, we only send name and version in the header:
sentry-javascript/packages/core/src/envelope.ts
Lines 16 to 24 in 2591d2a
According to the dev spec, we can send the entire
sdk
object though, so we could change it... I think for now we should go with SDK consistency, WDYT? Keeps the envelope a little smaller if we don't pass the integrations array twice for instanceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh, ok, I see. Sorry, this was/is a bit confusing for me, what goes on the event vs. what goes on the envelope 😅