Skip to content

Commit

Permalink
Merge f94cbe2 into 051ce9b
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich authored Jun 14, 2024
2 parents 051ce9b + f94cbe2 commit 2b69d80
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.sentry.IScope;
import io.sentry.ISerializer;
import io.sentry.ObjectWriter;
import io.sentry.Sentry;
import io.sentry.SentryEnvelope;
import io.sentry.SentryEnvelopeItem;
import io.sentry.SentryEvent;
Expand Down Expand Up @@ -164,7 +165,8 @@ public static SentryId captureEnvelope(final @NotNull byte[] envelopeData) {

// determine session state based on events inside envelope
@Nullable Session.State status = null;
boolean crashedOrErrored = false;
boolean crashed = false;
boolean errored = false;
for (SentryEnvelopeItem item : envelope.getItems()) {
envelopeItems.add(item);

Expand All @@ -173,17 +175,24 @@ public static SentryId captureEnvelope(final @NotNull byte[] envelopeData) {
if (event.isCrashed()) {
status = Session.State.Crashed;
}
if (event.isCrashed() || event.isErrored()) {
crashedOrErrored = true;
if (event.isCrashed()) {
crashed = true;
}
if (event.isErrored()) {
errored = true;
}
}
}

// update session and add it to envelope if necessary
final @Nullable Session session = updateSession(hub, options, status, crashedOrErrored);
final @Nullable Session session = updateSession(hub, options, status, crashed || errored);
if (session != null) {
final SentryEnvelopeItem sessionItem = SentryEnvelopeItem.fromSession(serializer, session);
envelopeItems.add(sessionItem);
if (crashed) {
session.end();
Sentry.startSession();
}
}

final SentryEnvelope repackagedEnvelope =
Expand Down

0 comments on commit 2b69d80

Please sign in to comment.