|  | 
| 2 | 2 | 
 | 
| 3 | 3 | ## Unreleased | 
| 4 | 4 | 
 | 
|  | 5 | +Version 8 of the Sentry Android/Java SDK brings a variety of features and fixes. The most notable changes are: | 
|  | 6 | + | 
|  | 7 | +- New `Scope` types have been introduced, see "Behavioural Changes" for more details. | 
|  | 8 | +- Lifecycle tokens have been introduced to manage `Scope` lifecycle, see "Behavioural Changes" for more details. | 
|  | 9 | +- `Hub` has been replaced by `Scopes` | 
|  | 10 | + | 
|  | 11 | +### Behavioural Changes | 
|  | 12 | + | 
|  | 13 | +- We're introducing some new `Scope` types in the SDK, allowing for better control over what data is attached where. Previously there was a stack of scopes that was pushed and popped. Instead we now fork scopes for a given lifecycle and then restore the previous scopes. Since `Hub` is gone, it is also never cloned anymore. Separation of data now happens through the different scope types while making it easier to manipulate exactly what you need without having to attach data at the right time to have it apply where wanted. | 
|  | 14 | +    - Global scope is attached to all events created by the SDK. It can also be modified before `Sentry.init` has been called. It can be manipulated using `Sentry.configureScope(ScopeType.GLOBAL, (scope) -> { ... })`. | 
|  | 15 | +    - Isolation scope can be used e.g. to attach data to all events that come up while handling an incoming request. It can also be used for other isolation purposes. It can be manipulated using `Sentry.configureScope(ScopeType.ISOLATION, (scope) -> { ... })`. The SDK automatically forks isolation scope in certain cases like incoming requests, CRON jobs, Spring `@Async` and more. | 
|  | 16 | +    - Current scope is forked often and data added to it is only added to events that are created while this scope is active. Data is also passed on to newly forked child scopes but not to parents. | 
|  | 17 | +- `Sentry.popScope` has been deprecated, please call `.close()` on the token returned by `Sentry.pushScope` instead or use it in a way described in more detail in "Migration Guide". | 
|  | 18 | +- We have chosen a default scope that is used for `Sentry.configureScope()` as well as API like `Sentry.setTag()` | 
|  | 19 | +    - For Android the type defaults to `CURRENT` scope | 
|  | 20 | +    - For Backend and other JVM applicatons it defaults to `ISOLATION` scope | 
|  | 21 | +- Event processors on `Scope` can now be ordered by overriding the `getOrder` method on implementations of `EventProcessor`. NOTE: This order only applies to event processors on `Scope` but not `SentryOptions` at the moment. Feel free to request this if you need it. | 
|  | 22 | +- `Hub` is deprecated in favor of `Scopes`, alongside some `Hub` relevant APIs. More details can be found in the "Migration Guide" section. | 
|  | 23 | + | 
|  | 24 | +### Breaking Changes | 
|  | 25 | + | 
|  | 26 | +- `Contexts` no longer extends `ConcurrentHashMap`, instead we offer a selected set of methods. | 
|  | 27 | + | 
|  | 28 | +### Migration Guide / Deprecations | 
|  | 29 | + | 
|  | 30 | +- `Hub` has been deprecated, we're replacing the following: | 
|  | 31 | +    - `IHub` has been replaced by `IScopes`, however you should be able to simply pass `IHub` instances to code expecting `IScopes`, allowing for an easier migration. | 
|  | 32 | +    - `HubAdapter.getInstance()` has been replaced by `ScopesAdapter.getInstance()` | 
|  | 33 | +    - The `.clone()` method on `IHub`/`IScopes` has been deprecated, please use `.pushScope()` or `.pushIsolationScope()` instead | 
|  | 34 | +    - Some internal methods like `.getCurrentHub()` and `.setCurrentHub()` have also been replaced. | 
|  | 35 | +- `Sentry.popScope` has been replaced by calling `.close()` on the token returned by `Sentry.pushScope()` and `Sentry.pushIsolationScope()`. The token can also be used in a `try` block like this: | 
|  | 36 | + | 
|  | 37 | +``` | 
|  | 38 | +try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushScope()) { | 
|  | 39 | +  // this block has its separate current scope | 
|  | 40 | +} | 
|  | 41 | +``` | 
|  | 42 | + | 
|  | 43 | +as well as: | 
|  | 44 | + | 
|  | 45 | + | 
|  | 46 | +``` | 
|  | 47 | +try (final @NotNull ISentryLifecycleToken ignored = Sentry.pushIsolationScope()) { | 
|  | 48 | +  // this block has its separate isolation scope | 
|  | 49 | +} | 
|  | 50 | +``` | 
|  | 51 | + | 
|  | 52 | +You may also use `LifecycleHelper.close(token)`, e.g. in case you need to pass the token around for closing later. | 
|  | 53 | + | 
| 5 | 54 | ### Features | 
| 6 | 55 | 
 | 
| 7 | 56 | - Report exceptions returned by Throwable.getSuppressed() to Sentry as exception groups ([#3396] https://github.com/getsentry/sentry-java/pull/3396) | 
|  | 
0 commit comments