diff --git a/docs/platforms/java/common/scope/index.mdx b/docs/platforms/java/common/scope/index.mdx deleted file mode 100644 index adf511573acc8..0000000000000 --- a/docs/platforms/java/common/scope/index.mdx +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: Scope & Breadcrumbs -sidebar_order: 11 ---- - -The Java SDK implements the idea of a “scope” to support attaching additional information to events, such as breadcrumbs. A scope may refer to a single request to a web framework, to the entire lifetime of an Android application, or something else that better suits your application’s needs. - -## Usage - -Breadcrumbs can be used to describe actions that occurred in your application leading up to an event being sent. For example, whether external API requests were made, or whether a user clicked on something in an Android application. By default the last 100 breadcrumbs per scope will be stored and sent with future events. - -The user can be set per scope so that you know who was affected by each event. - -Once a `Sentry` instance has been initialized you can begin setting state in the current scope. - -```java {tabTitle:Java} -import io.sentry.Sentry; -import io.sentry.protocol.User; - -public class MyClass { - - public void example() { - // Note that all fields set on the scope are optional. Scope data is copied onto - // all future events in the current scope. - - // Set the current user in the scope. - Sentry.configureScope(scope -> { - User user = new User(); - user.setUsername("user1"); - scope.setUser(user); - }); - - // Record a breadcrumb in the scope. - Sentry.addBreadcrumb("User did something specific again!"); - - // Add extra data to future events in this scope. - Sentry.configureScope(scope -> { - scope.setExtra("extra", "thing"); - }); - - // Add an additional tag to future events in this scope. - Sentry.configureScope(scope -> { - scope.setTag("tagName", "tagValue"); - }); - - // Send an event with the scope data attached. - Sentry.captureMessage("New event message"); - } -} -``` - -```kotlin {tabTitle:Kotlin} -import io.sentry.Sentry -import io.sentry.protocol.User - -class MyClass { - fun example() { - // Note that all fields set on the scope are optional. Scope data is copied onto - // all future events in the current scope. - - // Set the current user in the scope. - Sentry.configureScope { scope -> - scope.user = User().apply { - username = "user1" - } - } - - // Record a breadcrumb in the scope. - Sentry.addBreadcrumb("User did something specific again!") - - // Add extra data to future events in this scope. - Sentry.configureScope { scope -> scope.setExtra("extra", "thing") } - - // Add an additional tag to future events in this scope. - Sentry.configureScope { scope -> scope.setTag("tagName", "tagValue") } - - // Send an event with the scope data attached. - Sentry.captureMessage("New event message") - } -} -```