Skip to content
Merged
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 @@ -2,6 +2,7 @@

## Unreleased

* Ref: Make hints Map<String, Object> instead of only Object (#1929)
* Feat: Enable enableScopeSync by default for Android (#1928)

## 6.0.0-alpha.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.sentry.android.core;

import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND;
import static io.sentry.TypeCheckHint.ANDROID_ACTIVITY;

import android.app.Activity;
import android.app.ActivityManager;
Expand All @@ -22,6 +23,7 @@
import java.io.Closeable;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
Expand Down Expand Up @@ -123,7 +125,11 @@ private void addBreadcrumb(final @NotNull Activity activity, final @NotNull Stri
breadcrumb.setData("screen", getActivityName(activity));
breadcrumb.setCategory("ui.lifecycle");
breadcrumb.setLevel(SentryLevel.INFO);
hub.addBreadcrumb(breadcrumb);

final Map<String, Object> hintMap = new HashMap<>();
hintMap.put(ANDROID_ACTIVITY, activity);

hub.addBreadcrumb(breadcrumb, hintMap);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.sentry.android.core;

import static io.sentry.TypeCheckHint.ANDROID_CONFIGURATION;

import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.res.Configuration;
Expand All @@ -13,7 +15,9 @@
import io.sentry.util.Objects;
import java.io.Closeable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -95,7 +99,11 @@ public void onConfigurationChanged(@NotNull Configuration newConfig) {
breadcrumb.setCategory("device.orientation");
breadcrumb.setData("position", orientation);
breadcrumb.setLevel(SentryLevel.INFO);
hub.addBreadcrumb(breadcrumb);

final Map<String, Object> hintMap = new HashMap<>();
hintMap.put(ANDROID_CONFIGURATION, newConfig);

hub.addBreadcrumb(breadcrumb, hintMap);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import io.sentry.protocol.SentryThread;
import io.sentry.protocol.SentryTransaction;
import io.sentry.protocol.User;
import io.sentry.util.ApplyScopeUtils;
import io.sentry.util.HintUtils;
import io.sentry.util.Objects;
import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -117,7 +117,7 @@ public DefaultAndroidEventProcessor(

@Override
public @NotNull SentryEvent process(
final @NotNull SentryEvent event, final @Nullable Object hint) {
final @NotNull SentryEvent event, final @Nullable Map<String, Object> hint) {
final boolean applyScopeData = shouldApplyScopeData(event, hint);
if (applyScopeData) {
// we only set memory data if it's not a hard crash, when it's a hard crash the event is
Expand All @@ -143,8 +143,8 @@ private void setCommons(
}

private boolean shouldApplyScopeData(
final @NotNull SentryBaseEvent event, final @Nullable Object hint) {
if (ApplyScopeUtils.shouldApplyScopeData(hint)) {
final @NotNull SentryBaseEvent event, final @Nullable Map<String, Object> hint) {
if (HintUtils.shouldApplyScopeData(hint)) {
return true;
} else {
logger.log(
Expand Down Expand Up @@ -888,7 +888,7 @@ private void setSideLoadedInfo(final @NotNull SentryBaseEvent event) {

@Override
public @NotNull SentryTransaction process(
final @NotNull SentryTransaction transaction, final @Nullable Object hint) {
final @NotNull SentryTransaction transaction, final @Nullable Map<String, Object> hint) {
final boolean applyScopeData = shouldApplyScopeData(transaction, hint);

if (applyScopeData) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.sentry.android.core;

import static io.sentry.SentryLevel.ERROR;
import static io.sentry.TypeCheckHint.SENTRY_TYPE_CHECK_HINT;

import android.os.FileObserver;
import io.sentry.IEnvelopeSender;
Expand All @@ -14,6 +15,8 @@
import io.sentry.hints.SubmissionResult;
import io.sentry.util.Objects;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -56,7 +59,11 @@ public void onEvent(int eventType, @Nullable String relativePath) {
// TODO: Only some event types should be pass through?

final CachedEnvelopeHint hint = new CachedEnvelopeHint(flushTimeoutMillis, logger);
envelopeSender.processEnvelopeFile(this.rootPath + File.separator + relativePath, hint);

final Map<String, Object> hintMap = new HashMap<>();
hintMap.put(SENTRY_TYPE_CHECK_HINT, hint);

envelopeSender.processEnvelopeFile(this.rootPath + File.separator + relativePath, hintMap);
}

private static final class CachedEnvelopeHint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class PerformanceAndroidEventProcessor implements EventProcessor {
*/
@Override
@Nullable
public SentryEvent process(@NotNull SentryEvent event, @Nullable Object hint) {
public SentryEvent process(@NotNull SentryEvent event, @Nullable Map<String, Object> hint) {
// that's only necessary because on newer versions of Unity, if not overriding this method, it's
// throwing 'java.lang.AbstractMethodError: abstract method' and the reason is probably
// compilation mismatch.
Expand All @@ -52,7 +52,7 @@ public SentryEvent process(@NotNull SentryEvent event, @Nullable Object hint) {
@SuppressWarnings("NullAway")
@Override
public synchronized @NotNull SentryTransaction process(
@NotNull SentryTransaction transaction, @Nullable Object hint) {
@NotNull SentryTransaction transaction, @Nullable Map<String, Object> hint) {

if (!options.isTracingEnabled()) {
return transaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static android.content.Intent.ACTION_SHUTDOWN;
import static android.content.Intent.ACTION_TIMEZONE_CHANGED;
import static android.content.Intent.ACTION_TIME_CHANGED;
import static io.sentry.TypeCheckHint.ANDROID_INTENT;

import android.content.BroadcastReceiver;
import android.content.Context;
Expand Down Expand Up @@ -213,7 +214,11 @@ public void onReceive(Context context, Intent intent) {
breadcrumb.setData("extras", newExtras);
}
breadcrumb.setLevel(SentryLevel.INFO);
hub.addBreadcrumb(breadcrumb);

final Map<String, Object> hintMap = new HashMap<>();
hintMap.put(ANDROID_INTENT, intent);

hub.addBreadcrumb(breadcrumb, hintMap);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.sentry.android.core;

import static android.content.Context.SENSOR_SERVICE;
import static io.sentry.TypeCheckHint.ANDROID_SENSOR_EVENT;

import android.content.Context;
import android.hardware.Sensor;
Expand All @@ -15,6 +16,8 @@
import io.sentry.util.Objects;
import java.io.Closeable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
Expand Down Expand Up @@ -103,7 +106,11 @@ public void onSensorChanged(final @NotNull SensorEvent event) {
breadcrumb.setData("timestamp", event.timestamp);
breadcrumb.setLevel(SentryLevel.INFO);
breadcrumb.setData("degree", event.values[0]); // Celsius
hub.addBreadcrumb(breadcrumb);

final Map<String, Object> hintMap = new HashMap<>();
hintMap.put(ANDROID_SENSOR_EVENT, event);

hub.addBreadcrumb(breadcrumb, hintMap);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.sentry.android.core.internal.gestures;

import static io.sentry.TypeCheckHint.ANDROID_MOTION_EVENT;
import static io.sentry.TypeCheckHint.ANDROID_VIEW;

import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
Expand All @@ -10,6 +13,7 @@
import io.sentry.android.core.SentryAndroidOptions;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -51,7 +55,11 @@ public void onUp(final @NotNull MotionEvent motionEvent) {
}

final String direction = scrollState.calculateDirection(motionEvent);
addBreadcrumb(scrollTarget, scrollState.type, Collections.singletonMap("direction", direction));
addBreadcrumb(
scrollTarget,
scrollState.type,
Collections.singletonMap("direction", direction),
motionEvent);
scrollState.reset();
}

Expand Down Expand Up @@ -88,7 +96,7 @@ public boolean onSingleTapUp(final @Nullable MotionEvent motionEvent) {
return false;
}

addBreadcrumb(target, "click", Collections.emptyMap());
addBreadcrumb(target, "click", Collections.emptyMap(), motionEvent);
return false;
}

Expand Down Expand Up @@ -154,7 +162,8 @@ public void onLongPress(MotionEvent motionEvent) {}
private void addBreadcrumb(
final @NotNull View target,
final @NotNull String eventType,
final @NotNull Map<String, Object> additionalData) {
final @NotNull Map<String, Object> additionalData,
final @NotNull MotionEvent motionEvent) {
@NotNull String className;
@Nullable String canonicalName = target.getClass().getCanonicalName();
if (canonicalName != null) {
Expand All @@ -163,9 +172,14 @@ private void addBreadcrumb(
className = target.getClass().getSimpleName();
}

final Map<String, Object> hintMap = new HashMap<>();
hintMap.put(ANDROID_MOTION_EVENT, motionEvent);
hintMap.put(ANDROID_VIEW, target);

hub.addBreadcrumb(
Breadcrumb.userInteraction(
eventType, ViewUtils.getResourceId(target), className, additionalData));
eventType, ViewUtils.getResourceId(target), className, additionalData),
hintMap);
}

private @Nullable View ensureWindowDecorView(final @NotNull String caller) {
Expand Down
Loading