Skip to content

Commit 6cbfdf8

Browse files
committed
sprinkle with TODOs to highlight next PR steps
1 parent 10c7a1f commit 6cbfdf8

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

sentry-android-core/src/main/java/io/sentry/android/core/AnrV2EventProcessor.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ public AnrV2EventProcessor(
122122
return event;
123123
}
124124

125+
// TODO: right now, any event with a Backfillable Hint will get here. This is fine if the
126+
// enrichment code is generically applicable to any Backfilling Event. However some parts
127+
// in the ANRv2EventProcessor are specific to ANRs and currently override the tombstone
128+
// events. Similar to the Integration we should find an abstraction split that allows to
129+
// separate the generic from the specific.
130+
125131
// we always set exception values, platform, os and device even if the ANR is not enrich-able
126132
// even though the OS context may change in the meantime (OS update), we consider this an
127133
// edge-case
@@ -255,6 +261,7 @@ private void setFingerprints(final @NotNull SentryEvent event, final @NotNull Ob
255261
// sentry does not yet have a capability to provide default server-side fingerprint rules,
256262
// so we're doing this on the SDK side to group background and foreground ANRs separately
257263
// even if they have similar stacktraces
264+
// TODO: this will always set the fingerprint of tombstones to foreground-anr
258265
final boolean isBackgroundAnr = isBackgroundAnr(hint);
259266
if (event.getFingerprints() == null) {
260267
event.setFingerprints(
@@ -385,6 +392,8 @@ private void setApp(final @NotNull SentryBaseEvent event, final @NotNull Object
385392
// TODO: not entirely correct, because we define background ANRs as not the ones of
386393
// IMPORTANCE_FOREGROUND, but this doesn't mean the app was in foreground when an ANR happened
387394
// but it's our best effort for now. We could serialize AppState in theory.
395+
396+
// TODO: this will always be true of tombstones
388397
app.setInForeground(!isBackgroundAnr(hint));
389398

390399
final PackageInfo packageInfo = ContextUtils.getPackageInfo(context, buildInfoProvider);
@@ -533,6 +542,9 @@ private void setStaticValues(final @NotNull SentryEvent event) {
533542
private void setPlatform(final @NotNull SentryBaseEvent event) {
534543
if (event.getPlatform() == null) {
535544
// this actually means JVM related.
545+
// TODO: since we write this from the tombstone parser we are current unaffected. It is good
546+
// that it doesn't overwrite previous platform values, however we still rely on the
547+
// order in which each event processor was called.
536548
event.setPlatform(SentryBaseEvent.DEFAULT_PLATFORM);
537549
}
538550
}
@@ -564,12 +576,16 @@ private void setExceptions(final @NotNull SentryEvent event, final @NotNull Obje
564576
// and make an exception out of its stacktrace
565577
final Mechanism mechanism = new Mechanism();
566578
if (!((Backfillable) hint).shouldEnrich()) {
579+
// TODO: this currently overrides the signalhandler mechanism we set in the TombstoneParser
580+
// with a new type (can be the right choice down the road, but currently is
581+
// unintentional, and it might be better to leave it close to the Native SDK)
567582
// we only enrich the latest ANR in the list, so this is historical
568583
mechanism.setType("HistoricalAppExitInfo");
569584
} else {
570585
mechanism.setType("AppExitInfo");
571586
}
572587

588+
// TODO: this currently overrides the tombstone exceptions
573589
final boolean isBackgroundAnr = isBackgroundAnr(hint);
574590
String message = "ANR";
575591
if (isBackgroundAnr) {

sentry-android-core/src/main/java/io/sentry/android/core/TombstoneIntegration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import org.jetbrains.annotations.NotNull;
4141
import org.jetbrains.annotations.Nullable;
4242

43+
// TODO: This is very very close to ANRv2Integration in terms of mechanism. Find an abstraction
44+
// split that separates the equivalent mechanism from the differing policy between the two.
4345
@ApiStatus.Internal
4446
public class TombstoneIntegration implements Integration, Closeable {
4547
static final long NINETY_DAYS_THRESHOLD = TimeUnit.DAYS.toMillis(91);

sentry/src/main/java/io/sentry/cache/EnvelopeCache.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,15 @@ private boolean storeInternal(final @NotNull SentryEnvelope envelope, final @Not
122122
if (HintUtils.hasType(hint, AbnormalExit.class)) {
123123
tryEndPreviousSession(hint);
124124
}
125+
// TODO: adapt tryEndPreviousSession(hint); to CrashExit.class
125126

126127
if (HintUtils.hasType(hint, SessionStart.class)) {
127128
movePreviousSession(currentSessionFile, previousSessionFile);
128129
updateCurrentSession(currentSessionFile, envelope);
129130

130131
boolean crashedLastRun = false;
131132
final File crashMarkerFile = new File(options.getCacheDirPath(), NATIVE_CRASH_MARKER_FILE);
133+
// TODO: this should probably check whether the Native SDK integration is currently enabled or remove the marker file if it isn't. Otherwise, application that disable the Native SDK, will report a crash for the last run forever.
132134
if (crashMarkerFile.exists()) {
133135
crashedLastRun = true;
134136
}
@@ -153,6 +155,7 @@ private boolean storeInternal(final @NotNull SentryEnvelope envelope, final @Not
153155
}
154156
}
155157

158+
// TODO: maybe set crashLastRun for tombstone too?
156159
SentryCrashLastRunState.getInstance().setCrashedLastRun(crashedLastRun);
157160

158161
flushPreviousSession();

0 commit comments

Comments
 (0)