Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
### Fixes

- Session Replay: Fix first recording segment missing for replays in `buffer` mode ([#5753](https://github.com/getsentry/sentry-java/pull/5753))
- Fix error-to-replay linkage in buffer mode ([#5754](https://github.com/getsentry/sentry-java/pull/5754))
- Fix main thread identification for tombstone (native crash) events ([#5742](https://github.com/getsentry/sentry-java/pull/5742))

### Dependencies
Expand Down
1 change: 1 addition & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public final class io/sentry/Baggage {
public fun <init> (Lio/sentry/Baggage;)V
public fun <init> (Lio/sentry/ILogger;)V
public fun <init> (Ljava/util/concurrent/ConcurrentHashMap;Ljava/lang/Double;Ljava/lang/Double;Ljava/lang/String;ZZLio/sentry/ILogger;)V
public fun forceSetReplayId (Lio/sentry/protocol/SentryId;)V
public fun forceSetSampleRate (Ljava/lang/Double;)V
public fun freeze ()V
public static fun fromEvent (Lio/sentry/SentryBaseEvent;Ljava/lang/String;Lio/sentry/SentryOptions;)Lio/sentry/Baggage;
Expand Down
13 changes: 13 additions & 0 deletions sentry/src/main/java/io/sentry/Baggage.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,19 @@ public void setReplayId(final @Nullable String replayId) {
set(DSCKeys.REPLAY_ID, replayId);
}

/**
* Sets replay_id on the baggage bypassing the freeze check. In buffer mode the replay_id is
* unknown when the baggage is frozen, so it must be injected after {@link
* ReplayController#captureReplay} sets it on scope. This mirrors the JS SDK's <a
* href="https://github.com/getsentry/sentry-javascript/blob/develop/packages/replay-internal/src/util/resetReplayIdOnDynamicSamplingContext.ts">setReplayIdOnDynamicSamplingContext</a>.
*/
@ApiStatus.Internal
public void forceSetReplayId(final @NotNull SentryId replayId) {
if (!SentryId.EMPTY_ID.equals(replayId)) {
keyValues.put(DSCKeys.REPLAY_ID, replayId.toString());
}
}

@ApiStatus.Internal
public @Nullable String getOrgId() {
return get(DSCKeys.ORG_ID);
Expand Down
12 changes: 12 additions & 0 deletions sentry/src/main/java/io/sentry/SentryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,18 @@ private boolean shouldApplyScopeData(final @NotNull CheckIn event, final @NotNul
}
if (shouldCaptureReplay) {
options.getReplayController().captureReplay(event.isCrashed());
if (scope != null) {
final @Nullable SentryId replayId = scope.getReplayId();
if (replayId != null && !replayId.equals(SentryId.EMPTY_ID)) {
final @Nullable ITransaction transaction = scope.getTransaction();
if (transaction != null) {
final @Nullable Baggage baggage = transaction.getSpanContext().getBaggage();
if (baggage != null) {
baggage.forceSetReplayId(replayId);
}
}
}
}
}
}

Expand Down
Loading