|
| 1 | +# Upgrading from 6.x to 6.17.0 |
| 2 | + |
| 3 | +You only need to make changes when migrating to `6.17.0` if you are using our internal `Dsn` class. Our internal API class and typescript enums were deprecated, so we recommend you migrate them as well. |
| 4 | + |
| 5 | +The internal `Dsn` class was removed in `6.17.0`. For additional details, you can look at the [PR where this change happened](https://github.com/getsentry/sentry-javascript/pull/4325). To migrate, see the following example. |
| 6 | + |
| 7 | +```js |
| 8 | +// New in 6.17.0: |
| 9 | +import { dsnToString, makeDsn } from '@sentry/utils'; |
| 10 | + |
| 11 | +const dsn = makeDsn(process.env.SENTRY_DSN); |
| 12 | +console.log(dsnToString(dsn)); |
| 13 | + |
| 14 | +// Before: |
| 15 | +import { Dsn } from '@sentry/utils'; |
| 16 | + |
| 17 | +const dsn = new Dsn(process.env.SENTRY_DSN); |
| 18 | +console.log(dsn.toString()); |
| 19 | +``` |
| 20 | + |
| 21 | +The internal API class was deprecated, and will be removed in the next major release. More details can be found in the [PR that made this change](https://github.com/getsentry/sentry-javascript/pull/4281). To migrate, see the following example. |
| 22 | + |
| 23 | +```js |
| 24 | +// New in 6.17.0: |
| 25 | +import { |
| 26 | + initAPIDetails, |
| 27 | + getEnvelopeEndpointWithUrlEncodedAuth, |
| 28 | + getStoreEndpointWithUrlEncodedAuth, |
| 29 | +} from '@sentry/core'; |
| 30 | + |
| 31 | +const dsn = initAPIDetails(dsn, metadata, tunnel); |
| 32 | +const dsn = api.dsn; |
| 33 | +const storeEndpoint = getEnvelopeEndpointWithUrlEncodedAuth(api.dsn, api.tunnel); |
| 34 | +const envelopeEndpoint = getStoreEndpointWithUrlEncodedAuth(api.dsn); |
| 35 | + |
| 36 | +// Before: |
| 37 | +import { API } from '@sentry/core'; |
| 38 | + |
| 39 | +const api = new API(dsn, metadata, tunnel); |
| 40 | +const dsn = api.getDsn(); |
| 41 | +const storeEndpoint = api.getStoreEndpointWithUrlEncodedAuth(); |
| 42 | +const envelopeEndpoint = api.getEnvelopeEndpointWithUrlEncodedAuth(); |
| 43 | +``` |
| 44 | + |
| 45 | +## Enum changes |
| 46 | + |
| 47 | +We've detailed how to migrate off our enums `Severity`, `Status` and `SpanStatus`. We also made changes to deprecate `TransactionMethod`, `Outcome` and `RequestSessionStatus` enums, but those are internal only APIs. |
| 48 | + |
| 49 | +#### Severity |
| 50 | + |
| 51 | +We deprecated the `Severity` enum in `@sentry/types` and it will be removed in the next major release. We recommend using string literals to save on bundle size. [PR](https://github.com/getsentry/sentry-javascript/pull/4280). We also removed the `Severity.fromString` method. This was done to save on bundle size. |
| 52 | + |
| 53 | +```js |
| 54 | +// New in 6.17.0: |
| 55 | +import { severityFromString } from '@sentry/utils'; |
| 56 | + |
| 57 | +const severity = severityFromString(level); |
| 58 | + |
| 59 | +// Before: |
| 60 | +import { Severity } from '@sentry/types'; |
| 61 | + |
| 62 | +const severity = Severity.fromString(level); |
| 63 | +``` |
| 64 | + |
| 65 | +#### Status |
| 66 | + |
| 67 | +We deprecated the `Status` enum in `@sentry/types` and it will be removed in the next major release. We recommend using string literals to save on bundle size. [PR](https://github.com/getsentry/sentry-javascript/pull/4298). We also removed the `Status.fromHttpCode` method. This was done to save on bundle size. |
| 68 | + |
| 69 | +```js |
| 70 | +// New in 6.17.0: |
| 71 | +import { eventStatusFromHttpCode } from '@sentry/utils'; |
| 72 | + |
| 73 | +const status = eventStatusFromHttpCode(500); |
| 74 | + |
| 75 | +// Before: |
| 76 | +import { Status } from '@sentry/types'; |
| 77 | + |
| 78 | +const status = Status.fromHttpCode(500); |
| 79 | +``` |
| 80 | + |
| 81 | +#### SpanStatus |
| 82 | + |
| 83 | +We deprecated the `Status` enum in `@sentry/tracing` and it will be removed in the next major release. We recommend using string literals to save on bundle size. [PR](https://github.com/getsentry/sentry-javascript/pull/4299). We also removed the `SpanStatus.fromHttpCode` method. This was done to save on bundle size. |
| 84 | + |
| 85 | +```js |
| 86 | +// New in 6.17.0: |
| 87 | +import { spanStatusfromHttpCode } from '@sentry/utils'; |
| 88 | + |
| 89 | +const status = spanStatusfromHttpCode(403); |
| 90 | + |
| 91 | +// Before: |
| 92 | +import { SpanStatus } from '@sentry/tracing'; |
| 93 | + |
| 94 | +const status = SpanStatus.fromHttpCode(403); |
| 95 | +``` |
| 96 | + |
1 | 97 | # Upgrading from 4.x to 5.x/6.x
|
2 | 98 |
|
3 | 99 | In this version upgrade, there are a few breaking changes. This guide should help you update your code accordingly.
|
|
0 commit comments