Skip to content

Commit 1185f38

Browse files
chore(docs): split MIGRATION.MD code blocks for better readability
2 parents ccde98b + 5ad06c4 commit 1185f38

File tree

1 file changed

+57
-31
lines changed

1 file changed

+57
-31
lines changed

MIGRATION.md

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ We've removed the following packages:
6262
For Browser SDKs you can import `BrowserTracing` from the SDK directly:
6363

6464
```js
65-
// Before (v7)
65+
// v7
6666
import * as Sentry from '@sentry/browser';
6767
import { BrowserTracing } from '@sentry/tracing';
6868

@@ -71,8 +71,10 @@ Sentry.init({
7171
tracesSampleRate: 1.0,
7272
integrations: [new BrowserTracing()],
7373
});
74+
```
7475

75-
// After (v8)
76+
```js
77+
// v8
7678
import * as Sentry from '@sentry/browser';
7779

7880
Sentry.init({
@@ -86,16 +88,18 @@ If you were importing `@sentry/tracing` for the side effect, you can now use `Se
8688
tracing extensions to the SDK. `addTracingExtensions` replaces the `addExtensionMethods` method from `@sentry/tracing`.
8789

8890
```js
89-
// Before (v7)
91+
// v7
9092
import * as Sentry from '@sentry/browser';
9193
import '@sentry/tracing';
9294

9395
Sentry.init({
9496
dsn: '__DSN__',
9597
tracesSampleRate: 1.0,
9698
});
99+
```
97100

98-
// After (v8)
101+
```js
102+
// v8
99103
import * as Sentry from '@sentry/browser';
100104

101105
Sentry.addTracingExtensions();
@@ -109,16 +113,18 @@ Sentry.init({
109113
For Node SDKs you no longer need the side effect import, you can remove all references to `@sentry/tracing`.
110114

111115
```js
112-
// Before (v7)
116+
// v7
113117
const Sentry = require('@sentry/node');
114118
require('@sentry/tracing');
115119

116120
Sentry.init({
117121
dsn: '__DSN__',
118122
tracesSampleRate: 1.0,
119123
});
124+
```
120125

121-
// After (v8)
126+
```js
127+
// v8
122128
const Sentry = require('@sentry/node');
123129

