Skip to content

Commit ee8c08f

Browse files
committed
update replayId attaching logic
1 parent 9cb8442 commit ee8c08f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/core/src/metrics/internal.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,21 @@ export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: Internal
159159
setMetricAttribute(processedMetricAttributes, 'sentry.sdk.name', name);
160160
setMetricAttribute(processedMetricAttributes, 'sentry.sdk.version', version);
161161

162-
const replay = client.getIntegrationByName<Integration & { getReplayId: () => string }>('Replay');
163-
setMetricAttribute(processedMetricAttributes, 'sentry.replay_id', replay?.getReplayId());
162+
const replay = client.getIntegrationByName<
163+
Integration & {
164+
getReplayId: (onlyIfSampled?: boolean) => string;
165+
getRecordingMode: () => 'session' | 'buffer' | undefined;
166+
}
167+
>('Replay');
168+
169+
const replayId = replay?.getReplayId(true);
170+
171+
setMetricAttribute(processedMetricAttributes, 'sentry.replay_id', replayId);
172+
173+
if (replayId && replay?.getRecordingMode() === 'buffer') {
174+
// We send this so we can identify cases where the replayId is attached but the replay itself might not have been sent to Sentry
175+
setMetricAttribute(processedMetricAttributes, 'sentry._internal.replay_is_buffering', replayId);
176+
}
164177

165178
const metric: Metric = {
166179
...beforeMetric,

0 commit comments

Comments
 (0)