Skip to content

Commit d9f6584

Browse files
docs: Move Migration Guide to docs (getsentry#767)
1 parent 7510ecf commit d9f6584

File tree

1 file changed

+1
-282
lines changed

1 file changed

+1
-282
lines changed

MIGRATION.md

+1-282
Original file line numberDiff line numberDiff line change
@@ -1,282 +1 @@
1-
# Upgrading from 5.x to 6.x
2-
3-
In this version there are a few breaking changes. This guide should help you to update your code.
4-
5-
## Configuration Changes
6-
7-
With this version we changed a few things for the configuration:
8-
9-
- [Auto Session Tracking](https://github.com/getsentry/sentry-cocoa/blob/7876949ca78aebfe7883432e35727993c5c30829/Sources/Sentry/include/SentryOptions.h#L101)
10-
is enabled per default.
11-
[This feature](https://docs.sentry.io/product/releases/health/)
12-
is collecting and sending health data about the usage of your
13-
application.
14-
15-
- [Attach stacktraces](https://github.com/getsentry/sentry-cocoa/blob/b5bf9769a158c66a34352556ade243e55f163a27/Sources/Sentry/Public/SentryOptions.h#L109)
16-
is enabled per default.
17-
18-
- We bumped the minimum iOS version to 9.0.
19-
20-
- Use a BOOL in SentryOptions instead of NSNumber to store booleans.
21-
22-
- We removed [enabled](https://github.com/getsentry/sentry-cocoa/blob/5.2.2/Sources/Sentry/include/SentryOptions.h#L63) on the SentryOptions.
23-
24-
## Breaking Changes
25-
26-
### Store Endpoint
27-
28-
This version uses the [envelope endpoint](https://develop.sentry.dev/sdk/envelopes/).
29-
If you are using an on-premise installation it requires Sentry version
30-
`>= v20.6.0` to work. If you are using sentry.io nothing will change and
31-
no action is needed. For this change, we also cache events now in envelopes on the disk.
32-
We decided not to take the effort to migrate these few cached events from 5.x to 6.x into
33-
envelopes. Instead we remove them from the disk. This means you might lose a few cached
34-
events of your users when upgrading.
35-
36-
### SDK Inits
37-
38-
We removed the [deprecated SDK inits](https://github.com/getsentry/sentry-cocoa/blob/5.2.2/Sources/Sentry/include/SentrySDK.h#L35-L47). The recommended way to initialize Sentry is now:
39-
40-
```swift
41-
SentrySDK.start { options in
42-
options.dsn = "___PUBLIC_DSN___"
43-
// ...
44-
}
45-
```
46-
47-
```objective-c
48-
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
49-
options.dsn = @"___PUBLIC_DSN___";
50-
// ...
51-
}];
52-
```
53-
54-
### Cleanup Public Headers
55-
56-
We cleaned up our public headers and made most of our classes private. If you can't access one
57-
of the classes you need please [open an issue](https://github.com/getsentry/sentry-cocoa/issues/new/choose)
58-
and tell us your use case so we either make the class public again or provide another API for you.
59-
60-
### New type SentryId for eventId
61-
62-
In 5.x we use a nullable NSString to represent an event ID. The SDK, Hub and Client returned this
63-
nullable NSString for the event ID for capturing messages, events, errors, etc. With 6.x we have a new type SentryId which is not nullable to represent an event ID.
64-
Instead of returning `nil` when an event couldn't be queued for submission we return `SentryId.empty`.
65-
66-
`5.x`
67-
68-
```swift
69-
let eventId = SentrySDK.capture(message: "A message")
70-
if (nil != eventId) {
71-
// event was queued for submission
72-
} else {
73-
// event wasn't queued for submission
74-
}
75-
```
76-
77-
```objective-c
78-
SentryId *eventId = [SentrySDK captureMessage:@"A message"];
79-
if (nil != eventId) {
80-
// event was queued for submission
81-
} else {
82-
// event wasn't queued for submission
83-
}
84-
```
85-
86-
`6.x`
87-
88-
```swift
89-
let eventId = SentrySDK.capture(message: "A message")
90-
if (eventId != SentryId.empty) {
91-
// event was queued for submission
92-
} else {
93-
// event wasn't queued for submission
94-
}
95-
```
96-
97-
```objective-c
98-
SentryId *eventId = [SentrySDK captureMessage:@"A message"];
99-
if (eventId != SentryId.empty) {
100-
// event was queued for submission
101-
} else {
102-
// event wasn't queued for submission
103-
}
104-
```
105-
106-
### New type SentryMessage for Event.message
107-
108-
In 6.x we introduce a new type [SentryMessage](https://develop.sentry.dev/sdk/event-payloads/message/)
109-
for `event.message`. SentryMessage gives you the possibilty to pass a format string with parameters
110-
to Sentry, which can help to group similar messages into the same issue.
111-
112-
`5.x`
113-
114-
```swift
115-
let event = Event()
116-
event.message = "Hello World"
117-
```
118-
119-
```objective-c
120-
SentryEvent *event = [[SentryEvent alloc] init];
121-
event.message = "Hello World";
122-
```
123-
124-
`6.x`
125-
126-
```swift
127-
let event = Event()
128-
event.message = SentryMessage(formatted: "Hello World")
129-
```
130-
131-
```objective-c
132-
SentryEvent *event = [[SentryEvent alloc] init];
133-
event.message = [SentryMessage messageWithFormatted:"Hello World"];
134-
```
135-
136-
### Make Scope nonnull for capture methods
137-
138-
In 5.x you could pass a nullable scope to capture methods of the SDK, Hub and Client, such as
139-
`SentrySdk.captureMessage()`. In 6.x we changed the Scope to nonnull and provide overloads
140-
for the Hub and the Client.
141-
142-
Please checkout the [Changelog](CHANGELOG.md) for a complete list of changes.
143-
144-
# Upgrading from 4.x to 5.x
145-
146-
Here are some examples of how the new SDK works.
147-
148-
### Initialization
149-
150-
`4.x.x`
151-
152-
```swift
153-
do {
154-
Client.shared = try Client(dsn: "___PUBLIC_DSN___")
155-
try Client.shared?.startCrashHandler()
156-
} catch let error {
157-
print("\(error)")
158-
}
159-
```
160-
161-
```objective-c
162-
NSError *error = nil;
163-
SentryClient *client = [[SentryClient alloc] initWithDsn:@"___PUBLIC_DSN___" didFailWithError:&error];
164-
SentryClient.sharedClient = client;
165-
[SentryClient.sharedClient startCrashHandlerWithError:&error];
166-
if (nil != error) {
167-
NSLog(@"%@", error);
168-
}
169-
```
170-
171-
`5.x.x`
172-
173-
174-
```swift
175-
SentrySDK.start(options: [
176-
"dsn": "___PUBLIC_DSN___",
177-
"debug": true
178-
])
179-
```
180-
181-
```objective-c
182-
[SentrySDK startWithOptions:@{
183-
@"dsn": @"___PUBLIC_DSN___",
184-
@"debug": @(YES)
185-
}];
186-
```
187-
188-
### Add Breadcrumb
189-
190-
`4.x.x`
191-
192-
```swift
193-
Client.shared?.breadcrumbs.add(Breadcrumb(level: .info, category: "test"))
194-
```
195-
196-
```objective-c
197-
[SentryClient.sharedClient.breadcrumbs addBreadcrumb:[[SentryBreadcrumb alloc] initWithLevel:kSentrySeverityInfo category:@"test"]];
198-
```
199-
200-
`5.x.x`
201-
202-
```swift
203-
SentrySDK.addBreadcrumb(Breadcrumb(level: .info, category: "test"))
204-
```
205-
206-
```objective-c
207-
[SentrySDK addBreadcrumb:[[SentryBreadcrumb alloc] initWithLevel:kSentrySeverityInfo category:@"test"]];
208-
```
209-
210-
### CaptureMessage with tags/environment/extra
211-
212-
`4.x.x`
213-
214-
```swift
215-
let event = Event(level: .debug)
216-
event.message = "Test Message"
217-
event.environment = "staging"
218-
event.extra = ["ios": true]
219-
Client.shared?.send(event: event)
220-
```
221-
222-
```objective-c
223-
SentryEvent *event = [[SentryEvent alloc] initWithLevel:kSentrySeverityDebug];
224-
event.message = @"Test Message";
225-
event.environment = @"staging";
226-
event.extra = @{@"ios": @(YES)};
227-
[SentryClient.sharedClient sendEvent:event withCompletionHandler:nil];
228-
```
229-
230-
`5.x.x`
231-
232-
```swift
233-
SentrySDK.capture(message: "Test Message") { (scope) in
234-
scope.setEnvironment("staging")
235-
scope.setExtras(["ios": true])
236-
let u = Sentry.User(userId: "1")
237-
u.email = "[email protected]"
238-
scope.setUser(u)
239-
}
240-
```
241-
242-
```objective-c
243-
[SentrySDK captureMessage:@"Test Message" withScopeBlock:^(SentryScope * _Nonnull scope) {
244-
[scope setEnvironment:@"staging"];
245-
[scope setExtras:@{@"ios": @(YES)}];
246-
SentryUser *user = [[SentryUser alloc] initWithUserId:@"1"];
247-
user.email = @"[email protected]";
248-
[scope setUser:user];
249-
}];
250-
```
251-
252-
### setUser
253-
254-
`4.x.x`
255-
256-
```swift
257-
let u = User(userId: "1")
258-
u.email = "[email protected]"
259-
Client.shared?.user = user
260-
```
261-
262-
```objective-c
263-
SentryUser *user = [[SentryUser alloc] initWithUserId:@"1"];
264-
user.email = @"[email protected]";
265-
SentryClient.sharedClient.user = user;
266-
```
267-
268-
`5.x.x`
269-
270-
```swift
271-
let u = Sentry.User(userId: "1")
272-
u.email = "[email protected]"
273-
SentrySDK.setUser(u)
274-
```
275-
276-
```objective-c
277-
SentryUser *user = [[SentryUser alloc] initWithUserId:@"1"];
278-
user.email = @"[email protected]";
279-
[SentrySDK setUser:user];
280-
```
281-
282-
For more features, usage examples and configuration options, please visit: https://docs.sentry.io/platforms/cocoa/
1+
We moved the migration guide to the [docs](https://docs.sentry.io/platforms/apple/migration/).

0 commit comments

Comments
 (0)