124130
Sentry.init({
@@ -134,10 +140,12 @@ package (`@sentry/integrations`) to `@sentry/browser` and `@sentry/node`. in add
134140
classes.
135141

136142
```js
137-
// Before (v7)
143+
// v7
138144
import { RewriteFrames } from '@sentry/integrations';
145+
```
139146

140-
// After (v8)
147+
```js
148+
// v8
141149
import { rewriteFramesIntegration } from '@sentry/browser';
142150
```
143151

@@ -303,10 +311,12 @@ The `getIntegration()` and `getIntegrationById()` have been removed entirely, se
303311
[below](./MIGRATION.md#deprecate-getintegration-and-getintegrationbyid).
304312

305313
```js
306-
// Before (v7)
314+
// v7
307315
const replay = Sentry.getIntegration(Replay);
316+
```
308317

309-
// After (v8)
318+
```js
319+
// v8
310320
const replay = getClient().getIntegrationByName('Replay');
311321
```
312322

@@ -326,13 +336,15 @@ details.
326336
For example for the Browser SDKs:
327337

328338
```ts
329-
// Before (v7)
339+
// v7
330340
Sentry.init({
331341
dsn: '__DSN__',
332342
integrations: [new Sentry.BrowserTracing({ tracingOrigins: ['localhost', 'example.com'] })],
333343
});
344+
```
334345

335-
// After (v8)
346+
```ts
347+
// v8
336348
Sentry.init({
337349
dsn: '__DSN__',
338350
integrations: [Sentry.browserTracingIntegration()],
@@ -345,23 +357,23 @@ Sentry.init({
345357
The SDKs now support metrics features without any additional configuration.
346358

347359
```ts
348-
// Before (v7)
349-
// Server (Node/Deno/Bun)
360+
// v7 - Server (Node/Deno/Bun)
350361
Sentry.init({
351362
dsn: '__DSN__',
352363
_experiments: {
353364
metricsAggregator: true,
354365
},
355366
});
356367

357-
// Before (v7)
358-
// Browser
368+
// v7 - Browser
359369
Sentry.init({
360370
dsn: '__DSN__',
361371
integrations: [Sentry.metricsAggregatorIntegration()],
362372
});
373+
```
363374

364-
// After (v8)
375+
```ts
376+
// v8
365377
Sentry.init({
366378
dsn: '__DSN__',
367379
});
@@ -373,14 +385,16 @@ In v7 we deprecated the `Severity` enum in favor of using the `SeverityLevel` ty
373385
this has been removed in v8. You should now use the `SeverityLevel` type directly.
374386

375387
```js
376-
// Before (v7)
388+
// v7
377389
import { Severity, SeverityLevel } from '@sentry/types';
378390

379391
const levelA = Severity.error;
380392

381393
const levelB: SeverityLevel = "error"
394+
```
382395

383-
// After (v8)
396+
```js
397+
// v8
384398
import { SeverityLevel } from '@sentry/types';
385399

386400
const levelA = "error" as SeverityLevel;
@@ -394,12 +408,14 @@ The top level `Sentry.configureScope` function has been removed. Instead, you sh
394408
to access and mutate the current scope.
395409

396410
```js
397-
// Before (v7)
411+
// v7
398412
Sentry.configureScope(scope => {
399413
scope.setTag('key', 'value');
400414
});
415+
```
401416

402-
// After (v8)
417+
```js
418+
// v8
403419
Sentry.getCurrentScope().setTag('key', 'value');
404420
```
405421

@@ -413,10 +429,12 @@ Internally, this class is now called `SentrySpan`, and it is no longer meant to
413429
In v8, we are removing the `spanStatusfromHttpCode` function in favor of `getSpanStatusFromHttpCode`.
414430

415431
```js
416-
// Before (v7)
432+
// v7
417433
const spanStatus = spanStatusfromHttpCode(200);
434+
```
418435

419-
// After (v8)
436+
```js
437+
// v8
420438
const spanStatus = getSpanStatusFromHttpCode(200);
421439
```
422440

@@ -425,13 +443,15 @@ const spanStatus = getSpanStatusFromHttpCode(200);
425443
In v8, we are removing the `addGlobalEventProcessor` function in favor of `addEventProcessor`.
426444

427445
```js
428-
// Before (v7)
446+
// v7
429447
addGlobalEventProcessor(event => {
430448
delete event.extra;
431449
return event;
432450
});
451+
```
433452

434-
// After (v8)
453+
```js
454+
// v8
435455
addEventProcessor(event => {
436456
delete event.extra;
437457
return event;
@@ -448,12 +468,14 @@ The `send` method on the `Transport` interface now always requires a `TransportM
448468
the promise. This means that the `void` return type is no longer allowed.
449469

450470
```ts
451-
// Before (v7)
471+
// v7
452472
interface Transport {
453473
send(event: Event): Promise<void | TransportMakeRequestResponse>;
454474
}
475+
```
455476

456-
// After (v8)
477+
```ts
478+
// v8
457479
interface Transport {
458480
send(event: Event): Promise<TransportMakeRequestResponse>;
459481
}
@@ -530,7 +552,7 @@ With version 8 of the Sentry Next.js SDK, the SDK will no longer support passing
530552
property to `withSentryConfig`. Please use the third argument of `withSentryConfig` to configure the SDK instead:
531553

532554
```ts
533-
// OLD
555+
// v7
534556
const nextConfig = {
535557
// Your Next.js options...
536558

@@ -542,8 +564,10 @@ const nextConfig = {
542564
module.exports = withSentryConfig(nextConfig, {
543565
// Your Sentry Webpack Plugin Options...
544566
});
567+
```
545568

546-
// NEW
569+
```ts
570+
// v8
547571
const nextConfig = {
548572
// Your Next.js options...
549573
};
@@ -597,7 +621,7 @@ a subset of [2.x options](https://www.npmjs.com/package/@sentry/vite-plugin/v/2.
597621
optional just like before but here's an example of using the new options.
598622

599623
```js
600-
// Before (v7):
624+
// v7
601625
sentrySvelteKit({
602626
sourceMapsUploadOptions: {
603627
org: process.env.SENTRY_ORG,
@@ -609,8 +633,10 @@ sentrySvelteKit({
609633
ignore: ['**/build/client/**/*']
610634
},
611635
}),
636+
```
612637

613-
// After (v8):
638+
```js
639+
// v8
614640
sentrySvelteKit({
615641
sourceMapsUploadOptions: {
616642
org: process.env.SENTRY_ORG,

0 commit comments

Comments
 (0)