Skip to content

Commit cab74fa

Browse files
committed
ref(replay): Send SDK's name in replay event
1 parent 5ba721a commit cab74fa

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

packages/replay/src/constants.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,3 @@ export const MAX_SESSION_LIFE = 1_800_000; // 30 minutes
2525
*/
2626
export const DEFAULT_SESSION_SAMPLE_RATE = 0.1;
2727
export const DEFAULT_ERROR_SAMPLE_RATE = 1.0;
28-
29-
export const REPLAY_SDK_INFO = {
30-
name: 'sentry.javascript.integration.replay',
31-
version: __SENTRY_REPLAY_VERSION__,
32-
};

packages/replay/src/util/createReplayEnvelope.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import { Envelope, Event } from '@sentry/types';
22
import { createEnvelope } from '@sentry/utils';
33

4-
import { REPLAY_SDK_INFO } from '../constants';
5-
64
export function createReplayEnvelope(
75
replayId: string,
86
replayEvent: Event,
97
payloadWithSequence: string | Uint8Array,
108
): Envelope {
9+
const { name, version } = replayEvent.sdk || {};
1110
return createEnvelope(
1211
{
1312
event_id: replayId,
1413
sent_at: new Date().toISOString(),
15-
sdk: REPLAY_SDK_INFO,
14+
sdk: { name, version },
1615
},
1716
[
1817
// @ts-ignore New types

packages/replay/src/util/getReplayEvent.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Scope } from '@sentry/core';
22
import { Client, Event } from '@sentry/types';
33

4-
import { REPLAY_SDK_INFO } from '../constants';
5-
64
export async function getReplayEvent({
75
client,
86
scope,
@@ -18,9 +16,14 @@ export async function getReplayEvent({
1816
// @ts-ignore private api
1917
const preparedEvent: Event = await client._prepareEvent(event, { event_id }, scope);
2018

19+
// extract the SDK name because `client._prepareEvent` doesn't add it to the event
20+
const metadata = client.getOptions() && client.getOptions()._metadata;
21+
const { name } = (metadata && metadata.sdk) || {};
22+
2123
preparedEvent.sdk = {
2224
...preparedEvent.sdk,
23-
...REPLAY_SDK_INFO,
25+
version: __SENTRY_REPLAY_VERSION__,
26+
name,
2427
};
2528

2629
return preparedEvent;

0 commit comments

Comments
 (0)