Skip to content

Commit e464731

Browse files
author
Luca Forstner
committed
Merge remote-tracking branch 'origin/develop' into lforst-format-migration-guide
2 parents 0f82785 + 1005ba9 commit e464731

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

MIGRATION.md

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,51 @@ npx @sentry/migr8@latest
1010
This will let you select which updates to run, and automatically update your code. Make sure to still review all code
1111
changes!
1212

13+
## Deprecate `Hub`
14+
15+
The `Hub` has been a very important part of the Sentry SDK API up until now. Hubs were the SDK's "unit of concurrency"
16+
to keep track of data across threads and to scope data to certain parts of your code. Because it is overly complicated
17+
and confusing to power users, it is going to be replaced by a set of new APIs: the "new Scope API".
18+
19+
`Scope`s have existed before in the SDK but we are now expanding on them because we have found them powerful enough to
20+
fully cover the `Hub` API.
21+
22+
If you are using the `Hub` right now, see the following table on how to migrate to the new API:
23+
24+
| Old `Hub` API | New `Scope` API |
25+
| ---------------------- | ------------------------------------------------------------------------------------ |
26+
| `new Hub()` | `withScope()`, `withIsolationScope()` or `new Scope()` |
27+
| hub.isOlderThan() | REMOVED - Was used to compare `Hub` instances, which are gonna be removed |
28+
| hub.bindClient() | A combination of `scope.setClient()` and `client.setupIntegrations()` |
29+
| hub.pushScope() | `Sentry.withScope()` |
30+
| hub.popScope() | `Sentry.withScope()` |
31+
| hub.withScope() | `Sentry.withScope()` |
32+
| getClient() | `Sentry.getClient()` |
33+
| getScope() | `Sentry.getCurrentScope()` to get the currently active scope |
34+
| getIsolationScope() | `Sentry.getIsolationScope()` |
35+
| getStack() | REMOVED - The stack used to hold scopes. Scopes are used directly now |
36+
| getStackTop() | REMOVED - The stack used to hold scopes. Scopes are used directly now |
37+
| captureException() | `Sentry.captureException()` |
38+
| captureMessage() | `Sentry.captureMessage()` |
39+
| captureEvent() | `Sentry.captureEvent()` |
40+
| lastEventId() | REMOVED - Use event processors or beforeSend instead |
41+
| addBreadcrumb() | `Sentry.addBreadcrumb()` |
42+
| setUser() | `Sentry.setUser()` |
43+
| setTags() | `Sentry.setTags()` |
44+
| setExtras() | `Sentry.setExtras()` |
45+
| setTag() | `Sentry.setTag()` |
46+
| setExtra() | `Sentry.setExtra()` |
47+
| setContext() | `Sentry.setContext()` |
48+
| configureScope() | REMOVED - Scopes are now the unit of concurrency |
49+
| run() | `Sentry.withScope()` or `Sentry.withIsolationScope()` |
50+
| getIntegration() | `client.getIntegration()` |
51+
| startTransaction() | `Sentry.startSpan()`, `Sentry.startInactiveSpan()` or `Sentry.startSpanManual()` |
52+
| traceHeaders() | REMOVED - The closest equivalent is now `spanToTraceHeader(getActiveSpan())` |
53+
| captureSession() | `Sentry.captureSession()` |
54+
| startSession() | `Sentry.startSession()` |
55+
| endSession() | `Sentry.endSession()` |
56+
| shouldSendDefaultPii() | REMOVED - The closest equivalent is `Sentry.getClient().getOptions().sendDefaultPii` |
57+
1358
## Deprecate `scope.getSpan()` and `scope.setSpan()`
1459

1560
Instead, you can get the currently active span via `Sentry.getActiveSpan()`. Setting a span on the scope happens
@@ -76,17 +121,6 @@ Sentry.init({
76121
});
77122
```
78123

79-
## Deprecated fields on `Hub`
80-
81-
In v8, the Hub class will be removed. The following methods are therefore deprecated:
82-
83-
- `hub.startTransaction()`: See [Deprecation of `startTransaction`](#deprecate-starttransaction)
84-
- `hub.lastEventId()`: See [Deprecation of `lastEventId`](#deprecate-sentrylasteventid-and-hublasteventid)
85-
- `hub.startSession()`: Use top-level `Sentry.startSession()` instead
86-
- `hub.endSession()`: Use top-level `Sentry.endSession()` instead
87-
- `hub.captureSession()`: Use top-level `Sentry.captureSession()` instead
88-
- `hub.shouldSendDefaultPii()`: Access Sentry client option via `Sentry.getClient().getOptions().sendDefaultPii` instead
89-
90124
## Deprecated fields on `Span` and `Transaction`
91125

92126
In v8, the Span class is heavily reworked. The following properties & methods are thus deprecated:

packages/core/test/lib/tracing/dynamicSamplingContext.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('getDynamicSamplingContextFromSpan', () => {
2020
});
2121

2222
test('returns the DSC provided during transaction creation', () => {
23+
// eslint-disable-next-line deprecation/deprecation
2324
const transaction = new Transaction({
2425
name: 'tx',
2526
metadata: { dynamicSamplingContext: { environment: 'myEnv' } },
@@ -67,6 +68,7 @@ describe('getDynamicSamplingContextFromSpan', () => {
6768
});
6869

6970
test('returns a new DSC, if no DSC was provided during transaction creation (via new Txn and deprecated metadata)', () => {
71+
// eslint-disable-next-line deprecation/deprecation
7072
const transaction = new Transaction({
7173
name: 'tx',
7274
metadata: {
@@ -90,6 +92,7 @@ describe('getDynamicSamplingContextFromSpan', () => {
9092

9193
describe('Including transaction name in DSC', () => {
9294
test('is not included if transaction source is url', () => {
95+
// eslint-disable-next-line deprecation/deprecation
9396
const transaction = new Transaction({
9497
name: 'tx',
9598
metadata: {
@@ -106,6 +109,7 @@ describe('getDynamicSamplingContextFromSpan', () => {
106109
['is included if transaction source is parameterized route/url', 'route'],
107110
['is included if transaction source is a custom name', 'custom'],
108111
])('%s', (_: string, source) => {
112+
// eslint-disable-next-line deprecation/deprecation
109113
const transaction = new Transaction({
110114
name: 'tx',
111115
metadata: {

0 commit comments

Comments
 (0)